Delete Cards API

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

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

Basic authentication sends a Base64-encoded string containing a username and password for all API requests.

Do the following when you are using the API for the first-time authentication:

  1. Navigate to Settings > APIs > TRANSACTION PUSH/REPORT Settings.
  2. Click on the Click here to show API Secret to view the API Secret key.
  3. User name - APP ID and Password - API SECRET

For example, Basic Authentication encodes a 'username:password' using base64 encoding and prepends it with the string 'Basic '. The string is passed in the authorization header as follows:

{"Authorization": "Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}

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 is the authentication parameter for access control and needs to be passed along with the request. The APP ID and API SECRET need to be picked up from the TRANSACTION PUSH API Settings in the MoEngage Dashboard, and a Basic Authorization header needs to be created and set in the header. Navigation: Settings -> API -> General Settings -> TRANSACTION PUSH/REPORT SETTINGS section. For more information, 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.

  1. Android
  2. iOS
    Generate Device ID for iOS Devices
    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": {
    "android": {

        "success": [<campaign_id>],
        "failed": [<campaign_id>],
        "invalid": []

   },

   "ios": {

        "success": [<campaign_id>],
        "failed": [<campaign_id>],
        "invalid": []

   }

}

The platform-specific response objects – android and ios contain the same structure and have the following information:

"<platform>":{

        "success": [<campaign_id>],
        "failed": [<campaign_id>],
        "invalid": []

   }

  • success - This field contains the list of campagin ids for which cards have been successfully deleted.
  • failed - This field contains the list of campaigns ids for which the cards could not be deleted.
  • invalid - This field contains the list of campaign ids for which cards do not exist for the specified platform.
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

Sample cURL

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

200 400 401 429 5xx

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": []
      },
    }
}

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.

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

How can we improve this article?