Skip to content

Capture API

Send events to My Journey Analytics from your servers, apps and other systems over plain HTTP.

The capture API receives events. It is what the JavaScript library uses behind the scenes, and you can call it directly from any server, script or system that can make an HTTP request.

Capture requests are authenticated with your public project token, not a personal API key. Find the token under Settings → Project → General → Project token & ID.

Where to send events

EndpointUse it for
POST /i/v0/e/One event, or an array of events
POST /batch/Many events in one request

The older paths /e/ and /capture/ are accepted too, and behave like /i/v0/e/.

Send them to https://app.myjourneyanalytics.com, or to your custom tracking domain if you have one.

Send one event

bash
curl -X POST https://app.myjourneyanalytics.com/i/v0/e/ \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "<project token>",
    "event": "order completed",
    "distinct_id": "user_123",
    "properties": {
      "order_id": "A-1001",
      "total": 129.5,
      "currency": "AUD"
    }
  }'
js
await fetch("https://app.myjourneyanalytics.com/i/v0/e/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    api_key: process.env.MJ_PROJECT_TOKEN,
    event: "order completed",
    distinct_id: "user_123",
    properties: { order_id: "A-1001", total: 129.5, currency: "AUD" },
  }),
});

In a browser, use the library instead of calling the API yourself:

js
myjourney.capture("order completed", { order_id: "A-1001", total: 129.5 });

Event fields

FieldRequiredDescription
api_keyYesYour project token. token is accepted as another name for it
eventYesThe event name, such as order completed or $pageview
distinct_idYesThe ID of the person who did it. It can also be sent as properties.distinct_id
propertiesNoAny properties to store with the event
timestampNoWhen the event happened, as an ISO 8601 date and time. Defaults to the time it is received
uuidNoA UUID for the event. One is generated if you leave it out

Use the same distinct_id your website or app uses for that person, usually the ID you pass to myjourney.identify(), so server and browser events join up on one person. A distinct_id longer than 200 characters is cut to 200.

Send many events at once

The batch endpoint takes the token once, then a batch array of events:

bash
curl -X POST https://app.myjourneyanalytics.com/batch/ \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "<project token>",
    "batch": [
      {
        "event": "subscription renewed",
        "distinct_id": "user_123",
        "properties": { "plan": "growth" },
        "timestamp": "2026-10-01T09:30:00Z"
      },
      {
        "event": "invoice paid",
        "distinct_id": "user_456",
        "properties": { "amount": 49 }
      }
    ]
  }'

Every event in a batch must belong to the same project. Bodies compressed with gzip are accepted; they are detected automatically.

Set person properties

To store properties on the person rather than the event, add $set or $set_once inside properties:

json
{
  "api_key": "<project token>",
  "event": "plan changed",
  "distinct_id": "user_123",
  "properties": {
    "$set": { "plan": "enterprise" },
    "$set_once": { "first_plan": "starter" }
  }
}

$set overwrites the value each time. $set_once only sets it if the person does not have it yet. See person properties for more.

Responses

StatusMeaning
200Accepted
400The body could not be read, or an event has no name or no distinct_id
401The project token is missing or not valid
413An event or the request is too large
429Too many events right now: retry later
503A temporary problem: retry with a delay

A 200 response means the request was accepted, not that each event has been stored yet. To check that events arrive, look for them in the app under Activity.

Good practice

  • Keep the project token in configuration, not hard-coded, so you can change it easily.
  • Retry on 429 and 503 with an increasing delay.
  • Never send personal API keys to the capture API; it only needs the project token.
  • Avoid sending sensitive data you do not need, such as full card numbers or passwords.

Can't find what you need? Contact support