Skip to content
Menu

Reference

Server API

Markdown version

The REST endpoints your backend calls: users, events, real-time decide, the decisions and holdout exports, the decisions CSV, contacts and user deletion.

Before you start

  • The app's ingest token (nx_ingest_…), kept on your server. See Authentication.
  • For the decisions CSV only: an API key with the exports.read scope. For adding people to a journey: one with journeys.enter.
  • Your users' External IDs: the same IDs your apps pass to identify.

Your backend or warehouse uses these endpoints to send users and events, ask which message to show, read results back, manage contact points and erase a user. They never run in the app. For the endpoints the SDK calls, see SDK REST endpoints. To send messages, see the Send API.

Authentication

CredentialHeaderEndpoints
Ingest tokenAuthorization: Bearer <ingest token>Users, events, decide, decisions, holdout, contacts, user deletion
API key (hk_…) with exports.readAuthorization: Bearer hk_…Decisions CSV
API key (hk_…) with journeys.enterAuthorization: Bearer hk_…Adding people to a journey

Ingest token. Open the app under Settings → Sending & SDK and select Rotate next to Ingest token. Herald shows the token once, so copy it into your backend's secret store then. It also signs user tokens. Rotating it again invalidates the old token at once: see Rotating the ingest token.

API key. Create one under Settings → Sending, the app, then API keys. See Send API authentication for scopes and key rules.

A missing or unknown ingest token gets 401 Unauthorized. A token whose connection is disabled gets 403 Forbidden.

Base URL

Use your Herald base URL, the same endpoint your apps pass to configure. The examples use https://YOUR_HERALD_HOST. Every JSON response is { "data": ... } on success and { "error": "..." } on failure.

Rate limits

  • The decisions CSV counts toward exports.requests (60 per hour per app) and api.requests (36,000 per hour per app), with the rate-limit headers described on API errors.
  • Adding people to a journey counts each person toward journeys.enter (100,000 per hour per app) and each call toward api.requests.
  • The other endpoints have no hourly limit.

Note

Beta: POST /api/v1/events and POST /api/v1/users share an hourly pool, ingest.requests, of 36,000 requests per app. Over it they answer 429 with Retry-After. This is not live in production yet.

Idempotency

These endpoints take no Idempotency-Key header. Retrying is safe because each write is keyed:

EndpointRetry behavior
POST /api/v1/usersUpserts on userId
POST /api/v1/eventsStores each event once per id within the app; repeats count in duplicates
POST /api/v1/decideThe same user and agent within 30 minutes get the same decision
POST and DELETE /api/v1/contactsUpserts or removes on kind and value
DELETE /api/v1/users/{userId}A repeat returns zero counts

POST /api/v1/users

Creates or updates users. It merges attributes with the same reserved-key rules as the SDK (a computed_ key, reserved for computed attributes, fails the request with 400), registers each user as a member of the connection's app so the app's agents can reach them, and saves the email address as a contact.

Request

FieldRules
users1 to 1,000 items; body up to 4 MB
userId1 to 200 characters
attributesOptional object of attributes to merge into the profile; a null value removes that key
emailOptional valid address
signupAt, lastActiveAtOptional ISO 8601 date-times with offset
shell
curl -X POST "https://YOUR_HERALD_HOST/api/v1/users" \
  -H "Authorization: Bearer $HERALD_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "users": [
    { "userId": "u_123", "attributes": { "plan": "plus" }, "email": "maya@example.com",
      "signupAt": "2026-11-01T12:00:00Z", "lastActiveAt": "2026-11-15T08:00:00Z" }
  ] }'

Response

FieldValue
upsertedNumber of users created or updated
json
{ "data": { "upserted": 1 } }
StatusBody errorCause
200Done
400Invalid JSON, or Invalid users payload: ... with the fieldBad body
401UnauthorizedMissing or unknown ingest token
403ForbiddenThe connection is disabled
413Body exceeds 4 MBToo large
500Internal server errorServer failure

POST /api/v1/events

Sends events. They are stored and count toward agent goals exactly like SDK track and trackPurchase calls.

Request

FieldRules
events1 to 1,000 items; body up to 4 MB
id1 to 128 characters; unique per event
userId1 to 200 characters
name1 to 255 characters
timestampISO 8601 date-time with offset; no more than 5 minutes ahead of Herald's clock. Your server's clock is trusted: no correction and no age limit, so historical imports are kept
propertiesOptional object
schemaVersionOptional. The event schema version to check the event against, such as 1-0-0; without it (or null), the latest version. Ignored when the event name has no schema
Each eventUp to 32 KB as JSON

An event named purchase with a numeric properties.price is recorded as a purchase. quantity, currency and productId are optional.

Report a push your app sent itself with an event named $external_push, right after your backend sends it, so the push limit counts it. category is transactional, marketing or other (default), message_id (up to 200 characters) makes the push count once even if the SDK reports it too, and source (up to 100) is optional. Don't send the title or body. See Pushes your app sends.

shell
curl -X POST "https://YOUR_HERALD_HOST/api/v1/events" \
  -H "Authorization: Bearer $HERALD_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "events": [
    { "id": "evt_1", "userId": "u_123", "name": "subscription_started",
      "timestamp": "2026-11-15T08:00:00Z", "properties": {} },
    { "id": "evt_2", "userId": "u_123", "name": "$external_push",
      "timestamp": "2026-11-15T08:00:00Z",
      "properties": { "category": "transactional", "message_id": "order-42-shipped", "source": "orders" } }
  ] }'

Response

FieldValue
acceptedNumber of new events stored
duplicatesEvent IDs the app already had; they are skipped
rejectedOnly when an event was left out: its id, index, reason and detail. See Rejected events
json
{ "data": { "accepted": 1, "duplicates": 0 } }

Each event is checked on its own: an invalid one is left out, the rest are stored, and the response lists it in rejected. Events whose name has an event schema are checked against it, as SDK events are. Fix and resend only those events.

StatusBody errorCause
200Done, except any events listed in rejected
400Invalid JSON, or Invalid events payload: ... with the fieldBad body: not an object, no events array, or 0 or over 1,000 events
401UnauthorizedMissing or unknown ingest token
403ForbiddenThe connection is disabled
413Body exceeds 4 MBToo large
500Internal server errorServer failure

Send each goal event from one source: the server or the SDK, not both.

POST /api/v1/decide

Asks, at request time, which message an agent should show a user, for a web app or backend that renders the message itself instead of using the mobile SDK. Herald picks a variant with the agent's bandit and learned stats, records the decision, and returns the variant's content. A later goal event for that user, from /api/v1/events or the SDK, is credited to the decision like any other send.

The user must already exist: send them through POST /api/v1/users first. The agent must belong to the same app as the ingest token. Call decide when you are about to show the message, not ahead of time.

Request

FieldRules
agentIdRequired; the agent's ID from the console
userId1 to 200 characters
channelOptional, such as push or email; only that channel's variants are considered
shell
curl -X POST "https://YOUR_HERALD_HOST/api/v1/decide" \
  -H "Authorization: Bearer $HERALD_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "agentId": "AGENT_ID", "userId": "u_123", "channel": "email" }'

Response

FieldValue
decisionId, variantIdIDs of the recorded decision and the chosen variant; null in holdout
agentIdThe agent
channelThe variant's channel; null in holdout
holdouttrue when the user is in the agent's holdout group: show nothing
noSendtrue when the agent chose to send nothing to this person; render nothing
exploretrue when the pick was exploration rather than the best-known variant
warmupForcedtrue when a new variant was shown to gather data
predictedRewardThe bandit's estimate for the variant; null in holdout
contentThe variant's title, subject, body, cta, deeplink, iconImageUrl and htmlBody; null in holdout
json
{ "data": {
  "decisionId": "cmh…",
  "agentId": "AGENT_ID",
  "variantId": "cmh…",
  "channel": "email",
  "holdout": false,
  "explore": false,
  "warmupForced": false,
  "predictedReward": 0.12,
  "content": { "subject": "Your plan is waiting", "title": "Pick up where you left off", "body": "…", "cta": "Continue", "deeplink": "https://example.com/plan", "htmlBody": "<p>…</p>" }
} }

Fields the variant leaves unset or empty are left out of content; body is always present. When the agent has a deep link override, deeplink is that link. In holdout, no decision is recorded.

Real-time decisions are recorded for learning and conversion credit. They count toward the agent's per-user frequency cap, and scheduled sends are less likely to repeat a variant the user just got. They don't count toward daily send caps, and they don't show as sends on delivery dashboards. Your app decides whether to show the message.

A goal event is credited only if its timestamp is at or after the decision, by Herald's clock. Send event timestamps from a server with an accurate clock.

StatusBody errorCause
200Done
400Invalid JSON body, or the field and its problem, such as userId: must be at most 200 charactersBad body
400No active variantsThe agent has no active variant (on that channel)
401UnauthorizedMissing or unknown ingest token
403ForbiddenThe connection is disabled
404Agent not foundNo such agent in this app
404User not foundThe user has not been sent to Herald
409Agent is not activeThe agent is not active, or its sending is paused
500Internal server errorServer failure

GET /api/v1/decisions

Exports the app's decisions and their outcomes, for a warehouse job or a loader's HTTP source that runs on a schedule. Each row is one message decision for one user in the app that owns the ingest token.

Request

Query parameterRules
sinceOptional ISO 8601 date-time with offset. Returns decisions made, delivered, opened, converted or rescored at or after it. Omit it for every decision.
cursorOptional; the nextCursor of the previous page. Keep the same since while you page.
limitOptional, 1 to 1,000; default 500
shell
curl "https://YOUR_HERALD_HOST/api/v1/decisions?since=2026-11-15T00:00:00Z&limit=500" \
  -H "Authorization: Bearer $HERALD_INGEST_TOKEN"

Response

FieldValue
rowsDecisions, each with decisionId, userId (your External ID), agentId, agentName, variantId, variantName, channel, sentAt, deliveryStatus, deliveredAt, openedAt (the push open), conversionEvent, conversionAt, conversionValue and reward
nextCursorThe cursor for the next page, or null on the last page
json
{ "data": {
  "rows": [
    { "decisionId": "cmh…", "userId": "u_123", "agentId": "cmh…", "agentName": "Upgrade nudges",
      "variantId": "cmh…", "variantName": "Short copy", "channel": "push",
      "sentAt": "2026-11-15T08:00:00.000Z", "deliveryStatus": "delivered", "deliveredAt": "2026-11-15T08:00:02.000Z",
      "openedAt": "2026-11-15T09:10:00.000Z", "conversionEvent": "plan_started", "conversionAt": "2026-11-15T09:12:00.000Z",
      "conversionValue": 59.99, "reward": 1 }
  ],
  "nextCursor": "MjAyNi0xMS0xNVQwOToxMjowMC4wMDBafGNtaC4uLg"
} }

deliveryStatus is delivered, bounced, complained, failed, suppressed, expired, paused or null. Times are ISO 8601 in UTC; a missing value is null.

A decision comes back again whenever an outcome arrives, so rows change after you first load them. To sync:

  1. Upsert on decisionId.
  2. On each run, set since to the start of your previous run minus an overlap of at least 2 days. Delivery failures and bounces carry no timestamp of their own, so they surface only through the overlap; a weekly full reload catches anything later.

Errors are the same as for the holdout export below.

GET /api/v1/holdout

Exports which users an agent messaged and which it held out, so your warehouse can compute lift. The agent must belong to the token's app.

Request

It takes agentId (required) plus the same since, cursor and limit as the decisions export.

shell
curl "https://YOUR_HERALD_HOST/api/v1/holdout?agentId=AGENT_ID" \
  -H "Authorization: Bearer $HERALD_INGEST_TOKEN"

Response

FieldValue
rowsAssignments, each with userId, agentId, assignedAt, group (treated or holdout) and goalConvertedAt
nextCursorThe cursor for the next page, or null on the last page
json
{ "userId": "u_123", "agentId": "AGENT_ID", "assignedAt": "2026-11-15T08:00:00.000Z", "group": "holdout", "goalConvertedAt": null }

goalConvertedAt is the user's first conversion on the agent's main goal while assigned; a row comes back when it is set. Each row is the user's current assignment: when a user moves to another agent, they leave this export. Upsert on (agentId, userId).

StatusBody errorCause
200Done
400since must be an ISO 8601 timestamp, Invalid cursor, limit must be an integer from 1 to 1000, or agentId is requiredBad query
401UnauthorizedMissing or unknown ingest token
403ForbiddenThe connection is disabled
404Agent not foundNo such agent in this app (holdout only)
500Internal server errorServer failure

GET /api/v1/exports/decisions.csv

Downloads the app's decisions and outcomes sent in a date range as CSV, for a spreadsheet or a one-off load. It uses an API key with the exports.read scope, not the ingest token. See Decisions CSV for the columns.

Request

Query parameterRules
from, toDates as YYYY-MM-DD, UTC. Both days are included; at most 31 days
shell
curl -o decisions.csv "https://app.runherald.com/api/v1/exports/decisions.csv?from=2026-11-01&to=2026-11-21" \
  -H "Authorization: Bearer $HERALD_API_KEY"

Response

text/csv with a header row, one row per decision. Errors are JSON:

StatusBody errorCause
200The CSV
400from must be a date (YYYY-MM-DD), to must be a date (YYYY-MM-DD), to must not be before from or The range can be at most 31 daysBad range
401Invalid API keyMissing, unknown, revoked or expired key
403This API key lacks the exports.read scopeWrong scope
429Rate limit exceeded for exports.requests: 60 per hourOver the hourly limit

POST /api/v1/journeys/{id}/enter

Adds people to a live journey whose entry is set to When your server adds them (API). The journey's id is in its console address and in the entry step's settings. Each person enters only if they may: not already in the journey, allowed by its re-entry setting, and in its entry audience if it has one. Sending the same people again is harmless, so there's no Idempotency-Key.

Request

FieldRules
people1 to 1,000 items, each { "externalId": "..." } (up to 200 characters); repeats count once
bash
curl -X POST "https://YOUR_HERALD_HOST/api/v1/journeys/JOURNEY_ID/enter" \
  -H "Authorization: Bearer hk_..." -H "Content-Type: application/json" \
  -d '{ "people": [{ "externalId": "user_42" }, { "externalId": "user_43" }] }'

Response

json
{ "data": { "entered": ["user_42"], "skipped": ["user_43"] } }

People who enter move to the journey's first step within about a minute.

StatusBody errorCause
200Who entered and who was skipped
400Send 1 to 1,000 people or Every person needs an externalId (up to 200 characters)Bad body
401Invalid API keyMissing, unknown, revoked or expired key
403This API key lacks the journeys.enter scopeWrong scope
403Starting journeys from the API isn't on this account's plan.The account's plan doesn't include API entry
404No live journey with that id for this appUnknown id, another app's journey, or not live (paused, stopped or never published)
409This journey isn't set to let people in through the APIIts entry is an event or an audience
429Rate limit exceeded for journeys.enter: 100000 per hourOver the hourly limit

POST and DELETE /api/v1/contacts

Registers or removes contact points (email addresses, phone numbers and push tokens) for your users. Use it to import addresses and tokens you already hold, and to remove them on request.

Request

FieldRules
contacts1 to 1,000 items; body up to 512 KB
userId1 to 200 characters
kindemail, phone, apns, apns_live_activity, fcm, webpush
value1 to 4,096 characters. email must be a valid address; phone must be E.164; apns and apns_live_activity must be 64 or more hex characters; webpush must be an HTTPS endpoint with meta.p256dh and meta.auth.
metaOptional object. For apns, bundleId overrides the connection's bundle ID and sandbox: true sends to the APNs sandbox.
shell
curl -X POST "https://YOUR_HERALD_HOST/api/v1/contacts" \
  -H "Authorization: Bearer $HERALD_INGEST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "contacts": [
    { "userId": "u_123", "kind": "email", "value": "maya@example.com" },
    { "userId": "u_123", "kind": "phone", "value": "+15551234567" },
    { "userId": "u_123", "kind": "apns", "value": "<64 or more hex characters>", "meta": { "bundleId": "com.lumen.app", "sandbox": false } }
  ] }'

Response

FieldValue
upsertedPOST: contacts created or updated, keyed on (connection, kind, value)
removedDELETE: contacts removed, matched on kind and value
StatusBody errorCause
200Done
400Invalid JSON, or Invalid contacts payload: ... with the fieldBad body
401UnauthorizedMissing or unknown ingest token
403ForbiddenThe connection is inactive, or its type does not take contacts
413Request body too largeOver 512 KB
500Internal server errorServer failure

DELETE /api/v1/users/{userId}

Erases one user's data held for a connection, for privacy requests. Only an SDK connection's ingest token is accepted. The userId path segment is 1 to 255 characters.

shell
curl -X DELETE "https://YOUR_HERALD_HOST/api/v1/users/u_123" \
  -H "Authorization: Bearer $HERALD_INGEST_TOKEN"

Response

FieldValue
userIdThe External ID
sdkDevices, sdkEvents, sdkMessages, contactPoints, outboundMessages, userArmStats, userAgentAssignments, pseudonymizedDecisions, failedSendsScrubbedNumbers of rows
trackedUserdeleted, cleared or none; none, and the shared profile is left alone, when the connection held no data about the user
StatusBody errorCause
200Done. Repeating the call returns zero counts and trackedUser none.
400userId must be 1 to 255 charactersBad External ID
401UnauthorizedMissing or unknown ingest token
403ForbiddenThe connection is inactive, or its type does not take contacts
403User deletion needs an SDK connection's ingest tokenThe token belongs to a connection that is not an SDK connection, such as SendGrid
500Internal server errorServer failure

Decisions are kept with a pseudonymous External ID, and suppressions are kept so the address is not contacted again. See User data deletion for what is deleted and kept.

Errors

Every error body is { "error": "<message>" }. The tables above list each endpoint's messages. For status meanings, retries and rate-limit headers, see API errors.

See Herald decide live →