Quote, book and track deliveries from your own system. Start in the sandbox in minutes: no approval needed, nothing is collected or charged.
cfx_test_ and is shown once.curl https://charlesfreightx.co.za/api/v1/ping \
-H "Authorization: Bearer $CFX_KEY"
{"ok": true, "mode": "test", "business": "Acme Online", "time": "2026-11-13T09:15:40+02:00"}
| Base address | https://charlesfreightx.co.za/api/v1 |
|---|---|
| Authentication | Authorization: Bearer <your key> on every request. HTTPS only. |
| Format | JSON in, JSON out. Send Content-Type: application/json with a body. |
| Money | South African rand, as numbers with two decimals at most (70, 52.5). |
| Addresses | Send full addresses as text, house number first ("12 Main Road, Dawn Park, Boksburg"). CFX works out the road distance itself; any distance you send is ignored. |
| Duplicates | Send an Idempotency-Key header (up to 100 characters) or an external_ref when placing orders. Repeating the same request returns the first order instead of making a second one (keys are kept for 24 hours). |
| Rate limit | 120 requests a minute per key. Above that you get 429 with Retry-After: 60. |
| Request id | Every response has an X-Request-Id header. Quote it when you contact us. |
Sandbox keys (cfx_test_…) use the same address and the same requests as live keys. Quotes are priced exactly like live, and orders are checked the same way, but sandbox orders are pretend: no driver, no balance used, no e-mails to anyone. They get references like TEST-000001 and carry "sandbox": true.
A sandbox order stays where it is until you move it on, so you can test each webhook:
curl -X POST https://charlesfreightx.co.za/api/v1/test/orders/TEST-000001/advance \
-H "Authorization: Bearer $CFX_TEST_KEY"
Each call moves it one step: confirmed → ready_for_collection → out_for_delivery → completed. To test a failed delivery send {"to":"delivery_failed"}. Each step sends the normal order.status_changed webhook, with "test": true.
POST /test/webhook sends a signed webhook.test message to your webhook address. Live keys cannot use /test, sandbox keys never see live orders, and live keys never see sandbox orders.
POST/quote
Prices a delivery without booking it. Use it at your checkout.
curl -X POST https://charlesfreightx.co.za/api/v1/quote \
-H "Authorization: Bearer $CFX_KEY" -H "Content-Type: application/json" \
-d '{
"pickup": "1 Pickup St, Boksburg",
"dropoff": "2 Drop Rd, Kempton Park",
"packages": [{"size": "small", "qty": 1, "weight_kg": 2}],
"items": [{"desc": "Kettle", "value": 450}],
"prohibited_ok": true
}'
{
"total": 70,
"lines": [{"label": "Fare", "amount": 67.2}, {"label": "Booking fee", "amount": 2.8}],
"chargeable_km": 15,
"total_weight_kg": 2,
"requires_quote": false,
"adjustments": [],
"delivery_service": "STANDARD",
"handling_service": "STANDARD_HANDLING",
"plan": "growth"
}
| Field | What to send |
|---|---|
pickup, dropoff | Required. Full addresses with the house or building number. |
packages | The physical parcels: size (small, medium, large, xlarge), qty, and if you have them weight_kg, length_cm, width_cm, height_cm. A heavy parcel is moved up a size automatically and listed in adjustments. One parcel can weigh up to 180 kg. |
total_weight_kg | Optional if every package has a weight. |
items | Required. What is inside: desc and declared value in rand per line. No single item may be worth more than R65,000. |
prohibited_ok | Required, true: you confirm nothing is on the prohibited goods list. |
delivery_date, delivery_window | Optional. A date (2026-11-30) and a window code (morning or afternoon). |
If requires_quote is true, the delivery is outside what can be booked online (for example a very large load); contact us for a quote.
POST/orders
The same fields as a quote, plus who receives it. The order is paid from your prepaid CFX balance; if the balance is too low you get 402 insufficient_balance and nothing is booked.
curl -X POST https://charlesfreightx.co.za/api/v1/orders \
-H "Authorization: Bearer $CFX_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: order-1001" \
-d '{
"pickup": "1 Pickup St, Boksburg",
"dropoff": "2 Drop Rd, Kempton Park",
"recipient": "Thandi Mokoena",
"recipient_phone": "+27821234567",
"recipient_email": "thandi@example.com",
"packages": [{"size": "small", "qty": 1, "weight_kg": 2}],
"items": [{"desc": "Kettle", "value": 450}],
"prohibited_ok": true,
"external_ref": "SHOP-1001"
}'
201 Created (or 200 when it is a repeat of an earlier request):
{
"ref": "CFX-100245",
"external_ref": "SHOP-1001",
"status": "confirmed",
"created_at": "2026-11-13T09:15:40+02:00",
"pickup": "1 Pickup St, Boksburg",
"dropoff": "2 Drop Rd, Kempton Park",
"recipient": "Thandi Mokoena",
"packages": 1,
"total": 70,
"pricing": {"total": 70, "lines": [{"label": "Fare", "amount": 67.2}, {"label": "Booking fee", "amount": 2.8}]},
"waybill": "CFX-AB23CDE",
"tracking_token": "q8w2…",
"payment": {"status": "paid", "amount_paid": 70}
}
| Extra field | What to send |
|---|---|
recipient | Required. The person receiving the delivery. |
recipient_phone, recipient_email | Strongly advised. The recipient gets the tracking link by e-mail, and the driver can call them. |
external_ref | Your own order number. Shown on the waybill and in every webhook. |
collection_date | Optional. When the parcels are ready (2026-11-14). |
order_kind | delivery (default) or return (collect from your customer, deliver to you). |
The tracking_token opens your customer's tracking page: https://charlesfreightx.co.za/ops/track/?t=<token>.
GET/orders/{ref}
One order, in the same shape as above.
GET/orders?status=&limit=&before=
Your orders, newest first: {"orders": [ … ]}. limit up to 100 (default 25); before is a date-time for paging.
| Status | Meaning |
|---|---|
awaiting_payment | Waiting for payment (orders paid outside your balance). |
confirmed | Booked and paid. Waiting for the parcels to be ready. |
ready_for_collection | Ready; a driver will collect. |
out_for_delivery | Collected and on the way. |
partly_delivered | Some parcels of a multi-parcel order are delivered. |
delivery_failed | The delivery could not be completed (for example nobody home). You can ask for a rebooking. |
completed | Delivered, with PIN, signature and photo. |
cancelled | Cancelled before collection. |
POST/orders/{ref}/ready
Tell us the parcels are packed and ready for collection.
POST/orders/{ref}/cancel
Cancel before collection. Body (optional): {"reason": "Customer changed their mind"}. After collection you get 409 conflict.
GET/orders/{ref}/waybill
The data for the waybill label (reference, barcode values, recipient and parcels), for printing on your own labels.
POST/deliveries/{ref}/rebook
Ask for a failed delivery to be tried again. Body (optional): {"reason": "…"}. A new delivery fee applies.
GET/manifest?date=2026-11-14
Everything to be collected from you on that day: hand it to your packing team.
GET/invoices?from=2026-11-01&to=2026-11-30
Your paid invoices in that period.
Set an https address in the business portal under Webhooks. CFX sends a POST each time an order changes status. You get a signing secret once; keep it on your server.
POST /your-webhook-address
Content-Type: application/json
X-CFX-Event-Id: 1287
X-CFX-Event-Type: order.status_changed
X-CFX-Signature: t=1763018140,v1=5f2b…
{
"id": 1287,
"type": "order.status_changed",
"created_at": "2026-11-13T09:15:40+02:00",
"data": {
"ref": "CFX-100245",
"external_ref": "SHOP-1001",
"status": "out_for_delivery",
"previous_status": "ready_for_collection",
"waybill": "CFX-AB23CDE",
"tracking_token": "q8w2…"
}
}
Events: order.status_changed and webhook.test. Messages hold references and statuses only: no prices and no customer details.
Compute HMAC-SHA256 of t + "." + raw body with your signing secret, as hex, and compare it with v1. Reject messages where t is more than 5 minutes old.
// Node.js (Express: use express.raw() so you get the exact bytes)
const crypto = require('crypto');
function cfxVerify(rawBody, header, secret) {
const p = Object.fromEntries(header.split(',').map(x => x.split('=')));
if (Math.abs(Date.now() / 1000 - Number(p.t)) > 300) return false;
const expect = crypto.createHmac('sha256', secret).update(p.t + '.' + rawBody).digest('hex');
return crypto.timingSafeEqual(Buffer.from(expect), Buffer.from(p.v1 || ''));
}
<?php // PHP
function cfx_verify($raw, $header, $secret) {
parse_str(str_replace(',', '&', $header), $p);
if (abs(time() - (int)$p['t']) > 300) return false;
return hash_equals(hash_hmac('sha256', $p['t'] . '.' . $raw, $secret), $p['v1'] ?? '');
}
# Python
import hmac, hashlib, time
def cfx_verify(raw: bytes, header: str, secret: str) -> bool:
p = dict(x.split('=', 1) for x in header.split(','))
if abs(time.time() - int(p['t'])) > 300: return False
expect = hmac.new(secret.encode(), p['t'].encode() + b'.' + raw, hashlib.sha256).hexdigest()
return hmac.compare_digest(expect, p.get('v1', ''))
Reply with any 2xx within 10 seconds, then do your work. If we get no 2xx we try again after 2, 4, 8, 16 and 32 minutes, six tries in all. Use X-CFX-Event-Id to ignore a message you already handled. You can see every attempt under Webhooks in the portal, and send yourself a test with Send test webhook.
Errors always look like this, with a message you can show to a person:
{"error": {"code": "invalid_request", "message": "We cannot deliver a single item worth more than R65,000. This one is declared at R70000"}}
| HTTP | code | What to do |
|---|---|---|
| 400 | bad_json, bad_date, bad_status, bad_limit, bad_before | Fix the request. |
| 401 | invalid_api_key | Check the key and the Bearer header. A sandbox key only works in the sandbox. |
| 402 | insufficient_balance | Top up your CFX balance, then send the order again. |
| 403 | sandbox_only | The /test requests need a sandbox key. |
| 404 | not_found, no_such_endpoint | Check the reference or the address. |
| 409 | idempotency_conflict, conflict | The key was used for a different order, or the order can no longer change. |
| 413 | too_large | Keep requests under 100 KB. |
| 422 | invalid_request, address_not_found, not_in_sandbox | Show the message to the person; they can fix it. |
| 429 | rate_limited | Wait 60 seconds. |
| 5xx | server_error, upstream_unavailable, distance_unavailable | Try again shortly with the same Idempotency-Key: you will never get a duplicate. |
Products are sized from the weight Shopify sends. To give exact parcels, add an order note attribute cfx_packages holding a JSON list like [{"size":"medium","qty":1,"weight_kg":4}].
POST /quote and show the total as the delivery price.POST /orders with your order number as external_ref and an Idempotency-Key.ref and tracking_token. E-mail or show your customer the tracking link if you like (we e-mail it too).POST /orders/{ref}/ready.GET /orders?before=….Idempotency-Key or external_ref with every order.Questions: integrations@charlesfreightx.co.za, or WhatsApp +27 73 020 6951. Please include the X-Request-Id.