Maqetin takes three calls for data: identify, track and batch.

Each call takes a publishable key and answers 202 when it accepts the data. This page lists the routes, the fields, the limits and the other answers.

The three calls

CallRouteWhat it does
identifyPOST /v1/identifyUpserts a profile.
trackPOST /v1/trackRecords an event.
batchPOST /v1/batchSends 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.

FieldRequiredWhat it holds
userIdYesYour own id for the person, 1 to 256 characters.
traitsYesAn object. The email trait must be a valid address.
channelYesWhere the call came from: web, ios, android, node, python, go or rest.
anonymousIdNoLinks the earlier anonymous events of this visitor to the person.
messageIdNoAn id of 1 to 64 characters. Send the same id on a retry and the event is stored once.
timestampNoWhen it happened, as an ISO date-time.
sentAtNoWhen the client sent the request, so the gateway can correct a wrong clock.
context, sdkVersionNoThe 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

StatusMeaning
202The data was accepted. The body holds the number accepted, in accepted.
400The body does not match the call, for example a top-level field that is not in the list.
401The gateway saw no active key.
413The body is too large.
429Too many requests for the key. The Retry-After header says how long to wait.

Create a workspace and send your first event.