Batch Interaction API
Use the Batch Interaction API to send interaction and interaction update requests in batches of up to 5,000 records using current or historical timestamps on the events. Batch interactions do not trigger online optimization points, but offline optimization points.
Authentication and authorization
MXO security framework uses OAuth 2.0 for authenticating access to data. For detailed information on how to create API credentials for a user and request an OAuth 2.0 token from MXO, see MXO API security.
Available API calls
We provide the API calls listed below:
| Method | Summary | Details |
|---|---|---|
| POST | /batchv2/interactions/{siteKey} | Process a batch of interaction requests. |
| POST | /batchv2/interactions/{siteKey}/update | Process a batch of interaction update requests. |
| GET | /batchv2/interactions/{siteKey}/{batchId} | Retrieve the current status of a batch processing job. |
| GET | /batchv2/interactions/{siteKey}/{batchId}/error | Retrieve any errors that occurred during batch processing. |
Request elements
The table below provides an overview of the key elements to include as part of the request.
| Element | Type | Method | Required | Description |
|---|---|---|---|---|
| Query Parameters | ||||
| siteKey | STRING | POST/GET | Required | Site identifier key. |
| batchId | STRING | GET | Required | Batch identifier. |
| Headers | ||||
| workspaceId | STRING | POST/GET | Required | Workspace identifier. |
| batchId | STRING | POST | Optional | Optional batch identifier. |
| Body | ||||
| requestBody | ARRAY | POST | Required | application/json |
| requestBody | STRING | POST | Required | application/x-ndjson - Newline-delimited JSON stream of interactions. |
JSON elements
The table below provides an overview of the key elements to include for each interaction as part of the batch processing request.
| Element | Type | Required | Description |
|---|---|---|---|
| uri | STRING | Required | Interaction resource identifier. |
| timestamp | STRING | Required | Interaction timestamp in ISO 8601 (date-time) format. |
| customerKey | STRING | Optional | Unique customer identifier. Note: This key can be replaced by any key defined in the configuration. |
| customerKeyName | STRING | Optional | Additional customer identifier. |
| properties | OBJECT | Optional | Additional interaction properties. |
Response elements
For each request, the elements listed below may be present in the response.
| Element | Type | Description |
|---|---|---|
| batchId | STRING | Unique batch identifier. |
| acceptedCount | INTEGER | Number of interactions processed. |
| rejectedCount | INTEGER | Number of interactions with errors. |
| totalCount | INTEGER | Total number of interactions in the batch. |
| message (only in error responses) | STRING | Error message. |
Response status codes
MXO can return the following status codes in a response.
| Status code | Description |
|---|---|
| 200 | Successful request. |
| 400 | Bad input parameter. |
| 401 | Invalid OAuth 2.0 token. |
| 403 | Insufficient permissions. |
| 404 | Batch not found. |
| 500 | Internal server error. |
Example use cases
The Batch Interaction API is primarily used for two key purposes:
Loading historical events at initial implementation to prime your workspace with data for analysis.
Uploading events from a system MXO is not listening to.
Example parameters
| Field | Description |
|---|---|
| siteKey | Site identifier key. |
Example API call - Request
| Field | Description |
|---|---|
| Request Method | POST |
| Request URL | /batchv2/interactions/{siteKey} |
| Request Headers | workspaceId: NzM3MjE Content-Type: application/json |
| Request Body |
|
Example API call - Response
Expected response code
200 Batch processed successfullyExpected response body
{
"rejectedCount": 0,
"acceptedCount": 0,
"totalCount": 2,
"batchId": "3df46dbd-59f4-406c-8462-374df55cbaaf"
}Possible error response code
400 Bad request or duplicate batch IDError response body
{
"errorMessage": "Batch ID: test already exists",
"batchId": "3df46dbd-59f4-406c-8462-374df55cbaaf"
}