Create a pay-link
curl --request POST \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"reference": "<string>",
"description": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"max_uses": 2
}
'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links"
payload = {
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"reference": "<string>",
"description": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"max_uses": 2
}
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({
till_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
amount: 123,
reference: '<string>',
description: '<string>',
expires_at: '2023-11-07T05:31:56Z',
max_uses: 2
})
};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links', 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}/links",
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([
'till_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'amount' => 123,
'reference' => '<string>',
'description' => '<string>',
'expires_at' => '2023-11-07T05:31:56Z',
'max_uses' => 2
]),
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}/links"
payload := strings.NewReader("{\n \"till_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 123,\n \"reference\": \"<string>\",\n \"description\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"max_uses\": 2\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}/links")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"till_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 123,\n \"reference\": \"<string>\",\n \"description\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"max_uses\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links")
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 \"till_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 123,\n \"reference\": \"<string>\",\n \"description\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"max_uses\": 2\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",
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"amount": 123,
"reference": "<string>",
"description": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"max_uses": 123,
"uses": 123,
"status": "active",
"created_by": "<string>",
"created_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"
}
}Merchant API
Create a pay-link
A link is paid exactly like a till QR: share {PUBLIC_BASE_URL}/pay/{code} (QR at /pay/{code}/qr.png).
The payer picks M-Pesa or wallet; the money lands in the link’s till. amount (whole KES, in cents) fixes
the amount; omit it to let the payer choose. max_uses caps completed payments, expires_at ends it.
A pinned cashier’s links are always on their own till. Needs links.
POST
/
v1
/
merchants
/
{merchantID}
/
links
Create a pay-link
curl --request POST \
--url https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"reference": "<string>",
"description": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"max_uses": 2
}
'import requests
url = "https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links"
payload = {
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"reference": "<string>",
"description": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"max_uses": 2
}
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({
till_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
amount: 123,
reference: '<string>',
description: '<string>',
expires_at: '2023-11-07T05:31:56Z',
max_uses: 2
})
};
fetch('https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links', 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}/links",
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([
'till_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'amount' => 123,
'reference' => '<string>',
'description' => '<string>',
'expires_at' => '2023-11-07T05:31:56Z',
'max_uses' => 2
]),
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}/links"
payload := strings.NewReader("{\n \"till_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 123,\n \"reference\": \"<string>\",\n \"description\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"max_uses\": 2\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}/links")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"till_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 123,\n \"reference\": \"<string>\",\n \"description\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"max_uses\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cloudpay.africa/cloudpay/v1/merchants/{merchantID}/links")
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 \"till_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"amount\": 123,\n \"reference\": \"<string>\",\n \"description\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"max_uses\": 2\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",
"till_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"amount": 123,
"reference": "<string>",
"description": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"max_uses": 123,
"uses": 123,
"status": "active",
"created_by": "<string>",
"created_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"
}
}Authorizations
merchantKeybearer & merchantId
Body
application/json