Reference
Server API
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.readscope. For adding people to a journey: one withjourneys.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
| Credential | Header | Endpoints |
|---|---|---|
| Ingest token | Authorization: Bearer <ingest token> | Users, events, decide, decisions, holdout, contacts, user deletion |
API key (hk_…) with exports.read | Authorization: Bearer hk_… | Decisions CSV |
API key (hk_…) with journeys.enter | Authorization: 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) andapi.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 towardapi.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:
| Endpoint | Retry behavior |
|---|---|
POST /api/v1/users | Upserts on userId |
POST /api/v1/events | Stores each event once per id within the app; repeats count in duplicates |
POST /api/v1/decide | The same user and agent within 30 minutes get the same decision |
POST and DELETE /api/v1/contacts | Upserts 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
| Field | Rules |
|---|---|
users | 1 to 1,000 items; body up to 4 MB |
userId | 1 to 200 characters |
attributes | Optional object of attributes to merge into the profile; a null value removes that key |
email | Optional valid address |
signupAt, lastActiveAt | Optional ISO 8601 date-times with offset |
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" }
] }'const res = await fetch("https://YOUR_HERALD_HOST/api/v1/users", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.HERALD_INGEST_TOKEN}`, "Content-Type": "application/json" },
body: JSON.stringify({
users: [{ userId: "u_123", attributes: { plan: "plus" }, email: "maya@example.com" }],
}),
});
const { data, error } = await res.json();Response
| Field | Value |
|---|---|
upserted | Number of users created or updated |
{ "data": { "upserted": 1 } }| Status | Body error | Cause |
|---|---|---|
| 200 | Done | |
| 400 | Invalid JSON, or Invalid users payload: ... with the field | Bad body |
| 401 | Unauthorized | Missing or unknown ingest token |
| 403 | Forbidden | The connection is disabled |
| 413 | Body exceeds 4 MB | Too large |
| 500 | Internal server error | Server failure |
POST /api/v1/events
Sends events. They are stored and count toward agent goals exactly like SDK track and trackPurchase calls.
Request
| Field | Rules |
|---|---|
events | 1 to 1,000 items; body up to 4 MB |
id | 1 to 128 characters; unique per event |
userId | 1 to 200 characters |
name | 1 to 255 characters |
timestamp | ISO 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 |
properties | Optional object |
schemaVersion | Optional. 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 event | Up 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.
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" } }
] }'const res = await fetch("https://YOUR_HERALD_HOST/api/v1/events", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.HERALD_INGEST_TOKEN}`, "Content-Type": "application/json" },
body: JSON.stringify({
events: [
{ id: "evt_1", userId: "u_123", name: "subscription_started", timestamp: new Date().toISOString(), properties: {} },
],
}),
});
const { data, error } = await res.json();Response
| Field | Value |
|---|---|
accepted | Number of new events stored |
duplicates | Event IDs the app already had; they are skipped |
rejected | Only when an event was left out: its id, index, reason and detail. See Rejected events |
{ "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.
| Status | Body error | Cause |
|---|---|---|
| 200 | Done, except any events listed in rejected | |
| 400 | Invalid JSON, or Invalid events payload: ... with the field | Bad body: not an object, no events array, or 0 or over 1,000 events |
| 401 | Unauthorized | Missing or unknown ingest token |
| 403 | Forbidden | The connection is disabled |
| 413 | Body exceeds 4 MB | Too large |
| 500 | Internal server error | Server 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
| Field | Rules |
|---|---|
agentId | Required; the agent's ID from the console |
userId | 1 to 200 characters |
channel | Optional, such as push or email; only that channel's variants are considered |
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" }'const res = await fetch("https://YOUR_HERALD_HOST/api/v1/decide", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.HERALD_INGEST_TOKEN}`, "Content-Type": "application/json" },
body: JSON.stringify({ agentId: "AGENT_ID", userId: "u_123", channel: "email" }),
});
const { data } = await res.json();
if (!data.holdout && !data.noSend) render(data.content);Response
| Field | Value |
|---|---|
decisionId, variantId | IDs of the recorded decision and the chosen variant; null in holdout |
agentId | The agent |
channel | The variant's channel; null in holdout |
holdout | true when the user is in the agent's holdout group: show nothing |
noSend | true when the agent chose to send nothing to this person; render nothing |
explore | true when the pick was exploration rather than the best-known variant |
warmupForced | true when a new variant was shown to gather data |
predictedReward | The bandit's estimate for the variant; null in holdout |
content | The variant's title, subject, body, cta, deeplink, iconImageUrl and htmlBody; null in holdout |
{ "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.
| Status | Body error | Cause |
|---|---|---|
| 200 | Done | |
| 400 | Invalid JSON body, or the field and its problem, such as userId: must be at most 200 characters | Bad body |
| 400 | No active variants | The agent has no active variant (on that channel) |
| 401 | Unauthorized | Missing or unknown ingest token |
| 403 | Forbidden | The connection is disabled |
| 404 | Agent not found | No such agent in this app |
| 404 | User not found | The user has not been sent to Herald |
| 409 | Agent is not active | The agent is not active, or its sending is paused |
| 500 | Internal server error | Server 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 parameter | Rules |
|---|---|
since | Optional ISO 8601 date-time with offset. Returns decisions made, delivered, opened, converted or rescored at or after it. Omit it for every decision. |
cursor | Optional; the nextCursor of the previous page. Keep the same since while you page. |
limit | Optional, 1 to 1,000; default 500 |
curl "https://YOUR_HERALD_HOST/api/v1/decisions?since=2026-11-15T00:00:00Z&limit=500" \
-H "Authorization: Bearer $HERALD_INGEST_TOKEN"let cursor = null;
do {
const url = new URL("https://YOUR_HERALD_HOST/api/v1/decisions");
url.searchParams.set("since", "2026-11-15T00:00:00Z");
if (cursor) url.searchParams.set("cursor", cursor);
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.HERALD_INGEST_TOKEN}` } });
const { data } = await res.json();
await upsertRows(data.rows); // upsert on decisionId
cursor = data.nextCursor;
} while (cursor);Response
| Field | Value |
|---|---|
rows | Decisions, each with decisionId, userId (your External ID), agentId, agentName, variantId, variantName, channel, sentAt, deliveryStatus, deliveredAt, openedAt (the push open), conversionEvent, conversionAt, conversionValue and reward |
nextCursor | The cursor for the next page, or null on the last page |
{ "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:
- Upsert on
decisionId. - On each run, set
sinceto 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.
curl "https://YOUR_HERALD_HOST/api/v1/holdout?agentId=AGENT_ID" \
-H "Authorization: Bearer $HERALD_INGEST_TOKEN"const url = new URL("https://YOUR_HERALD_HOST/api/v1/holdout");
url.searchParams.set("agentId", "AGENT_ID");
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.HERALD_INGEST_TOKEN}` } });
const { data } = await res.json(); // { rows, nextCursor }Response
| Field | Value |
|---|---|
rows | Assignments, each with userId, agentId, assignedAt, group (treated or holdout) and goalConvertedAt |
nextCursor | The cursor for the next page, or null on the last page |
{ "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).
| Status | Body error | Cause |
|---|---|---|
| 200 | Done | |
| 400 | since must be an ISO 8601 timestamp, Invalid cursor, limit must be an integer from 1 to 1000, or agentId is required | Bad query |
| 401 | Unauthorized | Missing or unknown ingest token |
| 403 | Forbidden | The connection is disabled |
| 404 | Agent not found | No such agent in this app (holdout only) |
| 500 | Internal server error | Server 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 parameter | Rules |
|---|---|
from, to | Dates as YYYY-MM-DD, UTC. Both days are included; at most 31 days |
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"const res = await fetch("https://app.runherald.com/api/v1/exports/decisions.csv?from=2026-11-01&to=2026-11-21", {
headers: { Authorization: `Bearer ${process.env.HERALD_API_KEY}` },
});
const csv = await res.text();Response
text/csv with a header row, one row per decision. Errors are JSON:
| Status | Body error | Cause |
|---|---|---|
| 200 | The CSV | |
| 400 | from 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 days | Bad range |
| 401 | Invalid API key | Missing, unknown, revoked or expired key |
| 403 | This API key lacks the exports.read scope | Wrong scope |
| 429 | Rate limit exceeded for exports.requests: 60 per hour | Over 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
| Field | Rules |
|---|---|
people | 1 to 1,000 items, each { "externalId": "..." } (up to 200 characters); repeats count once |
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
{ "data": { "entered": ["user_42"], "skipped": ["user_43"] } }People who enter move to the journey's first step within about a minute.
| Status | Body error | Cause |
|---|---|---|
| 200 | Who entered and who was skipped | |
| 400 | Send 1 to 1,000 people or Every person needs an externalId (up to 200 characters) | Bad body |
| 401 | Invalid API key | Missing, unknown, revoked or expired key |
| 403 | This API key lacks the journeys.enter scope | Wrong scope |
| 403 | Starting journeys from the API isn't on this account's plan. | The account's plan doesn't include API entry |
| 404 | No live journey with that id for this app | Unknown id, another app's journey, or not live (paused, stopped or never published) |
| 409 | This journey isn't set to let people in through the API | Its entry is an event or an audience |
| 429 | Rate limit exceeded for journeys.enter: 100000 per hour | Over 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
| Field | Rules |
|---|---|
contacts | 1 to 1,000 items; body up to 512 KB |
userId | 1 to 200 characters |
kind | email, phone, apns, apns_live_activity, fcm, webpush |
value | 1 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. |
meta | Optional object. For apns, bundleId overrides the connection's bundle ID and sandbox: true sends to the APNs sandbox. |
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 } }
] }'const res = await fetch("https://YOUR_HERALD_HOST/api/v1/contacts", {
method: "POST", // DELETE with the same body removes them
headers: { Authorization: `Bearer ${process.env.HERALD_INGEST_TOKEN}`, "Content-Type": "application/json" },
body: JSON.stringify({ contacts: [{ userId: "u_123", kind: "fcm", value: fcmToken }] }),
});
const { data, error } = await res.json();Response
| Field | Value |
|---|---|
upserted | POST: contacts created or updated, keyed on (connection, kind, value) |
removed | DELETE: contacts removed, matched on kind and value |
| Status | Body error | Cause |
|---|---|---|
| 200 | Done | |
| 400 | Invalid JSON, or Invalid contacts payload: ... with the field | Bad body |
| 401 | Unauthorized | Missing or unknown ingest token |
| 403 | Forbidden | The connection is inactive, or its type does not take contacts |
| 413 | Request body too large | Over 512 KB |
| 500 | Internal server error | Server 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.
curl -X DELETE "https://YOUR_HERALD_HOST/api/v1/users/u_123" \
-H "Authorization: Bearer $HERALD_INGEST_TOKEN"const res = await fetch(`https://YOUR_HERALD_HOST/api/v1/users/${encodeURIComponent(userId)}`, {
method: "DELETE",
headers: { Authorization: `Bearer ${process.env.HERALD_INGEST_TOKEN}` },
});
const { data } = await res.json();Response
| Field | Value |
|---|---|
userId | The External ID |
sdkDevices, sdkEvents, sdkMessages, contactPoints, outboundMessages, userArmStats, userAgentAssignments, pseudonymizedDecisions, failedSendsScrubbed | Numbers of rows |
trackedUser | deleted, cleared or none; none, and the shared profile is left alone, when the connection held no data about the user |
| Status | Body error | Cause |
|---|---|---|
| 200 | Done. Repeating the call returns zero counts and trackedUser none. | |
| 400 | userId must be 1 to 255 characters | Bad External ID |
| 401 | Unauthorized | Missing or unknown ingest token |
| 403 | Forbidden | The connection is inactive, or its type does not take contacts |
| 403 | User deletion needs an SDK connection's ingest token | The token belongs to a connection that is not an SDK connection, such as SendGrid |
| 500 | Internal server error | Server 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.