API reference · Orders

Place an order

POST/v1/wallets/{walletId}/orders

Buys cards from a wallet, under an operation id you choose and keep. The same id sent again never buys twice: it resumes the same order.

Permissionorders:create
AuthenticationSigned order
Staff-set limits it counts towardAll requests, Orders
.NET SDKanis.Orders.CreateAsync(walletId, operationId, order) / ResumeAsync(...)
  • 201: the order completed, and this answer carries the card codes. Store them first.
  • 200: the answer a resume receives when the first answer was lost. If it carries card codes, it is the first time you see them — store them.
  • An answer marked Idempotency-Replayed: true repeats an order whose outcome was already sent: it carries the order, not the codes. If you never received that first answer — a timeout — the codes were in it: reveal them with the order’s invoice id, which needs cards:reveal.
  • 202: accepted, no outcome yet. Send the same order again after Retry-After.

Parameters

NameInTypeNotes
walletIdrequiredpathUUIDA UUID, lower-case with hyphens.

Request

Signed with your key, with a one-time nonce, a digest of the body and your operation id as Idempotency-Key.

Headers: Signature-Input, Signature, Content-Digest, Nonce, Idempotency-Key, X-Anis-Date, Accept-Language (optional). The SDKs set all of them for you.

Body: CreateOrderRequest, as JSON.

FieldTypeNotes
externalReferencestringYour own reference, 1 to 100 characters: Latin letters and digits, space and - _ . : / #.
cardIdrequiredUUIDThe catalogue card to buy.
quantityrequiredintegerAt least 1 and at most the per-order maximum (100 by default), and within the card’s own minimum and maximum.
expectedUnitPricerequiredMoneyThe card’s unitPrice exactly as the catalogue showed it for this wallet.
expectedTotalrequiredMoneyexpectedUnitPrice times quantity, exactly — computed without floating point.
useAllowedDebtbooleanSet to true only if you consent to use the account’s allowed debt. Defaults to false and is never switched on for you.

Responses

StatusMeaningBody
200Success.Order
201The order completed.Order
202Accepted — no outcome yet.Order
401Refused: not authenticated.Problem
402Refused: needs consent to use allowed debt.Problem
403Refused: not allowed.Problem
404Refused: not found, or not yours.Problem
409Refused: conflicts with the current state.Problem
422Refused: the request breaks a rule.Problem
429Refused: a limit was reached.Problem
503No decision: a dependency was unavailable.Problem

Every answer is signed by Anis; the SDKs check it before you see it.

Refusals

Every refusal is a signed problem. Branch on its code; each links to what it means and what to do.

ErrorCodeStatus
Invalid credentialsinvalid_credentials401
Insufficient scopeinsufficient_scope403
Source address not allowedsource_ip_not_allowed403
Rate limitedrate_limited429
Replay detectedreplay_detected409
Account not authorisedbinding_not_authorized403
Account inactiveaccount_inactive403
Wallet not grantedwallet_not_granted404
Not foundresource_not_found404
Validation failedvalidation_failed422
Currency not supportedcurrency_not_supported422
Operation id already usedidempotency_conflict409
Allowed-debt consent requiredallowed_debt_consent_required402
Insufficient balanceinsufficient_balance409
Purchase not allowedpurchase_not_allowed403
Order refusedpurchase_not_allowed409
Business subscription requiredbusiness_subscription_required409
Wallet disabledwallet_disabled409
Wallet expiredwallet_expired409
Card unavailablecard_unavailable409
Quantity unavailablequantity_unavailable409
Price changedprice_changed409
Spending allowance used upowner_limit_exceeded409
Daily limit reacheddaily_limit_exceeded429
Service unavailabledependency_unavailable503
Request timeoutrequest_timeout504
Internal errorinternal_error500

Types

CreateOrderRequest

FieldTypeNotes
externalReferencestringYour own reference, 1 to 100 characters: Latin letters and digits, space and - _ . : / #.
cardIdrequiredUUIDThe catalogue card to buy.
quantityrequiredintegerAt least 1 and at most the per-order maximum (100 by default), and within the card’s own minimum and maximum.
expectedUnitPricerequiredMoneyThe card’s unitPrice exactly as the catalogue showed it for this wallet.
expectedTotalrequiredMoneyexpectedUnitPrice times quantity, exactly — computed without floating point.
useAllowedDebtbooleanSet to true only if you consent to use the account’s allowed debt. Defaults to false and is never switched on for you.

Money

FieldTypeNotes
amountrequired / always presentstringA decimal string with exactly three decimals, such as "10.500" — never a JSON number.
currencyrequired / always presentstringThe currency code, such as LYD: always the wallet’s currency.
asOfstring (date-time)When this price or balance was read.

Order

FieldTypeNotes
operationIdalways presentUUIDThe operation id you chose and sent as Idempotency-Key.
statusalways presentstringprocessing: accepted, no outcome yet. completed: bought. failed: refused by a business rule, nothing bought. recoveryExhausted: Anis could not learn the outcome yet — it may have completed; keep resuming slowly and tell Anis. Values: processing, recoveryExhausted, completed, failed
invoiceIdUUIDThe invoice the cards are on. Use it to reveal them again later.
walletIdUUIDThe wallet the order was paid from.
cardIdUUIDThe catalogue card bought.
quantityintegerHow many cards.
totalMoneyWhat the order cost.
soldCardslist of RevealedCredentialThe card codes. Present only on the answer that FIRST reports the order completed — store them before anything else.
completedAtstring (date-time)When the order completed.

RevealedCredential

FieldTypeNotes
soldCardIdalways presentUUIDThe sold card these codes belong to.
serialNumberstringThe card’s serial number. A secret: store it where you keep secrets and never log it.
voucherstringThe card’s voucher code. A secret: store it where you keep secrets and never log it.
revealedAtstring (date-time)When it was revealed.