Skip to content
ndStill is in development. These docs describe the v2 API as designed; the SDKs and the hosted MCP server are previews and not generally available.
Docs

Policy schema reference

Every field of the agent spend policy document, the CEL context and the validation codes.

The agent spend policy is an open, portable document in YAML or JSON. It's versioned (every save is an immutable version with a content hash), validated by a compiler, and enforced as deep as each rail allows. This page lists every field, the CEL context for conditions, the validation codes and the inheritance rules. The field list is generated from the PolicyDocument type, so it always matches the API.

A complete example#

YAML
version: "2026-11-01"
budgets:
  - amount: { amount: 500000, asset: USD } # $5,000.00
    window: month
    time_zone: America/New_York
limits:
  per_payment: { amount: 120000, asset: USD } # $1,200.00
  per_day_count: 20
counterparties:
  block: [Acme Air]
categories:
  allow: [Airlines, Hotels, Ground transport]
rails:
  allow: [card, network_token, checkout_token]
time_windows:
  - days: [mon, tue, wed, thu, fri]
    from: "07:00"
    to: "20:00"
approvals:
  above: { amount: 60000, asset: USD } # $600.00
  new_counterparty: true
  assurance: passkey
  timeout_minutes: 240
  on_timeout: escalate
risk:
  velocity_per_10m: 6
  spike_multiplier: 4
  confidence_floor: 0.6
  off_hours: true
tolerance:
  - mcc: "4511"
    percent: 15
conditions:
  - name: Weekends need a person
    when: "time.weekday in ['sat', 'sun']"
    then: hold

Fields#

PolicyDocumentgenerated from packages/api/src/types/agents.ts
  • version"2026-11-01"required
  • budgetsobject[]
    4 fields
    • amountMoneyrequired

      An amount: integer minor units + asset.

      Money: 2 fields
      • amountnumberrequired
      • assetAssetCoderequired
        "USD""USDC""EUR""GBP"
    • windowBudgetWindowrequired
      "day""week""month""quarter""total"
    • rollingboolean
    • time_zonestring
  • limitsobject
    2 fields
    • per_paymentMoney

      An amount: integer minor units + asset.

      Money: 2 fields
      • amountnumberrequired
      • assetAssetCoderequired
        "USD""USDC""EUR""GBP"
    • per_day_countnumber
  • counterpartiesobject
    2 fields
    • allowstring[]
    • blockstring[]
  • categoriesobject
    2 fields
    • allowstring[]
    • blockstring[]
  • railsobject
    1 field
    • allowRail[]
      "card""network_token""checkout_token""stablecoin""bank""ai""cloud"
  • time_windowsobject[]
    3 fields
    • daysarray of string enumrequired
      "mon""tue""wed""thu""fri""sat""sun"
    • fromstringrequired
    • tostringrequired
  • approvalsobject
    6 fields
    • aboveMoney

      An amount: integer minor units + asset.

      Money: 2 fields
      • amountnumberrequired
      • assetAssetCoderequired
        "USD""USDC""EUR""GBP"
    • new_counterpartyboolean
    • routeobject
      3 fields
      • team_idId
      • user_idsstring[]
      • channelsarray of string enum
        "whatsapp""slack""push""email"
    • assurancestring enum
      "passkey""any""dual"
    • timeout_minutesnumber
    • on_timeoutstring enum
      "reject""escalate"
  • riskobject
    4 fields
    • velocity_per_10mnumber
    • spike_multipliernumber
    • confidence_floornumber
    • off_hoursboolean
  • toleranceobject[]
    2 fields
    • mccstringrequired
    • percentnumberrequired
  • conditionsobject[]

    CEL conditions: { when, then }.

    3 fields
    • namestringrequired
    • whenstringrequired
    • thenstring enumrequired
      "hold""decline""notify"

Notes on the fields:

  • Money is always { amount, asset } with an integer amount in minor units (cents for USD, six decimals for USDC).
  • budgets use calendar windows in time_zone (an IANA name, default the org's). total never resets.
  • limits.per_payment holds a payment over the limit; per_day_count caps how many payments a day.
  • counterparties and categories: a block list declines; a non-empty allow list declines everything not on it.
  • time_windows hold payments outside every window (24-hour HH:MM, to up to 24:00).
  • approvals.above holds at or above the amount; assurance is any, passkey or dual.
  • tolerance lets a card authorization exceed the approved amount by a percentage for a merchant category (tips, fuel, hotels), so the settlement doesn't fail.
  • conditions: hold and decline change the outcome; notify only alerts.

The CEL context#

Conditions are written in CEL (Common Expression Language): sandboxed, deterministic and fast. Supported: ||, &&, !, comparisons, in, arithmetic, parentheses, lists, string and number literals, true, false, null, size(x), has(x.y), and the string methods startsWith, endsWith, contains and matches. These names are available:

CEL context
NameType
payment.amountnumber
payment.assetstring
payment.railstring
payment.purposestring
counterparty.namestring
counterparty.categorystring
counterparty.first_seenbool
counterparty.paymentsnumber
agent.namestring
agent.teamstring
agent.depthnumber
agent.labelsmap
mandate.presentbool
mandate.maxnumber
time.hournumber
time.weekdaystring
budget.used_rationumber

payment.amount is in major units (dollars), so payment.amount > 500 means more than $500. counterparty.first_seen is true for the agent's first payment to that counterparty. time.hour and time.weekday (mon … sun) use the policy's time zone. budget.used_ratio is the share of the monthly budget already used, from 0 to 1.

Validation codes#

Validate a draft with POST/policies/{id}/validate (or watch the playground do it as you type). Each issue has a severity, a code, a plain message and a JSON path such as approvals.above or conditions[1].when.

Validation codes
`code`SeverityMeans
schemaerrorA field has the wrong type or an invalid value.
unknown_fielderrorA key the schema doesn't have (often a typo; the message suggests the closest name).
invalid_conditionerrorA CEL expression doesn't parse or type-check.
loosens_parenterrorThe document allows more than a parent policy (a higher limit, a removed block). Children may only tighten.
conflicterror or warningTwo rules contradict each other, such as a category both allowed and blocked.
unreachable_rulewarning or infoA rule can never fire (an approval line above the per-payment limit, a condition that is always false), or another rule always binds first.
unknown_counterpartywarningA named counterparty ndStill hasn't seen; check the spelling.
not_enforceable_nativelywarningA connection can't express the rule as its own limit; ndStill enforces it at decision time only.

A document that doesn't match the schema can't be saved. A version with other errors can be saved as a draft, but it can't be activated until they're fixed.

Inheritance#

Policies attach to four scopes, outermost first: org → team (and parent teams) → tree → agent. For each payment, every layer runs; the strictest result wins:

  • any layer that declines declines the payment
  • any layer that holds holds it (all hold reasons are reported)
  • budgets in every layer must have room

The compiler enforces that a child never loosens a parent: its budgets and limits can only be lower, its allow lists only narrower, its block lists only longer. GET/policies/{id}/inheritance shows the parent chain and the tightest inherited value for each rule, and GET/agents/{id}/effective-policy shows what finally applies to one agent.

Compiling to providers#

When a version is activated, the compiler also produces native projections: the same rules written as each provider's own limits (card spending controls on Stripe Issuing, Lithic and Increase programs, Ramp and Brex limits, OpenAI project limits, wallet policies, Shared Payment Token usage limits). They are a backstop if ndStill can't be reached. The validation report lists, per connection, which rules are projected and which are enforced by ndStill only. See Control levels.

Versions and the document version#

Each saved version is immutable, with a content_hash; decisions record the hash of the version they used, so any decision can be replayed exactly. The document's own version field ("2026-11-01") is the schema version, which changes only when the schema does; see Versioning.