Swap API
Our Swap API give merchants the ability to swap funds between their wallets via API using our internal Klasha rates.
Integration step
You can swap money in three easy steps:
Generate a bearer token (see authentication)
Generate a quote for the swap
Confirm swap
Generate a bearer token
Use the authentication API here to generate a bearer token and set your Authorization header to the token obtained.
You’d also need to set your public key as header the x-auth-token. This can be obtained from your merchant dashboard → Settings → Generate API keys → Merchant public key.
In summary, the request headers of all the requests sent to the APIs below should contain the data specified below;
Authorization
Bearer {{token}}
token generated from the authentication API
x-auth-token
MERCHANT PUBLIC KEY
public key retrieved from the dashboard
Generate a quote
POST - {{env_url}}/wallet/swap/generate/quote
Call the Create Quote API to generate your quote. See an example of the payload you need to encrypt and send in order to generate your quote.
The encrypted JSON body for the request can be found in the Postman link as well as other APIs.
Headers
As specified above
Request Body (plain)
sourceCurrency*
String
Example: NGN
destinationCurrency*
String
Example: USD
destinationAmount
String
Amount received by the recipient. Example: 1000.00
sourceAmount*
String
Amount sent from the sender. Example: 100.00
mode
String
When the mode is set to "SOURCE", the system will utilize the sourceAmount, making the destinationAmount field optional.
Request Body (encrypted)
Response
Confirm swap
POST - {{env_url}}/wallet/swap/initiate
Call the Confirm swap API to convert your quote into wallet swap transaction.
See an example of the payload you need to encrypt and send in order to generate your quote.
The encrypted JSON body for the request can be found in the Postman link as well as other APIs
Headers
As specified above
Request Body
quoteToken*
String
quote token return from the generate quote API above
Fetch all your payments
GET - {{env_url}}/wallet/swap/fetch/by/reference/{{transactionReference}}
Call this API to retrieve a swap transaction associated to a swap reference
You’d need to pass the transactionReference you obtained when you initiated the swap, as a path variable.
Headers
As specified above
Response
Fetch a single payment by quote token
GET - {{env_url}}/wallet/swap/fetch/by/token/{{quoteToken}}
Make a call to this API to retrieve all your previously initiated quoted swaps.
You’d need to pass the quoteToken you obtained when you initiated the swap, as a path variable.
Headers
As specified above
Response
Quote expiry logic
After you proceeded generating your quote, you can now convert that quote to confirm a swap transactions.
The confirmation would be successful if the quote is NOT expired.
A quote does not expire because of time but just if the rate in our system changed.
In case you try to initiate a payment with an expired quote, you’d have a Bad Request response with the the following body:
Last updated
