# Webhooks

> Receive Duty request events on your own HTTPS endpoint, signed with HMAC-SHA256 and retried automatically.

A webhook is a URL of yours that Duty calls whenever something happens to a request of the workspace. Use webhooks to keep another system in step without polling.

Events come from every channel: a request opened through the API, by email or in the portal, and a comment written by an agent or by the requester, all reach your webhook.

## Events

| Event | When | Extra in `data` |
| --- | --- | --- |
| `ticket.created` | A request was opened, from any channel. | — |
| `ticket.status_changed` | A request moved to another status. | `change.from`, `change.to` |
| `ticket.priority_changed` | A request's priority changed. | `change.from`, `change.to` |
| `ticket.comment_added` | A public comment was added. Internal notes are never sent. | `comment` |
| `ticket.attachment_added` | A file was attached. | `attachment` |

[`GET /v1/webhooks/events`](/en/api/reference/webhooks/list-webhook-events/) returns the same list, so your setup code can stay current.

## Create a webhook

Create it with a key that has the `webhooks` scope:

```sh
curl https://api.client.service-desk.goldmaster.io/v1/webhooks \
  -H "Authorization: Bearer $DUTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ERP sync",
    "url": "https://erp.example.com/hooks/duty",
    "events": ["ticket.created", "ticket.status_changed"]
  }'
```

The response includes `secret`, the key that signs every delivery. **It is shown only once**: store it with your other secrets. To replace it, [update the webhook](/en/api/reference/webhooks/update-a-webhook/) with `"rotateSecret": true`; the old secret stops working at once.

The URL must use HTTPS and point to a public address. Webhooks created through the API are managed through the API. They are separate from the webhooks administrators create in the portal, which send operational alerts such as SLA warnings with a different payload.

## The delivery

Duty sends a `POST` with a JSON body:

```json
{
  "id": "6f2d0c8e9a1b4e73b6a1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3",
  "type": "ticket.status_changed",
  "version": "v1",
  "createdAt": "2026-12-06T14:05:00Z",
  "data": {
    "ticket": {
      "number": "GM-000123",
      "subject": "VPN disconnects every few minutes",
      "status": { "code": "in_progress", "name": "In progress" },
      "priority": { "code": "high", "name": "High" },
      "service": { "id": 12, "name": "VPN and remote access" },
      "contact": { "name": "Ana Pérez", "email": "ana.perez@example.com" },
      "updatedAt": "2026-12-06T14:05:00Z"
    },
    "change": {
      "from": { "code": "open", "name": "Open" },
      "to": { "code": "in_progress", "name": "In progress" }
    }
  }
}
```

`data.ticket` has the same fields as a request in [List requests](/en/api/reference/requests/list-requests/) (shortened here). Names come in the workspace's language.

And these headers:

| Header | Meaning |
| --- | --- |
| `X-Goldmaster-Timestamp` | Unix time (seconds) when the delivery was signed. |
| `X-Goldmaster-Signature` | `sha256=` and the hex HMAC-SHA256 of `{timestamp}.{body}` with your secret. |
| `Idempotency-Key` | Same as the body's `id`. Equal on every retry of the same event. |
| `X-Request-ID` | Trace of the delivery, for support. |

## Verify every delivery

Before you trust a delivery:

1. Read the raw body as bytes, **before** parsing the JSON.
2. Compute `HMAC-SHA256(secret, timestamp + "." + body)` and compare it in constant time with the hex after `sha256=`.
3. Reject timestamps older than five minutes, to stop replays.
4. Skip `Idempotency-Key` values you already processed.

[Receive webhooks](/en/api/guides/receive-webhooks/) has the code in seven languages.

## Answer fast, retry safe

- Answer with any `2xx` within **10 seconds**. Do slow work after answering, in a queue.
- Any other status, a timeout or a connection error schedules a retry: after 1, 2, 4, 8, 16, 32 and 64 minutes, **8 attempts** in all.
- After the last attempt the delivery is marked `dead`. Administrators can requeue it from the portal under **Integrations → Retries**, and you can inspect it with [List deliveries](/en/api/reference/webhooks/list-webhook-deliveries/).
- Deliveries can arrive more than once and out of order. Use `Idempotency-Key` to deduplicate and the ticket's `updatedAt` to keep the latest state.

<Aside type="note">Disabling a webhook stops new deliveries. Deleting it also drops the deliveries still queued.</Aside>
