Sasio Pay API · v1
Connect your systems to Sasio Pay
Create quotes and invoices from your online shop, CRM or accounting system, record payments, and get a webhook the moment a client views, accepts or pays. It's free.
Base URL: https://pay.sasio.co.za/api/v1
Examples in curl, C# (.NET), Node.js, Python and PHP.
Quickstart
- Log in to Sasio Pay and open Settings → Developers.
- Create a test key. It starts with
pm_test_. Copy it: it's only shown once. - Create your first invoice:
curl https://pay.sasio.co.za/api/v1/invoices \
-H "Authorization: Bearer pm_test_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1001" \
-d '{
"client": { "name": "Acme Trading", "email": "accounts@acme.example", "external_id": "CUST-42" },
"reference": "PO-1001",
"items": [
{ "description": "Website design", "quantity": 1, "unit_price": 1500000 },
{ "description": "Hosting", "quantity": 12, "unit": "months", "unit_price": 25000 }
],
"vat": true
}'{
"object": "invoice",
"id": "cmhx1...",
"livemode": false,
"number": "INV-0001",
"status": "unpaid",
"reference": "PO-1001",
"issue_date": "2026-11-13",
"due_date": "2026-11-20",
"currency": "ZAR",
"subtotal": 1800000,
"vat": 270000,
"total": 2070000,
"amount_due": 2070000,
"public_url": "https://pay.sasio.co.za/d/…",
"pdf_url": "https://pay.sasio.co.za/d/…/pdf",
"whatsapp_url": null
}Then email it to the client with POST /invoices/{id}/send, or share public_url yourself. The client's page shows your payment details and lets them pay, download a PDF, or tell you they've paid.
The same in C# (.NET 6 or later, no extra packages), including recording a payment later:
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
var http = new HttpClient { BaseAddress = new Uri("https://pay.sasio.co.za/api/v1/") };
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("PAYME_API_KEY"));
var request = new HttpRequestMessage(HttpMethod.Post, "invoices")
{
Content = JsonContent.Create(new
{
client = new { name = "Acme Trading", email = "accounts@acme.example", external_id = "CUST-42" },
reference = "PO-1001",
items = new object[]
{
new { description = "Website design", quantity = 1, unit_price = 1500000 },
new { description = "Hosting", quantity = 12, unit = "months", unit_price = 25000 },
},
vat = true,
}),
};
request.Headers.Add("Idempotency-Key", "order-1001"); // safe to retry
var response = await http.SendAsync(request);
var invoice = await response.Content.ReadFromJsonAsync<JsonElement>();
if (!response.IsSuccessStatusCode)
throw new Exception(invoice.GetProperty("error").GetProperty("message").GetString());
var invoiceId = invoice.GetProperty("id").GetString();
Console.WriteLine($"{invoice.GetProperty("number")}: {invoice.GetProperty("public_url")}");
// later, when the money is in your bank:
var paid = await http.PostAsJsonAsync($"invoices/{invoiceId}/payments",
new { amount = 1000000, paid_on = DateTime.Today.ToString("yyyy-MM-dd"), method = "eft", note = "FNB ref 8812" });
paid.EnsureSuccessStatusCode();Keys and test mode
Send your key in the Authorization header on every request: Bearer pm_live_… or Bearer pm_test_…. Keep keys on your server; never put one in a website or mobile app. You can revoke a key at any time in Settings.
- Test keys work on a separate test copy of your business. Test quotes and invoices never appear in your real app, reports or numbering, emails are not actually sent, and their links and PDFs are clearly marked TEST. Webhooks still fire, with
"livemode": false. - Live keys work on your real quotes and invoices, exactly as if you'd made them in the app.
- Read only keys can only use
GETendpoints.
Amounts, dates and lists
- Money is in cents, as whole numbers, always in rand (ZAR):
150000is R1 500.00. Prices are excluding VAT; set"vat": trueto add 15% (your VAT number must be in Settings). - Dates are
YYYY-MM-DD, in South African time. Timestamps (likeviewed_at) are ISO 8601 in UTC. - Lists come newest first as
{ "data": [...], "has_more": true }. Get the next page with?starting_after=<last id>;limitis 1 to 100 (default 25). - Retries are safe with an
Idempotency-Keyheader on any POST (your order number works well). Sending the same key and body again within 24 hours returns the first response instead of making a second invoice. - Your ids: give clients an
external_id(your customer number) and documents areference(your order or PO number, printed on the invoice).
Creating invoices and quotes
POST /invoices and POST /quotes take the same fields:
client_id, or aclientobject. Sasio Pay finds the client byexternal_id, then phone number, then email, and creates them if they're new. A client needs an email or a WhatsApp number.items: 1 to 50 lines ofdescription,quantity(up to 3 decimals), optionalunit, andunit_pricein cents.- Optional:
issue_date,due_date(invoices; defaults to your payment terms) orvalid_until(quotes; 14 days),vat,discount({ "type": "percent", "value": 10 }or an amount in cents),deposit_percent,notes,reference.
Invoice numbers come from your Sasio Pay numbering and never repeat. Invoices can't be deleted, only cancelled, so your records stay complete. When a client accepts a quote on its link, Sasio Pay turns it into an invoice straight away (you get quote.accepted and quote.converted).
WhatsApp: messages go from your own phone, so the API doesn't send them. When the client has a phone number, whatsapp_url opens WhatsApp with the message ready to send.
Getting paid
Money never passes through Sasio Pay: clients pay you by EFT, PayShap or your own payment link. When money arrives, record it so the invoice shows what's still due:
curl https://pay.sasio.co.za/api/v1/invoices/{id}/payments \
-H "Authorization: Bearer pm_live_..." \
-H "Content-Type: application/json" \
-d '{ "amount": 1000000, "paid_on": "2026-11-12", "method": "eft", "note": "FNB ref 8812" }'The invoice's status becomes partially_paid or paid. Paying more than is due is refused. Invoice statuses: unpaid, partially_paid, overdue, paid, cancelled, credited. Quote statuses: open, accepted, declined, expired, invoiced.
Webhooks
Add your address in Settings → Developers (https only). Sasio Pay sends a POST with a JSON event; reply with any 2xx within 10 seconds. If it fails, Sasio Pay tries again after 1 minute, 5 minutes, 30 minutes, 2, 6 and 12 hours. The same event can arrive twice, so use its id to ignore repeats.
| Event | When |
|---|---|
| invoice.sent | The invoice was sent (by the API, or from the app) |
| invoice.viewed | The client opened the invoice link for the first time |
| invoice.paid | The invoice is paid in full |
| invoice.partially_paid | A payment was recorded and money is still due |
| invoice.overdue | The due date passed yesterday and money is still due (sent once, in the morning) |
| invoice.cancelled | The invoice was cancelled |
| payment.recorded | A payment was recorded (data.object is the payment) |
| payment_claim.created | The client tapped "I've paid" and attached proof of payment. Check your bank, then record the payment |
| quote.sent | The quote was sent |
| quote.viewed | The client opened the quote link for the first time |
| quote.accepted | The client accepted the quote |
| quote.declined | The client declined the quote |
| quote.converted | The quote became an invoice (data.object is the quote; invoice_id points to the invoice) |
{
"id": "evt_...",
"object": "event",
"type": "invoice.paid",
"created": 1763030400,
"livemode": true,
"data": { "object": { "object": "invoice", "id": "...", "status": "paid", ... } }
}Check the signature so nobody else can fake events. Each request has a PayMe-Signature header like t=1763030400,v1=5f8a…: an HMAC-SHA256 of <t>.<raw body> using your endpoint's signing secret (whsec_…). Compare it, and refuse timestamps older than 5 minutes.
import crypto from "node:crypto";
function verify(rawBody, header, secret) {
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const want = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
return want.length === v1.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(v1));
}import hmac, hashlib, time
def verify(raw_body: bytes, header: str, secret: str) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
if abs(time.time() - int(parts["t"])) > 300:
return False
want = hmac.new(secret.encode(), f"{parts['t']}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(want, parts["v1"])function verify(string $rawBody, string $header, string $secret): bool {
parse_str(str_replace(',', '&', $header), $p);
if (abs(time() - (int) $p['t']) > 300) return false;
$want = hash_hmac('sha256', $p['t'] . '.' . $rawBody, $secret);
return hash_equals($want, $p['v1']);
}using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
app.MapPost("/payme/webhook", async (HttpRequest req, IConfiguration config) =>
{
// read the raw body: parsing and re-encoding the JSON would change it and break the signature
using var reader = new StreamReader(req.Body, Encoding.UTF8);
var rawBody = await reader.ReadToEndAsync();
var header = req.Headers["PayMe-Signature"].ToString();
var secret = config["PayMe:WebhookSecret"]!; // whsec_... from Settings -> Developers
if (!PayMeSignature.Verify(rawBody, header, secret)) return Results.Unauthorized();
using var doc = JsonDocument.Parse(rawBody);
var eventId = doc.RootElement.GetProperty("id").GetString(); // store it to ignore repeats
var type = doc.RootElement.GetProperty("type").GetString();
var obj = doc.RootElement.GetProperty("data").GetProperty("object");
if (type == "invoice.paid")
{
var reference = obj.GetProperty("reference").GetString(); // your order / PO number
// mark the order as paid in your system
}
return Results.Ok();
});
static class PayMeSignature
{
public static bool Verify(string rawBody, string header, string secret, int toleranceSeconds = 300)
{
var parts = header.Split(',')
.Select(p => p.Split('=', 2))
.Where(p => p.Length == 2)
.ToDictionary(p => p[0], p => p[1]);
if (!parts.TryGetValue("t", out var t) || !parts.TryGetValue("v1", out var v1) || !long.TryParse(t, out var ts))
return false;
if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - ts) > toleranceSeconds)
return false;
using var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret));
var want = Convert.ToHexString(hmac.ComputeHash(Encoding.UTF8.GetBytes($"{t}.{rawBody}"))).ToLowerInvariant();
return CryptographicOperations.FixedTimeEquals(Encoding.ASCII.GetBytes(want), Encoding.ASCII.GetBytes(v1));
}
}Use the raw request body exactly as received; parsing and re-encoding the JSON changes it and the signature won't match.
Errors and limits
{
"error": {
"type": "invalid_request_error",
"code": "invalid_parameter",
"message": "Only R5 000 is still due on this invoice.",
"field": "amount"
}
}400bad JSON ·401missing or revoked key ·403read-only key or suspended account ·404not found (or not yours) ·409not allowed right now (e.g. paying a cancelled invoice) ·422a field isn't right;fieldsays which ·429too many requests ·5xxour side: retry with the same Idempotency-Key.- Up to 120 requests a minute per key. When you go over, wait for the number of seconds in the Retry-After header.
- Request bodies up to 1 MB; up to 50 lines per document.
- Emails sent with
/send: up to 200 a day per account (20 a day in an account's first week), and up to 3 a day to the same address. Over that you get429with codeemail_limit_reached; you can always sharepublic_urlyourself. Your ownmessagetext can be used once the account is a week old; until then the standard email goes out.
All endpoints
Full request and response details are in the OpenAPI file (import it into Postman, Insomnia or your code generator).
| GET | /me | The business your key belongs to, and whether it's live or test |
| POST | /clients | Create a client |
| GET | /clients | List clients (filter by email, phone or external_id) |
| GET | /clients/{id} | Get a client |
| PATCH | /clients/{id} | Update a client |
| POST | /invoices | Create an invoice |
| GET | /invoices | List invoices (filter by status, client_id, updated_since) |
| GET | /invoices/{id} | Get an invoice, with payments and amount due |
| POST | /invoices/{id}/send | Email the invoice to the client |
| POST | /invoices/{id}/payments | Record a payment you received |
| POST | /invoices/{id}/cancel | Cancel an invoice (its number is kept) |
| GET | /invoices/{id}/pdf | Download the PDF |
| GET | /payments | List payments (filter by since, invoice_id) |
| POST | /quotes | Create a quote |
| GET | /quotes | List quotes (filter by status, client_id, updated_since) |
| GET | /quotes/{id} | Get a quote |
| POST | /quotes/{id}/send | Email the quote to the client |
| POST | /quotes/{id}/convert | Turn a quote into an invoice (safe to repeat) |
| GET | /quotes/{id}/pdf | Download the PDF |
Coming next
Credit notes, client statements, saved items, monthly invoices and reports through the API, and managing webhooks by API.