> For the complete documentation index, see [llms.txt](https://docs.sectoral.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sectoral.xyz/developer-api/webhooks.md).

# Webhook Endpoints

Create and manage webhook subscriptions programmatically so your systems hear about each settlement the moment it occurs. The list of events and the payload structure are documented in [Real-Time Event Stream](/ai-agents/event-stream.md).

***

## Create a subscription

```
POST /v1/webhooks
```

### Body

```json
{
  "url": "https://yourapp.com/hooks/sectoral",
  "events": ["transfer.confirmed", "agent.transaction.pending_approval"]
}
```

### Response

```json
{
  "webhook_id": "wh_2c9f1a",
  "url": "https://yourapp.com/hooks/sectoral",
  "events": ["transfer.confirmed", "agent.transaction.pending_approval"],
  "secret": "whsec_xxxxxxxxxxxxxxxxxxxx",
  "created_at": "2026-07-02T09:00:00Z"
}
```

You will only see the `secret` in this response. Use it to check the `X-Sectoral-Signature` header on incoming deliveries.

***

## List subscriptions

```
GET /v1/webhooks
```

***

## Delete a subscription

```
DELETE /v1/webhooks/{webhook_id}
```

Deletion is immediate, and the subscription receives no more deliveries.

***

## Checking signatures

Each delivery includes an `X-Sectoral-Signature` header containing an HMAC-SHA256 of the raw request body, computed with your secret. Verification needs only a short function:

```python
import hmac
import hashlib

def verify_signature(payload_bytes, signature_header, secret):
    expected = hmac.new(
        secret.encode(),
        payload_bytes,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, signature_header)
```

If a delivery doesn't pass this check, discard it without processing it.

***

## Resend an event

```
POST /v1/webhooks/{webhook_id}/replay/{event_id}
```

Useful when your endpoint had a short outage and you want a particular event delivered now instead of waiting for the next automatic retry.

***

## View delivery history

```
GET /v1/webhooks/{webhook_id}/deliveries
```

Shows a subscription's recent deliveries, including response codes and retry counts, so you can troubleshoot from the complete record instead of guessing.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sectoral.xyz/developer-api/webhooks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
