# Webhooks

**Note**

The webhooks feature must be enabled using a feature flag on your Ripple Custody (Vault) instance. Contact your Ripple liaison if you're unable to access the feature.

Webhooks are lightweight HTTP callbacks that allow real-time delivery of event notifications to your systems. You can use the Event Distribution Service (EDS) API to programmatically manage webhook channels.

You can select from a wide range of events that you want to subscribe to and configure a webhook URL. Once you complete the setup, Ripple Custody (Vault) will automatically send minimal event payloads to your registered endpoint when the selected events occur.

## Available event types

You can subscribe to many event types when configuring a webhook. For detailed information about each event type and complete payload structures, see [Event tracking](/pt-br/products/custody/v1.34/system-management/events) for a complete list.

For intent state changes, subscribe to `IntentUpdated` to receive updates when an intent is approved or rejected. Subscribe to `IntentClosed` to receive updates when an intent reaches its final state.

## Event payload

Event payloads are minimal and designed for easy parsing.

The following sample shows a typical payload for an intent creation event:

```json
{
    "domainId": "25aaec0d-e8dc-44b6-8070-9231f1ddadf0",
    "id": "03424a3f-bdfc-4521-b8b2-933a8ff13cce",
    "payload": {
        "id": "35e4d8d9-f943-484b-865c-c736679ba0cc",
        "type": "IntentCreated"
    },
    "savedAt": "2025-03-07T14:22:37.389Z",
    "sequenceNumber": 369
}
```

**Payload fields:**

| Field | Description |
|  --- | --- |
| `domainId` | The unique identifier of the domain where the event originated |
| `id` | The unique ID of the event. It stays the same each time Ripple Custody (Vault) delivers the same event. |
| `payload.id` | The ID of the entity that the event is about, for example the intent ID |
| `payload.type` | The type of event (e.g., `IntentCreated`, `IntentUpdated`) |
| `savedAt` | The timestamp when the webhook notification was sent |
| `sequenceNumber` | The sequence in which this event occurred |


## Securing your webhook endpoint

Make sure your webhook endpoint is properly secured to prevent unauthorized access. Best practices include:

- Use HTTPS endpoints only
- Validate incoming requests
- Implement authentication/authorization
- Use IP allowlisting if needed


## Delivery behavior

Webhook delivery is designed so that you don't miss events, not so that each event arrives exactly once or in order. Build your webhook consumer around the guarantees in this section, not around the delivery pattern you observe in testing: timing, retries, and recovery after an outage change the order and number of the deliveries you receive. Some of this behavior changed in 1.34 patch releases. For the list, see [Delivery changes in 1.34 patch releases](#delivery-changes-in-134-patch-releases).

### Delivery guarantees

| Guarantee | What it means for your consumer |
|  --- | --- |
| At-least-once delivery | Your endpoint can receive the same event more than once, for example when Ripple Custody (Vault) re-sends an event that stayed in `PENDING`. Deduplicate by the top-level `id` of the callback payload, which stays the same each time Ripple Custody (Vault) delivers the same event. |
| No ordering guarantee | Events can arrive out of order. A retried or re-sent event can arrive after events that were created later. To process events in order, sort by `sequenceNumber`. To act on the current state of an entity, retrieve it with the relevant API. |
| Domain-scoped delivery | From 1.34.9, a webhook channel receives only events from the domain where you created it, not events from its subdomains. To receive events from several domains, create a channel in each domain. Events that don't belong to a domain aren't sent to webhooks. |
| Automatic re-send of pending events | From 1.34.6, every minute, Ripple Custody (Vault) re-sends events that have stayed in `PENDING` for more than 10 minutes. These events can arrive minutes or longer after they were created. |


The callback payload doesn't say which field of an entity changed. For example, Ripple Custody (Vault) emits `TransactionUpdated` for every processing status change and every ledger status change of a transaction. For details, see [Transaction events](/pt-br/products/custody/v1.34/system-management/events#transaction-events).

### Retry behavior

1. Ripple Custody (Vault) sends the event to your webhook endpoint.
2. If the attempt fails with a retryable error, Ripple Custody (Vault) waits and tries again, with a longer wait before each attempt.
3. When the last attempt fails, or the attempt fails with an error that isn't retryable, Ripple Custody (Vault) marks the delivery event as `FAILED`. Ripple Custody (Vault) doesn't retry a `FAILED` delivery event automatically.


The default retry settings are:

| Setting | Default | Description |
|  --- | --- | --- |
| Maximum attempts | 3 | Total number of delivery attempts, including the first one. |
| Initial interval | 500 ms | Wait time before the second attempt. |
| Multiplier | 2 | Factor applied to the wait time before each later attempt. |
| Maximum interval | 5000 ms | Upper limit for the wait time between attempts. |


With the default settings, Ripple Custody (Vault) waits 500 ms before the second attempt and 1000 ms before the third attempt.

Retry settings apply to the whole Ripple Custody (Vault) instance. To change them, contact your Ripple partner engineer. The `maxRetries` field of a webhook channel doesn't change the number of delivery attempts.

### Response timeout

Your endpoint must respond within 10 seconds. If it doesn't, Ripple Custody (Vault) treats the attempt as failed and retries it.

### HTTP status code handling

The following table describes the behavior from 1.34.18.

| Response | Behavior |
|  --- | --- |
| `2xx` | Delivery successful. The delivery event moves to `SUCCESS`. |
| `3xx` | Ripple Custody (Vault) doesn't follow redirects, and records the delivery as successful. Make sure your webhook URL doesn't redirect. |
| `408` or `429` | Delivery failed. Ripple Custody (Vault) retries. |
| Any other `4xx`, including `410` | Delivery failed. Ripple Custody (Vault) doesn't retry and marks the delivery event as `FAILED` after this attempt. |
| `5xx` | Delivery failed. Ripple Custody (Vault) retries. |
| Timeout or connection error | Delivery failed. Ripple Custody (Vault) retries. |


Return `2xx` only after your system has stored the event. Return a `4xx` status code other than `408` or `429` only when you don't want Ripple Custody (Vault) to retry the event. If your endpoint is temporarily unable to process events, return `503` or `429` so that Ripple Custody (Vault) retries.

### Rate limiting

Webhook deliveries are not rate-limited by default. Design your endpoint to handle:

- Multiple concurrent webhook deliveries.
- Bursts of events during high activity periods, including re-sent pending events after an outage or an upgrade.
- Retry attempts for failed deliveries.


If your endpoint cannot keep up with event volume, consider:

- Implementing a queue to buffer incoming webhooks.
- Scaling your webhook receiver horizontally.
- Using AMQP queues instead for guaranteed delivery and backpressure handling.


### Handling failed deliveries

Ripple Custody (Vault) doesn't retry `FAILED` delivery events automatically. To recover missed events, use one of the following methods:

| Recovery method | Description |
|  --- | --- |
| **Events API** | Use the [List events](/pt-br/products/custody/v1.34/api/reference/openapi/events/getevents) API to retrieve events that occurred during the downtime. Sort by sequence number to identify missed events. |
| **AMQP queue** | If your deployment includes an AMQP queue integration, you can inspect the queue to recover missed events. Contact [Ripple support](/pt-br/products/custody/v1.34/support/get-support) for assistance with AMQP-based recovery. |


### Delivery changes in 1.34 patch releases

The following patch releases changed how Ripple Custody (Vault) delivers events to webhooks. The event API didn't change. If you upgrade across one of these releases, test the behavior your integration relies on.

| Patch | Change | What to check in your integration |
|  --- | --- | --- |
| 1.34.0 | Ripple Custody (Vault) emits `TransactionUpdated` for every processing status change of a transaction, as well as for ledger status changes. In 1.26, it emitted `TransactionUpdated` only for ledger status changes. | Expect several `TransactionUpdated` events for each transaction. Retrieve the transaction to find which status changed. See [Transaction events](/pt-br/products/custody/v1.34/system-management/events#transaction-events). |
| 1.34.6 | Ripple Custody (Vault) re-sends events that have stayed in `PENDING` for more than 10 minutes. After the upgrade, this includes events that were stuck before the upgrade, some of them possibly months old. | Expect a one-off burst of old events after the upgrade, and late, out-of-order events afterward. Deduplicate by the top-level event `id` and don't rely on delivery order. |
| 1.34.6 | Ripple Custody (Vault) emits one `LedgerUpdated` event for each intent that updates a ledger. Previously, it could combine updates to the same ledger by different intents into a single event. | Expect more `LedgerUpdated` events. |
| 1.34.8 | When publishing an event to an external AMQP broker fails, Ripple Custody (Vault) no longer re-sends the webhook. Previously your endpoint could receive the same event up to three times. | If you set `RETRY_POLICY_MAX_TRIES=1` to avoid duplicates, you can remove it. |
| 1.34.9 | A webhook channel receives only events from its own domain. Previously, a channel also received events from its subdomains. Events without a domain aren't sent to webhooks. | If one channel received events from several domains, create a channel in each domain. |
| 1.34.18 | Ripple Custody (Vault) doesn't retry a `4xx` response other than `408` or `429`, and marks the event `FAILED` after one attempt. It retries `5xx` responses, `408`, `429`, timeouts, and connection errors with increasing waits between attempts. Previously, it could make up to three attempts in quick succession for any `4xx` or `5xx` response. | Make sure your endpoint returns a `4xx` status code only for events that you don't want retried. |
| 1.34.24 | Ripple Custody (Vault) no longer re-sends an event that it already delivered (`SUCCESS`) or retries an event that it already marked `FAILED`, when it processes the same event again, for example after a message broker redelivery. | Your deduplication logic catches fewer duplicates. Keep it in place for the at-least-once guarantee. If you later upgrade to 1.43, upgrade to 1.43.5 or later, which includes this change. |


## Create a webhook channel

Prerequisite
You must be a user with the role `eds-manager` to create and manage webhooks for your domain.

To create a webhook channel using the API:

1. Obtain a JWT token. See [Authenticate API requests](/pt-br/products/custody/v1.34/concepts/authenticate-api-requests).
2. Call the [Create channel](/pt-br/products/custody/v1.34/api/reference/openapi/event-distribution-service/createchannel) operation with the following request body:


```json
{
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "My Webhook Channel",
    "supportedEventTypes": [
        "IntentCreated",
        "IntentUpdated",
        "IntentClosed"
    ],
    "createdBy": "b7c8d9e0-f1a2-3456-bcde-f23456789012",
    "type": "WEBHOOK",
    "url": "https://your-domain.com/webhook-endpoint"
}
```

**Request body fields:**

| Field | Type | Required | Description |
|  --- | --- | --- | --- |
| `id` | string | Yes | The unique identifier for the webhook channel |
| `name` | string | Yes | A descriptive name for the webhook channel |
| `supportedEventTypes` | array | Yes | List of event types to subscribe to |
| `createdBy` | string | Yes | The unique identifier of the user creating the webhook channel |
| `type` | string | Yes | Must be `WEBHOOK` |
| `url` | string | Yes | The webhook endpoint URL where events will be sent |
| `status` | string | No | The channel status |
| `maxRetries` | integer | No | The maximum number of retry attempts for failed webhook deliveries |


1. The API returns a response with the created channel details:


**Example response:**

```json
{
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "domainId": "25aaec0d-e8dc-44b6-8070-9231f1ddadf0",
    "name": "My Webhook Channel",
    "supportedEventTypes": [
        "IntentCreated",
        "IntentUpdated",
        "IntentClosed"
    ],
    "type": "WEBHOOK",
    "status": "ACTIVE",
    "maxRetries": 3,
    "url": "https://your-domain.com/webhook-endpoint",
    "createdBy": "b7c8d9e0-f1a2-3456-bcde-f23456789012",
    "lastUpdatedBy": "b7c8d9e0-f1a2-3456-bcde-f23456789012",
    "createdAt": "2025-03-07T14:22:37.389Z",
    "lastUpdatedAt": "2025-03-07T14:22:37.389Z",
    "errorRate": 0
}
```

**Response fields:**

| Field | Description |
|  --- | --- |
| `id` | The unique identifier for the webhook channel |
| `domainId` | The unique identifier of the domain that owns the channel |
| `name` | The name of the webhook channel |
| `type` | The channel type (always `WEBHOOK`) |
| `url` | The configured webhook endpoint URL |
| `supportedEventTypes` | Array of subscribed event types |
| `status` | The channel status |
| `maxRetries` | The maximum number of retry attempts for failed webhook deliveries |
| `createdBy` | The unique identifier of the user who created the channel |
| `lastUpdatedBy` | The unique identifier of the user who last updated the channel |
| `createdAt` | Timestamp when the channel was created |
| `lastUpdatedAt` | Timestamp when the channel was last updated |
| `errorRate` | The webhook delivery error rate |


## Update a webhook channel

To update an existing webhook channel, use the [Update channel](/pt-br/products/custody/v1.34/api/reference/openapi/event-distribution-service/updatechannel) operation.

You can update:

- The webhook name
- The list of subscribed event types
- The channel status
- The maximum retry count


## Delete a webhook channel

To delete a webhook channel, use the [Delete channel](/pt-br/products/custody/v1.34/api/reference/openapi/event-distribution-service/deletechannel) operation.

## List webhook channels

To retrieve all webhook channels for a domain, use the [List channels](/pt-br/products/custody/v1.34/api/reference/openapi/event-distribution-service/getallchannels) operation.

## Get webhook channel details

To retrieve details for a specific webhook channel, use the [Get channel](/pt-br/products/custody/v1.34/api/reference/openapi/event-distribution-service/getchannel) operation.

Want to manage webhooks with the UI instead? See [Webhooks](/pt-br/products/custody/v1.34/ui/environment/events/webhooks) in the UI documentation.