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.
Endpoints
The available endpoints and methods are:
| HTTP Method | Endpoint | Description |
|---|---|---|
| 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 structure
The table below provides an overview of the key parameters and attributes to include as part of the request.
| Parameter/Attribute | 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 attributes | ||||
| requestBody | ARRAY | POST | Required | application/json |
| requestBody | STRING | POST | Required | application/x-ndjson - Newline-delimited JSON stream of interactions. |
JSON properties
The table below provides an overview of the key properties to include for each interaction as part of the batch processing request.
| Property | 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 structure
For each request, the attributes listed below may be present in the response body.
| Attribute | 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. |
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"
}