Docs / API reference
Collections
Take a payment from any source. The customer pays, Pitisha records it and matches it to the sale.
The Collection object
A payment from a customer into one of your wallets. It starts pending and settles to succeeded or failed. Money goes straight into your own till, so a collection is a record of that payment, not funds held by Pitisha.
Attributes
idstringUnique identifier, starting col_.
statusstringWhere the payment is.
One of
pending,succeeded,failed,reversedamountintegerAmount in the smallest unit. 250000 is KES 2,500.00.
currencystringAlways KES.
sourcestringHow the customer paid.
One of
till,paybill,qr,bank,airtelreferencestring | nullYour reference, for example an invoice or account number.
customerobjectWho paid: a phone number for mobile money, or account details for bank transfers.
wallet_idstringThe wallet the payment landed in.
shortcode_idstring | nullThe paybill or till it was paid to.
matchobject | nullHow the payment matched your sales. match.state is matched, pile or no_match. See Matching.
routingobjectWhich gateway took the payment, how many attempts it needed, and whether the smart switch failed over. See Gateways and failover.
failureobject | nullPresent when status is failed: a code and a message.
metadataobjectUp to 20 key-value pairs of your own.
livemodebooleanfalse in the sandbox.
created_atstringISO 8601 timestamp.
Example object
{
"id": "col_8f3k2q",
"object": "collection",
"status": "succeeded",
"amount": 250000,
"currency": "KES",
"source": "paybill",
"reference": "INV-204117",
"description": "Order 1042",
"customer": {
"phone": "+254712000000"
},
"wallet_id": "wal_main",
"shortcode_id": "sc_4012345",
"match": {
"state": "matched",
"sale_id": "sale_1042"
},
"routing": {
"gateway": "daraja",
"attempts": 2,
"failed_over": true
},
"failure": null,
"metadata": {
"order_id": "1042"
},
"livemode": false,
"created_at": "2026-10-28T11:20:04+03:00"
}/v1/collectionsCreate a collection
Ask a customer to pay and record the result.
For till, paybill and QR sources this sends a payment request to the customer's phone. Pitisha routes it through a healthy gateway and, if that gateway fails, moves it to the next one without you retrying. The response is pending until the customer approves; you learn the outcome from the collection.recorded or collection.failed webhook.
Headers
Idempotency-KeystringA unique value per logical request, up to 255 characters. Retrying with the same key returns the original result instead of creating a second one.
Pitisha-Sandbox-ScenariostringSandbox only. Force an outcome: success, insufficient_funds, customer_cancelled or no_response.
Body parameters
amountintegerrequiredAmount in the smallest unit.
currencystringrequiredAlways KES.
One of
KESsourcestringrequiredHow the customer pays.
One of
till,paybill,qr,bank,airtelcustomerobjectrequiredFor mobile money, { phone } in international format.
shortcode_idstringWhich shortcode to collect on. Defaults to your primary one for the source.
referencestringYour reference. Shown to the customer on a paybill.
descriptionstringShown in your portal.
metadataobjectYour own key-value pairs.
Errors
- 400 invalid_request
- 401 authentication_failed
- 422 shortcode_inactive
- 422 wallet_frozen
- 409 idempotency_conflict
- 429 rate_limited
See Errors for what each means.
curl -X POST "$PITISHA_API/v1/collections" \
-H "Authorization: Bearer $PITISHA_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-attempt-1" \
-d '{
"amount": 250000,
"currency": "KES",
"source": "paybill",
"customer": {
"phone": "+254712000000"
},
"reference": "INV-204117",
"description": "Order 1042",
"metadata": {
"order_id": "1042"
}
}'{
"id": "col_8f3k2q",
"object": "collection",
"status": "pending",
"amount": 250000,
"currency": "KES",
"source": "paybill",
"reference": "INV-204117",
"description": "Order 1042",
"customer": {
"phone": "+254712000000"
},
"wallet_id": "wal_main",
"shortcode_id": "sc_4012345",
"match": null,
"routing": {
"gateway": "daraja",
"attempts": 1,
"failed_over": false
},
"failure": null,
"metadata": {
"order_id": "1042"
},
"livemode": false,
"created_at": "2026-10-28T11:20:04+03:00"
}/v1/collections/{id}Retrieve a collection
Fetch one collection by id.
Path parameters
idstringrequiredThe collection id.
Errors
- 404 not_found
- 401 authentication_failed
See Errors for what each means.
curl -X GET "$PITISHA_API/v1/collections/ID_FROM_RESPONSE" \
-H "Authorization: Bearer $PITISHA_SECRET_KEY"{
"id": "col_8f3k2q",
"object": "collection",
"status": "succeeded",
"amount": 250000,
"currency": "KES",
"source": "paybill",
"reference": "INV-204117",
"description": "Order 1042",
"customer": {
"phone": "+254712000000"
},
"wallet_id": "wal_main",
"shortcode_id": "sc_4012345",
"match": {
"state": "matched",
"sale_id": "sale_1042"
},
"routing": {
"gateway": "daraja",
"attempts": 2,
"failed_over": true
},
"failure": null,
"metadata": {
"order_id": "1042"
},
"livemode": false,
"created_at": "2026-10-28T11:20:04+03:00"
}/v1/collectionsList collections
Newest first, with filters.
Query parameters
statusstringFilter by status.
One of
pending,succeeded,failed,reversedsourcestringFilter by source.
One of
till,paybill,qr,bank,airtelmatch_statestringFilter by how it matched.
One of
matched,pile,no_matchwallet_idstringOnly payments into this wallet.
created_gtestringISO 8601. Created on or after.
created_ltestringISO 8601. Created on or before.
limitintegerHow many items to return, from 1 to 100. Defaults to 20.
starting_afterstringA cursor from a previous response's next_cursor. Returns the next page.
Errors
- 401 authentication_failed
- 400 invalid_request
See Errors for what each means.
curl -X GET "$PITISHA_API/v1/collections" \
-H "Authorization: Bearer $PITISHA_SECRET_KEY"{
"object": "list",
"data": [
{
"id": "col_8f3k2q",
"object": "collection",
"status": "succeeded",
"amount": 250000,
"currency": "KES",
"source": "paybill",
"reference": "INV-204117",
"description": "Order 1042",
"customer": {
"phone": "+254712000000"
},
"wallet_id": "wal_main",
"shortcode_id": "sc_4012345",
"match": {
"state": "matched",
"sale_id": "sale_1042"
},
"routing": {
"gateway": "daraja",
"attempts": 2,
"failed_over": true
},
"failure": null,
"metadata": {
"order_id": "1042"
},
"livemode": false,
"created_at": "2026-10-28T11:20:04+03:00"
}
],
"has_more": true,
"next_cursor": "cur_9fK2mQ"
}/v1/collections/{id}/matchResolve a payment in the pile
Choose which sale a pile payment belongs to.
A collection lands in the pile when more than one sale could fit it. Send the sale it belongs to and it becomes matched. A collection with no match can be matched the same way once you find the sale.
Path parameters
idstringrequiredThe collection id.
Headers
Idempotency-KeystringA unique value per logical request, up to 255 characters. Retrying with the same key returns the original result instead of creating a second one.
Body parameters
sale_idstringrequiredThe sale this payment paid for.
Errors
- 404 not_found
- 400 invalid_request
- 409 idempotency_conflict
See Errors for what each means.
curl -X POST "$PITISHA_API/v1/collections/ID_FROM_RESPONSE/match" \
-H "Authorization: Bearer $PITISHA_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-attempt-1" \
-d '{
"sale_id": "sale_1042"
}'{
"id": "col_8f3k2q",
"object": "collection",
"status": "succeeded",
"amount": 250000,
"currency": "KES",
"source": "paybill",
"reference": "INV-204117",
"description": "Order 1042",
"customer": {
"phone": "+254712000000"
},
"wallet_id": "wal_main",
"shortcode_id": "sc_4012345",
"match": {
"state": "matched",
"sale_id": "sale_1042"
},
"routing": {
"gateway": "daraja",
"attempts": 2,
"failed_over": true
},
"failure": null,
"metadata": {
"order_id": "1042"
},
"livemode": false,
"created_at": "2026-10-28T11:20:04+03:00"
}