Skip to content
Menu

Reference

SDK REST endpoints

Markdown version

The HTTP endpoints the SDK calls, with headers, schemas, limits, status codes and verification modes, and how your backend mints user tokens.

The SDK talks to these Herald endpoints. You do not call them from the app yourself; this page is for backend engineers, security reviewers and anyone debugging traffic. Your backend mints user tokens (below) and calls the Server API.

All paths are relative to your Herald base URL, the endpoint you pass to configure. Every response body is JSON: { "data": ... } on success, { "error": "..." } on failure.

Authentication

HeaderSent onValue
x-herald-app-keyEvery SDK requestThe connection's app key (its publishable key). Public: it identifies the connection and grants no secret access.
x-herald-user-tokenRequests that name a user, when the SDK has a tokenHex HMAC-SHA256 of the External ID, keyed with the SHA-256 hex digest of the connection's ingest token

The app key must belong to an active Herald sending connection. Any other key gets 401 Invalid app key.

Getting the keys

Both keys live on the app's connection, under Settings → Sending & SDK:

  • App key. Open the app and select Generate app key on the Mobile SDK card. It goes in the app.
  • Ingest token (nx_ingest_…). Open the app and select Rotate next to Ingest token. Herald shows the token once, so copy it into your backend's secret store then. It signs user tokens and authorizes server calls as Authorization: Bearer <ingest token>. Rotating it again invalidates the old token at once: see Rotating the ingest token.

Verification modes

Set on the connection's Mobile SDK card. A connection without a setting uses Required.

ModeRequest names a user, valid tokenNames a user, no tokenNames a user, wrong tokenNames no user
requiredVerified401 Invalid user token401 Invalid user tokenAnonymous
optionalVerifiedProcessed as anonymous401 Invalid user tokenAnonymous
offTrusted as sentTrusted as sentTrusted as sent (not checked)Anonymous

A batch names a user through its userId field, or, when that is empty, the userId of its first identify event. A message fetch names a user through its userId query parameter. A token sent on a request that names no user is ignored.

Warning

With verification off, anyone with your app key can send data as any user and read their messages. Use it only for testing.

POST /api/v1/sdk/batch

Uploads queued events. Native clients only, so no CORS.

Request

HeaderRequiredValue
Content-TypeYesapplication/json
x-herald-app-keyYesApp key
x-herald-user-tokenDepends on the modeUser token
FieldTypeRules
sdk.namestring1 to 64 characters (herald-ios, herald-android)
sdk.versionstring1 to 32 characters
deviceIdstring1 to 128 characters
userIdstring or null1 to 200 characters; null or absent for an anonymous batch
sentAtstringISO 8601 date-time with offset
droppedinteger0 or more; events the device dropped (a full queue, over 32 KB, or queued more than 30 days). Default 0.
contextobjectDevice data; see Event payload spec
eventsarrayUp to 100 events; see Event payload spec
json
{
  "sdk": { "name": "herald-ios", "version": "0.4.0" },
  "deviceId": "6c1f2a9e-0b7d-4a8e-9f61-1b2c3d4e5f60",
  "userId": "u_123",
  "sentAt": "2026-11-09T14:00:00Z",
  "dropped": 0,
  "context": {
    "app": { "name": "Lumen", "version": "4.2.0", "build": "812", "namespace": "com.lumen.app" },
    "os": { "name": "iOS", "version": "18.1" },
    "region": "US"
  },
  "events": [
    { "id": "a1b2", "type": "track", "timestamp": "2026-11-09T13:59:58Z", "sessionId": "1731160800000",
      "name": "workout_completed", "properties": { "minutes": 32 } }
  ]
}

Limits

  • 512 KB per request body. Checked against Content-Length and the body itself.
  • 100 events per request.
  • 32 KB per event, as JSON. The SDKs drop a larger event on the device and count it in dropped.
  • Each event is checked on its own: an invalid one is rejected and the rest are stored. Only a problem with the batch itself (JSON, sdk, deviceId, userId, sentAt, dropped, context, the events array) fails it with a 400. The SDKs check every call on the device, so rejects are rare in normal use.
  • Event time: Herald corrects each event's timestamp for the device's clock, using sentAt and the time the batch arrived, and rejects events more than 30 days old. See Clock correction.

Response

json
{ "data": { "accepted": 1, "duplicates": 0, "heraldId": "7K3M-9QXA" } }

accepted counts new events stored. duplicates counts event IDs this connection already had; they are skipped, so a retried batch is safe. heraldId is the batch user's User ID (see Support ID), sent for the user the batch is verified as once their profile exists: with a valid user token under Required or Optional, and for any claimed user under Off. Anonymous batches and Optional batches without a token leave it out. It isn't secret. When events were rejected, rejected lists them, and accepted and duplicates count only the valid ones:

json
{ "data": { "accepted": 1, "duplicates": 0,
  "rejected": [{ "id": "e2", "index": 1, "reason": "too_old", "detail": "timestamp is more than 30 days old" }] } }

Each entry has the event's id (null when it has no usable one), its index in events, a reason code and a short detail. The codes are listed under Rejected events.

Status codes

StatusBody errorCauseWhat the SDK does
200Stored, except any events listed in rejectedRemoves the batch from its queue; logs each rejected event at debug level and never retries it
400Invalid JSONBody is not JSONDrops the batch, logs an error
400Path and message, such as deviceId: Too small: expected string to have >=1 charactersThe batch breaks the schemaDrops the batch, logs an error
401Invalid app keyMissing, unknown or inactive app keyKeeps every queued event, logs an error, and sends nothing more until the app launches again
401Invalid user tokenSee the verification tableKeeps that user's events until the app calls setUserToken, logs a warning; anonymous events keep flowing
413Batch exceeds 512 KB or Batch exceeds 100 eventsToo largeDrops the batch, logs an error
500Internal server errorServer failureKeeps the batch and retries with backoff

The SDKs also retry 408, 429 and any 5xx, and honor a Retry-After header (seconds or HTTP date) or a retryAfterSeconds body field, capped at one hour. Herald itself does not return 429 today; a proxy or firewall in front of it may.

What the server does with a batch

  • Device record. Creates or updates the device, with its platform, context and region. Region comes from the country of the request's IP address when the hosting platform supplies it, else from context.region.
  • Verified user. Only the verified user gets writes: attributes, email and phone contacts, push tokens, subscriptions, message state and outcome credit. Events that claim any other user are stored with no user, and the claim is kept in the stored payload.
  • Sign-out. A batch with no user unbinds the device from its previous user and deletes that user's push tokens for this device.
  • Time zone. A verified user's time zone is filled from context.timezone only when the profile has none.
  • Idempotency. Events are stored once per (connection, id).

POST /api/v1/sdk/diagnostics

Uploads crash and hang reports from the iOS SDK, when crashReports is on. Native clients only, so no CORS. The request carries no user or device id.

HeaderRequiredValue
Content-TypeYesapplication/json
x-herald-app-keyYesApp key

A request holds 1 to 20 reports and is at most 256 KB.

GET /api/v1/sdk/config

SDK 0.6.0+. Returns the app's remote SDK settings, set in the console under Settings, SDK settings. Native clients only.

HeaderRequiredValue
x-herald-app-keyYesApp key
If-None-MatchNoThe ETag of the last response
json
{ "data": { "version": "3f9c2a7b1d4e6f80", "settings": { "enabled": true, "flushIntervalSeconds": 30, "dataCollection": "minimal" } } }

version is opaque and changes on every save; it is "0" with empty settings until the first save. Every setting is optional, and an absent one means the value built into the app:

SettingValues
enabledtrue or false. false stops all collection and sending in the SDK and clears its queue (push tokens and subscriptions wait and go out when it is back on)
flushIntervalSeconds5 to 300
foregroundSessionTimeoutSeconds, backgroundSessionTimeoutSeconds60 to 86400, a multiple of 60 (whole minutes)
dataCollectionstandard or minimal
trackLifecycleEvents, trackExternalPushes, trackDeepLinkstrue or false
geofencestrue or false. SDK 0.7.0+. false stops geofence monitoring on every device; see Geofences

The response carries ETag (the quoted version) and Cache-Control: private, no-cache. A matching If-None-Match returns 304 with no body. A bad app key returns 401 Invalid app key. The SDKs fetch it at launch and on a foreground at most once an hour; see iOS API and Android API.

GET /api/v1/sdk/geofences

SDK 0.7.0+. Not released yet. Returns the app's whole geofence list, set in the console under Settings, Geofences, for the HeraldGeofence (iOS) and herald-geofence (Android) modules. The request carries no location: the device picks the regions to monitor itself. Native clients only.

HeaderRequiredValue
x-herald-app-keyYesApp key
If-None-MatchNoThe ETag of the last response
json
{ "data": { "enabled": true, "geofences": [ { "id": "4f1c2b9e-7a3d-4e8b-9c51-2d6f0a8b3e17", "name": "Store 12", "latitude": 40.7484, "longitude": -73.9857, "radiusMeters": 200 } ] } }

enabled is the app's Geofences SDK setting (geofences in GET /api/v1/sdk/config); it is true unless an admin set it to Off, and then geofences is empty and the SDK stops monitoring. Geofences are listed oldest first, at most 100. The response carries a strong ETag over the body and Cache-Control: private, no-cache; a matching If-None-Match returns 304 with no body. A bad app key returns 401 Invalid app key. See Geofences.

GET /api/v1/sdk/messages

Returns the content cards and in-app messages for the SDK's user.

Request

Query parameterRequiredRules
deviceIdYes1 to 128 characters
userIdNo1 to 200 characters; omit for an anonymous device
HeaderRequiredValue
x-herald-app-keyYesApp key
x-herald-user-tokenDepends on the modeUser token
If-None-MatchNoThe ETag of the last response

Response

json
{ "data": {
  "syncedAt": "2026-11-09T14:00:00.000Z",
  "contentCards": [
    { "id": "msg_1", "type": "captioned_image", "title": "Your 7 AM session, upgraded", "body": "Try Plus free for 7 days.",
      "imageUrl": "https://cdn.example.com/plus.jpg", "cta": "Try Plus", "url": "lumen://plus", "extras": {},
      "pinned": false, "dismissible": true, "categories": [], "createdAt": "2026-11-09T13:00:00.000Z",
      "expiresAt": null, "viewed": false, "clicked": false, "dismissed": false, "decisionId": "dec_1" }
  ],
  "inAppMessages": [
    { "id": "msg_2", "type": "modal", "priority": 0,
      "trigger": { "type": "session_start" }, "reEligibility": { "mode": "once" }, "expiresAt": null,
      "content": { "header": "Nice work, Maya", "body": "You logged 5 workouts this week.", "imageUrl": null,
        "buttons": [{ "id": "primary", "text": "See Plus", "action": { "type": "deeplink", "value": "lumen://plus" } }],
        "html": null, "slideFrom": null, "dismissAfterSeconds": null },
      "style": { "backgroundColor": null, "textColor": null, "buttonColor": null, "buttonTextColor": null, "cornerRadius": null },
      "decisionId": "dec_2" }
  ]
} }
FieldValues
Card typeclassic, captioned_image, image_only
Message typeslideup, modal, full, html
trigger.typesession_start, push_open, event (with event and optional propertyFilters)
propertyFilters[].opeq, neq, gt, gte, lt, lte, contains, exists
reEligibility.modeonce, after_hours (with hours, greater than 0)
Button action.typedeeplink, url, close
slideFromtop, bottom, null
Style fieldsHex color strings or null; null means use the app theme

Rules:

  • Only active, unexpired, undismissed messages are returned, newest first: up to 100 content cards and 50 in-app messages.
  • An anonymous or unverified caller gets empty lists.
  • The response carries a strong ETag and Cache-Control: private, no-cache. A matching If-None-Match returns 304 with no body. The ETag changes when any card or message changes, including its viewed or clicked state.
  • The SDKs skip an item they cannot read (for example a type from a newer version) and keep the rest.

Status codes

StatusBody errorCause
200The lists
304Nothing changed since the ETag you sent
400Parameter and message, such as deviceId: RequiredBad query
401Invalid app key or Invalid user tokenSee the verification table
500Internal server errorServer failure

On any failure the SDK keeps showing its cached cards and messages.

Backend: minting user tokens

There is no endpoint for this: your backend computes the token. It needs the connection's ingest token, which Rotate ingest token on the connection page shows once. Keep the ingest token on your server only.

javascript
// Node.js. HERALD_INGEST_TOKEN is the connection's ingest token.
import { createHash, createHmac } from "node:crypto";

const key = createHash("sha256").update(process.env.HERALD_INGEST_TOKEN).digest("hex");
const userToken = createHmac("sha256", key).update(userId).digest("hex");
sh
key=$(printf %s "$HERALD_INGEST_TOKEN" | openssl dgst -sha256 -r | cut -d' ' -f1)
printf %s "u_123" | openssl dgst -sha256 -hmac "$key" -r | cut -d' ' -f1

The token does not expire. Rotating the ingest token invalidates every user token at once, so re-mint after a rotation.

Backend endpoints

Your backend's own calls, authorized with the ingest token, are on Server API: users, events, decide, the decisions and holdout exports, contacts and user deletion.

See Herald decide live →