Skip to main content
A webhook subscription sends events to your HTTPS endpoint without a URL on every call. You register an endpoint once, then pick the events it should receive:
  • every call of one agent, or of the whole workspace, including inbound calls to your numbers and WhatsApp calls
  • campaign lifecycle: started, paused, resumed, finished, stopped
  • wallet alerts: balance low, calls refused for balance, balance back up
  • payments: payment received, payment failed
  • rented phone numbers: renewal coming up, renewed, released, purchase failed, and business verification updates
  • status: incidents and planned maintenance that may affect your calls
An endpoint can also be a list of email addresses instead of a URL, for the events a person acts on. See Send events by email. The per-call webhook_url, the campaign webhook_url and a phone number’s webhook_url keep working as described in Webhooks. If you use both for the same call or campaign with different URLs, both receive it. If a call’s webhook_url is the same URL as a destination, that URL receives each event once, signed with the destination’s secret. See Which webhook secret do I use?
In the console, open Webhooks to add an endpoint and tick events from a checklist. Everything on this page is the same feature through the API.

Set it up

All routes use your API key and act on the key’s workspace.
1

Create an endpoint

Response (201)
signing_secret is shown only in this response. Store it now. Reads never return it again.
The URL must be HTTPS on port 443. Optional headers (up to 16) are stored encrypted, and reads show only their names.
2

Subscribe it to events

For one agent only, use "scope": {"type": "agent", "agent_id": "agt_…"}. Wallet, payment and status events belong to the whole workspace, so an agent subscription cannot list them (the API answers 400).
3

Send a test

This sends a real, signed request to your endpoint with made-up data and "test": true. The 202 response is the queued delivery. Look it up under deliveries.
GET /v2/webhooks/event-types lists every event with its label, group, one-line description, scopes, email (whether an email endpoint can take it), JSON schema and an example payload. It needs your API key.

Event types

Calls

Scope: one agent or the whole workspace. data.call is the call object.

Campaigns

Scope: one agent (the campaigns that agent runs) or the whole workspace. data.campaign is the same object, with the same event id, that the campaign’s own webhook_url receives.

Wallet and payments

Scope: the whole workspace only. The balance in these events is the one GET /v2/wallet shows: what you can spend, after calls in progress. We check it about once a minute, so wallet.balance_low reaches you within a minute of the crossing. A top-up, a call or an API charge can each cause one. If several workspaces share your company’s wallet, each workspace with a subscription receives the payment events.

Phone numbers

Scope: the whole workspace only. There is no grace period on a rented number: if the wallet cannot cover the renewal when it is due, the number is released. That is why the reminders come twice. The account’s owners and billing members also get each of these moments by email (the two reminders, a receipt for each renewal, the release and a failed purchase), with or without a subscription. Pending verifications are checked in the background, so you do not need to poll refresh. data.workspace_id is the workspace that holds the number. For a sub-workspace, the event goes to that sub-workspace’s subscriptions and to your account’s own, because your account’s wallet pays. The two copies have different event ids and the same data. These events cannot go to an email endpoint.

Status

Scope: the whole workspace only. data.incident is the incident as the update left it, and data.impact is what it did to your workspace: your agents with failed calls, and whether those calls were charged. Incidents on the public status page reach every subscribed workspace. Others reach only the workspaces they affect. See Status and incidents for the payload and a receiver that tells your own customers. Your account’s owners also get these updates by email without any subscription. See Status emails to owners.

Send events by email

An endpoint can deliver to email addresses instead of a URL. Use one when a person should act on an event and you have no receiver to build: an incident, a low wallet, a stopped campaign.
Response (201)
Send type: "email" and emails (1 to 10 plain addresses, each once) instead of url. An email endpoint has no url, method, headers or signing secret, so the response has no signing_secret and rotate-secret answers 400. Then subscribe it like any other endpoint.

Who gets the emails

Each address has a state:
  • confirmed: it gets every event the endpoint is subscribed to. Someone on your team who has signed in to the console is confirmed as soon as you add them.
  • pending: anyone else first gets one email asking them to confirm, and nothing more until they open the link and press Confirm. The link works for 7 days.
Once an address confirms, it is confirmed for every email endpoint in the workspace. To ask a pending address again, save the endpoint with PATCH /v2/webhooks/endpoints/{id} and its emails: we send a fresh link at most once a day per address. A workspace sends at most 20 confirmation emails a day.

Which events can go by email

Call, recording, analysis and processing events go to HTTPS endpoints only. A subscription or test that puts one of them on an email endpoint answers 400, naming the event. In GET /v2/webhooks/event-types, each event says "email": true or "email": false.

Sending and receipts

  • Each event becomes one email to each confirmed address. Addresses are read when the email is sent, so an address you remove stops getting mail at once, even for events already queued.
  • A delivery’s state is sent when our mail server accepted the message for every confirmed address. We can’t see whether it then reached the inbox.
  • A refused address fails the attempt with smtp_error. The retry schedule then mails only the addresses still owed. An endpoint with no confirmed address fails with no_confirmed_address.
  • Test sends are marked [Test] in the subject. Each email endpoint takes at most 5 tests in a rolling hour. The next one answers 429 rate_limited.
  • Email endpoints count toward the workspace’s limit of 20 endpoints.

Low balance alert level

The alert level is ₹500 until you change it.
Response
GET /v2/webhooks/settings reads it, and also returns call_webhook_urls, the webhook_urls your calls used in the last 7 days (details). Set it to 0 to turn wallet.balance_low off; wallet.depleted still fires. Pass if_revision if you want a stale write refused. The same settings hold status_email, true until you change it. It controls the incident and maintenance emails your account’s owners get without a subscription. Send {"status_email": false} to leave this workspace out of them (details). A PATCH can change either field, or both; a field you leave out keeps its value.

Payloads

Every event has the same envelope.
required_inr is what the refused call needed to start. data.call is absent when a campaign paused before placing a call.
kind is top_up, monthly_payment, plan_upgrade or subscription. amount_inr is the amount credited, before GST. payment.failed carries the same payment object with a reason in the bank’s words.
days_left is 7 for the first reminder and 1 for the one 24 hours before. wallet_covers and short_by_* are worked out when the event is sent. Top up by renews_at to keep the number. agent_id and agent_name are null and "" when no agent answers the number.The other rental events carry the same data.workspace_id and data.rental, plus:
verification is the application as GET /v2/telephony/onboarding returns it. rejection_reason is null unless state is rejected. When an application is accepted you get one event with setup_state ready once your number account is set up, and you can rent.
data.impact is null when we have no numbers for your workspace. Every field is described in Status and incidents.
Each event type’s full JSON schema is in GET /v2/webhooks/event-types.

Verify the signature

Every delivery to an HTTPS endpoint is signed with the endpoint’s signing_secret (the Destination secret), using the same scheme as call webhooks. Email endpoints are not signed. A signed delivery carries these headers:
v1 is the lowercase hex HMAC-SHA256(signing_secret, "<t>.<raw_body>"). Reject a timestamp more than 300 seconds from now, and compare in constant time.
Verify the raw bytes you received, before parsing the JSON. X-Mirai-Signed-With names the destination whose secret signed the delivery. If a check fails, see A webhook failed its signature check. Rotating the secret. POST /v2/webhooks/endpoints/{id}/rotate-secret with {"if_revision": N} returns a new secret that starts signing five minutes later. Install it alongside the old one before then, and keep the old one for an hour. X-Mirai-Key-Version tells you which secret signed a delivery.

Deliveries and retries

Delivery is at least once. Return any 2xx after you have stored the event; store id with a unique constraint so a repeat does nothing. Events can arrive out of order, so act on created_at and the object’s state, not arrival order. A failed delivery is retried after 1 second, 7 seconds, 49 seconds, about 6 minutes, then every 30 minutes, for up to 24 hours. A Retry-After header from you is respected.

Manage endpoints and subscriptions

Creating an endpoint, rotating, testing and retrying accept an Idempotency-Key header, so a retried request never creates a second endpoint or secret. Two subscriptions that match the same event for the same endpoint produce one delivery.

Checklist

  • Endpoint is public HTTPS on port 443 and answers 2xx within a few seconds.
  • signing_secret stored; signature checked on the raw body; old timestamps rejected.
  • Events stored by id with a unique constraint.
  • Alert level set to the balance at which you want to top up.
  • Status events going to an HTTPS or email endpoint that someone watches.
  • A test event sent and seen in your logs.