User Track

post

/users/track

This endpoint can be used to record custom events, user attributes, and purchases for users. You can include up to 75 Attributes, Event, and Purchase Objects per request. That is, you can only post attributes for up to 75 users at a time, but in the same API call you can also provide up to 75 events and up to 75 purchases.

Request Body

1
Content-Type: application/json
1
2
3
4
5
6
{
   "api_key" : (required, string) see App Group REST API Key,
   "attributes" : (optional, array of Attributes Object),
   "events" : (optional, array of Event Object),
   "purchases" : (optional, array of Purchase Object)
}

Customers using the API for server-to-server calls may need to whitelist rest.iad-01.braze.com if they’re behind a firewall.

Objects Used

Example Request Body for Event Tracking

1
2
3
4
5
6
7
8
9
10
{
  "api_key": "123a45b6-cd78-9e01-g234-hi56j7k8l9m0",
  "events": [
    {
      "external_id": "string",
      "name": "string",
      "time": "string"
    }
  ]
}

You can see this example in action in our Swagger documentation.

User Track Responses

Upon using any of the aforementioned API requests you should receive one of the following three general responses:

Successful Message

Successful messages will be met with the following response:

1
2
3
4
5
6
{
  "message" : "success",
  "attributes_processed" : (optional, integer), if attributes are included in the request, this will return an integer of the number of attributes that were queued to be processed,
  "events_processed" : (optional, integer), if events are included in the request, this will return an integer of the number of events that were queued to be processed,,
  "purchases_processed" : (optional, integer), if purchases are included in the request, this will return an integer of the number of purchases that were queued to be processed,,
}

Successful Message with Non-Fatal Errors

If your message is successful but has non-fatal errors such as one invalid Event Object out of a longer list of events you will receive the following response:

1
2
3
4
5
6
7
8
{
  "message" : "success",
  "errors" : [
    {
      <minor error message>
    }
  ]
}

Message with Fatal Errors

In the case of a success, any data that was not affected by an error in the errors array will still be processed. If your message has a fatal error you will receive the following response:

1
2
3
4
5
6
7
8
{
  "message" : <fatal error message>,
  "errors" : [
    {
      <fatal error message>
    }
  ]
}

Queued Responses

During times of maintenance, Braze might pause real-time processing of the API. In these situations, the server will return an HTTP Accepted 202 response code and the following body, which indicates that we have received and queued the API call but have not immediately processed it. All scheduled maintenance will be posted to http://status.braze.com ahead of time.

1
2
3
{
  "message" : "queued"
}

Fatal Error Response Codes

The following status codes and associated error messages will be returned if your request encounters a fatal error. Any of these error codes indicate that no data will be processed.

Error Code Reason / Cause
400 Bad Request Bad Syntax.
401 Unauthorized Unknown or missing REST API Key.
404 Not Found Unknown REST API Key (if provided).
429 Rate Limited Over rate limit.
5XX Internal server error, you should retry with exponential backoff.

Importing Legacy User Data

You may submit data through the Braze API for a user who has not yet used your mobile app in order to generate a user profile. If the user subsequently uses the application all information following their identification via the SDK will be merged with the existing user profile you created via the API call. Any user behavior that is recorded anonymously by the SDK prior to identification will be lost upon merging with the existing API generated user profile.

The segmentation tool will include these users regardless of whether they have engaged with the app. If you want to exclude users uploaded via the User API whom have not yet engaged with the app you should add the filter – Session Count > 0.

WAS THIS PAGE HELPFUL?
New Stuff!