Skip to content
API documentationP2P EasyPay

Cancel a withdrawal ​

POST /v1/pay/withdrawals/{id}/cancel requires the Merchant's existing withdrawals:write scope and HMAC headers. This is not an employee approval command. The query must be empty. Send Content-Type: application/json and an 8–200 character Idempotency-Key. The body limit is 8 KiB and the total request deadline is 4.5 seconds.

Upgrade strict TEST readers before using cancellation

Upgrade the SDK and refresh the UI to a version accepting canceled, withdrawal.canceled and withdrawal.cancel before using this endpoint in TEST. Field names remain unchanged, but older closed-enum clients can reject the new values. They are not automatically compatible. Show a read error instead of falling back to Live data or another profile.

Request ​

json
{ "reason": "Customer requested cancellation" }

The exact body contains only reason: well-formed Unicode, 1–500 codepoints, not entirely whitespace, and no C0/C1 controls including newline. The server does not trim or rewrite it before signature verification: sign the exact raw bytes sent. The body digest is retained for idempotency; raw reason text is not persisted or returned as a Support record. Keep your own reason record if needed and avoid personal data.

Live: release only the unused amount ​

Status before cancellationResult
pending_approvalRelease the original principal and fee lock without a fabricated approver
open / partially_filledCancel only when no active allocation or reservation remains
settled / expired / canceled / rejectedA new command returns 409 withdrawal_not_cancelable

Only ordinary Merchant withdrawals belonging to the current key are eligible. Agent commission and internal reserve orders use their separate lifecycles. Keep existing paid principal, fills, approvals, fee snapshots and the original remaining_minor. The actual wallet release is:

text
released = remaining_minor + fee_total_minor - fee_recognized_minor

Success returns 200 and the unchanged Withdrawal object shape with status: canceled, reserved_minor: 0, refunded_minor = remaining_minor and an actual released_balance_transaction_id. The refunded field counts principal; the release also includes unused fee. Never credit the entire original amount again after a partial payout.

For example, principal100000, fee2000, paid40000 and recognized fee800 leave principal60000: the release is 61200 minor units. Paid funds are not recalled.

Live callbacks retain withdrawal.terminal and the existing seven-field signed envelope. This profile does not add canceled_by or cancel_reason_code, or promise two separate balance.credited callbacks. Reconcile using the current Withdrawal and balance/statement.

TEST: release the current run's pinned principal plus fee ​

Use api.sandbox.<domain>, an sk_test_ key and withdrawals:write. Cancellation does not require an additional sandbox:write grant. Only an open withdrawal in the active run can be canceled; no real account is used.

Available test funds increase by the pinned principal plus fee, while reserved funds decrease by the same amount. No fee is recognized. Existing public v1 fields remain unchanged: status: canceled, sandbox.outcome: cancel, refunded_minor = amount_total_minor, and filled_minor/remaining_minor/reserved_minor/fee_recognized_minor = 0.

An immutable withdrawal.canceled event and withdrawal.cancel ledger entry record the release, with fee_delta_minor: "0" in activity v2. Cancellation does not add a magic amount or a manual cancel outcome to the existing simulate tools. Archived-run orders return 409 sandbox_transaction_archived and cannot credit the new run's wallet.

Retries and isolation ​

  • First success and explicit replay both return 200. Only replay carries Idempotent-Replay: true.
  • After an uncertain network result retain the exact path, body bytes and key, but use a fresh nonce/signature. Changed body under the same key and concrete path returns 409 idempotency_key_reused. Different resources have separate path scopes, so changing the path does not replay the original command.
  • A completed replay returns the original receipt before terminal/quota checks, while still checking current authority. GET the resource for its latest state. The server does not automatically retry a monetary command.
  • A Live active fill returns 409 withdrawal_has_pending_fill with error.details.retry_after_seconds: 5, retryable: true and Retry-After: 5. Wait and check state before explicitly retrying; do not cancel a payer's reservation.
  • 404 not_found (Live) / 404 resource_not_found (TEST) do not reveal foreign resources. 429 uses Retry-After: 60. Cancellation does not reset quotas or cross-run idempotency history.
  • Deposit cancellation is a separate lifecycle outside this profile.

See partial fills, fees and the Sandbox execution scope.

เอกสารชุดนี้อิงสัญญา API เวอร์ชัน 2026-08-01