Events and Automations

Track custom events to start and resume automations

Use the Events API to record product or lifecycle activity from your app. Events can start published automations and resume “Wait for event” steps for the matching contact.

SDK method

noketa.events.track(payload: TrackEventRequest): Promise<TrackEventResponse>

HTTP

POST /api/v1/events

Authenticate with the Noketa-Secret header set to your organization API key, or with a valid session cookie when calling from the browser.

Request body

FieldTypeRequiredDescription
eventstringYesEvent key, e.g. product.purchased
emailstring?NoContact email. Used to find or create the contact
contactIdstring?NoExisting Noketa contact ID. Takes precedence over email
attributesContactAttributes?NoMerged into the contact when email is used
metadataRecord<string, unknown>?NoStored on the event and passed to matching automation runs

Provide either contactId or email. When only email is provided, Noketa upserts the contact before tracking the event. If that creates a new contact, contact.created automations also run.

Response

{
  "message": "Event tracked",
  "eventId": "<uuid>",
  "contactId": "<uuid>",
  "contactAction": "matched",
  "triggered": 1,
  "completedWaitpoints": 0,
  "failed": 0
}

Example

import { Noketa } from "noketa";

const noketa = new Noketa(process.env.NOKETA_API_KEY!);

await noketa.events.track({
  event: "product.purchased",
  email: "person@example.com",
  attributes: {
    first_name: "Jane",
    properties: {
      plan: "pro",
    },
  },
  metadata: {
    orderId: "order_123",
    amount: 4900,
  },
});

Event keys

Event keys may contain letters, numbers, dots, underscores, and hyphens. Built-in keys include contact.created; custom keys are automatically added to your organization’s automation event list when tracked.