The three calls
| Call | Route | What it does |
|---|---|---|
| identify | POST /v1/identify | Upserts a profile. |
| track | POST /v1/track | Records an event. |
| batch | POST /v1/batch | Sends 1 to 100 identify or track items in one request. |
Send them to https://in.maqetin.com with the publishable key in the header Authorization: Bearer mq_live_….
The JavaScript SDK makes these calls for you and batches them. Call the routes yourself from a language that has no SDK.
Identify
Identify sets the traits of a person. Send userId, traits and channel.
| Field | Required | What it holds |
|---|---|---|
| userId | Yes | Your own id for the person, 1 to 256 characters. |
| traits | Yes | An object. The email trait must be a valid address. |
| channel | Yes | Where the call came from: web, ios, android, node, python, go or rest. |
| anonymousId | No | Links the earlier anonymous events of this visitor to the person. |
| messageId | No | An id of 1 to 64 characters. Send the same id on a retry and the event is stored once. |
| timestamp | No | When it happened, as an ISO date-time. |
| sentAt | No | When the client sent the request, so the gateway can correct a wrong clock. |
| context, sdkVersion | No | The fields the SDK collects, and the version of the SDK. |
These traits have a type: email is a valid address, phone, firstName, lastName, plan and country are strings, and createdAt is an ISO date-time in UTC. Any other trait can hold any JSON value.
Any other top-level field is a 400. The body is at most 32 KiB.
curl https://in.maqetin.com/v1/identify \
-H 'Authorization: Bearer mq_live_…' \
-H 'Content-Type: application/json' \
-d '{
"userId": "user_123",
"traits": {
"email": "ada@example.com",
"firstName": "Ada",
"lastName": "Lovelace",
"plan": "pro"
},
"channel": "rest"
}'Track
Track records one event. Send event, channel and at least one of userId and anonymousId. A visitor who has not signed in has only anonymousId.
Send properties as an object. It defaults to {}. Also optional: sessionId, context, sdkVersion, messageId, timestamp and sentAt.
curl https://in.maqetin.com/v1/track \
-H 'Authorization: Bearer mq_live_…' \
-H 'Content-Type: application/json' \
-d '{
"userId": "user_123",
"event": "order.completed",
"properties": {
"orderId": "ord_1001",
"total": 49.9,
"currency": "USD"
},
"channel": "rest"
}'Name events
Name an event object.action, in lower case and in the past tense, such as order.placed.
Ten objects belong to Maqetin: app, install, deeplink, screen, page, push, in_app, link, message and email. The object is the part of the name before the first dot. Do not use one of them as the object of an event of your own: the SDK sends page.viewed itself.
The gateway takes any name that is not empty, so the convention is yours to keep.
Send many at once
A batch holds 1 to 100 items. Each item has a type of identify or track and follows the rules of that call. Send sentAt once, on the batch.
The body is at most 512 KiB. A single record over 900,000 bytes makes the whole request a 413.
curl https://in.maqetin.com/v1/batch \
-H 'Authorization: Bearer mq_live_…' \
-H 'Content-Type: application/json' \
-d '{
"batch": [
{
"type": "identify",
"userId": "user_123",
"traits": { "email": "ada@example.com", "plan": "pro" },
"channel": "rest"
},
{
"type": "track",
"userId": "user_123",
"event": "order.completed",
"properties": { "orderId": "ord_1002", "total": 12 },
"channel": "rest"
},
{
"type": "track",
"anonymousId": "anon_456",
"event": "plan.viewed",
"properties": { "path": "/pricing" },
"channel": "web"
}
]
}'Retries and ids
- A userId is 1 to 256 characters, and so is the anonymousId of a track.
- The SDK retries after a 5xx, a 429 or a network error, and sends the same message ids.
What the gateway answers
| Status | Meaning |
|---|---|
| 202 | The data was accepted. The body holds the number accepted, in accepted. |
| 400 | The body does not match the call, for example a top-level field that is not in the list. |
| 401 | The gateway saw no active key. |
| 413 | The body is too large. |
| 429 | Too many requests for the key. The Retry-After header says how long to wait. |