Developers

A batch is the same xlsx template the ekash apps use, uploaded as multipart/form-data. Your finance team can hand the API the very file they would have uploaded by hand.

Text
GET  /v1/batches/templates/bank     # or .../email   — download the template (payments:read)
POST /v1/batches                    # multipart, part name "file"
GET  /v1/batches/{id}               # poll until validation.complete
POST /v1/batches/{id}/submit        # hand over for approval (auto-approving keys also dispatch)
POST /v1/batches/{id}/approve
POST /v1/batches/{id}/reject
DELETE /v1/batches/{id}             # only while unsubmitted
cURL
curl -X POST https://ekash.ai/v1/batches \
  -H "Authorization: Bearer $EKASH_API_KEY" \
  -F "file=@september-payouts.xlsx"

The upload response already contains every parsed row, its payment id and its per-field errors:

JSON
{
  "data": {
    "id": "0f9b…-a41c",
    "rail": "email",
    "status": "draft",
    "row_count": 2,
    "validation": { "complete": false, "validating_count": 1, "error_count": 1 },
    "rows": [
      { "row": 1, "payment_id": "48210", "amount": "500.00", "currency": "USD",
        "status": "ready_to_process", "validation": { "status": "validating" } },
      { "row": 2, "payment_id": "48211", "amount": "250.00", "currency": "USD",
        "status": "ready_to_process",
        "errors": { "recipient.email": "This is not a payable account" },
        "validation": { "status": "invalid", "message": "This is not a payable account" } }
    ]
  }
}

Poll GET /v1/batches/{id} until validation.complete is true. Email-rail recipients are verified against the provider in the background; the apps poll roughly every 2.5 seconds, and so should you.

Each row also carries its fee breakdown (sender_fee, recipient_fee, conversion_fee, fee_currency, total_debited, recipient_gets_is_exact, expected_received, rate, price_locked_at, price_ref; see What a payment costs), and the batch carries total_fees (what you pay on top, over all rows), total_debited (the sum of the rows' total_debited: exactly what approving takes from the wallet) and their fee_currency. A batch whose rows do not share one wallet currency has no totals. Rows with errors have no price yet.

Then submit:

  • 409 validation_in_progress — recipients are still being checked. Keep polling.
  • 422 batch_has_errors — rows still need fixing; fields names them as <payment_id>.<field>.
  • 409 invalid_state — the batch was already submitted, approved or rejected. Read it with GET /v1/batches/{id} to see where it stands.
  • 200 — submitted. If your key auto-approves, the batch is also approved and dispatched.

Approving or rejecting a batch that was already approved or rejected, and deleting one that was already submitted, is also 409 invalid_state.

Batch approval re-checks the price like a single payment does. If any row's price is older than 48 hours or its rate moved by more than 0.5 %, the whole batch is re-priced and, when anything changes, you get 409 price_changed. Its error.fields carry:

  • totals.<CURRENCY>.previous_total_debited and totals.<CURRENCY>.new_total_debited: one pair per wallet currency of the batch (rows debited in different currencies are never added together). The single previous_total_debited / new_total_debited / wallet_currency appear only when every row is debited in one currency;
  • every re-priced row as <payment_id>.<field> (<payment_id>.new_total_debited, <payment_id>.wallet_currency, ...);
  • expected_debits: the figures to confirm, ready to send back, <payment_id>:<new_total_debited>,... (for example 123:1255.00,124:80.50).

Approve again with

Text
POST /v1/batches/{id}/approve?confirm_price_change=true&expected_debits=123:1255.00,124:80.50

expected_debits binds the confirmation to each row. Every row's fresh total is compared with the figure you sent for it, to the cent. A row you did not list must still cost what it costs now. If any row differs (the rate moved again, or a row that was not in the first answer has moved since), nothing is approved and you get 409 price_changed again with the newer figures; two rows moving in opposite directions can never cancel each other out. A malformed value is 422 validation_failed with fields.expected_debits.

The older single expected_debit=<total> still works as a fallback, but it is accepted only for a batch debited in one wallet currency whose rows do not move against each other (a total cannot tell a redistribution from a confirmation); otherwise you get 409 price_changed again. Without either parameter, confirm_price_change=true accepts whatever the fresh prices are, so always send expected_debits.

Submitting can answer 409 price_changed too. If your key auto-approves and the prices moved between the upload and the submit, POST /v1/batches/{id}/submit answers 409 price_changed with the same fields: the batch is submitted but was not approved, nothing was debited, and it stays approvable. Review the figures and call approve as above.

Limits are the ones the apps enforce: 50 rows per bank batch, one platform per email batch (and one target currency for PayPal batches). A file that is not a recognised template is 422 invalid_template.