Skip to content

Bulk payouts

Pay up to 500 people in one request, checked upfront, with optional approval by a second person.

A batch pays many people in one request: riders at the end of the week, farmers after a harvest, casual staff on payday. Up to 500 payouts per batch. Endpoint details are in the Batches reference.

Sending a batch

curl https://api.autopayke.com/api/v1/batches \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY" \
  -H "Idempotency-Key: riders-week-46" \
  -H "Content-Type: application/json" \
  -d '{
    "reference": "riders-week-46",
    "require_approval": true,
    "payouts": [
      { "amount": 150000, "currency": "KES", "reference": "rider-118",
        "destination": { "type": "mobile_money", "phone": "+254712345678" } },
      { "amount": 200000, "currency": "KES", "reference": "rider-207",
        "destination": { "type": "mobile_money", "phone": "+254722334455" } }
    ]
  }'

Each line has the same shape as a single payout. Use your own id as each line's reference so you can match payouts back to people.

All or nothing upfront

Before any money moves, we check every line (amount, destination, your per-payout limit), the batch total against today's and this month's limits, and your balance against the total with fees. If anything fails, nothing is paid and you get every problem at once:

422 response
{
  "ok": false,
  "code": "VALIDATION_ERROR",
  "error": "2 of 120 payouts can't be sent. Nothing was paid; fix them and send the batch again.",
  "details": {
    "lines": [
      { "index": 14, "code": "VALIDATION_ERROR", "message": "Enter a valid Kenyan mobile number" },
      { "index": 87, "code": "LIMIT_PER_TX_EXCEEDED", "message": "The most one payout can be is KES 150,000." }
    ]
  }
}

Approval by a second person

Every live batch waits as awaiting_approval until a workspace owner or admin approves it in the Console with their PIN. The API key that sent it can't approve it, so a leaked key alone can't pay out a batch. In the sandbox, batches start at once unless you send require_approval: true.

Cancel a batch any time with POST /api/v1/batches/{id}/cancel. Lines not yet sent are cancelled; payouts already created carry on.

Following it

  1. batch.processing when paying starts (straight away, or on approval).
  2. Each line becomes a payout with batch_id and batch_index in its metadata, and sends the usual payout.* webhooks.
  3. batch.completed when every line has a payout or has failed. Check counts, and GET /api/v1/batches/{id}/items for each line.
A line can fail after the batch was accepted, for example when a kill switch pauses payouts mid-way. It shows as failed with a failure_code; send it again in a new batch.

Testing

Fund the sandbox with POST /api/v1/sandbox/faucet, then send a batch with an apk_test_ key. Each line follows the sandbox payout numbers, so you can mix lines that succeed and fail.