When what you need has no dedicated SePay CLI command, call the SePay API endpoint directly with sepay api <path>. It uses your sepay login session, needs no API Token, and calls the active environment (sandbox by default, --env production for live data).
sepay api reaches the SePay API only. Payment Gateway, Bank Hub and eInvoice have their own command groups: pg, bankhub, einvoice.
Read data
The path is relative to the API base, for example /transactions: don't paste a full URL or repeat /v2. On GET, each -f key=value becomes a query parameter. Get the latest transaction:
$ sepay api /transactions -f per_page=1env: sandbox{"status": "success","data": [ { "id": "07ad3dc9-xxxx-xxxx-xxxx-0afffe87053b", "transaction_date": "2026-10-31 11:24:40", "account_number": "0000000002", "va": "", "transfer_type": "in", "amount_in": 50000, "amount_out": 0, "accumulated": 0, "transaction_content": "Giao dich sandbox 31/10/2026 11:24:40", "reference_number": "SBCF7A82A9EBC8", "code": "DH1709", "bank_brand_name": "ACB", "bank_account_id": "d6719d04-xxxx-xxxx-xxxx-a6006ab65aca", "va_id": null, "webhook_success": 8 }],"meta": { "pagination": { "total": 48, "per_page": 1, "current_page": 1, "last_page": 48, "has_more": true }}}The CLI prints the JSON the API returns as is, with or without --json; -o yaml prints the same data as YAML. The endpoint's page explains each field and filter, for example List transactions.
Write data
Pick the method with -X. On POST, PUT and DELETE, the -f fields form a JSON body. A value that is valid JSON (42, true, [1,2]) is sent typed, anything else as a string. Create a webhook in the sandbox:
$ sepay api /webhooks -X POST -f url=https://example.com/hook -f bank_mode=all -f event_type=in -f is_verify_payment=trueThe API returns the new webhook as JSON, including its id.
For a longer body, read a JSON file with --input, or --input - for stdin. --input can't be combined with -f or used with GET:
$ sepay api /webhooks -X POST --input body.json| Flag | Type | Description |
|---|---|---|
-X, --method | string | HTTP method. Defaults to GET |
-f, --field | string[] | One key=value field; repeat the flag for more |
--input | string | Read the JSON body from a file, or - for stdin |
-H, --header | string[] | Add a Name: value request header; repeat the flag for more |
Each run of a write sends a fresh idempotency key, so the CLI can safely resend it if the connection drops midway. Running the whole command again means a new key; to rerun without creating a duplicate, pass the same --idempotency-key both times, see Idempotency.
On production
-X DELETE asks for confirmation in every environment. On production, every method other than GET, HEAD changes data and follows the confirmation rule: it needs --env production on the command, prints env: production, then a ! live: … line, and asks for confirmation:
$ sepay api /webhooks/<webhook-xid> -X DELETE --env productionenv: production! live: api DELETE /webhooks/<webhook-xid> targets PRODUCTION? api DELETE /webhooks/<webhook-xid> on production? [y/N]A script you write yourself can run with --env production and --yes when the last path segment is an id (a UUID or a number), as in the example above. A path that doesn't end in an id, such as POST /webhooks or POST /bank-accounts/<xid>/va, creates a new resource: it runs only in a terminal, and --yes can't confirm it. Add --dry-run to print the request it would send without sending anything, not even a GET.
sepay api skips the checks a dedicated command makes, including the production block on sandbox-only commands. When the Command list has a command for the job, use it.