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 purchase
Anis’s answerSigned
Staff-set limits it counts towardAll requests, Purchases (orders limit)
.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 (your reference, the card, the quantity and the total), 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.
  • The order body must be at most 8,192 bytes (8 KB), in UTF-8 — a Content-Type naming any other charset is refused as HTTP 422, validation_failed. A larger body is refused as HTTP 422, validation_failed.
  • HTTP 429, spending_limit_exceeded: the order was not placed because it would exceed the application’s spending cap for this window. Wait until the window resets, as given by Retry-After, then place a new order with a new operation id; ask Anis staff to change the cap if needed.

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.
quantityrequiredintegerFrom 1 to the platform order limit of 100.
expectedUnitPricerequiredMoneyThe card’s unitPrice exactly as the catalogue showed it for this wallet, using the shared Money shape.
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
400Refused: the signed request is badly built.Problem
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 of this call is signed by Anis — success and every refusal. Require the signature and verify it before you act on the answer; an answer without one is a failure, never an answer (how).

Refusals

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

ErrorCodeStatus
Invalid credentialsinvalid_credentials401
Malformed signed requestmalformed_signed_request400
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
Spending cap reachedspending_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.
quantityrequiredintegerFrom 1 to the platform order limit of 100.
expectedUnitPricerequiredMoneyThe card’s unitPrice exactly as the catalogue showed it for this wallet, using the shared Money shape.
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
amountrequiredstringA decimal string, never a JSON number. Wallet balances may be negative while allowed debt is used. Prices and totals follow each route's amount rules.
currencyrequiredstringAn uppercase three-letter currency code, such as LYD. Read a wallet’s currency from balance.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 write to support@anis.ly with the operation id. 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.
cardIdanyThe catalogue card ordered. On every answer for the order — the first one, a repeat of it and a read.
quantityintegerHow many cards were ordered. On every answer for the order, a repeat and a read included.
totalanyWhat the order cost. On every answer whose status is completed, a repeat and a read included; absent while it is processing or after it failed.
externalReferencestringYour own reference, exactly as you sent it. On every answer for the order, a repeat and a read included — it tells you which of your sales this is. Absent when the order had none.
failureCodestringWhy the order failed: the refusal code Anis recorded, one of the Error codes. Only on a read of an order whose status is failed. Absent when that refusal has no public code.
codesWithheldbooleantrue only on the answer that first reports an order that is paid and complete but whose codes could not be released. Do not buy it again, and write to support@anis.ly with the operation id. Never false: on every other answer it is absent, and on a repeat or a read that means “not stated”.
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.
expiryDatestring (date)The last day the card can be used, as yyyy-MM-dd. Tell your end customer. Absent when the card has none.
invoiceIdanyThe invoice the card is on. Also inside an order’s soldCards.
cardCardSummaryThe catalogue card that was sold, so you know which card these codes are for. Also inside an order’s soldCards.
purchasedAtstring (date-time)When the card was bought. Also inside an order’s soldCards.

CardSummary

FieldTypeNotes
idUUIDThe catalogue card’s id.
nameLocalizedTextThe card name in Arabic and English; empty localized text is omitted.
faceValuestringOptional printed value; absent when empty.
logostringOptional absolute URL of the subcategory logo; absent when empty.
subcategoryobjectThe card’s subcategory, with id and localized name.
subcategory.idUUIDThe subcategory’s id.
subcategory.nameLocalizedTextThe subcategory’s name in Arabic and English.
categoryobjectThe card’s category, with id and localized name.
category.idUUIDThe category’s id.
category.nameLocalizedTextThe category’s name in Arabic and English.

LocalizedText

FieldTypeNotes
arstringThe Arabic text; omitted when empty.
enstringThe English text; omitted when empty.