Skip to main content

Phone line webhooks

Phone lines send their events to phone-line webhooks: a registry of their own, separate from the number webhooks. The two never mix:
  • A number webhook — even one subscribed to "*" — never receives a phone_line.* event.
  • A phone-line webhook receives only phone_line.* events, never message or number events.

Configure

Manage phone-line webhooks in the dashboard or through the API — it is the same registry: what you create through one shows up in the other. In the dashboard, under Phone lines → Line webhooks (/linhas/webhooks), as an Owner or Admin; in the API, with a tenant-scoped key on /v1/phone-lines/webhooks. The rules are the same on both:
  • Name — optional, up to 100 characters, to tell your webhooks apart in the list. Left blank, the webhook is named after the URL’s host (hooks.example.com), as number webhooks are. This webhook name is not sent in the deliveries (the name in a delivery is the line’s).
  • Destination URL — must be https, and must reach a public address. A URL that points to an internal or private network address — localhost, a loopback or private IP, a host name without a dot, or a name that resolves to one of those — is refused when you save it (WEBHOOK_URL_REFUSED), since it would never be called.
  • Events — pick one or more of the events below, or all ("*"). Inside this registry "*" means every phone-line event. At least one is required.
  • Signing secret — shown once, when the webhook is created (it starts with plwh_): in the dashboard, in the Signing secret window that opens right after you click Create webhook (with a Copy button; it closes on Got it); in the API, in the POST response. Store it right away: nothing shows it again, and there is no rotation. To change it, create a new webhook, move your receiver to its secret, and delete the old one.
  • Pause / resume, edit (name, URL and events), and delete. Editing never changes the signing secret. A new URL is checked the same way as on creation; saving without changing the URL does not check it again, so a webhook can always be paused.
  • Delivery log — per webhook: event, status (pending, delivered, failed), attempts, the HTTP status your endpoint answered and the last error.
A workspace can have more than one phone-line webhook; each receives the events it subscribed to.
This registry is also reachable as workspace webhooks, at /v1/workspace/webhooks and on the Workspace keys screen, which add the wallet event wallet.topup_paid. The list here shows those webhooks too; one that names wallet.topup_paid can be read and deleted here, but editing it here gets 400 INVALID_WEBHOOK — edit it on /v1/workspace/webhooks.

Through the API

Requires a tenant-scoped key — a workspace key, or an account key with x-workspace-id; a number-scoped key gets 403 NUMBER_SCOPE_NOT_ALLOWED, as on every /v1/phone-lines endpoint. With an account key or an OAuth / MCP token, the user must be an Owner or Admin (phone_lines:webhooks) — 403 PERMISSION_DENIED otherwise. All of them can be tried in the Playground → Phone Lines.

Create a webhook

POST https://pilotstatus.com.br/v1/phone-lines/webhooks with { name?, url, events }. Answers 201 with { "webhook": { … } }, sent with Cache-Control: no-store.
string
required
The public https URL that receives the deliveries.
string[]
required
One or more names from the events table, or ["*"] for every phone-line event. Duplicates are ignored.
string
Up to 100 characters. Absent or blank, it becomes the URL’s host.
Any other body field is refused with 400 UNKNOWN_FIELDS, which names the fields.
The secret comes only in this response. No read — GET, PATCH, the list — returns it, and there is no rotation. Store it on your server before doing anything else; if you lose it, create a new webhook and delete the old one. Creating is not idempotent: repeating the POST (after a timeout, for example) creates a second webhook with another secret — check the list before creating again.Over an OAuth/MCP token the creation is recorded in an audit trail first. If that record cannot be written, the webhook is still created but the response carries "secret": null with "secretWithheld": true, a bilingual secretWithheldReason and "secretWithheldCode": "OAUTH_SECRET_AUDIT_UNAVAILABLE" — delete that webhook and create another.

List and get

GET https://pilotstatus.com.br/v1/phone-lines/webhooks answers { "webhooks": [ … ], "events": [ … ] }: the workspace’s webhooks, oldest first, and the catalogue of events a phone-line webhook can subscribe to. GET …/webhooks/{id} answers { "webhook": { … } }. A webhook of another workspace answers 404 WEBHOOK_NOT_FOUND, like an id that does not exist.
Response (200) — GET /v1/phone-lines/webhooks

Edit, pause and delete

PATCH https://pilotstatus.com.br/v1/phone-lines/webhooks/{id} takes name, url, events and active, all optional; whatever is not sent stays as it is. It answers { "webhook": { … } } without the secret, which never changes. Only a URL that changes is checked again — pausing or changing the events always works, even when the stored URL would be refused today. A name sent blank goes back to the URL’s host.
DELETE https://pilotstatus.com.br/v1/phone-lines/webhooks/{id} answers { "ok": true }. The webhook’s pending deliveries are discarded.

Delivery log

GET https://pilotstatus.com.br/v1/phone-lines/webhooks/{id}/deliveries answers { "deliveries": [ … ] }, newest first, without the body of each delivery.
integer
default:"50"
From 1 to 200. Any other value → 400 INVALID_LIMIT.
Response (200)
status is PENDING, DELIVERED or FAILED; responseStatus is the HTTP status your endpoint answered, and lastError the last error when no accepted answer came back. GET https://pilotstatus.com.br/v1/phone-lines/webhooks/{id}/deliveries/{deliveryId} answers { "delivery": { … } } with the same fields plus three from the last attempt: durationMs, responseBody (your endpoint’s answer, up to 1,000 characters) and payload — the exact body that was sent and signed, as a JSON string. Compute the HMAC over that string with your secret and you get the x-pilot-status-signature the delivery carried. Sent with Cache-Control: no-store.
The payload of a phone_line.code_received carries the activation code, which is a credential. The list never carries it; reading one delivery does. Do not log that response.

Errors

Errors follow the phone-lines envelope: a bilingual error and a code. The authentication and scope errors (401, 403 NUMBER_SCOPE_NOT_ALLOWED, TENANT_REQUIRED, WORKSPACE_ARCHIVED, PERMISSION_DENIED, WORKSPACE_MEMBERSHIP_REQUIRED) are the same as on every /v1/phone-lines endpoint.
INVALID_BODY, UNKNOWN_FIELDS, INVALID_FIELD_TYPE and INVALID_LIMIT build their message from the request — it names the field at fault — and follow the same English | Portuguese pattern.

Events

Every accepted code request ends with one phone_line.code_received — with the code, or with code: null — so waiting on that event alone is enough. A failed transcription is retried from the stored recording (up to 3 attempts in all); only the final outcome is sent, never the attempts in between. A request refused at creation (503 SUPPLIER_UNAVAILABLE, poll_not_scheduled) sends no event: its caller already got the error.phone_line.audio_received and phone_line.code_failed were added on 2026-09-28. A webhook subscribed to all events ("*") receives them; a webhook with an explicit list receives only the events it lists — edit it to add them.

Payload format

Every delivery is a POST with a JSON body:
Headers: Every event about a line — all but phone_line.verification_updated — carries the line’s lineId, number and name: the name your team gave it in the dashboard or, when it has none, its formatted number ((11) 4863-7200), the same as name on the line object. A line is bought without a name, so phone_line.purchased always carries the formatted number. name is the name at the time of the event: renaming a line sends no event, and a retry of a delivery carries the name it was recorded with. Like displayName in the number webhooks, it is a label — match lines by lineId.
Numbers here have no +. number is E.164 digits without the plus sign (551148637200), exactly as in the /v1/phone-lines endpoints — unlike the number webhooks, whose phone fields carry +.

The recording URL

The three events of a code request — phone_line.audio_received, phone_line.code_received and phone_line.code_failed — carry audioUrl: the absolute URL of GET /v1/phone-lines/activations/{activationId}/audio, which serves the call recording.
  • When the request has a recording, it is there. phone_line.audio_received always has it — it is sent once the recording is stored. phone_line.code_received and phone_line.code_failed have it whenever the call was stored: with the code, and also when no code could be read (no_code_in_transcript, transcription_failed), which is when you most want to listen.
  • null when there is none — the key is always present. That is a request that ended before any call was stored: no_call_in_window, canceled_by_customer, audio_download_failed or audio_store_failed.
  • It holds no credential. Fetch it with your tenant-scoped key (x-api-key), like any /v1/phone-lines endpoint; without a key it answers 401, and another workspace’s key gets 404. Storing or logging the URL does not expose the recording.
  • It stops answering when the line leaves your workspace. A RETURNED or CANCELED line has its recordings deleted, and the URL then answers 404.

Payloads

lineId is the line’s id in GET /v1/phone-lines/{id}.
code is null when the request ended without one; failureReason then says why, with the request’s own failureReason: no_code_in_transcript, transcription_failed (all 3 attempts failed), no_call_in_window, canceled_by_customer, audio_download_failed or audio_store_failed. audioUrl is the recording, or null when the request has none — see The recording URL.
This payload carries the activation code, which is a credential. Verify the signature before trusting it, and do not log the body.
The call arrived and its recording is stored; the code is being read. Sent once per request. audioUrl is always set here: download the recording with your key. The recording itself is never in the body, and its transcription is never sent. A call whose recording could not be downloaded or stored sends no audio_received — only code_failed and code_received.
reason is the request’s failureReason — see Statuses. The same value comes in the failureReason of the phone_line.code_received sent with it. audioUrl is null here because no call arrived; with no_code_in_transcript or transcription_failed it points to the recording.
currentPeriodEnd is the end of the period just paid for.
reason is why the line went back to the carrier — a stable snake_case code:Treat a reason you do not know as a return all the same. The line’s code history — codes and call recordings — is deleted when it is returned.
status is one of:Read the whole state — masked document, contact channels, the reviewer’s note — with GET /v1/phone-lines/verification. verificationId is its verification.id, and also identifies it in support conversations.

Verify the signature

Every phone-line webhook has a secret, so every delivery is signed. x-pilot-status-signature is the hex-encoded HMAC-SHA256 of the raw request body, keyed with the webhook’s secret (the whole string, plwh_ prefix included). Compute it over the bytes exactly as received — before any JSON parsing — and compare in constant time. With the Python SDK (pilot-status 1.16.0 or later), verify_webhook_signature(raw_body, signature_header, secret) does it for you — the same function as for the number webhooks, called with the full plwh_... secret. Pass the body exactly as it came off the wire — Flask request.get_data(), FastAPI await request.body() — never the parsed and re-serialized JSON. It compares in constant time and returns False, never raising, for a missing or malformed header, an empty secret or a tampered body:
Without the SDK, compute it yourself:
It is the same computation as the number webhooks, so a receiver that already verifies those works here with this webhook’s secret. The signature covers the body only — there is no timestamp header — so rely on id to discard duplicates.

Delivery and retries

  • Answer with any 2xx within 10 seconds. Anything else — another status, a timeout, a connection error — counts as a failed attempt.
  • 6 attempts in total: the first right away, then retries about 30 s, 1 min, 2 min, 4 min and 8 min apart — normally about 15 minutes end to end. After the last one the delivery is marked failed in the log. A delivery that could not be queued at first is picked up again by an hourly sweep, so its first attempt can come later.
  • Redirects are not followed. A 3xx answer counts as a failed attempt.
  • At least once. A retry after your endpoint processed the event but did not answer in time delivers it again, with the same id. Order is not guaranteed.
  • Paused or deleted webhooks. An event is delivered only to webhooks that are active and subscribed when it happens. Every attempt checks the webhook again: a delivery whose webhook is paused when an attempt is due — including one already in its retries — is marked failed and is not sent later; deleting a webhook drops its pending deliveries. Events are never replayed to a webhook created or resumed afterwards.
  • Internal destinations are refused. A URL whose host resolves to a private or internal network address is not called, and is not retried. Such a URL is already refused when you save the webhook; this covers a name whose DNS moved inside afterwards. A DNS lookup that fails is different: it does not block saving, and at delivery it is retried like any other failure.
Treat these events as notifications, not as the source of truth. When one could have been missed — your endpoint was down for longer than the retries — read the current state with GET /v1/phone-lines.