Collections
Ask a customer's phone to pay by mobile money, follow the payment, and do it from your code.
A collection asks a customer's phone to pay: Swichi sends a USSD push, and the customer approves
it with their PIN. Send POST /v1/collections with the amount, "currency": "TZS", the payer's
phone, your reference and an Idempotency-Key. The answer comes at once with
status: "pending".
Supported networks
Swichi picks the network from the payer's number; you only send the phone.
| Network | Country |
|---|---|
| Airtel Money | TZ |
| M-Pesa (Vodacom) | TZ |
| Mixx by Yas | TZ |
| HaloPesa (Halotel) | TZ |
The smallest collection is set by Swichi (TZS 500 by default). A smaller amount is refused at
once with amount_too_small; nothing is sent to the phone.
What happens next
| Status | Meaning |
|---|---|
pending | The push was sent; the payer has not answered yet |
succeeded | Swichi confirmed the money with the network; the collection has its fee, net and signed receipt |
failed | The payer declined or had too little; failure.code says why |
expired | Nobody approved it in time |
Swichi tells your server with the collection.succeeded, collection.failed and
collection.expired webhooks. Try each outcome with the
sandbox's magic numbers.
List collections
Lists page with limit and starting_after, newest first:
# The last five collections, newest first.
curl "https://gateway.swichi.cc/v1/collections?limit=5" \
-H "Authorization: Bearer $SWICHI_KEY"Collect a payment in your code
Plain HTTP is enough; there is nothing to install. Use your sandbox key while you build (these
examples read it from SWICHI_KEY) and keep every key on your server.
curl https://gateway.swichi.cc/v1/collections \
-H "Authorization: Bearer $SWICHI_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042" \
-d '{"amount": 25000, "currency": "TZS", "phone": "0754 000 001", "reference": "order-1042"}'Retry a failed request with the same Idempotency-Key: the money moves once
(Idempotency). Errors are on Errors.