Approvals
Operations that wait for a person: what is held and why, how a person decides, and two approvers.
Some operations wait for a person. This page covers what is held and why, how a person decides, what the person sees, two approvers, the hold on a first payment to a new destination, risk rules, and what an agent can never do.
Status: available. Approver emails need outbound mail configured; the approval page cannot present a passkey. The code is lib/spend.ts, lib/approval-links.ts, lib/customer-controls.ts and lib/pure/risk-rules.ts.
A held operation
A held operation is not run. It answers 202:
HTTP/1.1 202
{ "status": "requires_approval", "approval_id": "…", "reason": "…", "reason_code": "amount" }
reason_code is one of:
reason_code | What held it |
|---|---|
amount | The mandate's approval_above (or second_approval_above). |
operation | The operation is in the mandate's approve_operations, which always wait for a person. |
new_payee | The customer holds the first payout to a destination it has never paid. |
risk | A risk rule on the customer with action: "approve" was tripped. |
The whole request is stored, so a person approves exactly what was asked. An approval that is not decided expires after 24 hours, or after the mandate's approval_expires_minutes; the operation then did not run (approval_expired). approval.requested and approval.decided are events.
GET /approvals?customer_id=&status=pending
GET /approvals/{id}?wait=30&until=approved
Each approval carries payee_display: the destination as a person would recognise it, where there is one.
Three ways to decide
Another key.
POST /approvals/{id}/approve
{ note?, evidence? }
POST /approvals/{id}/deny
{ note? }
The approving key must not be the one that asked (self_approval) and must not be acting as an agent (agent_cannot_approve). Approval runs the stored request once, as the key that asked and under that key's policies: a hard limit still applies.
A link for one person.
POST /approvals/{id}/links
{ approver, email?, expires_minutes? }
It makes an approve link and a deny link. approver is your reference for the person, and the decision is recorded against it. A link's token is random, stored only as a hash, works once and expires (expires_minutes, 60 by default, at most 1440). When approvers are named for the customer (POST /customers/{id}/approvers with { email, reference, name? }) and outbound mail is configured, each approver is emailed their own links when an operation is held; mail_configured in the answer says whether this deployment sends mail.
A signed-in member in the console. The console reaches the API as that person; see console-api.md. An approval that needs passkey evidence is decided this way.
In the sandbox, POST /sandbox/approvals/{id}/decide with { decision: approve | deny, approver? } decides as a person would, without a second key or a link.
In the person's Praecise account. Where Skerry's deployment has the account's feed switched on, each person who may decide a held operation also finds it in the feed of their Praecise account: the person themselves on Skerry Personal, and otherwise the owners and admins of the Skerry account the customer belongs to. The item names the operation, the amount and currency and the payee's name, and opens the approval in Skerry; it is finished for everyone when the approval is decided or lapses, and for a person who has given their part of two approvals. Nothing about it changes how the operation is decided. See account-feed.md.
The page a person sees
GET /approve/{token} is public: the token is the credential. The page states the operation, amount, currency, destination, agent, mandate and why it was held. Opening it decides nothing, so a mail scanner that fetches the link decides nothing. POST /approve/{token} is the page's confirm button: it uses the link, records the decision against its approver and, when the operation is now approved, runs it.
Operations the route performs itself
For checkout sessions, payment links, subscriptions, standing orders, payees and wallets, approval does not run the operation. The answer says to send the same request again with:
Skerry-Approval: <approval id>
The approval must be approved for exactly this request, asked by this key, and not used yet (approval_not_usable otherwise).
Two approvers, and passkey evidence
A mandate with approvers_required: 2, or an amount above second_approval_above, needs two approvals. The first leaves the operation held (status: pending). The two must be different keys, members or approver references (approver_not_distinct). In the sandbox, call the decide helper twice with different approver values.
A mandate with approval_evidence: "passkey" needs evidence from the approver, sent as evidence on the approve call. It is accepted only with an attestation signed by the configured identity provider; without it the call answers approval_evidence_required.
Controls on a customer
These apply to every caller, whatever its mandate. Every control is off until it is set, and an agent's own credential cannot change one.
| Operation | Scope | Idempotency-Key | Moves money | What it does |
|---|---|---|---|---|
GET /customers/{id}/payee-controls | controls:read | none | no | How a new destination is treated: new_payee_hold, payee_cooling_off_minutes and cooling_off_max. |
PUT /customers/{id}/payee-controls | controls:write | none | no | Hold the first payout to a payee, wallet or address the customer has never paid (an approval with reason new_payee), and limit what a newly trusted destination can be paid during its cooling-off period. |
POST /customers/{id}/trusted-payees | payees:write | optional | no | Trust a destination before it is first paid, so that payout is not held. |
GET /customers/{id}/trusted-payees | payees:read | none | no | Destinations the customer has paid or a person has trusted, newest first, with how each came to be trusted (source: paid, pre_approved or approved). |
GET /customers/{id}/risk-rules | controls:read | none | no | The customer's velocity and anomaly rules. |
PUT /customers/{id}/risk-rules | controls:write | none | no | Replace the customer's risk rules. |
GET /customers/{id}/withdrawal-allow-list | controls:read | none | no | The destinations this customer's payouts may go to. |
PUT /customers/{id}/withdrawal-allow-list | controls:write | none | no | Replace the withdrawal allow-list: payee ids, wallet ids and addresses, up to 500. |
POST /customers/{id}/approvers | approvals:write | optional | no | Name a person who is emailed an approve link and a deny link when one of this customer's operations is held. |
GET /customers/{id}/approvers | approvals:read | none | no | The customer's approvers, and whether this deployment sends mail. |
DELETE /customers/{id}/approvers | approvals:write | none | no | Remove an approver. |
New-payee hold and cooling-off
PUT /customers/{id}/payee-controls
{ new_payee_hold?, payee_cooling_off_minutes?, cooling_off_max? }
With new_payee_hold, the first payout to a payee, wallet or address the customer has never paid becomes an approval with reason_code: "new_payee". When a person approves it, the destination is trusted from then on. POST /customers/{id}/trusted-payees with { payee_id | wallet_id | address, chain? } trusts a destination before it is first paid, so that payout is not held; it is a person's decision and is refused for an agent's own credential. GET /customers/{id}/trusted-payees shows how each destination came to be trusted (source: paid, pre_approved or approved).
A destination trusted by approval or in advance then has a cooling-off period of payee_cooling_off_minutes: until it ends, a payout to it above cooling_off_max is refused with payee_cooling_off. cooling_off_max is integer minor units of the fiat currency of the payout's unit family (cents); null means nothing may be paid.
Withdrawal allow-list
PUT /customers/{id}/withdrawal-allow-list
{ destinations: [ ... ] | null }
While a list is in force, every payout by any caller must go to a destination on it (destination_not_allowed otherwise), in addition to any mandate's own allow-list. Payee ids, wallet ids and addresses, up to 500; null removes the list.
Risk rules
PUT /customers/{id}/risk-rules
{ rules: { velocity?: { max_count, window_minutes, action }, amount_anomaly?: { factor, min_samples?, action }, first_use?: { dimensions?, action }, lookalike_address?: { max_different?, action } } }
The rules are data, counted from recorded operations; no model takes part. Each has an action: approve turns an operation that trips it into an approval with the reason, refuse refuses it with risk_refused (detail.rules says which and why). A rule that is null is off. They are evaluated on payouts, conversions, refunds, settlements and off-session charges.
lookalike_address is for address poisoning: an outside address that shares its beginning and end with one the customer already pays, or differs from it in only a few places, is reported with the address it resembles. Address format is checked by shape; the mixed-case checksum of an EVM address is not verified.
POST /sandbox/customers/{id}/risk-rules/trip sets one rule with the history it needs, so the next matching operation trips it.
The order the checks run in
On a guarded operation (lib/spend.ts), and reported in the same order as checks on a dry run: freeze, agent, withdrawal_allow_list, payee, risk, policy, budget, and for payouts and conversions provider (the provider's own dry run). A refusal at one stage ends it; a hold from the payee or risk stage is carried into the policy stage, so a held operation states every reason at once.
What an agent can never do
An agent's own credential (a key bound to an agent, a token acting as one, or a request naming one) is refused for the following, whatever its scopes:
| Refused | With |
|---|---|
| Approving or denying a held operation | 403 agent_cannot_approve |
| Making approval links | 403 agent_not_permitted (a key bound to the agent, a request it signed, or a token acting as it); 403 agent_cannot_approve when a shared key only names an agent with Skerry-Agent |
| Naming or removing a customer's approvers | 403 agent_not_permitted |
| Recording consent to a mandate, or changing a spend policy | 403 agent_not_permitted |
| Creating, topping up or releasing a budget | 403 agent_not_permitted |
| Changing payee controls, risk rules or the withdrawal allow-list | 403 agent_not_permitted |
| Trusting a destination in advance | 403 agent_not_permitted |
| Releasing a conditional payout | 403 agent_not_permitted |
| Lifting a freeze, on a customer or the account | 403 agent_not_permitted |
| Registering, changing or resuming an agent; minting agent keys; approving or withdrawing an OAuth client | 403 agent_not_permitted |
| Changing another agent's signing keys, or stopping an agent it did not delegate to | 403 agent_not_permitted |
| Acting through the console | 403 agent_not_permitted |
An agent can freeze (stopping money is always allowed), can ask for an operation that is then held, and can read the approval it is waiting for.
Events
| Event | Concerns | When |
|---|---|---|
approval.requested | approval | An operation is held for a person to approve. |
approval.decided | approval | A held operation was approved or denied. |
Written and kept by Skerry. Read from https://api.skerry.xyz/guides/approvals.md.