curl --request POST \
--url https://sandbox-api.kotanipay.io/api/v3/offramp \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"referenceId": "<string>",
"cryptoAmount": 123,
"currency": "<unknown>",
"depositStatus": "<unknown>",
"transactionHash": "<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.io/api/v3/offramp"
payload = {
"referenceId": "<string>",
"cryptoAmount": 123,
"currency": "<unknown>",
"depositStatus": "<unknown>",
"transactionHash": "<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({
referenceId: '<string>',
cryptoAmount: 123,
currency: '<unknown>',
depositStatus: '<unknown>',
transactionHash: '<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.io/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.io/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([
'referenceId' => '<string>',
'cryptoAmount' => 123,
'currency' => '<unknown>',
'depositStatus' => '<unknown>',
'transactionHash' => '<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.io/api/v3/offramp"
payload := strings.NewReader("{\n \"referenceId\": \"<string>\",\n \"cryptoAmount\": 123,\n \"currency\": \"<unknown>\",\n \"depositStatus\": \"<unknown>\",\n \"transactionHash\": \"<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.io/api/v3/offramp")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"referenceId\": \"<string>\",\n \"cryptoAmount\": 123,\n \"currency\": \"<unknown>\",\n \"depositStatus\": \"<unknown>\",\n \"transactionHash\": \"<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.io/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 \"referenceId\": \"<string>\",\n \"cryptoAmount\": 123,\n \"currency\": \"<unknown>\",\n \"depositStatus\": \"<unknown>\",\n \"transactionHash\": \"<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>",
"status": "<string>",
"cryptoAmount": 123,
"cryptoAmountReceived": 123,
"feeInCrypto": 123,
"feeType": "<string>",
"cryptoWallet": "<string>",
"chain": {},
"token": {},
"transactionHash": "<string>",
"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.io/api/v3/offramp \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"referenceId": "<string>",
"cryptoAmount": 123,
"currency": "<unknown>",
"depositStatus": "<unknown>",
"transactionHash": "<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.io/api/v3/offramp"
payload = {
"referenceId": "<string>",
"cryptoAmount": 123,
"currency": "<unknown>",
"depositStatus": "<unknown>",
"transactionHash": "<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({
referenceId: '<string>',
cryptoAmount: 123,
currency: '<unknown>',
depositStatus: '<unknown>',
transactionHash: '<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.io/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.io/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([
'referenceId' => '<string>',
'cryptoAmount' => 123,
'currency' => '<unknown>',
'depositStatus' => '<unknown>',
'transactionHash' => '<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.io/api/v3/offramp"
payload := strings.NewReader("{\n \"referenceId\": \"<string>\",\n \"cryptoAmount\": 123,\n \"currency\": \"<unknown>\",\n \"depositStatus\": \"<unknown>\",\n \"transactionHash\": \"<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.io/api/v3/offramp")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"referenceId\": \"<string>\",\n \"cryptoAmount\": 123,\n \"currency\": \"<unknown>\",\n \"depositStatus\": \"<unknown>\",\n \"transactionHash\": \"<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.io/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 \"referenceId\": \"<string>\",\n \"cryptoAmount\": 123,\n \"currency\": \"<unknown>\",\n \"depositStatus\": \"<unknown>\",\n \"transactionHash\": \"<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>",
"status": "<string>",
"cryptoAmount": 123,
"cryptoAmountReceived": 123,
"feeInCrypto": 123,
"feeType": "<string>",
"cryptoWallet": "<string>",
"chain": {},
"token": {},
"transactionHash": "<string>",
"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
Onramp reference ID
The crypto amount
Fiat currency
Deposit status
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
Transaction hash
Optional refund destination for this transaction. For Lightning: provide a bolt11 invoice so Kotani can refund immediately if fiat disbursement fails, without waiting for you to submit one manually. Include generate_invoice_url so Kotani can refresh the invoice if it expires. For on-chain chains: provide address as the fallback refund destination. If omitted, Kotani notifies you via webhook and email when a refund is needed and you submit via POST /offramp/submit-refund-invoice/:referenceId.
Show child attributes
Show child attributes