Batch requests
updated 2 years ago
In this article:
The Batch API allows batching multiple create user, update user and add user events. This lets you make multiple requests at the cost of a single API call.
POST /v1/batch
Notes
Depending on the number of batched request items, processing the request may take some time.
The endpoint returns
{"status": "queued"}
without validating all the requests. Therefore, there is no guarantee that all the request items will be successfully processed. To ensure request items are successfully processed, be sure you are sending the correct request parameters.
There is currently no limit to the number of items that can be batched but kindly keep the request size below 100KB.
Parameters
data
- An array of request items. Each item should have atype
,id
, and additional request parameters.type
- The request type. Supported values arecreate
(for creating a new user),update
(for updating user attributes), andevent
(for sending user event).id
- The ID of the user on your platform.Additional parameters
To create a new user, add parameters required by the create user endpoint.
To update user attributes, add the parameters required by the update user endpoint.
To send a user event, add the parameters required by the track user event endpoint.
Request format
Here is an example batch request to create a user, update the user's attribute and add an event for the user.
{
"data": [
{
"type": "create",
"id": "u144",
"first_name": "Akinyele",
"last_name": "Jinadu",
"email": "[email protected]",
"meta": {
"plan": "pro",
"age": 34
},
"created_at": "2021-01-12T05:24:39.062+00:00"
},
{
"type": "update",
"id": "u144",
"meta": {
"plan": "Custom",
"coverage": 20
}
},
{
"type": "event",
"id": "u144",
"event": "Paid",
"value": 49.99
},
{...}
]
}
Response
{
"status": "queued"
}
Was this article helpful?