OpenPoly logo
Wallet Adapter

Debit

Debit contract for buy-side wallet mutations.

Debit

Debit user wallet for buy-side flow.

Path

POST /debit

Request body

{
  "external_user_id": "operator-user-123",
  "amount_minor": 10000,
  "currency_code": "IDR",
  "idempotency_key": "mini_app_order:1:debit",
  "reason": "mini_app_buy_order",
  "metadata": {
    "orderId": 1,
    "marketId": 51,
    "outcome": "yes",
    "resolveDeadlineTs": "2026-06-30T12:00:00.000Z"
  }
}

There is no direction field in the REST v1 JSON body. The path POST /debit is the direction.

Request fieldTypeRequirementNotes
external_user_idstringRequiredStable operator-side user ID.
amount_minorintegerRequiredExact debit amount in minor units.
currency_codestringRequiredCurrent REST v1 value: IDR.
idempotency_keystringRequiredDebit operation key.
reasonstringRequiredBuy flow uses mini_app_buy_order.
metadataobjectRequiredAlways present, possibly empty; fields are additive.

Required buy-debit metadata:

Metadata fieldTypeRequirement
orderIdpositive integerRequired
marketIdpositive integerRequired
resolveDeadlineTsISO-8601 string or nullOptional

Current buy requests also include outcome and resolveDeadlineTs as additive context. resolveDeadlineTs is the related market's resolution deadline when configured, otherwise null. Do not reject unknown metadata fields.

Response body

{
  "external_user_id": "operator-user-123",
  "status": "succeeded",
  "currency_code": "IDR",
  "amount_minor": 10000,
  "idempotency_key": "mini_app_order:1:debit",
  "remote_reference": "wallet-op-123",
  "balance_minor": 90000
}

Status values

Response field requirements:

Response fieldTypeRequirementOpenPoly behavior
statusstringRequiredMust be succeeded, failed, or pending. Any other/missing value is an invalid response.
external_user_idstringOptionalFalls back to the request value. Full-contract tests reject a mismatch.
idempotency_keystringOptionalFalls back to the request key.
remote_referencestringOptionalPreserved when non-empty.
balance_minorintegerOptionalPost-operation balance, preserved for reconciliation.
failure_reasonstringOptionalRecommended when status = failed.
amount_minor, currency_codemixedOptional echoesNot consumed from the response; OpenPoly keeps the request values.
  • succeeded
  • failed
  • pending

Direct mutation responses must not return unknown. A pending response is treated as ambiguous and sent to manual review; OpenPoly does not automatically replay the primary debit.

Rules

  • same idempotency key must return same effective result
  • response should echo external_user_id when available
  • do not silently convert failure into success
  • do not debit the same user twice for the same idempotency_key
  • timeout, network failure, pending, HTTP 408, HTTP 429, and HTTP 5xx are ambiguous; investigate the original idempotency key manually
Copyright © 2026