Get User

This API facilitates the retrieval of information of users by specifying the user ids.

API Endpoint

API Endpoint
POST https://api-0X.moengage.com/v1/customers/export

The 'X' in the API Endpoint URL refers to the MoEngage Data Center (DC). MoEngage hosts each customer in a different DC. You can find your DC number (value of X) and replace the value of 'X' in the URL by referring to the DC and API endpoint mapping.

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

  1. Navigate to Settings -> Account -> APIs.
  2. Click Generate Key in the Data tile in the API Keys section, and click Save.
  3. Use the App ID as the username and the Data API Key as the password to generate the authentication header.

Old UI

  1. Navigate to Settings -> APIs -> DATA API Settings.
  2. Click Generate Key.
  3. Click Save on the Data APIs settings section. 
  4. Use the DATA API ID as the username and the DATA API KEY as the password to generate the authentication header.

Request Parameters

Key Required Data Type Description

app_id

Yes

String

This is your MoEngage account's APP ID that has to be passed along with the request. You can find your MoEngage APP ID in the following navigation on the Dashboard:

Revamped UI: Settings -> Account -> APIs -> App ID

Old UI: Settings -> API -> General Settings -> DATA API

Request Headers

Key Required Sample Values Description

X-Forwarded-For

Yes

Header Value Format: <IP Address>

The 'X-Forwarded-For' header is used to specify the IP address of the client that made the request. This header may be added by proxy servers or load balancers. The header value must contain the IP address of the original client that initiated the request. Multiple IP addresses may be specified in the header value, separated by commas.

Content-Type

Yes

application/json 

Set the Content-Type header to application/json.

Authorization

Yes

{"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

Identifiers

 Yes

Array of JSON Objects

This field is used to specify the identifiers for the users for whom the data needs to be fetched.

Structure:

"identifiers": [

   {

        "identifier_type": "customer_id",

        "identifier": "<customer_id>"

    },

   {

        "identifier_type": "id",

         "identifier":"<MoEngageID>" 

    },

    ...{}

]

  • identifier_type - This field specifies the identifier type. Identifier types can either be customer_id (ID field in the User Profile) or id (the MoEngageID of the user in the User Profile). It is a String.
  • identifier - This field specifies the unique identifier that identifies the user. It is a String.

user_fields_to_export

Yes

Array of Strings

This field is used to specify the fields that need to be fetched for the user specified in Identifiers. Tracked standard user attributes and custom attributes can be fetched using this API. For the list of tracked standard attributes in MoEngage, refer to User Attributes.

Response

Key Data Type Description

status

String

This field contains the status of the request and specifies whether the request was successful. 

Supported Values: success, failure

Example: "status": "success"

type

String

This field denotes the fetch type.

Supported Values: export_users

Example: "type": "export_users"

data

JSON Object

This field contains the list of users who were not found in MoEngage and returns the data specified for the list of users who were found in MoEngage.

Structure:

{
    "users_not_found": [
        {
            "identifier_type": "customer_id",
            "identifier": "<customer_id>"
        }
    ],
    "users": [
        {
             "user_attributes": {
                   <list of user attributes>
             } 
        }
    ]
}

users_not_found - an array of JSON Objects that contains the list of users who were not found in MoEngage.

users - contains the user_attributes specified in the request for each user in specified in the request.

error

JSON Object

This field is present in the response only in the case of an error and contains the error details.

Structure:

{

   "attribute": "<attribute causing the error >",

   "message": "<error message>",

   "type": "<error type>",

   "request_id": "<request_id>"

}

 

attribute - This field contains the name of the request attribute causing the error. For example, "attribute": "identifiers" implies that the identifiers request attribute is causing the error.

message - This field contains the error message.

type - This field contains the error type. For example, "type": "Malformed JSON" implies that the JSON in the request is incorrectly formed.

request_id - This field denotes the request-id for which the error response is being returned.

 

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 APP KEY, user_id, and so on are missing from the request or when the provided params are invalid.

401

Authorization Failure

This response is returned when the authorization fails due to incorrect values for the APP KEY/ HTTP Auth Header.

403

Account Suspended/Blocked Temporarily

This response is returned when the user account has been suspended temporarily or blocked.

413

Payload Limit Exceeded

This response is returned when the payload size has exceeded the limit set.

415

Unsupported media type

This response is returned when the header “Content-Type” is not provided/is not supported.

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 20 users per payload and 1000 users per minute.

Sample cURL Request

cURL
curl --location 'https://s2s.moestaging.com/v1/customers/export' \
--header 'X-Forwarded-For: 34.249.175.81' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic e3tEQVRBIEFQSSBJRH19Ont7REFUQSBBUEkgS0VZfX0=' \
--data '{
    "data": {
        "identifiers": [
            {
                "identifier_type": "customer_id",
                "identifier": "{{user_id_that_you_want_to_fetch_details_of}}"
            },
            {
                "identifier_type": "id",
                "identifier": "{{moengage_user_id_that_you_want_to_fetch_details_of}}"
            }
        ]
    }
}'

Sample Response

200 400 401 403 413 415 429 500
Success Response
{ "status": "success", "type": "export_users", "data": { "users_not_found": [ { "identifier_type": "customer_id", "identifier": "john_doe" } ], "users": [ { "user_attributes": { "last_name": "Doe", "customer_id": "john_doe", "name": "John", "custom_user_attr": 12345, "id": "62e79fb15ada55x123g987bu" } } ] } }

Postman Collections

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

FAQs

  1. How do I know which users are available to export and which users are not available in MoEngage to export?
    All available users will be found in the users key, and users not available will be found in the users_not_found key. Please refer to the sample response in this doc.
  2. What if I want to get all the user data available based on the user ids without specifying the fields?

    If the user_fields_to_export is not passed, then all the custom attributes and exportable standard attributes will be passed. For specific fields, user_fields_to_export needs to be passed along with the required fields.

Previous

Next

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

How can we improve this article?