Create Event

The Create Event API allows you to track the actions of a user.

API Endpoint

URL
POST https://api-0X.moengage.com/v1/event/<APP_ID>

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 here.

info

Note

The APP_ID for your MoEngage account is available on the MoEngage Dashboard in Settings > App Settings > Account Settings > APP ID.

Request Body

Request Body Fields

Key Datatype Required Description
type String Yes This is used to identify the type of request. 

Allowed Value: event

Example: "type": "event"

Note: This field is case-sensitive. Follow the case as in the example when passing the value in the request.

customer_id String Yes Identifier to identify or create a user in MoEngage.
device_id String No device_id in event payload is optional. The default value is the customer_id value. The value is used to map events to specific devices.
actions List Yes List of events to be tracked for the user.
action String Yes The name of the event to be tracked.
attributes JSON Object No A dictionary containing event attributes to track with the event.
platform String No Used to identify the platform on which the event happened. Allowed values are ANDROID, iOS, web, or unknown.
app_version String No App Version of the app on which the event originated.
user_time Numeric(Epoch time in seconds) or String (ISO 8601 - ) No Local Time at which the event happened.
current_time Numeric (Epoch time in seconds) or String( ISO 8601) No UTC Time at which the event happened
user_timezone_offset Numeric No user_timezone_offset should have a value in seconds which can be between -54000 to 54000. For example, for IST (UTC+0530), "user_timezone_offset" will be 19800
warning

Warning

Ensure that the platform value sent is Android, iOS, or web. Platform value depends on which platform the event was generated.
If you are unsure about the platform on which the event occurred, send the value as unknown or do not send any value. Incorrect platform value leads to inconsistencies in platform level campaigns like Push and In-App.

info

Note

MoEngage depends on current_time and user_timezone_offset for generating the local time at which the event occurred. The local time is displayed in the user profile on the dashboard.

user_timezone_offset

Used to determine the local timezone at which the event occurred.

If the field is not present, then either one of the following is used: *The timezone present in user profile is considered. *The event occurred in the UTC timezone.

The format contains a numeric value between -54000 to 54000. The value is the timezone offset of the local time from UTC in seconds.

current_time

Used to identify the UTC time at which the event occurred.

If the field is not present, then the time at which the request was received is used as the current_time.

Allowed formats for current_time are ISO 8601, for example, 2020-05-31T16:33:35Z, or Epoch time in seconds, for example - 1590404615

Example Payload

The following example provides tracking of numeric, boolean, and date type event attributes.
Use the payload described, where the price is numeric, departure_date is a date type attribute and premium_seat is a boolean attribute.

JSON
{
    "type": "event",
    "customer_id": "john@example.com",
    "actions": [{
		    "action": "Flight Booked",
		    "attributes": {
				"price": 3999,
				"departure_date": "2019-05-21T03:47:35Z",
				"premium_seat": true
			},
		    "platform": "iOS",
		    "app_version": "1.2.3",
		    "current_time": 1433837969,
		    "user_timezone_offset": 19800
		}
	]
}
Was this article helpful?
5 out of 14 found this helpful

How can we improve this article?