Quotes & Swaps Overview
Choose a locked quote or a live rate, execute a balance swap, and reconcile the transaction.
A swap moves funds between two balances on your HoneyCoin account. For example, you can convert USD to KES, swap USDC for USDT, or move XOF between your Benin and Senegal ledgers. The debit and credit settle together.
| When you need to… | Use | API calls |
|---|---|---|
| Show the receiver amount before committing | A quoted swap | Create a quote, then create a swap |
| Convert immediately at the current rate | A direct swap | Create a swap |
Before you start
Use the bearer token for your environment and send Content-Type: application/json with POST requests.
| Environment | Base URL |
|---|---|
| Production | https://api-v2.honeycoin.app/api/b2b |
| Sandbox | https://api-v2.honeycoin.app/api/sandbox/b2b |
In production, enable Swaps on an onboarded, approved account and fund the source balance. The account’s active IP allowlist applies to quotes, swaps, transaction history, and balances. In sandbox, you can start with an unfunded account. Authentication · IP allowlisting
Execute a quoted swap
1. Get the rate and receiver amount
Send this body to POST /quotes to price a 100 USD debit in KES. Creating the quote leaves both balances unchanged.
{
"type": "swap",
"senderAmount": 100,
"senderCurrency": "USD",
"receiverCurrency": "KES"
}From the 201 Created response, save data.id as the quote ID. Show the customer data.exchangeRate, data.receiverAmount, and data.receiverCurrency. The rate is valid through data.expiresAt, a Unix timestamp in milliseconds. Use the returned deadline for each quote.
2. Submit the confirmed quote
Send the saved ID to POST /swaps. Include an X-Idempotency-Key header and a unique externalReference for this swap. The quote supplies the amount, currencies, and countries. Sending those fields again returns 400 VALIDATION_ERROR.
{
"quoteId": "qt_01JXYZ123456",
"externalReference": "kes-top-up-001",
"note": "KES treasury top-up"
}Execute a direct swap
For an immediate conversion, send the amount and both currencies to POST /swaps. Include a fresh X-Idempotency-Key header for this new swap. This example buys USDC with 100 USD.
{
"senderAmount": 100,
"senderCurrency": "USD",
"receiverCurrency": "USDC",
"externalReference": "usdc-top-up-001"
}Use senderCountry or receiverCountry to select a country-specific fiat balance. XOF requires an explicit country. USD defaults to US and XAF to CM. Omit the country for USDC and USDT. Both legs must resolve to different ledgers. Supported currencies and country codes
Confirm settlement
For either mode, 201 Created with data.status set to successful confirms that both balances have been updated. The response includes the transaction ID, exchange rate, and before-and-after balances for each leg. Direct swaps return data.quoteId: null.
| To verify | Read |
|---|---|
| The recorded swap | GET /transactions/{id} using the swap’s data.id. Match type: "swap" and your externalReference. |
| Which transaction used a quote | GET /quotes/{quoteId}. A consumed quote’s data.consumedById is the swap transaction ID. |
| Current balances | GET /users/balances. Match the currency and country for each leg. |
Recover after a timeout or conflict
A consumed quote already has a settled swapIf the response was lost, check the quote and its linked transaction before starting another conversion. A fresh quote and external reference can move the funds a second time.
Keep the original request body, external reference, and idempotency key together. Replay the same request after a timeout or 5xx. The keyed replay window is one hour. For 409 IDEMPOTENCY_IN_PROGRESS, wait for Retry-After before replaying.
| What you find | What to do |
|---|---|
The quote is consumed | Fetch the transaction identified by consumedById. The conversion has already settled. |
| The external reference is already in use | Look up GET /transactions?externalReference=… and match the transaction to the intended swap. This also works for a direct swap. |
The quote is expired and consumedById is null | Create a fresh quote, confirm the new amounts, and use a new idempotency key for the updated request. |
Updated about 3 hours ago
