Skip to content

Batches (bulk payouts)

Send up to 500 payouts in one request. The whole batch is checked before any money moves, and can wait for a second person to approve it.

Every line is checked first: amount, destination, your per-payout, daily and monthly limits, and your balance against the total with fees. If any line fails, nothing is paid and details.lines says which.

Each line becomes an ordinary payout (po_…) with batch_id and batch_index in its metadata, so it gets the same payout.* webhooks.

Statuses: awaiting_approval, processing, completed, cancelled.

Send your API key as Authorization: Bearer apk_test_… (sandbox) or apk_live_… (live). Each endpoint lists the scope the key needs. See API keys.

Create a batch

POST/api/v1/batches
API keybatches:write Idempotency-Key required

Checks every line, then queues them. With require_approval it waits for a workspace owner or admin to approve it in the Console.

Body (JSON)
  • payoutsarrayrequired

    1 to 500 payouts, each shaped like the body of POST /api/v1/payouts: amount, currency, destination, reference?, description?, metadata?.

  • require_approvalbooleanoptional

    Test keys: wait for approval in the Console before paying (default false). Live batches always wait for approval.

  • referencestringoptional

    Your own id for the batch, up to 64 characters.

  • descriptionstringoptional

    Up to 140 characters.

  • metadataobjectoptional

    Up to 20 string key-value pairs, copied onto every payout.

Request
curl -X POST "https://api.autopayke.com/api/v1/batches" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "reference": "riders-week-46",
    "description": "Rider pay, week 46",
    "payouts": [
      {
        "amount": 150000,
        "currency": "KES",
        "destination": {
          "type": "mobile_money",
          "phone": "+254712345678"
        },
        "reference": "rider-118"
      },
      {
        "amount": 200000,
        "currency": "KES",
        "destination": {
          "type": "mobile_money",
          "phone": "+254722334455"
        },
        "reference": "rider-207"
      },
      {
        "amount": 100000,
        "currency": "KES",
        "destination": {
          "type": "till",
          "till_number": "5123456"
        },
        "reference": "fuel-stage-3"
      }
    ]
  }'
Response201 application/json
{
  "ok": true,
  "data": {
    "id": "bat_6Tn3Qw8Lx2Zp7Vk4Rm9Yd5Hc",
    "object": "batch",
    "livemode": false,
    "status": "processing",
    "reference": "riders-week-46",
    "description": "Rider pay, week 46",
    "metadata": {},
    "item_count": 3,
    "total_amount": 450000,
    "currency": "KES",
    "counts": {
      "queued": 3,
      "created": 0,
      "failed": 0,
      "cancelled": 0
    },
    "approved_at": null,
    "completed_at": null,
    "cancelled_at": null,
    "created": "2026-11-03T09:10:00.000Z",
    "updated": "2026-11-03T09:10:00.000Z"
  }
}

List batches

GET/api/v1/batches
API keybatches:read

Newest first, in the key's environment.

Query parameters
  • limitintegeroptional

    How many to return, 1 to 100. Default 20.

  • starting_afterstringoptional

    Cursor for the next page: the id of the last item you got. Lists are newest first; when has_more is true, pass the last id here.

  • statusstringoptional

    Only batches in this status.

    awaiting_approvalprocessingcompletedcancelled
Request
curl "https://api.autopayke.com/api/v1/batches" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "ok": true,
  "data": {
    "object": "list",
    "data": [
      {
        "id": "bat_6Tn3Qw8Lx2Zp7Vk4Rm9Yd5Hc",
        "object": "batch",
        "livemode": false,
        "status": "processing",
        "reference": "riders-week-46",
        "description": "Rider pay, week 46",
        "metadata": {},
        "item_count": 3,
        "total_amount": 450000,
        "currency": "KES",
        "counts": {
          "queued": 3,
          "created": 0,
          "failed": 0,
          "cancelled": 0
        },
        "approved_at": null,
        "completed_at": null,
        "cancelled_at": null,
        "created": "2026-11-03T09:10:00.000Z",
        "updated": "2026-11-03T09:10:00.000Z"
      }
    ],
    "has_more": false
  }
}

Get a batch

GET/api/v1/batches/{id}
API keybatches:read

One batch with counts of queued, created, failed and cancelled lines.

Path parameters
  • idstringrequired

    The batch id (bat_…).

Request
curl "https://api.autopayke.com/api/v1/batches/bat_6Tn3Qw8Lx2Zp7Vk4Rm9Yd5Hc" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "ok": true,
  "data": {
    "id": "bat_6Tn3Qw8Lx2Zp7Vk4Rm9Yd5Hc",
    "object": "batch",
    "livemode": false,
    "status": "completed",
    "reference": "riders-week-46",
    "description": "Rider pay, week 46",
    "metadata": {},
    "item_count": 3,
    "total_amount": 450000,
    "currency": "KES",
    "counts": {
      "queued": 0,
      "created": 3,
      "failed": 0,
      "cancelled": 0
    },
    "approved_at": null,
    "completed_at": "2026-11-03T09:10:00.000Z",
    "cancelled_at": null,
    "created": "2026-11-03T09:10:00.000Z",
    "updated": "2026-11-03T09:10:00.000Z"
  }
}
Errors

Plus the key and rate errors any keyed call can return.

List a batch's lines

GET/api/v1/batches/{id}/items
API keybatches:read

Lines in the order you sent them, each with its payout id once created. Phone and account numbers are masked.

Path parameters
  • idstringrequired

    The batch id (bat_…).

Query parameters
  • limitintegeroptional

    1 to 100, default 50.

  • offsetintegeroptional

    Lines to skip, default 0.

Request
curl "https://api.autopayke.com/api/v1/batches/bat_6Tn3Qw8Lx2Zp7Vk4Rm9Yd5Hc/items" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "ok": true,
  "data": {
    "object": "list",
    "data": [
      {
        "object": "batch_item",
        "index": 0,
        "status": "created",
        "amount": 150000,
        "destination": {
          "type": "mobile_money",
          "phone": "+2547•••••678",
          "network": "safaricom"
        },
        "reference": "rider-118",
        "payout": "po_8Fq2mZx7Lk3Rt9Vb",
        "failure_code": null,
        "failure_message": null
      }
    ],
    "has_more": true
  }
}
Errors

Plus the key and rate errors any keyed call can return.

Cancel a batch

POST/api/v1/batches/{id}/cancel
API keybatches:write

Stops lines not yet sent. Payouts already created carry on.

Path parameters
  • idstringrequired

    The batch id (bat_…).

Request
curl -X POST "https://api.autopayke.com/api/v1/batches/bat_6Tn3Qw8Lx2Zp7Vk4Rm9Yd5Hc/cancel" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "ok": true,
  "data": {
    "id": "bat_6Tn3Qw8Lx2Zp7Vk4Rm9Yd5Hc",
    "object": "batch",
    "livemode": false,
    "status": "cancelled",
    "reference": "riders-week-46",
    "description": "Rider pay, week 46",
    "metadata": {},
    "item_count": 3,
    "total_amount": 450000,
    "currency": "KES",
    "counts": {
      "queued": 0,
      "created": 0,
      "failed": 0,
      "cancelled": 3
    },
    "approved_at": null,
    "completed_at": null,
    "cancelled_at": "2026-11-03T09:10:00.000Z",
    "created": "2026-11-03T09:10:00.000Z",
    "updated": "2026-11-03T09:10:00.000Z"
  }
}
Errors

Plus the key and rate errors any keyed call can return.