REST API
The endpoints of herald cloud and of herald, with their requests and responses.
There are two APIs, and the same API key works for both:
- herald cloud's API, at
<herald cloud URL>/api/cli/…: the workspace, numbers, trunks, keys, the voice URL and the call history. It is what the CLI uses. - herald's API, at the address
herald-cloud whoami --jsonprints asapi: calls out, the calls in progress, hangup and transfer. It is whatHeraldClientuses.
Authentication
Send an API key of the workspace as a bearer token:
curl <herald cloud URL>/api/cli/workspace \
-H "Authorization: Bearer hc_…"Create keys in the dashboard (Developers → API keys), with herald-cloud keys create, or with POST /api/cli/keys. A key sees and changes only its own workspace.
Errors
Responses are JSON. An error is a 4xx (or 502 when herald is not reachable) with a message:
{ "error": "unknown API key: run herald-cloud login" }| Status | |
|---|---|
| 400 | the request is not valid: the message says which field |
| 401 | no key, or a key that is not valid |
| 404 | no such number, trunk, key, call or endpoint |
| 409 | the key name matches several keys |
| 502 | herald is not reachable (live calls) |
Changes answer { "ok": true, "message": "…" }. When herald could not be told about a change at once, the message says so: herald reads it again within a minute.
herald cloud
GET workspace
GET /api/cli/workspace
GET /api/cli/workspace?secret=1The workspace of the key. With secret, it includes the signing secret.
{
"id": "w-…",
"name": "Acme",
"mode": "tunnel",
"voice_url": "https://w-….<tunnel host>/herald",
"path": "/herald",
"secret": "…",
"test_line": "712345678901",
"sip": "<herald SIP host:port>",
"dashboard": "<herald cloud URL>/app",
"api": "<herald API URL>"
}| Field | |
|---|---|
mode | tunnel, url or none: how calls reach the program |
voice_url | where herald sends the workspace's calls, or null |
path | the tunnel path |
secret | only with ?secret=1 |
test_line | digits that ring the workspace from any SIP phone at sip |
api | herald's API, for calls out and live calls, or null |
PATCH backend
PATCH /api/cli/backendChanges where the workspace's calls go. Send only the fields to change.
| Field | |
|---|---|
mode | url or tunnel |
voice_url | http(s)://…, or ws(s)://… for a program that takes every call as a stream; required for mode: "url" unless already set |
tunnel_path | the path on your machine, starting with / |
status_webhook | where herald posts call.ended; empty or null: the voice URL |
curl -X PATCH <herald cloud URL>/api/cli/backend \
-H "Authorization: Bearer hc_…" -H "content-type: application/json" \
-d '{"mode": "url", "voice_url": "https://api.example.com/herald"}'{ "ok": true, "message": "Saved", "workspace": { "id": "w-…", "mode": "url", "voice_url": "https://api.example.com/herald", … } }workspace is the object of GET workspace.
POST backend/test
POST /api/cli/backend/testSends the voice URL a call.incoming as herald would, signed with the workspace's secret, and reports what came back. The test call's id starts with test- and it comes from sip:test@herald.cloud; the request body has "test": true.
{ "ok": true, "status": 200, "ms": 41, "url": "https://api.example.com/herald", "verbs": [{ "verb": "play", "file": "?audio=…" }, { "verb": "gather", "max_digits": 1, "timeout": "6s", "action": "?h=…" }], "body": "…" }{ "ok": false, "status": 401, "ms": 12, "url": "https://api.example.com/herald", "error": "It answered 401", "hint": "It refused herald's signature: give your program this workspace's secret as HERALD_SECRET.", "body": "…" }The answer must be {"verbs": [...]} (or a 204) within 10 seconds. A ws(s):// voice URL cannot be tested this way.
POST tunnel
POST /api/cli/tunnelSwitches the workspace to the tunnel. herald-cloud tunnel calls it once connected.
| Field | |
|---|---|
path | optional: the tunnel path, starting with / |
Answers the object of GET workspace.
POST secret/rotate
POST /api/cli/secret/rotateA new signing secret. herald signs with it at once. Read it with GET workspace?secret=1.
{ "ok": true, "message": "New secret: update your backend" }POST test-line/rotate
POST /api/cli/test-line/rotateA new test line; the old one stops ringing.
{ "ok": true, "message": "New test line: the old one no longer rings" }GET numbers
GET /api/cli/numbers[{ "number": "+390212345678", "verified": true }]POST numbers
POST /api/cli/numbers| Field | |
|---|---|
number | international format, e.g. +390212345678 (required) |
At most 10 numbers in a workspace. A number takes calls once verified.
{ "ok": true, "message": "+390212345678 added: verify it to take its calls" }POST numbers/:number/verify
POST /api/cli/numbers/+390212345678/verifyherald calls the number; the person who answers types the code on the keypad.
{ "ok": true, "code": "4821", "message": "herald is calling +390212345678: answer, and type 4821 on the keypad" }When the number is verified at once: { "ok": true, "verified": true }. Poll GET numbers to see when it is verified.
DELETE numbers/:number
DELETE /api/cli/numbers/+390212345678{ "ok": true, "message": "+390212345678 removed" }GET trunks
GET /api/cli/trunks[
{
"name": "main",
"registrar": "sip.provider.example",
"username": "0212345678",
"transport": "udp",
"outbound": true,
"no_register": false,
"sources": [],
"approved": null,
"registered": true
}
]| Field | |
|---|---|
approved | for a trunk without registration: whether it passed review; null otherwise |
registered | whether herald is registered with it now; null when herald cannot be asked |
POST trunks
POST /api/cli/trunks| Field | |
|---|---|
name | lowercase letters, digits and -, up to 32 (required) |
registrar | host or host:port (required) |
username | the SIP username (required) |
password | the SIP password; stored encrypted |
transport | udp (default), tcp or tls |
outbound | true: calls out go through this trunk |
caller_id | the number calls out show |
no_register | true: herald does not register; needs sources |
sources | addresses or CIDR prefixes calls come from (at most /16 for IPv4, /32 for IPv6), as a list or comma-separated |
auth_username | the authentication username, when different |
domain | the SIP domain, when different from the registrar |
contact_user | the user in the Contact header |
{ "ok": true, "message": "Trunk added" }A trunk with no_register takes calls once approved: "Trunk added: we review trunks without registration before they take calls".
DELETE trunks/:name
DELETE /api/cli/trunks/main{ "ok": true, "message": "Trunk main removed" }GET keys
GET /api/cli/keys[{ "name": "laptop", "prefix": "hc_a1b2", "created_at": "2026-11-29T10:00:00.000Z", "this_cli": true }]this_cli marks the key of the request.
POST keys
POST /api/cli/keys| Field | |
|---|---|
name | optional: where you use it |
{ "ok": true, "key": "hc_…", "message": "Copy the key now: it is not shown again" }DELETE keys/:prefix
DELETE /api/cli/keys/hc_a1b2Revokes a key by its prefix or its name. A name shared by several keys answers 409.
{ "ok": true, "message": "Key laptop revoked" }GET calls
GET /api/cli/calls?limit=20
GET /api/cli/calls?live=1The ended and refused calls, newest first (limit: default 20, at most 200):
[
{
"id": "…",
"kind": "ended",
"direction": "inbound",
"from": "sip:+393331234567@…",
"number": "+390212345678",
"startedAt": "2026-11-29T10:00:00.000Z",
"endedAt": "2026-11-29T10:01:12.000Z",
"durationMs": 72000,
"endReason": "caller_hangup",
"limit": null
}
]| Field | |
|---|---|
kind | ended, or refused when a limit refused the call |
direction | inbound or outbound |
endReason | how it ended, as herald reports it |
limit | for a refused call: the limit that refused it |
With live=1, the calls in progress, from herald:
[
{
"id": "…",
"from": "sip:+393331234567@…",
"number": "+390212345678",
"tenant": "w-…",
"direction": "inbound",
"matched_by": "request-uri",
"started_at": "2026-11-29T10:00:00Z",
"answered": true,
"streaming": false,
"transferring": false
}
]GET calls/:id
GET /api/cli/calls/<id>One ended or refused call, with the fields above plus workspaceId and event, the call.ended or call.refused herald sent.
POST calls/:id/hangup
POST /api/cli/calls/<id>/hangupEnds a call in progress of the workspace.
{ "ok": true }GET prompt
GET /api/cli/prompt?template=agent&port=4000&task=…The prompt for a coding agent with the workspace's details, as text/plain. template: agent, menu or custom (default); port: default 4000; task: what the line should do.
CLI sign-in
The CLI signs in with two unauthenticated requests:
POST /api/cli/login{ "token": "…", "code": "BCDF-GHJK", "url": "<herald cloud URL>/cli?code=BCDF-GHJK", "interval": 2 }Open url, sign in and approve the code. Then poll every interval seconds:
GET /api/cli/login?token=…| Status | |
|---|---|
| 202 | { "status": "pending" }: not approved yet |
| 200 | { "status": "ok", "key": "hc_…", "workspace": "w-…", "name": "Acme", "tunnel": "<tunnel server>", "app": "<herald cloud URL>" }, once |
| 410 | the code expired (after 10 minutes) |
The key is created with the name CLI, <date>.
herald
herald's API is at the address herald-cloud whoami --json prints as api, under /v1. It takes the same API keys, and a key sees only its workspace's calls. Request bodies are JSON (at most 1 MiB); unknown fields are refused with 400. Errors are { "error": "…" }.
| Status | |
|---|---|
| 401 | missing or wrong API key |
| 403 | the request names another workspace, or needs herald's admin key |
| 404 | no such call in progress (unknown, ended, or another workspace's) |
| 409 | the call has no stream, or a transfer is already in progress |
| 410 | the call hung up meanwhile |
| 429 | a limit of the workspace refused the call: limit <name>: <detail> |
POST /v1/calls
POST /v1/callsPlaces a call out through a trunk of the workspace with calls out.
| Field | |
|---|---|
to | the number to call (required) |
voice_url | the program that takes the call once answered: it gets call.incoming with "direction": "outbound" |
verbs | verbs to run once answered, instead of voice_url |
trunk | the trunk to call through; default: the first with calls out |
caller_id | the number shown; default: the trunk's |
timeout | ringing, e.g. "30s" (default 30 s) |
customer | a label carried in the call's events (default "outbound") |
status_webhook | where call.ended goes; default: the workspace's |
One of voice_url and verbs is required.
curl -X POST <herald API URL>/v1/calls \
-H "Authorization: Bearer hc_…" -H "content-type: application/json" \
-d '{"to": "+390212345678", "voice_url": "https://api.example.com/herald"}'{ "id": "6b1f…", "status": "calling" }The status is 202: the answer comes at once. How the call went arrives as call.ended on the status webhook; an unanswered call ends with end_reason no_answer, busy or failed. Calls over the workspace's limits (calls at once, number prefixes, calls out per hour) answer 429.
GET /v1/calls
GET /v1/callsThe workspace's calls in progress.
{
"calls": [
{
"id": "6b1f…",
"sip_call_id": "…",
"from": "sip:+393331234567@carrier",
"to": "sip:+390212345678@herald",
"request_uri": "sip:+390212345678@herald",
"number": "+390212345678",
"matched_by": "request-uri",
"customer": "",
"started_at": "2026-11-29T10:00:00Z",
"direction": "inbound",
"tenant": "w-…",
"answered": true,
"streaming": false,
"transferring": false
}
]
}| Field | |
|---|---|
matched_by | how herald found the number: diversion, history-info, request-uri, to or test_line |
tenant | the workspace id |
streaming | a program has the call's audio (call.stream(), connect) |
transferring | a person has the call through a transfer |
GET /v1/calls/:id
GET /v1/calls/6b1f…One call in progress, as in the list.
POST /v1/calls/:id/hangup
POST /v1/calls/6b1f…/hangup{ "status": "hung_up" }The call ends with end_reason: "api_hangup".
POST /v1/calls/:id/redirect
POST /v1/calls/6b1f…/redirectReplaces what the call is doing with these verbs; the verb that is running stops.
{ "verbs": [{ "verb": "play", "file": "https://cdn.example.com/closing.wav" }, { "verb": "hangup" }] }{ "status": "redirected" }POST /v1/calls/:id/transfer
POST /v1/calls/6b1f…/transferPasses a call whose audio a program has (a stream) to a person.
| Field | |
|---|---|
target | a number (tel:+39… or digits) (required) |
trunk, caller_id | the trunk with calls out, and the number shown (inherit: the caller's) |
mode | return (default): the call comes back to the program when the person hangs up; handoff: it stays with them |
timeout | ringing (default 30 s) |
reason | why, for the program |
summary | what the person sees before answering |
{ "status": "transferring" }The status is 202. The program gets the outcome on its stream.
POST /v1/calls/:id/resume
POST /v1/calls/6b1f…/resumeHands a transferred call back to the program, with an optional note it receives.
{ "note": "customer verified" }{ "status": "resuming" }What herald sends your program
Your program does not call herald for a call: herald calls it. With herald() the SDK handles these requests; this is the protocol underneath, for a program written without it.
Every request is signed with the workspace's signing secret:
X-Herald-Timestamp: 1795980000
X-Herald-Signature: sha256=<hex HMAC-SHA256(secret, "<timestamp>.<body>")>For a WebSocket voice URL the signed payload is the URL herald connects to instead of the body. verifySignature checks it.
| Event | Sent to | When | Your answer |
|---|---|---|---|
call.incoming | the voice URL | a call arrives, before it is answered (within 5 s) | {"verbs": [...]}; a 404 refuses the call |
call.result | the action URL of a verb | a verb with a result is done | {"verbs": [...]}: what runs next |
call.redirect | the URL of a redirect verb | the verb runs | {"verbs": [...]} |
call.ended | the status webhook | the call is over | ignored |
{
"event": "call.incoming",
"call": {
"id": "6b1f…",
"from": "sip:+393331234567@carrier",
"to": "sip:+390212345678@herald",
"number": "+390212345678",
"matched_by": "request-uri",
"direction": "inbound",
"tenant": "w-…",
"started_at": "2026-11-29T10:00:00Z"
},
"stream_url": "wss://…"
}call.result adds result, the verb's result; call.ended adds results (every result, in order), last_result, ended_at and end_reason. end_reason is one of flow_hangup, flow_end, caller_hangup, stream_hangup, api_hangup, rejected, error, step_limit, rtp_timeout, session_expired, shutdown, max_duration, and for unanswered calls out no_answer, busy, failed. stream_url is a single-use WebSocket for the call, valid while that request waits for its answer: a program that opens it runs the call on it (verbs with herald.verb, and the audio), and herald answers the call only when the program needs the audio.
The verbs are listed under call.run(). An answer that ends the list ends the call.
Other endpoints
These serve the site itself, herald and the tunnel server; the ones herald and the tunnel server call are signed with secrets only they have. A program does not call them.
| Endpoint | |
|---|---|
/api/auth/* | the dashboard's sign-up and sign-in |
POST /api/demo/code, GET /api/demo/live, /api/demo/herald | the homepage demo: a code to call with, its events, its program |
GET /api/search | the search of these docs |
GET /api/herald/tenants | herald reads every workspace: numbers, trunks, voice URLs, keys, limits |
POST /api/herald/events | herald posts call.ended and call.refused: the call history |
GET, POST /api/verify/:id | the verification call of a number |
POST /api/internal/tunnel/auth | the tunnel server asks which workspace a key belongs to |
GET /api/health | { "ok": true } when the app and its database answer |