The Delete Cards API can be used to delete cards for a specified user (using the unique_id or uid) from the MoEngage Cards database. This option allows you to delete cards for a user by yourself without any assistance.
API Endpoint
DELETE https://api-0X.moengage.com/v1/cards/delete
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 bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}
The username and password details can be obtained from the MoEngage Dashboard. We've revamped the settings UI in the Dashboard. If you're using the API for the first time, follow these steps for the revamped and old UIs:
Revamped UI
- Navigate to Settings -> Account -> APIs.
- Click the Copy icon in the Campaign report/Business events/Custom templates tile in the API Keys section to copy the API Key.
- Use the App ID as the username and the Push API Key as the password to generate the authentication header.
Old UI
- Navigate to Settings -> APIs -> TRANSACTION PUSH/REPORT Settings.
- Click on the Click here to show APP Secret link to view the API SECRET.
- Use the APP ID as the username and the API SECRET as the password to generate the authentication header.
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 bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="} |
This authentication parameter, used for access control, must be passed along with the request. To generate the authentication header, refer to Authentication. |
Request Body
Key | Required | Data Type | Description |
---|---|---|---|
unique_id or uid | Required (Either the unique_id or the uid should be passed in the request) | String |
This field is used to identify the cards based on the unique_id or uid specified in the request. The unique_id is the unique value that identifies the user to send the cards. The unique_id is the platform-specific device identifier; refer to Generating unique_id for details. The uid is the unique MoEngage Standard ID (Email ID Standard or the Mobile Number Standard or any unique identifier mapped to a MoEngage Standard attribute) that identifies the user. |
campaign_ids | Required | Array of String |
This field denotes the campaign ids associated with the cards being deleted. In the case of a periodic campaign, if the campaign id of the parent campaign is specified, the cards will get deleted for the child campaigns as well. |
platforms | Optional | Array of String |
This field is used to specify the platforms for which the card should be deleted. If this field is not present in the request, the cards specified for deletion will be deleted from all the platforms they are associated with. Allowed Values: ANDROID, IOS, WEB Example: "platforms": ["ANDROID", "WEB", "IOS"] |
Generating unique_id
The unique_id refers to the device identifier and is platform-specific. You can generate the unique id for Android and iOS using the methods listed below.
- Android
- iOS
MoEngageSDKCore.getMoEngageDeviceId(completionHandler: @escaping UserInfoHandler)
Response
Key | Data Type | Description |
---|---|---|
status | Boolean |
This field represents whether the request was successful and contains true when the request was successful and false otherwise. |
request_id | String |
This field contains the unique identifier that denotes the request. |
data | Array of JSON Objects |
This field contains the list of cards that satisfy the search criteria. "data": { "success": [<campaign_id>], }, "ios": { "success": [<campaign_id>], } } The platform-specific response objects – android and ios contain the same structure and have the following information: "<platform>":{ "success": [<campaign_id>], }
|
title | String | This field is present in the response body only when the request is unsuccessful and contains the error type. |
description | String | This field is present in the response body only when the request is unsuccessful and contains the error description. |
code | String | This field is present in the response body only when the request is unsuccessful and contains the error code. |
Response Codes
Status Code | Request State | Description |
---|---|---|
200 |
Success |
This response is returned when the request is processed successfully. |
400 |
Bad Request |
This response is returned when the required parameters are missing from the request or when the provided parameters are invalid. |
401 |
Authorization Failure |
This response is returned when the authorization parameters are missing in the HTTP Auth Header. |
429 |
Rate Limit Breach |
This response is returned when the number of requests per minute has exceeded the rate limit. |
5xx |
Internal Server Error |
This response is returned when the system runs into an unexpected error. |
Rate Limit
The rate limit is 50K RPM and is applicable at the DB(App) level.
Sample cURL Request
curl --location --request DELETE 'https://api-{{0X}}.moengage.com/v1/cards/delete' \
--header 'Authorization: Basic Q000RDFMWk4ySU1KTkJZOVVMWEFVNzNEOlIxWk1PS0FYUENCNg==' \
--header 'Content-Type: application/json' \
--data '{
"uid": "{{uid}}",
"campaign_ids": ["{{campaign_id1}}", "{{campaign_id2}}"],
"platforms": ["android", "ios"]
}'
Sample Response
Sample Response for a successful request
{
"status": true/false, // true when call succeeds else false
"request_id": "645ab4f8b1c6b5d384b8176f", // bson objectid,
"data": {
"android": {
"success": [<campaign_id>], // successfully deleted campaigns
"failed": [<campaign_id>], // campaigns failed to delete
"invalid": [] // campaigns that don't exist for platform
},
"ios": {
"success": [<campaign_id>],
"failed": [<campaign_id>],
"invalid": []
},
}
}
Sample Response for when the Unique ID is not there in the request
{
"status": false,
"error": "Required field missing. Please include either 'uid' or 'unique_id'",
"request_id": "64f6a59ed1e36d0d57a790c1"
}
Sample Response for when the Campaign IDs are invalid or missing in the request
{
"status": false,
"error": "Invalid or missing 'campaign_ids' field",
"request_id": "64f6a59ed1e36d0d57a790c1"
}
Sample Response for when the Unique ID is not found
{
"status": false,
"error": "User not found for this uid/ unique_id",
"request_id": "64f6a59ed1e36d0d57a790c1"
}
Sample Response for when the APP_SECRET or APP_ID is invalid
{
"title": "Authentication required",
"description": "APP_ID and APP_SECRET_KEY is missing in Authorization Header.",
"code": "KMxkunyz"
}
Sample Response for Rate Limit Breach
{
"title": "Request limit reached",
"description": "This API call has exceeded the rate limit",
"code": "KMxkunyz"
}
Sample Response for server side errors
{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}
Postman Collections
We have made it easy for you to test the APIs. Click here to view it in Postman.
FAQs
What is the difference between unique_id and uid?
The unique_id is the unique value that identifies the user to whom the cards need to be deleted. It is a platform-specific device identifier that can be generated, as mentioned in the Generating unique_id section. The uid is the unique MoEngage Standard ID that identifies the user.