Exchange Webhook
Last updated
Last updated
The Exchange Request Webhook is a special webhook that allows you to receive an exchange request on the order you've created. This is a different webhook from the webhook you use to receive on various events like transaction confirmed, transaction created and transaction failed. As a market provider, you must register one Exchange Request Webhook URL to create order and accept any exchange request.
Go to the dashboard and register a webhook URL to receive exchange request through this URL. Once you register a webhook URL, there will be a checkbox beside the URL. Check this box to mark the URL as the exchange request webhook URL.
If you unset this checkbox, this will immediately suspend any exchange request webhooks, which means that you will not be able to accept any exchange requests until you recheck this box.
When an exchange is requested using your order, Gluwa will make a POST request to the exchange webhook URL for the permission to proceed with the exchange. The following request body is sent with the request.
Attribute | Type | Description |
ID |
| ID of the exchange request |
EventType |
| Always "ExchangeRequest" |
Type |
| Always "Webhook" |
ResourceID |
| Order ID |
Conversion |
| The conversion of the exchange. |
DestinationAddress |
| The address where the source amount must be sent to. |
SourceAmount |
| The amount in source currency that this order will exchange. |
Fee |
| The fee amount that must be used to create |
Executor |
| Optional. Required if the source currency is Gluwacoin currency (ex> |
ExpiryBlockNumber |
| Optional. Required if the source currency is Gluwacoin currency (ex> After this block number, the exchange will not execute, and you may call reclaim function on the blockchain to release your reserved funds. |
ReservedFundsAddress |
| Optional. Required if the source currency is |
ReservedFundsRedeemScript |
| Optional. Required if the source currency is |
If you want to verify that the request was actually sent from Gluwa, you can check the veracity of the webhook as shown here.
After the you receive the webhook receive, you must do the following to accept the exchange request:
Return 200 status code as a response to the webhook request. If you return any other response, Gluwa will try to send the same webhook for the maximum of 5 times, before treating the exchange request as declined.
Use PATCH /V1/ExchangeRequest/{ID} endpoint to accept the exchange request. If you fail to successfully accept the exchange request within 10 minutes, the exchange request is automatically declined.
If you decline the exchange request for an order 5 times, that order will be canceled automatically.
Gluwa will send a webhook when an exchange succeeds or fails. This will be sent to the same webhook URL as the one you use to receive transaction confirmed, transaction created and transaction failed webhooks, NOT to the exchange equest webhook URL.
Attribute | Type | Description |
EventType |
| Always "ExchangeSuccess" |
Type |
| Always "Webhook" |
ResourceID |
| Order ID |
OrderAmountRemaining |
| The amount remaining in the order. |
Conversion |
| Conversion symbol for the order. See conversion. |
SendingAddress |
| The address that will fund the source amount. |
ReceivingAddress |
| The address that the exchanged currency will be received. For example, if the conversion is |
SourceAmount |
| The amount in source currency that this order will exchange. |
Price |
| The price the order will use for the exchange. The unit is |
ExchangedAmount |
| The exchanged amount in exchanged currency. |
Attribute | Type | Description |
EventType |
| Always "ExchangeFailed" |
Type |
| Always "Webhook" |
ResourceID |
| Order ID |
OrderAmountRemaining |
| The amount remaining in the order. |
Conversion |
| Conversion symbol for the order. See conversion. |
SendingAddress |
| The address that will fund the source amount. |
ReceivingAddress |
| The address that the exchanged currency will be received. For example, if the conversion is |
SourceAmount |
| The amount in source currency that this order will exchange. |
Price |
| The price the order will use for the exchange. The unit is |
ExchangedAmount |
| The exchanged amount in exchanged currency. |