Request a settlement from the main account
curl --request POST \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 100000,
"idempotency_key": "<string>",
"note": "<string>"
}
'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements"
payload = {
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 100000,
"idempotency_key": "<string>",
"note": "<string>"
}
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({
destination_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
amount: 100000,
idempotency_key: '<string>',
note: '<string>'
})
};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements', 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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements",
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([
'destination_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'amount' => 100000,
'idempotency_key' => '<string>',
'note' => '<string>'
]),
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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements"
payload := strings.NewReader("{\n \"destination_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 100000,\n \"idempotency_key\": \"<string>\",\n \"note\": \"<string>\"\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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"destination_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 100000,\n \"idempotency_key\": \"<string>\",\n \"note\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements")
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 \"destination_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 100000,\n \"idempotency_key\": \"<string>\",\n \"note\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"fee": 123,
"status": "requested",
"payout": "rail",
"disbursement_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"receipt": "<string>",
"note": "<string>",
"requested_by": "<string>",
"approved_by": "<string>",
"decided_by": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"fee": 123,
"status": "requested",
"payout": "rail",
"disbursement_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"receipt": "<string>",
"note": "<string>",
"requested_by": "<string>",
"approved_by": "<string>",
"decided_by": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}Merchant API
Request a settlement from the main account
Needs KYB approved (unless staff waived kyb_required) and a verified destination. Within the merchant’s auto-approve limits it is
approved and paid at once (approved_by: system:auto-approve); otherwise someone else approves.
Payout: an M-Pesa destination on a custodial disbursement rail is paid by B2C (payout: rail, fee kind merchant.disbursement);
anything else is paid by CloudPay staff by hand (payout: manual, fee kind merchant.settlement). Replays with the same key return 200. Needs settle.
Test environment: refused with 403 live_mode_required (as are approve and manual-finish); a live merchant not yet approved for production gets 403 production_not_approved.
POST
/
v1
/
merchants
/
{merchantID}
/
settlements
Request a settlement from the main account
curl --request POST \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 100000,
"idempotency_key": "<string>",
"note": "<string>"
}
'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements"
payload = {
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 100000,
"idempotency_key": "<string>",
"note": "<string>"
}
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({
destination_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
amount: 100000,
idempotency_key: '<string>',
note: '<string>'
})
};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements', 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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements",
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([
'destination_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'amount' => 100000,
'idempotency_key' => '<string>',
'note' => '<string>'
]),
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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements"
payload := strings.NewReader("{\n \"destination_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 100000,\n \"idempotency_key\": \"<string>\",\n \"note\": \"<string>\"\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://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"destination_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 100000,\n \"idempotency_key\": \"<string>\",\n \"note\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/settlements")
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 \"destination_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 100000,\n \"idempotency_key\": \"<string>\",\n \"note\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"fee": 123,
"status": "requested",
"payout": "rail",
"disbursement_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"receipt": "<string>",
"note": "<string>",
"requested_by": "<string>",
"approved_by": "<string>",
"decided_by": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"status": {
"ok": true,
"code": 123,
"desc": "<string>"
},
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"destination_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"fee": 123,
"status": "requested",
"payout": "rail",
"disbursement_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"receipt": "<string>",
"note": "<string>",
"requested_by": "<string>",
"approved_by": "<string>",
"decided_by": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}{
"status": {
"ok": false,
"code": 422,
"desc": "Unprocessable Entity"
},
"errors": {
"code": "insufficient_funds",
"message": "insufficient funds"
}
}Authorizations
merchantKeybearer & merchantId
Body
application/json