Message Archival

You can use this API to store any communication sent to customers for later access. For more information, refer to Message Archival.

API Endpoint

API Endpoint
POST https://api-0X.moengage.com/v1/archival/view

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=="}

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:

  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 Data 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 bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="}

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
user_id Required String This field denotes the unique identifier of the user. 
delivery_type Required String

This field denotes the delivery type of the channel. Supported values are:

  • ONE_TIME
  • PERIODIC
  • EVENT_TRIGGERED
  • LOCATION_TRIGGERED
  • DEVICE_TRIGGERED
  • API_TRIGGERED
  • BUSINESS_EVENT_TRIGGERED
  • API_TRIGGERED
campaign_type Required String

This field denotes the campaign type. Supported values are:

Push:

  • General Push Campaign (General Push)
  • Autotrigger Campaign (Event Triggered Push)
  • Geo-fencing Campaign (Location Triggered Push)
  • Business Event Trigger Push Campaign (Business Event Triggered Push)

SMS:

  • sms (all SMS campaigns except Business Event Triggered campaign)
  • Business Event Trigger SMS Campaign (Business Event Triggered campaign)

Email:

  • Email Campaign (all Email campaigns except Event triggered and Business Event Triggered campaigns)
  • Email Triggers (Event triggered campaigns)
  • Business Event Trigger Email Campaign (Business Event Triggered campaigns)

Alerts/Inform:

  • Inform Email (for Email Campaign)
  • Inform SMS (for SMS Campaign)
  • Inform Push (for Push Campaign)
campaign_channel Required String

This field denotes the campaign channel. Supported values are:

  • EMAIL
  • SMS
  • PUSH
  • FLOWS
sent_epoch_time Required Integer

This field denotes the sent time of the campaign. 

<how to fetch>

campaign_id Required String This field denotes the campaign ID.
event_name Required String

This field denotes the name of the event. Supported event names are:

  • Email Sent
  • SMS Sent
  • Notification Sent iOS
  • Notification Received Android
  • Notification Received Web
platform Required String

This field denotes the target platform of the campaign. Supported values are: 

  • IOS
  • ANDROID
  • WEB
  • EMAIL
  • SMS
  • MWEB
event_id Optional String

This field denotes the event ID.

This field is required for event-triggered campaigns.

  • You must pass moe_event_id if any event attribute is present for campaigns.
  • You must pass moe_transaction_id for alerts, which is mandatory.

Response

Key Data Type Description
message String This field contains a brief description of the request status in the case of success.
error JSON Object

This field contains the reason for the request's failure.

Structure:

{
    "status": false,
    "error_message": "<error_message>"
}

The error object contains the following fields:

  • status - This field is of String type and denotes the status of the request.
  • message - This field is of String type and describes why the request has failed.

Response Codes

Status Code Request State Description

200

Success

The server successfully processed the request, but is not returning any content.

400

Bad Request

This response is returned when the required parameters are missing from the request, or when the provided parameters are invalid, or when a template already exists with the same version, name, or id.

401

Authentication Failure

This response is returned when the authorization parameters are missing in the HTTP Auth Header.

500

Internal Server Error

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

429

Too Many Requests

A number of headers are returned in case of a rate-limit breach.

502

Server Error

Something went wrong on MoEngage.

Rate Limit

The rate limit is 1000 RPM.

Sample cURL Request

SMS

Sample cURL
curl --location 'https://api-0X.moengage.com/v1/archival/view' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Authorization: Basic {{Authorization_Key}}' \ --data '{ "user_id": "{{User_ID}}", "delivery_type": "ONE_TIME", "campaign_type": "SMS", "campaign_channel": "SMS", "sent_epoch_time": 1716972486, "campaign_id": "{{Campaign_ID}}", "event_name": "SMS Sent", "platform": "SMS", "event_id": "{{Event_ID}}" }'

Email

Sample cURL
curl --location 'https://api-0X.moengage.com/v1/archival/view' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Authorization: Basic {{Authorization_Key}}' \ --data '{ "user_id": "{{User_ID}}", "delivery_type": "ONE_TIME", "campaign_type": "Email Campaign", "campaign_channel": "EMAIL", "sent_epoch_time": 1717150294, "campaign_id": "{{Campaign_ID}}", "event_name": "Email Sent", "platform": "EMAIL" }'

Push

Android iOS Web
curl --location 'https://api-0X.moengage.com/v1/archival/view' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Authorization: Basic {{Authorization_Key}}' \ --data '{ "user_id": "{{User_ID}}", "delivery_type": "ONE_TIME", "campaign_type": "General Push Campaign", "campaign_channel": "PUSH", "sent_epoch_time": 1716915262, "campaign_id": "{{Campaign_ID}}", "event_name": "Notification Received Android", "platform": "ANDROID" }'

Sample Response

200 400 401 500
{
    "status": true,
    "data": {
        "message_details": {
            "message_type": "campaign",
            "message_id": "66560c2d2880326031c474a6",
            "channel": "push",
            "platform": "android",
            "delivery_type": "ONE_TIME",
            "sent_time": "Tue, 28 May 2024 22:24:22 IST",
            "message_to": "cZug38RqRd2-cF30bd2vda:APA91bGEG-OHMiWV3eHd_ohLs8V-yTgDJuQXNV32jO13or-R118OAC65MXdSx5ozYsIiL-RFan_iflQ62XVX7T2BiNqqQQfKd3FitlpbLR7nVBdkFF1yv_s8pqZux-HfThn-ojhpBIWd",
            "moe_event_id": null,
            "service": {
                "type": "FCM"
            },
            "template_info": {
                "type": "Native",
                "version": null,
                "id": "stylizedbasic"
            }
        },
        "message_content": {
            "title": "expiry in 1 hour",
            "summary": "expiry in 1 hour",
            "message": "expiry in 1 hour",
            "related_urls": [
                "https://image-staging-ap1.moengage.com/checkfcsgainmoengage/20240527083246095196HE4ELHScreenshotofUploadyourAppDiawiDevelopmentandInhouseAppsWirelessInstallationjpgcheckfcsgainmoengage.jpg"
            ]
        },
        "backup_content": {
            "title": "Stylized Android Template",
            "summary": null,
            "message": "Sample Stylized Android Template",
            "related_urls": []
        },
        "file_info": {
            "version": "v2",
            "file_name": "66560c2d2880326031c474a6_pramodseg_1716915262_push_android.json"
        }
    }
}

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?