Replace {subdomain}
in the endpoint below with your Vitally subdomain.
You can find your subdomain in the URL used to log into Vitally (i.e., https://yoursubdomain.vitally.io
Create/update a batch of organizations, accounts, users, or tracks
POST
https://{subdomain}.api.vitally.io/analytics/v1/batch
The batch API allows sending organization, account, user, and track messages in batches instead of one at a time. It is ideal for importing historical data into Vitally.
Batch size
The maximum number of messages in a batch is 100.
Headers
Name | Type | Description |
Authorization* | string | Set to |
Content-Type* | string | Set to |
200 Cake successfully retrieved.
{"message":"Success."}
Request body
The body of the request should be a JSON array whose elements are account, user, and track messages. Each message in the batch should have the additional field:
type
: Indicates the type of message. Must be either"organization"
,"account"
,"user"
,"track"
, or"unlink"
Example
An example batch containing an account, user, and track would look like:
curl -X POST https://{subdomain}.api.vitally.io/analytics/v1/batch \
-H "Authorization: Basic [your token]" \
-H "Content-Type: application/json" \
-d '[
{
"type": "organization",
"organizationId": "abcdefg",
"traits": {
"name": "World Cup",
"sport": "futbol"
},
"messageId": "7ac1c682-a54b-4d0d-9f56-d6d3618f4915",
"timestamp": "2018-05-15T12:31:12.123Z"
},
{
"type": "account",
"accountId": "123456",
"organizationId": "abcdefg",
"traits": {
"name": "Argentina",
"group": "D"
},
"messageId": "7ac1c682-a54b-4d0d-9f56-d6d3618f4915",
"timestamp": "2018-05-15T12:31:12.123Z"
},
{
"type": "user",
"userId": "32",
"accountId": "123456",
"organizationId": "abcdefg",
"traits": {
"name": "Lionel Messi",
"position": "Forward",
"number": 10,
"email": "messi@barcelona.sp"
},
"messageId": "7ac1c682-a54b-4d0d-9f56-d6d3618f4915",
"timestamp": "2018-05-15T12:31:12.123Z"
},
{
"type": "track",
"userId": "32",
"event": "scored-goal",
"properties": {
"minute": 14,
"opponentId": 421243,
"matchId": 9
},
"messageId": "7ac1c682-a54b-4d0d-9f56-d6d3618f4915",
"timestamp": "2018-05-15T12:31:12.123Z"
}
]