Skip to main content

Documentation Index

Fetch the complete documentation index at: https://segmentflow.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

events.track records one identified backend business event as a durable UserEvent. Segmentflow resolves the Profile, applies any profile.properties as durable Profile Properties, stores the one-event data payload, and evaluates active Journeys that listen for the event. Journey-triggered email templates can reference event payload values under /event/*, for example { "$state": "/event/orderId" }. Event data is not copied into Profile Properties and remains separate from EmailSend /data/* state. Use this for facts like order.created, trial.started, or payment.failed when Journey configuration should decide whether to enroll the Profile. If you already know that you need one expected email, use Emails. If you are choosing between email sending, event-triggered Journeys, direct Journey trigger, Broadcasts, and Newsletter Issues, start with Which API should I use?.
events.track uses API Keys with events:write. The WriteKey-authenticated Ingest API remains separate for browser SDKs, plugins, and Segment-compatible userId / properties traffic.

Track an event

import Segmentflow from "@segmentflow/segmentflow-typescript";

const client = new Segmentflow({
  apiKey: process.env.SEGMENTFLOW_API_KEY,
});

const result = await client.v1.events.track(
  {
    event: "order.created",
    profile: {
      email: "alex@example.com",
      externalId: "cus_123",
      properties: {
        firstName: "Alex",
        plan: "Pro",
      },
    },
    data: {
      orderId: "ord_9421",
      total: 49,
      payment: {
        token: "tok_live_abc",
      },
    },
    redactedDataPaths: ["/event/payment/token"],
    referenceId: "ord_9421",
    occurredAt: "2026-05-31T12:00:00.000Z",
  },
  {
    headers: { "Idempotency-Key": "order.created:ord_9421" },
  },
);

console.log(result.eventId, result.profileId, result.matchedJourneys);

Request fields

FieldPurpose
eventFree-form business event name. Unknown names are accepted.
profile.emailEmail identity used to resolve or create the Profile.
profile.externalIdCaller-owned Profile identifier.
profile.propertiesDurable Profile Property updates. Not copied into the event payload.
dataOne-event payload exposed to Journey email templates under /event/*.
redactedDataPathsOptional /event/* paths to redact before durable retention.
referenceIdSafe caller correlation id. Not used for idempotency.
occurredAtEvent time. If omitted, Segmentflow uses receipt time.
Every request requires Idempotency-Key. Retrying the same key with the same request replays the original response. Reusing it with different request parameters returns 409 Conflict.

Response

events.track returns 202 Accepted after Segmentflow durably accepts the event.
{
  "eventId": "019bf964-302b-7a7f-add2-589343ef9f32",
  "profileId": "019bf964-302b-7a7f-add2-589343ef9f31",
  "matchedJourneys": 0,
  "enrolledJourneys": 0,
  "skippedJourneys": 0
}
When no active Journey listens to the event, the request still succeeds and the Journey counts are all zero.