Update a Coupon List

This API allows users to modify existing coupon lists within a defined workspace. It facilitates changes to specifications like list name, expiry date, and alert settings, thereby promoting efficient coupon operations management.

info

Information

This API reactivates the ARCHIVED or EXPIRED coupon list upon modification, provided the list has a future expiration date.

API Endpoint

API Endpoint
PATCH https://api-0X.moengage.com/v1/coupon-list/{{coupon_list_id}}

Each customer is hosted on a different data center; you can find your data center number (value of X) by checking the data center and API endpoint mapping page.

Authentication

The API request will be authenticated through Basic Authentication. Basic Authentication sends a Base64-encoded string containing your username and password with every API request. It encodes a 'username: password' string in Base64 and appends the encoded string with 'Basic '. This string is included in the authorization header as shown below:

{"Authorization": "Basic Base64_ENCODED_APPKEY_APIKEY"}

You can obtain the username and password details from the MoEngage Dashboard.

  1. Navigate to Settings > Account > APIs.
  2. Copy the following details:
    • Username: Under Workspace ID (earlier App ID), click the copy icon to copy the username.
    • Password: In the API keys section, click the copy icon in the Campaign report/Business events/Custom templates/Catalog API tile to copy the API key.
  3. Use these details to authenticate the API requests.

Request Headers

Key Required Sample Values Description

Content-Type

Required

{"Content-Type": "application/json"}

Set the Content-Type header to application/json.

Authorization

Required

{"Authorization": "Basic Base64_ENCODED_APPKEY_APIKEY"}

This authentication parameter, used for access control, must be passed in the request. To generate the authentication header, refer to Authentication.

MOE-APPKEY Required

{“MOE-APPKEY”: “Workspace ID”}

This is the workspace ID (earlier APP ID) of your MoEngage workspace. The MOE-APPKEY has to be passed in the request. You can find your MoEngage Workspace ID in the MoEngage Dashboard:

Settings -> Account -> APIs -> Workspace ID (earlier app id)

For more information, refer to Authentication.

Request Body

Key Required Values Description
name Optional

string

This field contains the new name of the coupon list.

expires_at Optional

string

This field contains the new date of the coupon list in yyyy-mm-dd format.

email_alert_subscribers Optional

string

This field consists of the new email address of the coupon list subscriber. The subscriber will receive all the alerts on the coupon list in the email provided in this field.

alert_conditions Optional

JSON object

This object contains the updated details for the alert conditions listed below:

  • success_alert (boolean)
  • failure_alert (boolean)
  • coupon_shortage_alert
    • alert (boolean)
    • threshold_count (integer)
  • expiry_alert
    • alert (boolean)
    • days_before (integer)

Response

Status Key Data Type Description
Success

name

 

string

This field consists of the updated name of the coupon list.

label

 

string

This field consists of the label name for the coupon list.

expires_at

 

string

This field contains the updated expiration date of the coupon list in yyyy-mm-dd format.

status

string

This field consists of the status of the coupon list.

Note: You can only update active coupon lists.

total_coupons

integer

This field consists of the total number of coupons in the coupon list.

created_at

string

This field consists of the date and time the coupon list was created.

updated_at

string

This field consists of the date and time of the most recent update to the coupon list.

email_alert_subscribers string

This field contains the subscriber's updated email address on the coupon list.

alert_conditions JSON object

This field consists of the updated alert conditions and the statuses specified for the coupon list.

available_coupons integer

This field consists of the available number of coupons in coupon list.

created_by string

This field consists of the user name who created the coupon list.

_id string

This field contains the unique ID of the coupon list requested for update. This ID is used in the params to fetch and archive coupon lists.

Failure error code string

Each error codes are unique and serve as a shorthand representation for the type of error, providing a quick reference that can be used to diagnose, troubleshoot, and address the problem based on a predefined set of error conditions.

message string

Along with the error code, a detailed message is also provided in the response, describing the specifics of the request failure and the nature of the error. 

Refer to the Sample Response section for examples.

Response Codes

Status Code Request State Description

200

Success

Indicates that the request is successful and the coupon list update request is accepted.

400

Bad request

Possible issues include duplicates, such as coupon list names, invalid data types, or missing mandatory attributes. For more information, refer to Error Messages.

401

Unauthenticated

Your request is unauthorized.

403

Forbidden

Your account does not have access to the Coupon Management features.

500

Internal server error

This response is returned when the system runs into an unexpected error.

Error Messages

Status Code Error code Description
400 duplicate-coupon-list-name

The coupon list name already exists. Enter a unique name and try again.

duplicate-coupon-list-label The coupon list label already exists. Enter a unique label and try again.
missing-mandatory-attributes You must include the mandatory attributes: name, label, expiry date, and email ID of the creator with string data type and try again.
invalid-request
  • Invalid field in the request: ['<key name>']. Verify and try again.
  • The value provided for the '<key name>' is invalid. Verify and try again.
  • The requested JSON is incorrect. Verify and try again.
  • The expiry date should not be a past date. Verify and try again.
  • The 'alert' value is set to False, but the 'days_before' value is provided.
  • The 'alert' value is set to True, but the 'days_before' value is missing.
  • The expiry alert days should not exceed the expiry date.
  • The 'alert' value is set to True, but the 'threshold_count' value is missing.
  • The 'alert' value is set to False, but the 'threshold_count' value is provided.
  • The data type provided for some of the attributes is invalid.
401 request-unauthenticated Your request is unauthorized. Verify your credentials and try again.
403 request-forbidden Your account does not have access to the Coupon Management features. Contact the MoEngage team for further assistance.
500 unexpected-error Something went wrong with your request. Contact the MoEngage team for further assistance.

Sample cURL Request

cURL
curl --location --request PATCH 'https://api-0X.moengage.com/v1/coupon-list/{{coupon_list_id}}' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data '{
  "name": "signup coupons",
  "expires_at": "2024-10-26T18:29:00.000Z",
  "email_alert_subscribers": [
    "john.doe@example.com"
  ],
  "alert_conditions": {
    "success_alert": true,
    "failure_alert": true,
    "coupon_shortage_alert": {
      "alert": true,
      "threshold_count": 100
    },
    "expiry_alert": {
      "alert": true,
      "days_before": 100
    }
  }
}'

Sample Response

200 400 401 403 500
{
  "name": "Updated_Name",
  "label": "signup_coupons",
  "expires_at": "2024-10-26T18:29:00.000Z",
  "status": "ACTIVE",
"total_coupons": 0,
"created_at": "2024-10-01T11:29:00.000Z", "updated_at": "2024-10-01T11:39:00.000Z", "email_alert_subscribers": [ "john.doe@example.com" ], "alert_conditions": { "success_alert": true, "failure_alert": true,
"expiry_alert": { "alert": true, "days_before": 100 }, "coupon_shortage_alert": { "alert": true, "threshold_count": 100 }
}, "available_coupons": 0,
"created_by": "test_user",
"_id": "{{coupon_list_id}}" }

Postman Collections

We have made it easy for you to test the APIs. Click here to view it in Postman.

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?