The decision pipeline
The 11 stages every payment passes through, the gate strip, outcomes and plain-language reasons.
Every payment an agent makes goes through one decision pipeline: the same code for a card authorization, a pay() call, an x402 challenge, a bank payout or a simulated payment in test mode. It has 11 stages. Each stage writes a trace entry, and the trace is what the gate strip draws.
The 11 stages#
| # | Stage | What it checks | When it fails |
|---|---|---|---|
| 1 | Identity | The agent, its key or passport, and its org. | Declines |
| 2 | Plan and go-live | Plan limits, verification status, sandbox or live. | Declines |
| 3 | Freeze check | No freeze on the agent, its tree, team, org, credential or funding source. | Declines |
| 4 | Funding source | A funding source the agent may use, with access. | Declines |
| 5 | Counterparty | Who is being paid, and how sure we are. | Never stops a payment |
| 6 | Mandate match | The payment fits a signed human instruction. | Holds |
| 7 | Policy rules | Limits, allow and block lists, categories, time windows. | Holds or declines |
| 8 | Risk | Velocity, spikes, loops, odd hours, sanctions. | Holds |
| 9 | Budget | Room in every budget in scope; reserves the amount. | Holds or declines |
| 10 | Approval threshold | Whether a person must approve, and how. | Holds |
| 11 | Sign and record | The decision is signed and written to evidence. | Never stops a payment |
Stages run in order. A stage that declines ends the decision: later stages are not reached, and only the final sign-and-record stage still runs, so the decline itself is signed. A stage that holds does not stop the pipeline: every later stage still runs, so a held payment reports all of its hold reasons at once, not just the first.
The pipeline is deterministic. It makes no model calls and no network calls beyond ndStill's own budget ledger and caches, so the same request against the same policy version always gets the same outcome. Every decision records the policy_version_hash it used, which is what makes replay exact.
Outcomes#
A decision (dec_…) has one of three outcomes:
| Outcome | What happens next | Payment status |
|---|---|---|
approve | Budgets are reserved, a scoped credential is minted, and the agent pays. | Approved, then Authorized and Settled |
hold | An approval (apr_…) is created and routed to people. Nothing is reserved yet. | Held |
decline | The agent gets structured reasons it can act on. Nothing is reserved. | Declined |
When a person approves a held payment, the pipeline runs again from the top. Approval never skips a freeze, a budget check or a policy that changed while the payment waited.
Reading the gate strip#
The console, the mobile app and these docs draw a decision as a strip of 11 blocks, one per stage:
- Passed
- Held here
- Declined here
- Not on this rail
- Not reached
- Passed
- Held here
- Declined here
- Not on this rail
- Not reached
- Passed
- Held here
- Declined here
- Not on this rail
- Not reached
- Passed
- Held here
- Declined here
- Not on this rail
- Not reached
Colour is never the only signal. The skipped stage is a different shape, every strip has a text equivalent for screen readers, and each block has a tooltip with the stage's detail.
The trace#
The trace is an array on the decision, one entry per stage reached:
{
"id": "dec_01JD9A7K2M",
"object": "decision",
"outcome": "hold",
"rail": "card",
"reasons": [
{
"code": "approval_required_amount",
"stage": "approval",
"effect": "hold",
"params": { "amount": { "amount": 54000, "asset": "USD" }, "threshold": { "amount": 30000, "asset": "USD" } }
}
],
"trace": [
{ "stage": "authenticate", "result": "pass", "detail": "Agent key akey_7Q2… verified", "ms": 1 },
{ "stage": "entitlement", "result": "pass", "detail": "Live mode; plan limits OK", "ms": 0 },
{ "stage": "freeze", "result": "pass", "detail": "No freeze on the agent, its tree, team, org or funding source", "ms": 1 },
{ "stage": "funding", "result": "pass", "detail": "Travel card program (Stripe Issuing)", "ms": 2 },
{ "stage": "counterparty", "result": "pass", "detail": "Delta Air Lines (confidence 0.97)", "ms": 3 },
{ "stage": "mandate", "result": "pass", "detail": "Within mandate (up to $600.00)", "ms": 1 },
{ "stage": "policy", "result": "pass", "detail": "Within $1,000.00 per payment; category allowed", "ms": 1 },
{ "stage": "risk", "result": "pass", "detail": "Normal pace (2 payments in 10 min)", "ms": 4 },
{ "stage": "budget", "result": "pass", "detail": "Within Travel desk's monthly budget ($2,310.00 of $5,000.00)", "ms": 14 },
{ "stage": "approval", "result": "hold", "detail": "$540.00 is above the $300.00 approval line.", "code": "approval_required_amount", "ms": 0 },
{ "stage": "record", "result": "pass", "detail": "Decision signed (held)", "ms": 18 }
],
"policy_version_hash": "sha256:9f2c…",
"latency_ms": 45
}Each entry is { stage, result, detail, code?, ms }. result is pass, hold, decline or skip. Fetch a decision with GET/decisions/{id}, or read the compact gate marks that every payment carries in its gates field.
Reasons, written for people#
Reasons are what an agent, an approver and an auditor all read. Each has a machine code, the stage that produced it, its effect, and parameters, and the API renders a sentence from them: "Over the Travel desk's weekly budget by $112.00", not BUDGET_EXCEEDED. Agents should branch on the code; people read the sentence.
| Code | Stage | Example message |
|---|---|---|
agent_unknown | 1 Identity | This agent isn't registered in the org. |
key_revoked | 1 Identity | The agent used a key that has been revoked. |
passport_invalid | 1 Identity | The agent's request signature didn't match its passport. |
plan_limit | 2 Plan and go-live | The org's plan limit for this has been reached. |
verification_required | 2 Plan and go-live | The org must finish verification before live payments. |
sandbox_only | 2 Plan and go-live | This agent can only make test payments. |
agent_frozen | 3 Freeze check | Travel desk is frozen. |
tree_frozen | 3 Freeze check | The agent tree under Travel desk is frozen. |
team_frozen | 3 Freeze check | Travel desk is frozen. |
org_frozen | 3 Freeze check | Every agent in the org is frozen. |
credential_frozen | 3 Freeze check | The credential used for this payment is frozen. |
funding_frozen | 3 Freeze check | The funding source Travel desk is frozen. |
no_funding_access | 4 Funding source | Travel desk isn't allowed to use Travel desk. |
funding_insufficient | 4 Funding source | Travel desk doesn't have enough available for $612.00. |
mandate_missing | 6 Mandate match | No signed mandate covers this payment. |
mandate_amount_mismatch | 6 Mandate match | $612.00 is above the mandate's limit of $600.00. |
mandate_counterparty_mismatch | 6 Mandate match | The mandate is for Delta Air Lines, but the agent is paying Acme Air. |
mandate_expired | 6 Mandate match | The mandate covering this payment has expired. |
mandate_uses_exhausted | 6 Mandate match | The mandate has already been used as many times as allowed. |
over_per_payment_limit | 7 Policy rules | $612.00 is over the $500.00 limit per payment. |
blocked_counterparty | 7 Policy rules | Acme Air is on the block list. |
blocked_category | 7 Policy rules | Gambling purchases are blocked by policy. |
outside_time_window | 7 Policy rules | Payments aren't allowed at this time of day by policy. |
first_time_counterparty | 7 Policy rules | First payment to Acme Air; policy holds new sellers. |
confidence_below_floor | 7 Policy rules | The agent's confidence was below the policy's floor. |
velocity | 8 Risk | 9 payments in 10 minutes is faster than usual for Travel desk. |
spend_spike | 8 Risk | $612.00 is far above Travel desk's usual payment. |
loop_detected | 8 Risk | The agent sent the same request repeatedly; this looks like a loop. |
off_hours | 8 Risk | The payment came outside this agent's usual hours. |
price_drift | 8 Risk | The price drifted from what the mandate expected ($600.00). |
stolen_key_signal | 8 Risk | The agent's key was used from an unfamiliar place. |
sanctions_hit | 8 Risk | Acme Air matched a sanctions list. |
over_budget | 9 Budget | Over Travel desk's weekly budget by $112.00. |
budget_nearly_exhausted | 9 Budget | This would use the last of Travel desk's weekly budget. |
approval_required_amount | 10 Approval threshold | $612.00 is above the $250.00 approval line. |
approval_required_counterparty | 10 Approval threshold | Payments to Acme Air always need approval. |
approval_required_policy | 10 Approval threshold | Policy requires a person to approve this payment. |
rejected_by_person | After the decision | Rejected by Priya Shah: Not this vendor. |
approval_expired | After the decision | Nobody approved this in time, so it expired. |
rail_error | After the decision | The Not this vendor returned an error; no money moved. |
Three more codes appear after the decision rather than inside it: rejected_by_person, approval_expired and rail_error.
Where decisions come from#
Most decisions start with an agent's pay() call. Some start elsewhere, and still go through the same stages:
- Card authorizations. When an agent uses an ndStill card, or a card on a program the owner connected, the processor's authorization webhook comes to ndStill. The decision service matches it to the open reservation from the approved payment, or decides it fresh against policy (a recurring charge, for example). This is the strictest path; it is designed for a p99 under 300 ms.
- 402 challenges. The SDK's x402 hook, or the MCP
pay_402tool, passes the challenge's amount, asset,payToand resource to ndStill before the wallet signs. - The AI proxy. Each model call reserves its maximum cost before the request goes upstream.
- Simulations and replays. The same code runs with
simulate: true, against a snapshot, with nothing reserved or minted.
Timing and reliability#
Each stage reports its own ms, and the decision records latency_ms. Budget reservation and signing take most of the time; the policy itself evaluates in memory. When a dependency is slow, each rail has a documented fallback: card programs are minted with spending controls equal to their scope, so a processor that falls back to its own rules still cannot exceed the mandate. See Cards and issuing.