Quickstart

Collect money by mobile money, pay out and move money with Swichi Payments, from your first sandbox request.

Swichi Payments is Swichi's payments API: ask a customer's phone to pay (a USSD push), pay out to mobile money and banks, move money to another Swichi business, and make hosted checkout links. Customers see Swichi; the API never names a mobile money provider.

Every request goes to https://gateway.swichi.cc/v1 with Authorization: Bearer $SWICHI_KEY. Amounts are whole Tanzanian shillings ("currency": "TZS").

Your first payment

Open Swichi Gateway → Developers → API keys in your Swichi dashboard. Your sandbox is already there, with test money: press Get my sandbox key (API keys). Set it in your shell:

export SWICHI_KEY=YOUR_SANDBOX_KEY   # a sandbox key: test money only

1. See your test money.

# Your sandbox wallet: it starts with test money.
curl https://gateway.swichi.cc/v1/balance \
  -H "Authorization: Bearer $SWICHI_KEY"

2. Ask a phone to pay. Every request that moves money needs an Idempotency-Key: send the same key again when you retry, and the money moves once. The answer comes at once with status: "pending".

# Ask a phone to pay: a USSD push. Numbers ending in 005 wait for you to decide. save: COLLECTION_ID=id
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 005", "reference": "order-1042", "description": "Two kitenge dresses"}'

3. The payer approves. In the sandbox you decide what the payer does. With a real phone, this is the customer entering their PIN.

# Sandbox only: the payer approves on their phone.
curl https://gateway.swichi.cc/v1/sandbox/collections/$COLLECTION_ID/simulate \
  -H "Authorization: Bearer $SWICHI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"outcome": "succeeded"}'

4. Read it back. A collection is succeeded only once Swichi has confirmed the money with the network. It shows the fee, what reached your wallet (net) and the signed Swichi receipt.

# The collection is succeeded, with its fee, what reached you and its receipt.
curl https://gateway.swichi.cc/v1/collections/$COLLECTION_ID \
  -H "Authorization: Bearer $SWICHI_KEY"

In production you don't poll: add a webhook and Swichi tells your server when a payment succeeds or fails. Then go live.

In this section

On this page