await_settled → awaitSettled), with identical parameters and byte-identical signed requests.
Authentication
Two credentials on every request:- API key (tier 1) — read from
ATOA_API_KEY; identifies your business and pins the environment. Sandbox and production keys are separate and not interchangeable. - ES256 signing key (tier 2) — the SDK signs every request; Atoa checks the signature against the public key you registered once. The private key is never sent. Requests can’t be tampered with or replayed.
privateKeyPem loaded from
your secrets manager, or a custom signer (below) so the key never enters your process. Re-registering the same
agent with a different key is rejected. Keep both credentials out of source control, logs, and client-side code.
Three ways to supply the two credentials — pick one (Python shown; TypeScript mirrors it in camelCase):
KMS / custom signer
Keep the private key in a KMS (key management service) so it never enters your process: pass asigner instead of
a PEM. Per request, the SDK hands your signer the canonical subject string and expects a detached compact JWS
(JSON Web Signature) back: b64url(header)..b64url(rawSig), where rawSig is the 64-byte IEEE-P1363 r‖s
form (a KMS returns DER — convert it). Register the public key.
Methods
Every operation is laid out the same way — Parameters (marked required or optional), a Request example (Python + TypeScript), then the Response type and an example. Python is snake_case; TypeScript mirrors it in camelCase; every call is async. Amounts are in pounds, not pence —{ amount: 12.50, currency?: "GBP" }, so £12.50
is 12.50, never 1250; currency defaults to GBP.
Pagination. Every list(opts?) returns a Page<T> envelope; the paired listAll(opts?) walks every page and
returns a flat T[].
Common paging inputs on every list: page (zero-based, default 0) and size (default 20).
agent
agent.register(opts)
Set up your agent’s identity — the challenge → sign → register handshake in one call. Idempotent (safe to call
again): the same key/env/business returns the same agent; a changed name/description is a metadata update, not
a conflict.
Parameters
Your ES256 public key (PEM, SPKI). Pass it only with a KMS/custom signer; omit when the SDK holds the private
key (it derives the public key itself).
RegisteredAgent
agent.me()
Read this agent’s own identity as the service sees it. Takes no parameters.
Request
AgentIdentity
agent.list()
List every agent registered under your business + environment. Authenticated by the SDK API key alone (no JWS).
Takes no parameters.
Request
AgentIdentity[]
An array of AgentIdentity (shape as agent.me).
contract
contract.create(input)
Create a spending contract. Returns it PENDING_AUTHORIZATION with an authorizationUrl the account holder (SEND)
or customer (COLLECT) opens to authorize; poll awaitActive until ACTIVE.
Parameters
Required for
COLLECT — the customer this contract charges (id from customer.create).
Ignored for SEND.COLLECT only — take a first charge inside the customer’s approval: their single approval activates the contract
and pays this amount, so there is no separate approval (or
payment.collect call) for charge #1. See
Charge on approval.Contract
COLLECT only — the masked card the customer linked. Absent until they link one on the contract page.
COLLECT only — authorized terms version (1 on first approval; increments per approved update).
COLLECT only, when one was set at create — the bundled first charge:
{ amount, currency, orderId, storeId?, status, paymentRequestId?, failureReason? }.
status runs AWAITING_APPROVAL → PENDING → COMPLETED / FAILED (INITIATION_FAILED if the charge could not
start — the contract stays ACTIVE regardless). paymentRequestId is minted when the customer approves; once
present, poll payment.get with it. Before that, orderId is your correlation handle.A staged limits change; the
limits above stay enforced until it’s authorized. null when nothing is staged.contract.awaitActive(id, opts?)
Poll get until the contract is ACTIVE, with internal backoff. Throws AUTHORIZATION_TIMEOUT on timeout or
AUTHORIZATION_FAILED if the human declined / the link expired.
Parameters
Request
Contract
The Contract (shape above) once status is ACTIVE.
contract.get(id)
Read a contract’s current state, including live usage. No webhooks — poll this.
Parameters
Request
Contract
The Contract shape (see contract.create), plus live per-period usage:
contract.list(opts?) · contract.listAll(opts?)
List this business’s contracts. list returns one page; listAll walks every page and returns a flat array. (Two
methods, one underlying list — grouped for that reason.)
Parameters
Request
Page<Contract> (listAll → Contract[])
contract.update(id, input)
Change a contract’s limits — the human must approve the new caps. Returns it PENDING_AUTHORIZATION with a
new authorizationUrl; the old consent stays live and payable until the new one is approved. Poll
awaitActive again.
Parameters
Request
Contract
The Contract, back at PENDING_AUTHORIZATION with a fresh authorizationUrl.
contract.revoke(id)
Terminate the contract. Payments against it are then rejected.
Parameters
Request
ContractRevokeResult
payment
payment.collect(input)
Money in, one verb. contractId absent → a pay-link/QR the customer pays now. contractId present →
an off-session charge on the linked method of that COLLECT contract (no card details, ever). Either way, follow
with awaitSettled(paymentRequestId). One payment per call; not idempotent.
Parameters
Your order reference — echoed on the payment and the dashboard (and on webhooks, when they arrive in a later
phase). Not an idempotency key.
Present → off-session charge on this
COLLECT contract’s linked method. Absent → a pay-link/QR the customer pays
now.The managed Atoa customer (
id from customer.create). Required for an off-session charge — pass it with
contractId, and it must match the contract’s own atoaCustomerId (a mismatch is rejected with
CONTRACT_CUSTOMER_MISMATCH). Optional for a pay-link, where it links the payment to a managed customer (and
enables savePaymentMethod). Not the same as customerId, which is your own reference.Prefill the checkout with the customer’s details.
Save the card during checkout. Needs
atoaCustomerId + paymentMethod: ['CARD']; incompatible with splitBill.Till/receipt QR template — sets
templateUrl.PaymentRequest
Off-session charge mode, only when the customer must approve — see approval gate. Absent for a pay-link.
payment.send(input)
Money out against an ACTIVE SEND contract. payments is always an array (1–20; a single payment = one
element); the result is a Payment[] in the same order. A terminal FAILED with a failureReason is a returned
per-item Payment, not a thrown error — only operational faults throw. Confirm each with
awaitSettled.
Parameters
Request
SendResult (a Payment[] + optional nextAction)
A Payment[] in input order (iteration / result[0] work as before), with an optional nextAction (present when
an owner approval gates the batch — see approval gate). See payment.get for the
full Payment shape.
payment.get(id)
Read one payment. One read model for both directions; accepts a paymentRequestId (CREDIT parent — current/best
state) or a paymentIdempotencyId (one attempt).
Parameters
Request
Payment
CREDIT = money in (COLLECT) · DEBIT = money out (SEND). Discriminates which fields below are present.AWAITING_AUTHORIZATION · PENDING · AUTHORIZED · COMPLETED · FAILED · CANCELLED · EXPIRED · PARTIALLY_REFUNDED · REFUNDED.COLLECT (CREDIT) only — who paid, once an attempt exists: payer name, bank, and masked account.
payment.awaitSettled(id, opts?)
Poll a payment until it stops moving (COMPLETED/FAILED/CANCELLED, EXPIRED on CREDIT, or AUTHORIZED). Throws
SETTLEMENT_TIMEOUT on timeout. Accepts a paymentRequestId or a paymentIdempotencyId.
Parameters
Request
Payment
The Payment (shape above) at a resting state.
payment.list(opts?) · payment.listAll(opts?)
List this agent’s payments across both directions. list returns one page; listAll walks every page. (Two
methods, one underlying list.)
Parameters
Request
Page<Payment> (listAll → Payment[])
payment.refund(id, input)
Refund a COMPLETED collected payment — full or partial.
Parameters
{ amount, reason? } — the amount must not exceed the paid amount. Sandbox: reason: "FAILURE TEST" forces a
FAILED refund.Refund
payment.listRefunds(id) · payment.cancelRefund(refundId)
List the refunds of one collected payment, or cancel a still-INITIATED refund.
Parameters
Request
payment.cancel(id)
Cancel an unpaid collect (link) or a charge resting at AUTHORIZED.
Parameters
Request
Payment
The CANCELLED payment.
payment.awaitDecision(approvalId)
Poll an approval (from a send/collect nextAction) to its terminal decision. See the
approval gate for the flow.
Parameters
Request
Approval
payment.cancelApproval(contractId, approvalId)
Agent-initiated cancel of a pending approval — voids the underlying draws.
Parameters
Request
customer
customer.create(input)
Create a managed customer — needed for off-session COLLECT contracts (the customer links a card to the contract on
its authorization page). Guest checkout does not require one.
Parameters
Request
Customer
customer.get(id) · customer.update(id, input) · customer.delete(id)
Read, edit, or remove one managed customer. (Three verbs on one resource id — grouped for that reason.)
Parameters
Request
customer.list(opts?)
List the customers this agent created.
Parameters
Request
Page<Customer>
store · client-level
store.list(opts?)
List this business’s stores — discover a storeId to tag a collect by location.
Parameters
Request
Page<Store>
checkAvailability()
Unauthenticated health probe. Takes no parameters and never throws — check the returned flag.
Request
AvailabilityStatus
sandboxTestAccounts()
The sandbox SEND recipients and the outcome each forces. Takes no parameters; production has none.
Request
SandboxTestAccounts
Errors
Business outcomes are returned — branch on thePayment’s status and failureReason. Operational faults are
thrown AgentPayError subclasses — catch and switch on code.
Returned failureReason values:
Thrown
AgentPayError subclasses:
Retry guidance:
- Retry:
RATE_LIMIT(back off),SERVER_ERROR,NETWORK_ERRORand timeouts — but re-read withget/awaitSettledfirst; the operation may still be in flight, andorderIdis not a de-duplication key. - Fix first:
VALIDATION_ERROR,AUTH_ERROR,PARAMS_CONFLICT,CAP_EXCEEDED(charge ≤.remaining),CONTRACT_NOT_ACTIVE(re-approve). - Don’t retry: a returned
FAILEDis a decision, not a glitch.
Sandbox
Create the client withenvironment: "sandbox" and a sandbox API key. No real money moves; you choose every
outcome.
Production is the same code with a production key and
environment: "production" — real banks, real approvers,
real money.
Approval gate
Every send and every off-session charge pauses for approval — this is SCA (Strong Customer Authentication). Asend result (still a Payment[]) and an off-session collect result carry the action under nextAction
(TS) / next_action (Python); a pay-link collect has none. The approver is the person bound to the contract —
the business owner for SEND, the customer for an off-session COLLECT — deciding on Atoa’s hosted page with
a one-time code or a passkey. Your app never collects the credential.
"APPROVAL" for this gate. The full action vocabulary — every type, for, mustEscalate, and the fallback rule — is the nextAction contract; switch on type so new kinds don’t break you.Approvals browser SDK
@atoapayments/agentic-payment-approvals-js embeds Atoa’s hosted approval page as an iframe inside a container you
provide and resolves to the decision. Browser/TypeScript only; zero dependencies. Python integrators share the
approvalUrl or drive this from their web layer. Full guide: Approvals SDK.
confirmApproval returns an ApprovalHandle (result · on(…) · destroy()) — it is not awaited directly. Other
options: theme (bounded, contrast-clamped tokens), labels.approve
(APPROVE | PAY | CONFIRM | AUTHORIZE), onResult, apiUrl (local-stack override). Events: opened ·
loaded · approved · declined · expired · superseded · error · closed.
FAQ
Do I have to register my domain to use the embedded checkout?
Do I have to register my domain to use the embedded checkout?
No. There’s no origin allowlist and nothing to register — any page can host the checkout,
localhost
included.What protects the payment is the API key your server used to create it, and the customer’s own one-time code
or passkey, entered inside the frame on Atoa’s origin.Can I use the embed without a backend?
Can I use the embed without a backend?
No. The API key creates payments and must stay on your server, and there is no method to create a payment
from the browser.
AtoaUI.mount() shows a payment that already exists.With no backend, send the customer a pay-link from payment.collect instead.My container stays blank.
My container stays blank.
Check the browser console.
AtoaUI.mount: the embed frame at <origin> never connected within <n>ms means the
iframe loaded but never answered — usually a frame-src content-security policy on your own page, or a
network path that can’t reach Atoa.If nothing is logged at all, confirm container resolved to a real element and that you passed
environment.Can I apply my brand colours and font to the checkout?
Can I apply my brand colours and font to the checkout?
Not today.
theme takes mode — 'auto', 'light' or 'dark' — and nothing else.A checkout a host can restyle is a checkout a host can make look like something it is not, and the trust
the frame carries is what you are embedding. Brand treatment, when it ships, will be issued to your
business from Atoa’s side rather than accepted from the page.Do webhooks fire for agentic contract payments?
Do webhooks fire for agentic contract payments?
Not in this phase. Merchant webhooks do not fire for contract payments — poll from your server with
payment.get or awaitSettled for settlement truth. Webhooks arrive in a later phase.Go-live checklist
- Production API key as
ATOA_API_KEY, client withenvironment: "production". - Signing key from a secrets manager, or a KMS signer — never a generated throwaway.
- Branch on all three shapes: returned
COMPLETED, returnedFAILED/CANCELLEDwith afailureReason, thrownAgentPayError. - Deliver the
approvalUrlto the approver (or drive the browser SDK) on every send and off-session charge; handleAPPROVAL_DECLINED/APPROVAL_EXPIRED; observe withawaitDecision. - Poll from your server —
get/awaitSettled— for settlement truth. Merchant webhooks do not fire for agentic contract payments in this phase; webhooks arrive in a later phase. - Run one small real payment end to end — including a declined and a cancelled path — before scaling up.
Changelog
- 0.0.3 —
initialChargeon COLLECT contracts (charge on approval), theget_agenttool, and thenextActionenvelope on verb results. - 0.0.2 — first MIT-licensed release.
- 0.0.1 — initial release.
paymentRequestId, customer ids, statuses, field names) carry straight over to Atoa’s direct API if
you outgrow the SDK.