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

# webhooks

Biti sends a POST to your Webhook URL after a change is saved. Ask Biti to set the URL for your app.

## Event body

The body is a `WebhookEvent`.

| Field     | Description                                              |
| --------- | -------------------------------------------------------- |
| `event`   | The event name                                           |
| `id`      | Stays the same on every retry. Use it to ignore repeats. |
| `created` | When the event was made                                  |
| `data`    | The event fields, see the table below                    |

```json
{ "event": "payment.paid", "id": "evt_9f2c...", "created": "2026-11-18T10:30:00",
  "data": { "id": "MPO-00012", "reference": "INV-7", "amount": 12.0, "currency": "USD", "transaction_id": "5Q5QNT72JH", "status": "paid" } }
```

## Headers

| Header             | Value                                                                         |
| ------------------ | ----------------------------------------------------------------------------- |
| `X-Biti-Event`     | The event name                                                                |
| `X-Biti-Timestamp` | Unix seconds when the attempt was sent. Reject anything older than 5 minutes. |
| `X-Biti-Signature` | Hex HMAC-SHA256 of the raw body. The key is your `client_secret`.             |

## Events

| Event                                         | Sent when                              | Extra `data` fields                                                                                                                  |
| --------------------------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `payment.paid`                                | An order is paid, or a charge succeeds | `reference`, `amount`, `currency`, `transaction_id`                                                                                  |
| `payment.failed`                              | The payment is refused by the ledger   | `reference`, `error`                                                                                                                 |
| `request.declined`                            | The customer declines a request        | `reference`, `amount`, `currency`                                                                                                    |
| `request.expired`                             | A request passes its expiry unpaid     | `reference`                                                                                                                          |
| `mandate.active`, `mandate.revoked`           | The customer approves or revokes       | `reference`, plus `max_amount`, `currency`, `period` on `active`                                                                     |
| `mandate.charged`                             | A mandate charge succeeds              | `reference`, `amount`, `currency`, `transaction_id`                                                                                  |
| `hold.held`, `hold.captured`, `hold.released` | The hold state changes                 | `reference`, `amount` or `captured_amount`, `currency`                                                                               |
| `refund.done`                                 | A refund is made                       | `reference`, `amount`, `refunded_amount`, `transaction_id`                                                                           |
| `payout.done`, `payout.failed`                | A payout ends                          | `reference`, `amount`, `to_wallet`, `transaction_id` or `error`. A bulk item also has `batch_id`, `ref`, `method`, `number`, `note`. |
| `split.held`, `split.released`                | A split is paid and held, or released  | `reference`, `ref`, `amount`, `currency`, `to_wallet`, `transaction_id`, `note`. `split.released` also has `sms_status`.             |
| `bulk.completed`                              | Every item of a bulk send ended        | `reference`, `currency`, `total`, `done`, `failed`, `status`                                                                         |

## Answer and retries

Answer with any 2xx code within 10 seconds. Other answers and network errors are retried 3 times, after 1, 5 and 30 minutes. The same event keeps its `id` on every retry.

{% hint style="warning" %}
Verify the signature on the raw body before you parse it.
{% endhint %}

## Verify the signature

{% tabs %}
{% tab title="Python" %}

```python
import hashlib, hmac

def is_valid(raw_body: bytes, signature: str, client_secret: str) -> bool:
    expected = hmac.new(client_secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const crypto = require("crypto");

function isValid(rawBody, signature, clientSecret) {
  const expected = crypto.createHmac("sha256", clientSecret).update(rawBody).digest("hex");
  const a = Buffer.from(expected), b = Buffer.from(signature || "");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}
```

{% endtab %}
{% endtabs %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.biti.so/webhooks-1.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
