> For the complete documentation index, see [llms.txt](https://developers.coincircuit.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.coincircuit.io/webhooks/readme/swaps.md). Agents can also search and read this documentation through its [MCP server](https://developers.coincircuit.io/~gitbook/mcp).

# Swaps

Swap webhook events and example payloads.

Swap webhooks tell you when a swap between two of your balances completes or fails.

### Field descriptions

Swap webhook events use `data.swap`. It has the same shape as the swap returned by the API.

| Field                              | Type             | Description                                        |
| ---------------------------------- | ---------------- | -------------------------------------------------- |
| `data.swap.id`                     | `string`         | Unique swap identifier.                            |
| `data.swap.fromCurrency`           | `string`         | Currency taken from your balance, such as `USDT`.  |
| `data.swap.toCurrency`             | `string`         | Currency added to your balance, such as `NGN`.     |
| `data.swap.sourceAmount`           | `string`         | Amount taken, as a decimal string.                 |
| `data.swap.targetAmount`           | `string`         | Amount added, as a decimal string.                 |
| `data.swap.rate`                   | `string`         | Exchange rate used, as a decimal string.           |
| `data.swap.status`                 | `string`         | Swap status. See each event below.                 |
| `data.swap.completedAt`            | `string \| null` | When the swap completed. Null for failed swaps.    |
| `data.swap.createdAt`              | `string`         | When the swap was created (ISO 8601).              |
| `data.swap.quotation`              | `object`         | The quote the swap was made from.                  |
| `data.swap.quotation.id`           | `string`         | Unique quotation identifier.                       |
| `data.swap.quotation.fromCurrency` | `string`         | Quoted source currency.                            |
| `data.swap.quotation.toCurrency`   | `string`         | Quoted target currency.                            |
| `data.swap.quotation.sourceAmount` | `string`         | Quoted source amount.                              |
| `data.swap.quotation.targetAmount` | `string`         | Quoted target amount.                              |
| `data.swap.quotation.rate`         | `string`         | Quoted rate.                                       |
| `data.swap.quotation.executed`     | `boolean`        | Whether the quote was used for a swap.             |
| `data.swap.quotation.expiresAt`    | `string`         | When the quote expires (ISO 8601).                 |
| `data.swap.quotation.createdAt`    | `string`         | When the quote was created (ISO 8601).             |
| `data.failureReason`               | `string`         | Why the swap failed. Sent only with `swap.failed`. |

### Events

* `swap.completed`
* `swap.failed`

### `swap.completed`

Sent when a swap completes and both balances are updated. `data.swap.status` is `completed`.

```json
{
  "event": "swap.completed",
  "data": {
    "swap": {
      "id": "f2908051-6326-4708-bc73-1153209e7689",
      "fromCurrency": "USDT",
      "toCurrency": "NGN",
      "sourceAmount": "4.00",
      "targetAmount": "5493.95",
      "rate": "1373.48767500",
      "status": "completed",
      "completedAt": "2026-05-29T20:25:23.680Z",
      "createdAt": "2026-05-29T20:25:23.640Z",
      "quotation": {
        "id": "99f41fc8-47e2-4f34-a1dd-64f52ee4ff0c",
        "fromCurrency": "USDT",
        "toCurrency": "NGN",
        "sourceAmount": "4.00",
        "targetAmount": "5493.95",
        "rate": "1373.487675",
        "executed": true,
        "expiresAt": "2026-05-29T20:25:38.553Z",
        "createdAt": "2026-05-29T20:25:23.556Z"
      }
    }
  }
}
```

### `swap.failed`

Sent when a swap fails after it has started. `data.swap.status` is `failed`.

Requests that are rejected before the swap starts, such as invalid input, do not send this event.

{% hint style="danger" %}
Check `data.failureReason` for why the swap failed.
{% endhint %}

```json
{
  "event": "swap.failed",
  "data": {
    "swap": {
      "id": "f2908051-6326-4708-bc73-1153209e7689",
      "fromCurrency": "USDT",
      "toCurrency": "NGN",
      "sourceAmount": "4.00",
      "targetAmount": "5493.95",
      "rate": "1373.48767500",
      "status": "failed",
      "completedAt": null,
      "createdAt": "2026-05-29T20:25:23.640Z",
      "quotation": {
        "id": "99f41fc8-47e2-4f34-a1dd-64f52ee4ff0c",
        "fromCurrency": "USDT",
        "toCurrency": "NGN",
        "sourceAmount": "4.00",
        "targetAmount": "5493.95",
        "rate": "1373.487675",
        "executed": true,
        "expiresAt": "2026-05-29T20:25:38.553Z",
        "createdAt": "2026-05-29T20:25:23.556Z"
      }
    },
    "failureReason": "Swap could not be completed"
  }
}
```
