curl --request POST \
--url https://sandbox-api.kotanipay.com/api/v3/offramp \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cryptoAmount": 123,
"currency": "<string>",
"referenceId": "<string>",
"senderAddress": "<string>",
"callbackUrl": "<string>",
"rateId": "<string>",
"refund_config": {
"bolt11": "lnbc1500n1p0xyz...",
"payment_hash": "a1b2c3d4e5f6...",
"amount_msat": 150000000,
"expires_at": "2024-11-22T13:00:00Z",
"generate_invoice_url": "https://api.yourapp.com/lightning/generate-refund-invoice",
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}
}
'import requests
url = "https://sandbox-api.kotanipay.com/api/v3/offramp"
payload = {
"cryptoAmount": 123,
"currency": "<string>",
"referenceId": "<string>",
"senderAddress": "<string>",
"callbackUrl": "<string>",
"rateId": "<string>",
"refund_config": {
"bolt11": "lnbc1500n1p0xyz...",
"payment_hash": "a1b2c3d4e5f6...",
"amount_msat": 150000000,
"expires_at": "2024-11-22T13:00:00Z",
"generate_invoice_url": "https://api.yourapp.com/lightning/generate-refund-invoice",
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cryptoAmount: 123,
currency: '<string>',
referenceId: '<string>',
senderAddress: '<string>',
callbackUrl: '<string>',
rateId: '<string>',
refund_config: {
bolt11: 'lnbc1500n1p0xyz...',
payment_hash: 'a1b2c3d4e5f6...',
amount_msat: 150000000,
expires_at: '2024-11-22T13:00:00Z',
generate_invoice_url: 'https://api.yourapp.com/lightning/generate-refund-invoice',
address: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
}
})
};
fetch('https://sandbox-api.kotanipay.com/api/v3/offramp', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.kotanipay.com/api/v3/offramp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cryptoAmount' => 123,
'currency' => '<string>',
'referenceId' => '<string>',
'senderAddress' => '<string>',
'callbackUrl' => '<string>',
'rateId' => '<string>',
'refund_config' => [
'bolt11' => 'lnbc1500n1p0xyz...',
'payment_hash' => 'a1b2c3d4e5f6...',
'amount_msat' => 150000000,
'expires_at' => '2024-11-22T13:00:00Z',
'generate_invoice_url' => 'https://api.yourapp.com/lightning/generate-refund-invoice',
'address' => '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.kotanipay.com/api/v3/offramp"
payload := strings.NewReader("{\n \"cryptoAmount\": 123,\n \"currency\": \"<string>\",\n \"referenceId\": \"<string>\",\n \"senderAddress\": \"<string>\",\n \"callbackUrl\": \"<string>\",\n \"rateId\": \"<string>\",\n \"refund_config\": {\n \"bolt11\": \"lnbc1500n1p0xyz...\",\n \"payment_hash\": \"a1b2c3d4e5f6...\",\n \"amount_msat\": 150000000,\n \"expires_at\": \"2024-11-22T13:00:00Z\",\n \"generate_invoice_url\": \"https://api.yourapp.com/lightning/generate-refund-invoice\",\n \"address\": \"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox-api.kotanipay.com/api/v3/offramp")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cryptoAmount\": 123,\n \"currency\": \"<string>\",\n \"referenceId\": \"<string>\",\n \"senderAddress\": \"<string>\",\n \"callbackUrl\": \"<string>\",\n \"rateId\": \"<string>\",\n \"refund_config\": {\n \"bolt11\": \"lnbc1500n1p0xyz...\",\n \"payment_hash\": \"a1b2c3d4e5f6...\",\n \"amount_msat\": 150000000,\n \"expires_at\": \"2024-11-22T13:00:00Z\",\n \"generate_invoice_url\": \"https://api.yourapp.com/lightning/generate-refund-invoice\",\n \"address\": \"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox-api.kotanipay.com/api/v3/offramp")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cryptoAmount\": 123,\n \"currency\": \"<string>\",\n \"referenceId\": \"<string>\",\n \"senderAddress\": \"<string>\",\n \"callbackUrl\": \"<string>\",\n \"rateId\": \"<string>\",\n \"refund_config\": {\n \"bolt11\": \"lnbc1500n1p0xyz...\",\n \"payment_hash\": \"a1b2c3d4e5f6...\",\n \"amount_msat\": 150000000,\n \"expires_at\": \"2024-11-22T13:00:00Z\",\n \"generate_invoice_url\": \"https://api.yourapp.com/lightning/generate-refund-invoice\",\n \"address\": \"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Offramp has been successfully created",
"data": {
"referenceId": "<string>",
"fiatAmount": 123,
"fiatTransactionAmount": 123,
"cryptoAmount": 123,
"fiatCurrency": "<string>",
"customerKey": "<string>",
"fiatWalletId": "<string>",
"senderAddress": "<string>",
"transactionHash": "<string>",
"transactionHashAmount": 123,
"status": "<string>",
"onchainStatus": "<string>",
"rate": {},
"escrowAddress": "<string>",
"usingIntegratedWallet": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"onchainError": {},
"transactionError": {}
}
}{
"success": false,
"message": "Bad Request",
"data": {}
}{
"success": false,
"message": "Unauthorized",
"data": {}
}Create Offramp Request
This endpoint will create a offramp request for a customer. If the fiat transfer fails after successful crypto receipt, an automatic refund will be initiated after 5 minutes. Use the refund-status endpoint to check refund status.
curl --request POST \
--url https://sandbox-api.kotanipay.com/api/v3/offramp \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cryptoAmount": 123,
"currency": "<string>",
"referenceId": "<string>",
"senderAddress": "<string>",
"callbackUrl": "<string>",
"rateId": "<string>",
"refund_config": {
"bolt11": "lnbc1500n1p0xyz...",
"payment_hash": "a1b2c3d4e5f6...",
"amount_msat": 150000000,
"expires_at": "2024-11-22T13:00:00Z",
"generate_invoice_url": "https://api.yourapp.com/lightning/generate-refund-invoice",
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}
}
'import requests
url = "https://sandbox-api.kotanipay.com/api/v3/offramp"
payload = {
"cryptoAmount": 123,
"currency": "<string>",
"referenceId": "<string>",
"senderAddress": "<string>",
"callbackUrl": "<string>",
"rateId": "<string>",
"refund_config": {
"bolt11": "lnbc1500n1p0xyz...",
"payment_hash": "a1b2c3d4e5f6...",
"amount_msat": 150000000,
"expires_at": "2024-11-22T13:00:00Z",
"generate_invoice_url": "https://api.yourapp.com/lightning/generate-refund-invoice",
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cryptoAmount: 123,
currency: '<string>',
referenceId: '<string>',
senderAddress: '<string>',
callbackUrl: '<string>',
rateId: '<string>',
refund_config: {
bolt11: 'lnbc1500n1p0xyz...',
payment_hash: 'a1b2c3d4e5f6...',
amount_msat: 150000000,
expires_at: '2024-11-22T13:00:00Z',
generate_invoice_url: 'https://api.yourapp.com/lightning/generate-refund-invoice',
address: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
}
})
};
fetch('https://sandbox-api.kotanipay.com/api/v3/offramp', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.kotanipay.com/api/v3/offramp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cryptoAmount' => 123,
'currency' => '<string>',
'referenceId' => '<string>',
'senderAddress' => '<string>',
'callbackUrl' => '<string>',
'rateId' => '<string>',
'refund_config' => [
'bolt11' => 'lnbc1500n1p0xyz...',
'payment_hash' => 'a1b2c3d4e5f6...',
'amount_msat' => 150000000,
'expires_at' => '2024-11-22T13:00:00Z',
'generate_invoice_url' => 'https://api.yourapp.com/lightning/generate-refund-invoice',
'address' => '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.kotanipay.com/api/v3/offramp"
payload := strings.NewReader("{\n \"cryptoAmount\": 123,\n \"currency\": \"<string>\",\n \"referenceId\": \"<string>\",\n \"senderAddress\": \"<string>\",\n \"callbackUrl\": \"<string>\",\n \"rateId\": \"<string>\",\n \"refund_config\": {\n \"bolt11\": \"lnbc1500n1p0xyz...\",\n \"payment_hash\": \"a1b2c3d4e5f6...\",\n \"amount_msat\": 150000000,\n \"expires_at\": \"2024-11-22T13:00:00Z\",\n \"generate_invoice_url\": \"https://api.yourapp.com/lightning/generate-refund-invoice\",\n \"address\": \"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox-api.kotanipay.com/api/v3/offramp")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cryptoAmount\": 123,\n \"currency\": \"<string>\",\n \"referenceId\": \"<string>\",\n \"senderAddress\": \"<string>\",\n \"callbackUrl\": \"<string>\",\n \"rateId\": \"<string>\",\n \"refund_config\": {\n \"bolt11\": \"lnbc1500n1p0xyz...\",\n \"payment_hash\": \"a1b2c3d4e5f6...\",\n \"amount_msat\": 150000000,\n \"expires_at\": \"2024-11-22T13:00:00Z\",\n \"generate_invoice_url\": \"https://api.yourapp.com/lightning/generate-refund-invoice\",\n \"address\": \"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox-api.kotanipay.com/api/v3/offramp")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cryptoAmount\": 123,\n \"currency\": \"<string>\",\n \"referenceId\": \"<string>\",\n \"senderAddress\": \"<string>\",\n \"callbackUrl\": \"<string>\",\n \"rateId\": \"<string>\",\n \"refund_config\": {\n \"bolt11\": \"lnbc1500n1p0xyz...\",\n \"payment_hash\": \"a1b2c3d4e5f6...\",\n \"amount_msat\": 150000000,\n \"expires_at\": \"2024-11-22T13:00:00Z\",\n \"generate_invoice_url\": \"https://api.yourapp.com/lightning/generate-refund-invoice\",\n \"address\": \"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Offramp has been successfully created",
"data": {
"referenceId": "<string>",
"fiatAmount": 123,
"fiatTransactionAmount": 123,
"cryptoAmount": 123,
"fiatCurrency": "<string>",
"customerKey": "<string>",
"fiatWalletId": "<string>",
"senderAddress": "<string>",
"transactionHash": "<string>",
"transactionHashAmount": 123,
"status": "<string>",
"onchainStatus": "<string>",
"rate": {},
"escrowAddress": "<string>",
"usingIntegratedWallet": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"onchainError": {},
"transactionError": {}
}
}{
"success": false,
"message": "Bad Request",
"data": {}
}{
"success": false,
"message": "Unauthorized",
"data": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The crypto amount
Fiat currency (e.g. KES, GHS, SLE, TZS)
Chain
ETHEREUM, CELO, AVALANCHE, POLYGON, ARBITRUM, OPTIMISM, BINANCE, STELLAR, TRON, FUSE, LIGHTNING, SOLANA, PROVENANCE, CARDANO, HEDERA, BASE, LISK, VICTION, SCROLL Stable Coin or Token
CUSD, USDC, USDT, USDT0, SAT, BTC, HASH, FUSE, HBAR, USDGLO, CKES, CGHS, MSAT, XLM, ADA Reference ID
Mobile Money receiver details
Show child attributes
Show child attributes
Bank receiver details
Show child attributes
Show child attributes
Lipa na M-Pesa (Till/Buy Goods) receiver — Kenya only
Show child attributes
Show child attributes
Paybill receiver — Kenya only
Show child attributes
Show child attributes
Sender address (optional - if not provided, will use integrator crypto wallet)
Callback URL
Rate ID obtained from the /offramp/rate endpoint
Where to send a refund if the fiat disbursement fails. See the refunds guide.
Show child attributes
Show child attributes