# Exchange Callbacks

## Exchange Withdrawal&#x20;

{% hint style="info" %}
Fiat batch withdrawals are used here. Read more about that [here](#batch-withdrawal).
{% endhint %}

Statuses

* :hourglass\_flowing\_sand:**Exchanged** - your swap is filled and balances are exchanged
* **😡 Failed** – can fire before exchanged status or after exchanged status (order not filled, withdraw is not successful and etc. In that case you should check you account in web application)
* :white\_check\_mark: **Done** – withdrawal was sent

**Webhook request body:**

<table><thead><tr><th width="265">Field</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>kind</td><td>"FiatExchangeWithdraw" | "CryptoExchangeWithdraw"</td><td></td></tr><tr><td>id</td><td>string*</td><td>Identifier</td></tr><tr><td>ticker</td><td>string*</td><td>"KZT"</td></tr><tr><td>amount</td><td>string*</td><td>amount in decimal format, look at the example</td></tr><tr><td>paidAmount</td><td>string*</td><td>This field can differ from amount field in specific bank cases so it should be used as source of true. </td></tr><tr><td>failedAmount</td><td>string*</td><td>withdraw amount that not sent on bank side</td></tr><tr><td>fee</td><td>string*</td><td>withdraw service fee, learn more <a href="/pages/0AFl5R1WbizXQrZ6mNTy">here</a></td></tr><tr><td>meta</td><td>string</td><td>metadata you defined when <a href="/pages/NzsQOCYaWvM0rbwFyiYG#sending-an-asset">withdrawal was created</a></td></tr><tr><td>localId</td><td>string</td><td>localId you defined when <a href="/pages/NzsQOCYaWvM0rbwFyiYG#sending-an-asset">withdrawal was created</a>, or it could be the id of an entity that caused this withdrawal if it happens due to auto-targeting</td></tr><tr><td>status</td><td>string*</td><td>"Done" | "Exchanged" | "Failed"</td></tr><tr><td>time</td><td>number*</td><td>timestamp when withdrawal was created in ms</td></tr><tr><td>exchangeFee</td><td>string*</td><td>exchange fee used</td></tr><tr><td>spendTicker</td><td>string*</td><td>ticker that was withdrawn from balance (exchanged)</td></tr><tr><td>spendAmount</td><td>string*</td><td>amount that was withdrawn from balance (exchanged)</td></tr><tr><td>price</td><td>string*</td><td>price value, example: 23000 for BTC -> USDT pair</td></tr><tr><td>pricePair</td><td>string*[2]</td><td>pair that used in exchange</td></tr><tr><td>exchanged</td><td>boolean</td><td>balances were swapped and exchanged succeeded</td></tr><tr><td>to</td><td>string*</td><td>card number</td></tr><tr><td>causedBy</td><td>string</td><td>If this field present, it's mean that this is auto withdrawal, caused by some deposit. Posible values: "fiat-invoice", "crypto-invoice", "crypto-replenishment"</td></tr><tr><td>internal</td><td>boolean</td><td>offchain withdraw to 0xpay address</td></tr></tbody></table>

## Exchange

Statuses:

* **😡 Failed** – can fire before exchanged status or after exchanged status (order not filled, exchange is not successful and etc. In that case you should check you account in web application)
* :white\_check\_mark: **Done** – success exchange

**Webhook request body:**

<table><thead><tr><th width="258">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>string*</td><td>Identifier</td></tr><tr><td>localId</td><td>string</td><td>localId you defined when <a href="/pages/NzsQOCYaWvM0rbwFyiYG#post-create-exchange">exchange was created</a>, or it could be the id of an entity that caused this exchange if it happens due to auto-targeting</td></tr><tr><td>time</td><td>number*</td><td>timestamp when exchange was created in ms</td></tr><tr><td>meta</td><td>string</td><td>metadata you defined</td></tr><tr><td>status</td><td>string*</td><td>"Failed", "Done"</td></tr><tr><td>kind</td><td>"Exchange"</td><td></td></tr><tr><td>targetTicker</td><td>string*</td><td>Ticker you chose to receive.</td></tr><tr><td>targetAmount</td><td>string*</td><td>amount that was received to balance (exchanged)</td></tr><tr><td>spendTicker</td><td>string*</td><td>ticker that was withdrawn from balance (exchanged)</td></tr><tr><td>spendAmount</td><td>string*</td><td>amount that was exchange from balance (exchanged)</td></tr><tr><td>fee</td><td>string*</td><td>withdraw service fee, learn more <a href="/pages/0AFl5R1WbizXQrZ6mNTy">here</a></td></tr><tr><td>price</td><td>string*</td><td>price value, example: 23000 for BTC -> USDT pair</td></tr><tr><td>pricePair</td><td>[string*, string*]</td><td>array of two tickers (targetTicker, spendTicker).<br>Values you can find <a href="/pages/RKfD5DpwkzBv16lJiXg0#blockchains">here</a> (Ticker column) + Fiat ticker "UAH"</td></tr><tr><td>merchantId</td><td>string*</td><td>your own merchant identifier</td></tr><tr><td>failedReason</td><td>string</td><td>reason why exchange was failed</td></tr><tr><td>causedBy</td><td>string</td><td>If this field present, it's mean that this is auto exchange, caused by some deposit. Posible values: "fiat-invoice", "crypto-invoice", "crypto-replenishment"</td></tr></tbody></table>


---

# Agent Instructions: 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:

```
GET https://docs.0xpay.app/public-api/notifications/exchange-callbacks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
