Skip to main content

How to create an exchange via API

Overview​

Exchange API allows you to convert one asset to another inside a merchant account.

Use this guide to check available exchange options, create an exchange, and track its processing status until the exchange reaches a final status.

Integration flow​

  1. Check account balance and ensure enough funds for the exchange are available by using the method - [POST] account
  2. Optionally get available currency pairs by using the method - [POST] exchange/pairs
  3. Optionally check minimum and maximum exchange limits for the selected currency pair by using the method - [POST] exchange/limit
  4. Optionally pre-calculate the expected exchange amount by using the method - [POST] exchange/pre-calculate
  5. Create the exchange by using the method - [POST] exchange/create
  6. Get exchange details and current status by using the method - [POST] exchange/get

Sequence​

Names of requests on the scheme indicate certain exchange API methods.

Exchange sequence

API methods​

Create exchange - [POST] exchange/create​

Request fields​

FieldTypeRequiredDescription
accountstringYesMerchant account ID. The request will be sent for this account.
timestampnumberYesCurrent Unix UTC timestamp in milliseconds. The value must not be less than 3 minutes in the past or greater than 3 minutes in the future.
payloadobjectYesObject with exchange creation data.

Payload fields​

FieldTypeRequiredDescription
sourceCurrencystringYesCurrency that will be exchanged from.
destinationCurrencystringYesCurrency that will be exchanged to.
amountnumberYesExchange amount. The meaning of the amount depends on the selected direction.
directionstringYesExchange direction: SOURCE means the amount is set in source currency; DESTINATION means the amount is set in destination currency. Default value: SOURCE.
idempotencyKeystringYesExternal ID in UUID format. Can be generated by the merchant while creating the exchange to prevent duplicate requests.

Request example​

{
"account": "0x0000000000000000000000000000000000000000",
"timestamp": 1761650432438,
"payload": {
"sourceCurrency": "USDT",
"destinationCurrency": "BTC",
"amount": 100,
"direction": "SOURCE",
"idempotencyKey": "123e4567-e89b-12d3-a456-426614174000"
}
}

Response fields​

FieldTypeDescription
idnumberCalypso exchange ID.
accountstringMerchant account ID.
sourceCurrencystringCurrency exchanged from.
sourceAmountnumberAmount debited from the source currency balance.
destinationCurrencystringCurrency exchanged to.
destinationAmountnumberAmount credited to the destination currency balance.
statestringCurrent exchange status.
createdDatestringDate and time when the exchange was created.

Response example 200 OK​

{
"id": 123456,
"account": "0x0000000000000000000000000000000000000000",
"sourceCurrency": "USDT",
"sourceAmount": 100,
"destinationCurrency": "BTC",
"destinationAmount": 0.0015,
"state": "IN_PROGRESS",
"createdDate": "2026-06-29T09:00:00.000Z"
}

Optional methods​

MethodPurposeMain response
[POST] exchange/pairsReturns available currency pairs for the merchant account.currencyPairs map.
[POST] exchange/limitReturns minimum and maximum limits for a selected currency pair.sourceCurrency, destinationCurrency, minLimit, maxLimit.
[POST] exchange/pre-calculateCalculates the expected exchange amount before creating an exchange.sourceCurrency, destinationCurrency, amount, direction.
[POST] exchange/average-rateReturns the average rate for a selected currency pair.rate.
[POST] exchange/filterReturns a paginated list of exchanges by filter.result, page, size, total, totalElements.

Pre-calculate payload fields​

FieldTypeRequiredDescription
sourceCurrencystringYesCurrency that will be exchanged from.
destinationCurrencystringYesCurrency that will be exchanged to.
amountnumberYesExchange amount. The meaning of the amount depends on the selected direction.
directionstringYesExchange direction: SOURCE means the amount is set in source currency; DESTINATION means the amount is set in destination currency. Default value: SOURCE.

Limit and average rate payload fields​

FieldTypeRequiredDescription
sourceCurrencystringYesCurrency that will be exchanged from.
destinationCurrencystringYesCurrency that will be exchanged to.

Get exchange payload fields​

FieldTypeRequiredDescription
idnumberYesCalypso exchange ID.

Status lifecycle​

Diagram nodes indicate exchange statuses, arrows indicate processes a successful completion of which transfers an exchange from one status to another.

StatusDescription
IN_PROGRESSThe exchange has been created and is awaiting execution.
COMPLETEDFunds have been successfully exchanged on the merchant account.
FAILED

An error occurred during the exchange. There can be many reasons for the error. You may follow these remediation steps:
1. Wait a while and create a new exchange.
2. Contact our technical support.

Errors and edge cases​

CaseDescription
Not enough fundsCheck the account balance before creating an exchange.
Currency pair is not availableCheck available pairs by using [POST] exchange/pairs before creating an exchange.
Amount is outside limitsCheck minimum and maximum limits by using [POST] exchange/limit.
Duplicate requestUse a unique idempotencyKey for each exchange creation request.
Processing failedThe exchange was not completed. You can create a new exchange with corrected data or contact technical support.
DocumentLink
Account API[POST] account
Exchange API referenceExchange API
Exchange transactions reportExchange transactions
LimitsLimits