> This page is for version v2.
> For other versions, use one of these documentation indexes:
> - v1 (default): https://doc.youratlas.com/v1/llms.txt
> - v2: https://doc.youratlas.com/v2/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://doc.youratlas.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://doc.youratlas.com/_mcp/server.

# Webhooks

A webhook is a message Atlas sends to your system when something happens. You give Atlas a URL. Atlas sends a signed `POST` with the details, and tries again for about an hour if your endpoint doesn't answer.

Use webhooks to log calls in your own database, start a workflow when a call ends, or keep a CRM current. You don't have to ask Atlas over and over.

This is the other direction from Atlas actions. An action lets your agent call out to your system during a conversation. You add one in the app under **Connections**, then **Actions**, then **New action**, then **Custom action** ("Call your own API or webhook"). A webhook is the reverse: Atlas tells your system after something happened.

If you use Zapier, Make, Keragon or GoHighLevel, set up triggers from those tools instead. Webhooks are for sending events to your own endpoint.

## Where you set it up

Event webhooks are set up through the API or the CLI. The Atlas app has no screen for them. The one thing you need from the app is the ID of the job to watch.

The API calls a job a **campaign**. That is why the fields below say `campaignId`. To find the ID, open the job in the app. The ID is in the page address, after `id=`. Or list your jobs with `GET /campaign`.

## How it works

1. You subscribe to one event for one job, and give a URL.
2. When the event happens, Atlas sends a `POST` to that URL. The body is JSON.
3. Your endpoint answers with a `2xx` status. If it doesn't, Atlas retries on a schedule. See [Delivery](#delivery).

## Events

You can subscribe to five events. `triggerName` is the value you send when you subscribe.

| Event             | `triggerName`               | Fires when                                                          |
| ----------------- | --------------------------- | ------------------------------------------------------------------- |
| Call started      | `call_started`              | A call begins. Inbound and outbound calls both fire it              |
| Call completed    | `call_completed`            | A call ends. Includes summary, transcript and recording link        |
| Message received  | `message_received`          | A customer message arrives on a chat job                            |
| Message sent      | `message_sent`              | Your agent sends a chat message                                     |
| Session completed | `message_session_completed` | A chat session has been quiet for a set time. One event per session |

## Subscribe

Send a `POST` to `/events-gateway/trigger/subscribe`:

```bash
curl 'https://api.youratlas.com/v1/api/events-gateway/trigger/subscribe' \
  --request POST \
  --header 'api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "hookUrl": "https://example.com/atlas/webhook",
    "campaignId": "YOUR_CAMPAIGN_ID",
    "triggerName": "call_completed",
    "provider": "custom"
  }'
```

With the CLI:

```bash
atlas events-gateway events-subscribe-trigger --body '{"hookUrl": "https://example.com/atlas/webhook", "campaignId": "YOUR_CAMPAIGN_ID", "triggerName": "call_completed", "provider": "custom"}'
```

| Field                      | Required | What it is                                                                                                                                                    |
| -------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hookUrl`                  | Yes      | The URL Atlas posts to. Use HTTPS.                                                                                                                            |
| `campaignId`               | Yes      | The ID of the job to watch. It must be a job on your account. Use `"*"` to watch every job on your account.                                                   |
| `triggerName`              | Yes      | One of the five events above.                                                                                                                                 |
| `provider`                 | Yes      | Use `"custom"` for your own endpoint.                                                                                                                         |
| `inactivityTimeoutMinutes` | No       | Only for `message_session_completed`. How long a chat must be quiet before it counts as finished. A whole number from 1 to 10080 (7 days). The default is 60. |

A good subscription returns `201`:

```json
{
  "id": "https://example.com/atlas/webhook",
  "campaignId": "YOUR_CAMPAIGN_ID",
  "triggerName": "call_completed"
}
```

The `id` is your URL. Each subscription is one event on one job. To get both `call_started` and `call_completed`, subscribe twice. To watch two jobs, subscribe once for each. To watch all of them, subscribe once with `"campaignId": "*"`.

Atlas does not check for duplicates. If you subscribe the same URL to the same event twice, you get every event twice.

If a value is wrong you get `400`. The body says why:

| Problem                                  | Body                                                                                                                                  |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| No `provider`                            | `{"message":"Validation failed","errors":["Provider is required. Send it in the x-provider header or the \"provider\" body field."]}` |
| Unknown `provider`                       | `{"message":"Validation failed","errors":["Invalid provider: <value>"]}`                                                              |
| Unknown `triggerName`                    | `{"message":"Invalid triggerName: <value>"}`                                                                                          |
| No `campaignId`                          | `{"message":"Validation failed","errors":["Missing campaignId"]}`                                                                     |
| `campaignId` isn't a job on your account | `{"message":"Validation failed","errors":["campaignId <value> not found"]}`                                                           |
| `inactivityTimeoutMinutes` out of range  | `{"message":"Validation failed","errors":["Invalid inactivityTimeoutMinutes: must be an integer between 1 and 10080"]}`               |

## What Atlas sends

Atlas sends `POST` with `Content-Type: application/json`. The body is a **JSON array** that holds one event object. Read the first item.

Every request also carries three headers from the open [Standard Webhooks](https://www.standardwebhooks.com) specification. The body is the same as before, so a receiver that ignores the headers keeps working.

| Header              | What it is                                                                                                         |
| ------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `webhook-id`        | The id of this event, for example `msg_5f1c…`. It is the same on every retry of the event. Use it to drop repeats. |
| `webhook-timestamp` | When this attempt was sent, in Unix seconds. A retry gets a new timestamp.                                         |
| `webhook-signature` | `v1,` and a base64 HMAC-SHA256 signature. During a secret rotation it holds two signatures, separated by a space.  |

### `call_started`

```json
[
  {
    "campaignId": "string",
    "agentId": "string",
    "callId": "string",
    "customerNumber": "string",
    "customerName": "string",
    "campaignName": "string",
    "agentName": "string",
    "campaignType": "string"
  }
]
```

### `call_completed`

Everything in `call_started`, plus the result:

```json
[
  {
    "campaignId": "string",
    "agentId": "string",
    "callId": "string",
    "customerNumber": "string",
    "customerName": "string",
    "campaignName": "string",
    "agentName": "string",
    "campaignType": "string",
    "callSummary": "string",
    "startedAt": "2026-01-01T13:04:30.000Z",
    "endedAt": "2026-01-01T13:08:11.000Z",
    "durationMs": 221000,
    "durationSeconds": 221,
    "durationMinutes": 3.683333333333333,
    "callTranscript": "string",
    "audioUrl": "https://...",
    "customerEmail": "string",
    "status": "Accepted",
    "endedReason": "customer-ended-call"
  }
]
```

The call length comes as `durationMs`, `durationSeconds` and `durationMinutes` (seconds divided by 60, not rounded). `status` is the final outcome of the call: `Accepted`, `Rejected` or `Missed`. `endedReason` is the raw reason the call ended, passed through as is.

Calls that ran a flow can carry extra fields, such as `collected`, `flowId`, `flowVersion`, `blocksVisited`, `flowOutcome` and `answeredBy`. They are only there when the call used that feature. Don't depend on them being present.

#### When a job's workflow handles the end of the call

If the job's workflow has a step for how the call ended (a post-call step, a voicemail step or a no-answer step), that workflow handles the call. Then the `call_completed` webhooks you subscribed to for that one job do not fire for that call. Webhooks subscribed with `"campaignId": "*"` still fire. If you move a job onto a workflow, check which of these you rely on.

### `message_received` and `message_sent`

```json
[
  {
    "campaignId": "string",
    "agentId": "string",
    "customerNumber": "string",
    "customerName": "string",
    "campaignName": "string",
    "agentName": "string",
    "campaignType": "string",
    "messageContent": "string",
    "receivedAt": "2026-01-01T13:04:30.000Z"
  }
]
```

`message_sent` carries `sentAt` in place of `receivedAt`.

### `message_session_completed`

Sent once per chat session, after the chat has been quiet for `inactivityTimeoutMinutes`. If the customer writes again before then, the wait starts over. A message or follow-up that Atlas has scheduled for later also keeps the chat open: the wait starts after that message is due. If a session is marked completed on purpose, the event goes out without waiting. If you have several session-completed subscriptions on one job, the shortest `inactivityTimeoutMinutes` among them decides when Atlas checks. The event has the whole conversation and a summary.

```json
[
  {
    "campaignId": "string",
    "agentId": "string",
    "customerNumber": "string",
    "customerName": "string",
    "campaignName": "string",
    "agentName": "string",
    "campaignType": "string",
    "sessionId": "string",
    "startedAt": "2026-01-01T13:04:30.000Z",
    "endedAt": "2026-01-01T13:14:30.000Z",
    "messageCount": 2,
    "messages": [
      { "role": "user", "content": "string", "timestamp": "2026-01-01T13:04:30.000Z" },
      { "role": "assistant", "content": "string", "timestamp": "2026-01-01T13:05:10.000Z" }
    ],
    "conversationSummary": "string"
  }
]
```

In `messages`, `role` tells you who spoke. `user` is the customer. Any other value is your agent. Match on `user` and treat everything else as the agent.

### Get a sample payload first

Build your receiver against real-shaped data. This returns a sample for a job you own. With the CLI it is `atlas events-gateway events-get-sample-payload call_completed --campaignId YOUR_CAMPAIGN_ID`.

```bash
curl 'https://api.youratlas.com/v1/api/events-gateway/trigger/perform/call_completed?campaignId=YOUR_CAMPAIGN_ID' \
  --header 'api-key: YOUR_API_KEY'
```

## List your webhooks

This lists the subscriptions on one job. With the CLI it is `atlas events-gateway events-get-campaign-triggers YOUR_CAMPAIGN_ID`.

```bash
curl 'https://api.youratlas.com/v1/api/events-gateway/triggers/campaign/YOUR_CAMPAIGN_ID' \
  --header 'api-key: YOUR_API_KEY'
```

## Unsubscribe

Send a `DELETE` with the same values you subscribed with. A good call returns `200`.

```bash
atlas events-gateway events-unsubscribe-trigger --body '{"hookUrl": "https://example.com/atlas/webhook", "campaignId": "YOUR_CAMPAIGN_ID", "triggerName": "call_completed", "provider": "custom"}'
```

Or with curl:

```bash
curl 'https://api.youratlas.com/v1/api/events-gateway/trigger/unsubscribe' \
  --request DELETE \
  --header 'api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "hookUrl": "https://example.com/atlas/webhook",
    "campaignId": "YOUR_CAMPAIGN_ID",
    "triggerName": "call_completed",
    "provider": "custom"
  }'
```

Atlas finds the subscription by its URL. It removes one subscription per call, and it does not look at `campaignId` or `triggerName` to choose. If you use one URL for several events, put a different path on the URL for each event (for example `/atlas/webhook/call-completed`). Then you can remove each one on its own.

## Delivery

* Atlas sends one `POST` per event per subscription, and waits up to **30 seconds** for your reply.
* Any `2xx` status counts as delivered.
* **Atlas retries** when the request times out, can't connect, or gets `429` or any `5xx`. It sends the same body with the same `webhook-id`.
* Atlas does **not** retry other `4xx` statuses. Your endpoint said the request itself is wrong, so sending it again won't help.
* Atlas does **not** follow redirects. A `3xx` reply counts as a failed delivery and is not retried. Give Atlas the final URL.
* Atlas does **not** send to a URL that points at a private, loopback or link-local address. That delivery fails and is not retried. Use a public URL.
* An event larger than 200 KB is sent once. If that attempt fails, it is not retried.
* A failed delivery does not cancel your subscription. Later events still go out.
* If you unsubscribe a URL, pending retries to it stop.
* Atlas does not promise an order. Two events close together, or a retry and a newer event, can reach you in either order.

### Retry schedule

Five attempts in total, over about an hour:

| Attempt | Sent                             |
| ------- | -------------------------------- |
| 1       | Right away                       |
| 2       | About 30 seconds after attempt 1 |
| 3       | About 2 min after attempt 2      |
| 4       | About 10 min after attempt 3     |
| 5       | About 45 min after attempt 4     |

Each wait varies by up to 20% so retries don't all land at once. If your reply has a `Retry-After` header (seconds or an HTTP date) that asks for a longer wait, Atlas waits that long, up to one hour.

After the fifth attempt fails, Atlas stops. The event is not sent again. Atlas keeps a record of every attempt (time, status code and how long it took). It does not keep a copy of the body in that record.

So a webhook can still miss events if your endpoint is down for more than an hour. Don't use it as your only record. After an outage, read the gap from the API. For calls, use the call records endpoints.

## Build a reliable receiver

* Answer with `2xx` fast, well within 30 seconds. Do the heavy work after you reply.
* Store the event first. Process it from your own queue.
* **Dedupe on `webhook-id`.** The same event can reach you more than once: a retry after a timeout you did reply to, or Atlas handling the same call twice. Keep the ids you've seen for at least a day and skip repeats.
* Read `body[0]`. The body is an array.
* Reconcile on a schedule. List recent calls and compare against what you received.

## Verify signatures

Atlas signs every request with a secret that belongs to your account. Check the signature, and drop any request that fails. Then you know Atlas sent it and nobody changed it on the way.

### Your signing secret

Your secret looks like `whsec_` followed by base64 text. It is the same for every webhook on your account. Atlas creates it the first time it signs a request for you.

To read your secret:

```bash
curl 'https://api.youratlas.com/v1/api/events-gateway/webhooks/signing-secret' \
  --header 'api-key: YOUR_API_KEY'
```

```json
{ "secret": "whsec_...", "createdAt": "2026-11-20T15:04:05.000Z" }
```

With the CLI: `atlas events-gateway events-get-webhook-signing-secret`. In the 24 hours after a rotation, the answer also has `previousExpiresAt`.

Keep it like a password. Store it in your secret manager, not in code.

### How the signature is made

Atlas joins three things with dots: the `webhook-id`, the `webhook-timestamp` and the raw request body. It signs that text with HMAC-SHA256, using the base64-decoded part of your secret after `whsec_`. The header is `v1,` and the base64 result.

```text
signed_content = "{webhook-id}.{webhook-timestamp}.{raw body}"
signature      = base64(HMAC_SHA256(base64decode(secret without "whsec_"), signed_content))
header         = "v1," + signature
```

You don't need to build this yourself. Use a Standard Webhooks library. It checks the signature, compares in constant time, and rejects old timestamps.

### Use the raw body

Verify the body **exactly as it arrived**, byte for byte, before you parse it. If your framework parses JSON first and you turn it back into text, spacing or key order can change and the signature won't match. In Express, use `express.raw()` on the webhook route. In Flask, use `request.get_data()`.

### Node.js

```bash
npm install standardwebhooks
```

```javascript
import express from "express";
import { Webhook } from "standardwebhooks";

const wh = new Webhook(process.env.ATLAS_WEBHOOK_SECRET); // "whsec_..."
const app = express();

app.post("/atlas/webhook", express.raw({ type: "application/json" }), (req, res) => {
  let body;
  try {
    // Throws if the signature is wrong or the timestamp is more than 5 min off.
    body = wh.verify(req.body, req.headers);
  } catch {
    return res.status(400).send("invalid signature");
  }

  const webhookId = req.headers["webhook-id"];
  // if (alreadySeen(webhookId)) return res.sendStatus(200);
  // queue(webhookId, body[0]);
  res.sendStatus(200);
});
```

### Python

```bash
pip install standardwebhooks
```

```python
import os
from flask import Flask, request
from standardwebhooks import Webhook, WebhookVerificationError

wh = Webhook(os.environ["ATLAS_WEBHOOK_SECRET"])  # "whsec_..."
app = Flask(__name__)

@app.post("/atlas/webhook")
def atlas_webhook():
    try:
        # Raw bytes, not request.json. Raises if the signature is wrong
        # or the timestamp is more than 5 min off.
        body = wh.verify(request.get_data(), dict(request.headers))
    except WebhookVerificationError:
        return "invalid signature", 400

    webhook_id = request.headers["webhook-id"]
    # if already_seen(webhook_id): return "", 200
    # queue(webhook_id, body[0])
    return "", 200
```

### Timestamp tolerance

The libraries reject a request whose `webhook-timestamp` is more than **5 min** older or newer than your server's clock. That stops someone from replaying an old request they captured. Keep your server clock synced (NTP). Every retry is signed again with a fresh timestamp, so retries pass this check.

### Rotate your secret

If your secret leaks, or on your own schedule, rotate it. With the CLI: `atlas events-gateway events-rotate-webhook-signing-secret`.

```bash
curl 'https://api.youratlas.com/v1/api/events-gateway/webhooks/signing-secret/rotate' \
  --request POST \
  --header 'api-key: YOUR_API_KEY'
```

```json
{
  "secret": "whsec_...new...",
  "createdAt": "2026-11-20T15:04:05.000Z",
  "previousExpiresAt": "2026-11-21T15:04:05.000Z"
}
```

For the next 24 hours (until `previousExpiresAt`) Atlas signs each request with **both** secrets. The `webhook-signature` header holds two `v1,` values separated by a space, and a library accepts the request if either one matches. Put the new secret in your receiver during that window. After it, only the new secret signs.

### Other good habits

* Use an `https://` URL.
* Answer `400` or `401` to a request that fails verification. Atlas won't retry it.
* When a step is risky, such as moving money, take the `callId` and fetch the call from the API with your key before you act.

## Troubleshooting

* If no events arrive, then list the job's subscriptions and check the `hookUrl` and `triggerName`. A subscription watches one event on one job, or every job with `"campaignId": "*"`.
* If `call_completed` stopped after you moved a job onto a workflow with a post-call, voicemail or no-answer step, then subscribe with `"campaignId": "*"`. See [When a job's workflow handles the end of the call](#when-a-jobs-workflow-handles-the-end-of-the-call).
* If you get every event twice, then you subscribed the same URL to the same event twice. Unsubscribe one, and dedupe on `webhook-id`.
* If your endpoint gets nothing and your URL redirects, then give Atlas the final URL. Atlas does not follow redirects.
* If your URL points at a private or local address, then expose a public HTTPS URL. Atlas won't send to private, loopback or link-local addresses.
* If events stop after your endpoint was down for over an hour, then read the gap from the API. Atlas does not send an event again after the fifth attempt.
* If subscribe returns `400`, then read the `errors` list in the body. The table in [Subscribe](#subscribe) lists each message.

## Related

* [API overview](/v2/developers/api-overview)
* [Errors](/v2/developers/errors)
* [Atlas for AI agents](/v2/developers/atlas-for-ai-agents)