{
  "info": {
    "name": "ekash API (v1)",
    "description": "Send payments from your ekash wallets — single or batch — and track them to settlement.\n\n**Set up once:** open the collection Variables tab and fill in `base_url` and `api_key`.\n\n- Sandbox `base_url`: `https://stage.ekash.ai/dev` (keys begin `ek_test_`)\n- Production `base_url`: `https://ekash.ai` (keys begin `ek_live_`)\n\nEvery request inherits the collection-level bearer auth, so you do not set an Authorization header per request.\n\nThe create-payment request generates a fresh `Idempotency-Key` in a pre-request script and stores it in `last_idempotency_key`, so the \"Create a payment (REPLAY)\" request can demonstrate replay with the same key. Requests that return an id (payment, batch, recipient) save it to a collection variable for the follow-up requests. The quote request also saves `quote_ref` (pass it on the next create within its validity) and `expected_debit` (the total you were shown, to pass when you approve).\n\nSee README.md beside this file for the full documentation.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{api_key}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://stage.ekash.ai/dev",
      "type": "string"
    },
    {
      "key": "api_key",
      "value": "ek_test_replace_me",
      "type": "string"
    },
    {
      "key": "payment_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "batch_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "recipient_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "last_idempotency_key",
      "value": "",
      "type": "string"
    },
    {
      "key": "quote_ref",
      "value": "",
      "type": "string"
    },
    {
      "key": "expected_debit",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhook_secret",
      "value": "",
      "type": "string"
    },
    {
      "key": "webhook_endpoint_id",
      "value": ""
    },
    {
      "key": "webhook_delivery_id",
      "value": ""
    },
    {
      "key": "received_timestamp",
      "value": ""
    },
    {
      "key": "received_body",
      "value": ""
    },
    {
      "key": "received_signature",
      "value": ""
    },
    {
      "key": "expected_debits",
      "value": "",
      "type": "string"
    }
  ],
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// Applies to every request in the collection.",
          "pm.test('carries an X-Request-Id', function () {",
          "    pm.expect(pm.response.headers.has('X-Request-Id')).to.be.true;",
          "});",
          "",
          "// A failure always uses the documented error envelope and a real HTTP status.",
          "if (pm.response.code >= 400) {",
          "    pm.test('failure uses the ekash error envelope', function () {",
          "        const body = pm.response.json();",
          "        pm.expect(body).to.have.property('error');",
          "        pm.expect(body.error).to.have.property('code');",
          "        pm.expect(body.error).to.have.property('type');",
          "    });",
          "    console.log('ekash error:', pm.response.code, pm.response.json().error.code,",
          "                'request_id=', pm.response.json().error.request_id);",
          "}"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Payments",
      "item": [
        {
          "name": "Create a payment (bank)",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// An Idempotency-Key is REQUIRED on every create. Reuse the SAME value when you retry a",
                  "// request that timed out — that is what makes a network failure safe on a payouts API.",
                  "const key = 'pm-' + Date.now() + '-' + Math.random().toString(36).slice(2, 10);",
                  "pm.collectionVariables.set('last_idempotency_key', key);",
                  "pm.request.headers.upsert({ key: 'Idempotency-Key', value: key });"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "    const payment = pm.response.json().data;",
                  "    pm.collectionVariables.set('payment_id', payment.id);",
                  "    pm.test('money is a 2-decimal string', function () {",
                  "        pm.expect(payment.amount).to.match(/^\\d+\\.\\d{2}$/);",
                  "    });",
                  "    pm.test('status is one of the eight public statuses', function () {",
                  "        pm.expect(['ready_to_process','processing','sent','received','refunded','canceled','unclaimed','on_hold'])",
                  "          .to.include(payment.status);",
                  "    });",
                  "    if (payment.expected_received !== undefined) {   // payments priced by the v2 engine",
                  "        pm.test('the fee breakdown is in one currency', function () {",
                  "            pm.expect(payment.fee_currency).to.be.a('string');",
                  "            pm.expect(payment.expected_received).to.match(/^\\d+\\.\\d{2}$/);",
                  "        });",
                  "    }",
                  "} else if (pm.response.code === 422) {",
                  "    console.log('fix these fields:', JSON.stringify(pm.response.json().error.fields));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"rail\": \"bank\",\n  \"amount\": \"1250.00\",\n  \"currency\": \"USD\",\n  \"source_currency\": \"USD\",\n  \"target_currency\": \"GBP\",\n  \"fee_bearer\": \"sender\",\n  \"reference\": \"INV-2026-0417\",\n  \"quote_ref\": \"{{quote_ref}}\",\n  \"recipient\": {\n    \"name\": \"Jane Contractor\",\n    \"country_code\": \"GB\",\n    \"sort_code\": \"231470\",\n    \"account_number\": \"28821822\",\n    \"receiver_type\": \"PRIVATE\",\n    \"address_line1\": \"1 Example Street\",\n    \"address_city\": \"London\",\n    \"address_postal_code\": \"EC1A 1BB\"\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/payments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments"
              ]
            },
            "description": "Creates one payment. If your key auto-approves and holds `payments:approve`, it is also dispatched in this request; otherwise it waits in the approval queue as `ready_to_process`.\n\nWhich bank fields are required depends on the destination — see **Reference → Bank requirements**, or just read the `fields` map of a 422.\n\n`quote_ref` is optional: the value returned by **Price a payment (quote)**. Sent within its validity (`quote_valid_until`, 15 minutes by default) with exactly the same inputs, the payment is priced at the rates you were quoted; otherwise it is simply priced at the current rates. Leave it empty to price at the current rates.\n\nThe payment carries the fee breakdown: `sender_fee` (what you pay on top), `recipient_fee` (taken off what the recipient receives), `conversion_fee`, all in `fee_currency`; `expected_received` and `recipient_gets_is_exact`; the locked `rate`, `price_locked_at` and `price_ref`."
          }
        },
        {
          "name": "Create a payment (email / wallet rail)",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.request.headers.upsert({",
                  "    key: 'Idempotency-Key',",
                  "    value: 'pm-mail-' + Date.now() + '-' + Math.random().toString(36).slice(2, 10)",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"rail\": \"email\",\n  \"amount\": \"500.00\",\n  \"currency\": \"USD\",\n  \"source_currency\": \"USD\",\n  \"target_currency\": \"USD\",\n  \"fee_bearer\": \"sender\",\n  \"reference\": \"Contractor September\",\n  \"recipient\": {\n    \"name\": \"Sam Payee\",\n    \"email\": \"sam@example.com\",\n    \"platform\": \"wise wallet\"\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/payments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments"
              ]
            },
            "description": "A wallet payout keyed by the recipient's identifier. `platform` is one of `wise wallet`, `payoneer wallet`, `paypal wallet`, `e-kash wallet`.\n\nThe recipient is verified with the provider in the background, so the payment may come back with `validation.status = \"validating\"`. Poll `GET /v1/payments/{id}` until it settles; only a `valid` recipient can be approved."
          }
        },
        {
          "name": "Create a payment (REPLAY — same Idempotency-Key)",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// Deliberately reuses the key from the first create, which is what a retry does.",
                  "pm.request.headers.upsert({",
                  "    key: 'Idempotency-Key',",
                  "    value: pm.collectionVariables.get('last_idempotency_key')",
                  "});"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('a replay returns the ORIGINAL payment, not a second one', function () {",
                  "    pm.response.to.have.status(200);",
                  "    pm.expect(pm.response.headers.get('Idempotent-Replayed')).to.eql('true');",
                  "    pm.expect(pm.response.json().data.id).to.eql(pm.collectionVariables.get('payment_id'));",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"rail\": \"bank\",\n  \"amount\": \"1250.00\",\n  \"currency\": \"USD\",\n  \"source_currency\": \"USD\",\n  \"target_currency\": \"GBP\",\n  \"fee_bearer\": \"sender\",\n  \"reference\": \"INV-2026-0417\",\n  \"recipient\": {\n    \"name\": \"Jane Contractor\",\n    \"country_code\": \"GB\",\n    \"sort_code\": \"231470\",\n    \"account_number\": \"28821822\",\n    \"receiver_type\": \"PRIVATE\",\n    \"address_line1\": \"1 Example Street\",\n    \"address_city\": \"London\",\n    \"address_postal_code\": \"EC1A 1BB\"\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/payments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments"
              ]
            },
            "description": "Run this straight after the first create. Same key, same body → HTTP 200, header `Idempotent-Replayed: true`, and the ORIGINAL payment. Nobody is paid twice.\n\nChange any field in the body and rerun to see `409 idempotency_key_reused` instead."
          }
        },
        {
          "name": "Price a payment (quote)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"rail\": \"bank\",\n  \"amount\": \"1250.00\",\n  \"currency\": \"USD\",\n  \"source_currency\": \"USD\",\n  \"target_currency\": \"GBP\",\n  \"fee_bearer\": \"sender\",\n  \"recipient\": {\n    \"name\": \"Jane Contractor\",\n    \"country_code\": \"GB\",\n    \"sort_code\": \"231470\",\n    \"account_number\": \"28821822\",\n    \"address_line1\": \"1 Example Street\",\n    \"address_city\": \"London\",\n    \"address_postal_code\": \"EC1A 1BB\"\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/payments/quote",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "quote"
              ]
            },
            "description": "Dry run — creates nothing and moves no money.\n\nIf `recipient_gets_is_exact` is `false`, the payout provider prices the final amount at dispatch; show it as an estimate.\n\nThe quote shows who pays what: `sender_fee` (you pay it on top), `recipient_fee` (taken off what the recipient receives) and `conversion_fee` (your share is inside `fees` and `you_pay`, the rest comes off the payout), all in `fee_currency`; plus `expected_received`, the locked `rate`, `price_locked_at` and `price_ref`.\n\n`quote_ref` (valid until `quote_valid_until`) can be sent on the create so the payment is priced at exactly these rates. This request saves it, and `you_pay` as `expected_debit`."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "    const quote = pm.response.json().data;",
                  "    // Pass quote_ref on the next create (same inputs, within quote_valid_until) to be priced at these rates,",
                  "    // and expected_debit when you approve, to be sure you approve the total you were shown.",
                  "    pm.collectionVariables.set('quote_ref', quote.quote_ref || '');",
                  "    pm.collectionVariables.set('expected_debit', quote.you_pay);",
                  "    pm.test('the fee breakdown adds up', function () {",
                  "        pm.expect(quote.fee_currency).to.be.a('string');",
                  "        pm.expect(quote.recipient_gets).to.eql(quote.expected_received);",
                  "    });",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "List payments",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/payments?limit=25",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "25"
                },
                {
                  "key": "status",
                  "value": "sent",
                  "disabled": true
                },
                {
                  "key": "direction",
                  "value": "out",
                  "disabled": true
                },
                {
                  "key": "rail",
                  "value": "bank",
                  "disabled": true
                },
                {
                  "key": "currency",
                  "value": "USD",
                  "disabled": true
                },
                {
                  "key": "from",
                  "value": "2026-09-01",
                  "disabled": true
                },
                {
                  "key": "to",
                  "value": "2026-09-30",
                  "disabled": true
                },
                {
                  "key": "batch_id",
                  "value": "{{batch_id}}",
                  "disabled": true
                },
                {
                  "key": "reference",
                  "value": "INV-2026-0417",
                  "disabled": true
                },
                {
                  "key": "cursor",
                  "value": "",
                  "disabled": true
                }
              ]
            },
            "description": "Newest first. Pass `next_cursor` back as `?cursor=` for the next page; `limit` is 1–100.\n\nBatch members are listed individually and carry their `batch_id`, so a reconciliation sees each payment exactly once."
          }
        },
        {
          "name": "Get a payment",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/payments/{{payment_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "{{payment_id}}"
              ]
            },
            "description": "A payment id that is not your company's returns 404 — never 403, which would confirm the id exists."
          }
        },
        {
          "name": "Approve a payment",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{base_url}}/v1/payments/{{payment_id}}/approve",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "{{payment_id}}",
                "approve"
              ],
              "query": [
                {
                  "key": "confirm_price_change",
                  "value": "true",
                  "disabled": true,
                  "description": "Set after a 409 price_changed, to accept the new price it showed."
                },
                {
                  "key": "expected_debit",
                  "value": "{{expected_debit}}",
                  "disabled": true,
                  "description": "The total debited you were shown (the quote's you_pay, or new_total_debited of the 409 body). If the payment would now debit another amount, you get 409 price_changed again instead of an approval."
                }
              ]
            },
            "description": "Needed only when your key does NOT auto-approve. Approving something already approved or rejected is 409 `invalid_state`.\n\n**Price changed (409 `price_changed`).** A payment is priced when it is created. If its price is older than 48 hours, or the exchange rate moved by more than 0.5 %, approving re-prices it first; when the total debited would change nothing is approved and you get `409 price_changed` with the new figures in `error.fields` (`previous_total_debited`, `new_total_debited`, `new_fees`, `new_sender_fee`, `new_recipient_fee`, `new_conversion_fee`, `new_expected_received`, `fee_currency`, `rate`, `reason`). Approve again with `confirm_price_change=true` and `expected_debit` set to the `new_total_debited` you were shown: if the price moved again meanwhile you get `409 price_changed` again with the newer figures, never a surprise debit. `confirm_price_change=true` without `expected_debit` accepts whatever the fresh price is."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 409 && pm.response.json().error.code === 'price_changed') {",
                  "    const f = pm.response.json().error.fields;",
                  "    console.log('The price changed: was', f.previous_total_debited, 'now', f.new_total_debited, f.wallet_currency);",
                  "    // Show these numbers to whoever approves; then send the request again with the two parameters enabled.",
                  "    pm.collectionVariables.set('expected_debit', f.new_total_debited);",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Approve a payment (confirm a price change)",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{base_url}}/v1/payments/{{payment_id}}/approve?confirm_price_change=true&expected_debit={{expected_debit}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "{{payment_id}}",
                "approve"
              ],
              "query": [
                {
                  "key": "confirm_price_change",
                  "value": "true"
                },
                {
                  "key": "expected_debit",
                  "value": "{{expected_debit}}"
                }
              ]
            },
            "description": "Use after **Approve a payment** answered `409 price_changed`. `expected_debit` is the `new_total_debited` it showed (saved by the test script). If the price moved again, this answers `409 price_changed` once more with the newer figures."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 409 && pm.response.json().error.code === 'price_changed') {",
                  "    const f = pm.response.json().error.fields;",
                  "    console.log('The price changed: was', f.previous_total_debited, 'now', f.new_total_debited, f.wallet_currency);",
                  "    // Show these numbers to whoever approves; then send the request again with the two parameters enabled.",
                  "    pm.collectionVariables.set('expected_debit', f.new_total_debited);",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Reject a payment",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{base_url}}/v1/payments/{{payment_id}}/reject",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "{{payment_id}}",
                "reject"
              ]
            },
            "description": "Cancels a prepared payment. Already approved → 409."
          }
        },
        {
          "name": "Download the remittance advice (PDF)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/payments/{{payment_id}}/remittance",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "{{payment_id}}",
                "remittance"
              ]
            },
            "description": "Returns `application/pdf`. Available once the payout has been successfully dispatched to the provider (`remittance_available: true` on the payment). 409 `remittance_not_available` before that."
          }
        }
      ]
    },
    {
      "name": "Batches",
      "item": [
        {
          "name": "Download the bank template",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/batches/templates/bank",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "batches",
                "templates",
                "bank"
              ]
            },
            "description": "The xlsx to fill in. Use `email` instead of `bank` for the wallet-payout template.\n\nIn Postman, use **Send and Download** to save the file."
          }
        },
        {
          "name": "Upload a batch",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "    const batch = pm.response.json().data;",
                  "    pm.collectionVariables.set('batch_id', batch.id);",
                  "    console.log('rows:', batch.row_count,",
                  "                'validating:', batch.validation.validating_count,",
                  "                'errors:', batch.validation.error_count);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": [],
                  "description": "The filled xlsx template"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/v1/batches",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "batches"
              ]
            },
            "description": "Pick your filled template in the **Body → form-data** `file` row.\n\nThe response already lists every parsed row with its payment id and per-field errors. Email-rail recipients are then verified in the background — poll **Get a batch** until `validation.complete` is true.\n\n50 rows max per bank batch; one platform per email batch."
          }
        },
        {
          "name": "Get a batch (poll until validation.complete)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const batch = pm.response.json().data;",
                  "console.log('complete:', batch.validation.complete,",
                  "            'validating:', batch.validation.validating_count,",
                  "            'errors:', batch.validation.error_count);",
                  "pm.test('safe to submit', function () {",
                  "    pm.expect(batch.validation.complete, 'still validating — poll again').to.be.true;",
                  "    pm.expect(batch.validation.error_count, 'rows still need fixing').to.eql(0);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/batches/{{batch_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "batches",
                "{{batch_id}}"
              ]
            },
            "description": "Poll roughly every 2.5 s, as the ekash apps do, until `validation.complete` is true.\n\nEach row carries its fee breakdown (`sender_fee`, `recipient_fee`, `conversion_fee`, `fee_currency`, `total_debited`, `expected_received`, `rate`) and the batch carries `total_fees` and `total_debited`, the sum of the rows' `total_debited`: exactly what approving takes from the wallet."
          }
        },
        {
          "name": "Submit a batch",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{base_url}}/v1/batches/{{batch_id}}/submit",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "batches",
                "{{batch_id}}",
                "submit"
              ]
            },
            "description": "409 `validation_in_progress` → keep polling. 422 `batch_has_errors` → `fields` names them as `<payment_id>.<field>`.\n\nIf your key auto-approves, submitting also approves and dispatches the batch.\n\nIf the prices moved since the upload and the key auto-approves, the answer can be `409 price_changed`: the batch IS submitted but was not approved. Review the figures and call **Approve a batch** with `confirm_price_change=true&expected_debits=...`."
          }
        },
        {
          "name": "Approve a batch",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{base_url}}/v1/batches/{{batch_id}}/approve",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "batches",
                "{{batch_id}}",
                "approve"
              ],
              "query": [
                {
                  "key": "confirm_price_change",
                  "value": "true",
                  "disabled": true,
                  "description": "Set after a 409 price_changed, to accept the new batch price it showed."
                },
                {
                  "key": "expected_debit",
                  "value": "",
                  "disabled": true,
                  "description": "Older single-number form: the batch total_debited you were shown. Only accepted for a batch debited in one wallet currency whose rows do not move against each other. Prefer expected_debits."
                },
                {
                  "key": "expected_debits",
                  "value": "{{expected_debits}}",
                  "disabled": true,
                  "description": "Recommended. The expected_debits string of the 409 price_changed body: <payment_id>:<new_total_debited>,... (for example 123:1255.00,124:80.50). Every row is compared with its own figure, so rows moving in opposite directions cannot cancel out."
                }
              ]
            },
            "description": "Approves and dispatches a submitted batch. 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 the total changes, you get `409 price_changed` (totals per wallet currency as `totals.<CUR>.new_total_debited`, each row as `<payment_id>.<field>`, and `expected_debits`). Approve again with `confirm_price_change=true` and `expected_debits` = the `expected_debits` you were shown (one figure per row). If any row, listed or not, would now cost another amount, nothing is approved and you get `409 price_changed` again. `expected_debit` (one total) still works as a fallback for a batch debited in a single wallet currency; without either, `confirm_price_change=true` accepts whatever the fresh prices are. If your key auto-approves, `POST .../submit` can answer the same 409: the batch is then submitted but not approved; approve it as described here."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 409 && pm.response.json().error.code === 'price_changed') {",
                  "    const f = pm.response.json().error.fields;",
                  "    console.log('The batch price changed; confirm with expected_debits =', f.expected_debits);",
                  "    pm.collectionVariables.set('expected_debits', f.expected_debits);",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Reject a batch",
          "request": {
            "method": "POST",
            "url": {
              "raw": "{{base_url}}/v1/batches/{{batch_id}}/reject",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "batches",
                "{{batch_id}}",
                "reject"
              ]
            }
          }
        },
        {
          "name": "Delete a batch",
          "request": {
            "method": "DELETE",
            "url": {
              "raw": "{{base_url}}/v1/batches/{{batch_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "batches",
                "{{batch_id}}"
              ]
            },
            "description": "Only while the batch is unsubmitted. A submitted or approved batch is 409 — reject it instead."
          }
        }
      ]
    },
    {
      "name": "Recipients",
      "item": [
        {
          "name": "List recipients",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/recipients?limit=25",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "recipients"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "25"
                },
                {
                  "key": "search",
                  "value": "jane",
                  "disabled": true
                },
                {
                  "key": "cursor",
                  "value": "",
                  "disabled": true
                }
              ]
            },
            "description": "Account identifiers come back masked, and only masked."
          }
        },
        {
          "name": "Add a recipient",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "    pm.collectionVariables.set('recipient_id', pm.response.json().data.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Jane Contractor\",\n  \"payment_method\": \"BANK\",\n  \"country_code\": \"GB\",\n  \"currency\": \"GBP\",\n  \"sort_code\": \"231470\",\n  \"account_number\": \"28821822\",\n  \"receiver_type\": \"PRIVATE\",\n  \"address_line1\": \"1 Example Street\",\n  \"address_city\": \"London\",\n  \"address_postal_code\": \"EC1A 1BB\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/recipients",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "recipients"
              ]
            },
            "description": "The returned `id` can be used as `recipient_id` when creating a payment, so you never re-send bank details."
          }
        },
        {
          "name": "Get a recipient",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/recipients/{{recipient_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "recipients",
                "{{recipient_id}}"
              ]
            }
          }
        },
        {
          "name": "Pay a saved recipient",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.request.headers.upsert({",
                  "    key: 'Idempotency-Key',",
                  "    value: 'pm-saved-' + Date.now() + '-' + Math.random().toString(36).slice(2, 10)",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"rail\": \"bank\",\n  \"amount\": \"300.00\",\n  \"currency\": \"USD\",\n  \"source_currency\": \"USD\",\n  \"target_currency\": \"GBP\",\n  \"fee_bearer\": \"sender\",\n  \"reference\": \"INV-2026-0418\",\n  \"recipient_id\": \"{{recipient_id}}\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/payments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments"
              ]
            },
            "description": "`recipient_id` instead of an inline `recipient`. A saved BANK payee must use rail `bank`, an E_WALLET payee rail `email`."
          }
        },
        {
          "name": "Delete a recipient",
          "request": {
            "method": "DELETE",
            "url": {
              "raw": "{{base_url}}/v1/recipients/{{recipient_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "recipients",
                "{{recipient_id}}"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Wallets & reference",
      "item": [
        {
          "name": "Wallet balances",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/wallets",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "wallets"
              ]
            },
            "description": "Payments are funded from the wallet matching `source_currency`. Topping up is done in the ekash apps."
          }
        },
        {
          "name": "Supported currencies",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/currencies",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "currencies"
              ]
            }
          }
        },
        {
          "name": "Bank requirements for a country",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/countries/GB/bank-requirements?currency=GBP",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "countries",
                "GB",
                "bank-requirements"
              ],
              "query": [
                {
                  "key": "currency",
                  "value": "GBP"
                },
                {
                  "key": "source_currency",
                  "value": "USD",
                  "disabled": true
                }
              ]
            },
            "description": "Which bank fields a payout to this corridor needs. Several `account_types` may be offered (IBAN vs sort code vs SWIFT) — supply the fields of any one of them.\n\nUse this instead of hard-coding a country matrix: a corridor ekash adds then works with no change on your side."
          }
        }
      ]
    },
    {
      "name": "Errors (try these)",
      "item": [
        {
          "name": "401 — no API key",
          "request": {
            "auth": {
              "type": "noauth"
            },
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/wallets",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "wallets"
              ]
            },
            "description": "Nothing under /v1 is reachable without a key, on any verb."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('401 authentication_required', function () {",
                  "    pm.response.to.have.status(401);",
                  "    pm.expect(pm.response.json().error.code).to.eql('authentication_required');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "400 — Idempotency-Key missing",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"rail\": \"bank\",\n  \"amount\": \"10.00\",\n  \"currency\": \"USD\",\n  \"recipient\": { \"name\": \"Jane Contractor\", \"country_code\": \"GB\" }\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/payments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments"
              ]
            },
            "description": "The header is required on every create."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('400 idempotency_key_required', function () {",
                  "    pm.response.to.have.status(400);",
                  "    pm.expect(pm.response.json().error.code).to.eql('idempotency_key_required');",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "404 — a payment that is not yours",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/v1/payments/999999999",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "payments",
                "999999999"
              ]
            },
            "description": "Another company's payment is reported as not found, never as forbidden."
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "description": "Register endpoints, inspect deliveries and replay the event history. The full reference, including the retry schedule and runnable verification samples, is webhooks.md.\n\nStart with \"Register a webhook endpoint\": its test script saves the one-time signing secret into `webhook_secret` for the verification scratchpad at the bottom of this folder.",
      "item": [
        {
          "name": "Register a webhook endpoint",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// The signing secret is returned ONCE, here. Capture it now — there is no endpoint",
                  "// that reads it back, and every later response omits it on purpose.",
                  "const body = pm.response.json();",
                  "const endpoint = (body && body.data) || {};",
                  "if (endpoint.secret) {",
                  "    pm.collectionVariables.set('webhook_secret', endpoint.secret);",
                  "    pm.collectionVariables.set('webhook_endpoint_id', endpoint.id);",
                  "    console.log('Saved webhook_secret and webhook_endpoint_id from the creation response.');",
                  "} else {",
                  "    console.warn('No secret in the response — this is only ever returned by POST /v1/webhooks.');",
                  "}",
                  "",
                  "pm.test('the secret is returned exactly once, on creation', function () {",
                  "    pm.expect(endpoint).to.have.property('secret');",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://example.com/hooks/ekash\",\n  \"events\": [\"payment.sent\", \"payment.refunded\", \"payment.canceled\"],\n  \"description\": \"Payouts ledger\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/webhooks",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks"
              ]
            },
            "description": "Registers an https endpoint and returns its signing `secret` — the ONLY time it is ever returned. The test script saves it into `webhook_secret` for you.\n\nOmit `events` to receive every event type. `http://localhost` and `http://127.0.0.1` are accepted outside production so you can receive real deliveries from a laptop.\n\n409 `endpoint_already_exists` if this URL is already registered — registering it twice means receiving everything twice."
          }
        },
        {
          "name": "List webhook endpoints",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks"
              ]
            },
            "description": "Your endpoints. Never includes the signing secret."
          }
        },
        {
          "name": "Get a webhook endpoint",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks/{{webhook_endpoint_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "{{webhook_endpoint_id}}"
              ]
            },
            "description": "404 for an endpoint that belongs to another company — never 403, which would confirm the id exists."
          }
        },
        {
          "name": "Update a webhook endpoint",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"events\": [\"payment.sent\", \"payment.refunded\", \"payment.canceled\", \"batch.approved\"],\n  \"enabled\": true\n}"
            },
            "url": {
              "raw": "{{base_url}}/v1/webhooks/{{webhook_endpoint_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "{{webhook_endpoint_id}}"
              ]
            },
            "description": "Only the members you send are changed. Disabling stops deliveries without losing the endpoint or its log; re-enabling also clears the consecutive-failure count."
          }
        },
        {
          "name": "Send a test delivery (ping)",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks/{{webhook_endpoint_id}}/test",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "{{webhook_endpoint_id}}",
                "test"
              ]
            },
            "description": "Queues a `ping` to this endpoint alone, whatever it is subscribed to. The response is the queued delivery, not its outcome — check the delivery log a few seconds later."
          }
        },
        {
          "name": "List deliveries",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks/{{webhook_endpoint_id}}/deliveries?limit=25",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "{{webhook_endpoint_id}}",
                "deliveries"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "25"
                }
              ]
            },
            "description": "Newest first. Each row carries the attempt count, the status code you returned, the first 500 characters of your response and `next_attempt_at` while a retry is scheduled."
          }
        },
        {
          "name": "Retry a delivery",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks/{{webhook_endpoint_id}}/deliveries/{{webhook_delivery_id}}/retry",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "{{webhook_endpoint_id}}",
                "deliveries",
                "{{webhook_delivery_id}}",
                "retry"
              ]
            },
            "description": "Re-queues a `dead` or `failed` delivery with the ORIGINAL payload and the attempt count reset. A delivery that already succeeded is 409 `already_delivered`."
          }
        },
        {
          "name": "List event types",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks/event-types",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "event-types"
              ]
            },
            "description": "Every value that can appear in `type` and be subscribed to."
          }
        },
        {
          "name": "Verify a received delivery (script only)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// Paste a delivery your endpoint received into the three variables below and run this",
                  "// request to check your verification logic against ekash's, before you debug your server.",
                  "//",
                  "//   signed_payload = '<ekash-timestamp>' + '.' + '<raw body>'",
                  "//   ekash-signature = 'v1=' + hex(HMAC_SHA256(endpoint secret, signed_payload))",
                  "//",
                  "// Two things that break every first attempt: the key is the secret STRING as UTF-8 bytes",
                  "// (never hex-decoded), and the message must be the RAW body exactly as received —",
                  "// re-serialising the parsed JSON changes the bytes and the signature will not match.",
                  "const secret = pm.collectionVariables.get('webhook_secret');",
                  "const timestamp = pm.collectionVariables.get('received_timestamp');",
                  "const rawBody = pm.collectionVariables.get('received_body');",
                  "const received = pm.collectionVariables.get('received_signature');",
                  "",
                  "if (!secret || !timestamp || !rawBody || !received) {",
                  "    console.log('Set received_timestamp, received_body and received_signature to check a delivery.');",
                  "} else {",
                  "    const CryptoJS = require('crypto-js');",
                  "    const expected = 'v1=' + CryptoJS.HmacSHA256(timestamp + '.' + rawBody, secret).toString(CryptoJS.enc.Hex);",
                  "    pm.test('the delivery signature verifies', function () {",
                  "        pm.expect(expected).to.eql(received);",
                  "    });",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks/event-types",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "event-types"
              ]
            },
            "description": "A scratchpad, not an API call: set `received_timestamp`, `received_body` and `received_signature` from a delivery your endpoint got, then run this and read the test result. It checks your understanding of the signature recipe against ekash's."
          }
        },
        {
          "name": "Delete a webhook endpoint",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/webhooks/{{webhook_endpoint_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "webhooks",
                "{{webhook_endpoint_id}}"
              ]
            },
            "description": "Removes the endpoint and its delivery log. Your event history survives — it is readable from GET /v1/events."
          }
        },
        {
          "name": "Replay the event history",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/events?limit=25",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "v1",
                "events"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "25"
                }
              ]
            },
            "description": "Scope `events:read`. Every event recorded for your company, newest first, in exactly the shape a delivery carries — so the handler you wrote for webhooks can process a replay unchanged. This is the recovery path after an outage on your side.\n\n`since` is RFC 3339 UTC. Pass `next_cursor` back as `cursor`. History is kept for 90 days and starts when you register your first endpoint."
          }
        }
      ]
    }
  ]
}
