Policies API
Versioned spend policies for an org, team, agent tree or agent: validate, simulate, replay and activate.
Base URL https://api.ndstill.com/v2. Send Authorization: Bearer with a key, Ndstill-Version: 2026-11-01, and an Idempotency-Key on every POST. Conventions, scopes and errors are in the API overview and Errors and decline reasons. Examples come from the mock backend; the shapes are the TypeScript types in packages/api.
Create a policy#
/v2/policies- namestringrequired
- descriptionstring
- scopeobjectrequired
2 fields
- kindPolicyScopeKindrequired
"team""org""agent""tree" - idIdrequired
- from_template_idId | null
- documentPolicyDocument
Agent spend policy document (backend plan §7). YAML or JSON; this is the JSON form.
PolicyDocument: 11 fields
- 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"
- idId
- object"policy"
- org_idId
- created_atTimestamp
- updated_atTimestampoptional
- test_modebooleanoptional
True for test-mode objects (simulations, sandbox).
- namestring
- descriptionstring
- scopeobject
3 fields
- kindPolicyScopeKind
"team""org""agent""tree" - idId
- namestring
- is_templateboolean
Templates are not attached to a scope until used.
- template_keystring enumoptional
null"research_agent""travel_agent""procurement_agent""consumer_allowance" - active_version_idId | null
- active_version_numbernumber | null
- draft_version_idId | null
- versions_countnumber
- applies_to_agentsnumber
Agents this policy currently applies to (directly or inherited).
- updated_byRef | null
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- 400invalid_request
A field is missing or invalid; fields names each one.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 409conflict
The object changed or already exists, or the Idempotency-Key was reused with a different body.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X POST "https://api.ndstill.com/v2/policies" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"name": "Docs example",
"scope": {
"kind": "team",
"id": "example"
},
"document": {
"version": "2026-11-01"
}
}'{
"object": "error",
"type": "not_found",
"code": "not_found",
"message": "No team with id example.",
"request_id": "req_7c197403a977b8ed802d"
}The mock answered this sample with an error; its message says why. Adjust the request in Try it below.
Runs against the in-browser mock with a test key. Nothing leaves your browser.
List policies#
/v2/policies- scope_kindstring
- scope_idId
- is_templateboolean
- cursorstring
- limitnumber
1–200, default 50.
- qstring
Free-text search over names, ids and descriptors.
- sortstring
Sort field, prefix "-" for descending ("-created_at" is the default).
- created_gteTimestamp
created_at >= (ISO).
- created_lteTimestamp
created_at <= (ISO).
Returns a list envelope: object "list", data[], has_more, next_cursor (pass it back as cursor) and total when cheap to count. Items:
The same Policy object as Create a policy.
- 400invalid_request
A query parameter is invalid.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X GET "https://api.ndstill.com/v2/policies?limit=2" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01"{
"object": "list",
"data": [
{
"id": "pol_01KYXCCRME9QXCXCFR6RPQ6HFG",
"object": "policy",
"org_id": "org_A99F918124609C9DAAACB209D8",
"created_at": "2026-08-01T00:43:11.374Z",
"name": "Acme Robotics org policy",
"description": "Applies to every agent. Teams, trees and agents can tighten it but never loosen it.",
"scope": {
"kind": "org",
"id": "org_A99F918124609C9DAAACB209D8",
"name": "Acme Robotics"
},
"is_template": false,
"template_key": null,
"active_version_id": "polv_01M4689JCEXN5J5CXANDR3RJMY",
"active_version_number": 3,
"draft_version_id": "polv_01M627F4RE8C2H1TKNN5XEYZ2W",
"versions_count": 4,
"applies_to_agents": 24,
"updated_by": {
"id": "usr_01KETCX0MEA9RA05FCKG947HTQ",
"name": "Hana Sato"
},
"updated_at": "2026-10-28T21:43:11.374Z"
},
{
"id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"object": "policy",
"org_id": "org_A99F918124609C9DAAACB209D8",
"created_at": "2026-07-02T00:43:11.374Z",
"name": "Cloud cost guard policy",
"description": "Agent-level rules for Cloud cost guard.",
"scope": {
"kind": "agent",
"id": "agt_01KYW6M8REDTGCTQ2ZK0CMDADJ",
"name": "Cloud cost guard"
},
"is_template": false,
"template_key": null,
"active_version_id": "polv_01M4AZBHWEX6BPNM85336FAQ45",
"active_version_number": 2,
"draft_version_id": null,
"versions_count": 2,
"applies_to_agents": 1,
"updated_by": {
"id": "usr_01KDY2H3MEZQFZQ0R60FFMFZ3X",
"name": "Leo Novak"
},
"updated_at": "2026-10-07T10:43:11.374Z"
}
],
"has_more": true,
"next_cursor": "Mg==",
"total": 12
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
Retrieve a policy#
/v2/policies/{id}- idIdrequired
A prefixed ID from this org.
The same Policy object as Create a policy.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X GET "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01"{
"id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"object": "policy",
"org_id": "org_A99F918124609C9DAAACB209D8",
"created_at": "2026-07-02T00:43:11.374Z",
"name": "Cloud cost guard policy",
"description": "Agent-level rules for Cloud cost guard.",
"scope": {
"kind": "agent",
"id": "agt_01KYW6M8REDTGCTQ2ZK0CMDADJ",
"name": "Cloud cost guard"
},
"is_template": false,
"template_key": null,
"active_version_id": "polv_01M4AZBHWEX6BPNM85336FAQ45",
"active_version_number": 2,
"draft_version_id": null,
"versions_count": 2,
"applies_to_agents": 1,
"updated_by": {
"id": "usr_01KDY2H3MEZQFZQ0R60FFMFZ3X",
"name": "Leo Novak"
},
"updated_at": "2026-10-07T10:43:11.374Z"
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
Update a policy#
/v2/policies/{id}- idIdrequired
A prefixed ID from this org.
- namestring
- descriptionstring
The same Policy object as Create a policy.
- 400invalid_request
A field is missing or invalid; fields names each one.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X PATCH "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01" \
-H "Content-Type: application/json" \
-d '{}'{
"id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"object": "policy",
"org_id": "org_A99F918124609C9DAAACB209D8",
"created_at": "2026-07-02T00:43:11.374Z",
"name": "Cloud cost guard policy",
"description": "Agent-level rules for Cloud cost guard.",
"scope": {
"kind": "agent",
"id": "agt_01KYW6M8REDTGCTQ2ZK0CMDADJ",
"name": "Cloud cost guard"
},
"is_template": false,
"template_key": null,
"active_version_id": "polv_01M4AZBHWEX6BPNM85336FAQ45",
"active_version_number": 2,
"draft_version_id": null,
"versions_count": 2,
"applies_to_agents": 1,
"updated_by": {
"id": "usr_01K7WYQ6MEYNYVHTQCVYZCTCDX",
"name": "Dana Whitfield"
},
"updated_at": "2026-11-23T00:43:13.448Z"
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
Get a policy's inheritance#
/v2/policies/{id}/inheritance- idIdrequired
A prefixed ID from this org.
- object"policy_inheritance"
- policy_idId
- parentsobject[]
Outermost first. Each parent's active version.
3 fields
- policyobject
3 fields
- idId
- namestring
- scopeobject
3 fields
- kindPolicyScopeKind
"team""org""agent""tree" - idId
- namestring
- versionobject
2 fields
- idId
- numbernumber
- documentPolicyDocument
Agent spend policy document (backend plan §7). YAML or JSON; this is the JSON form.
PolicyDocument: 11 fields
- version"2026-11-01"
- budgetsobject[]optional
4 fields
- amountMoney
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- windowBudgetWindow
"day""week""month""quarter""total" - rollingbooleanoptional
- time_zonestringoptional
- limitsobjectoptional
2 fields
- per_paymentMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- per_day_countnumberoptional
- counterpartiesobjectoptional
2 fields
- allowstring[]optional
- blockstring[]optional
- categoriesobjectoptional
2 fields
- allowstring[]optional
- blockstring[]optional
- railsobjectoptional
1 field
- allowRail[]optional
"card""network_token""checkout_token""stablecoin""bank""ai""cloud"
- time_windowsobject[]optional
3 fields
- daysarray of string enum
"mon""tue""wed""thu""fri""sat""sun" - fromstring
- tostring
- approvalsobjectoptional
6 fields
- aboveMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- new_counterpartybooleanoptional
- routeobjectoptional
3 fields
- team_idIdoptional
- user_idsstring[]optional
- channelsarray of string enumoptional
"whatsapp""slack""push""email"
- assurancestring enumoptional
"passkey""any""dual" - timeout_minutesnumberoptional
- on_timeoutstring enumoptional
"reject""escalate"
- riskobjectoptional
4 fields
- velocity_per_10mnumberoptional
- spike_multipliernumberoptional
- confidence_floornumberoptional
- off_hoursbooleanoptional
- toleranceobject[]optional
2 fields
- mccstring
- percentnumber
- conditionsobject[]optional
CEL conditions: { when, then }.
3 fields
- namestring
- whenstring
- thenstring enum
"hold""decline""notify"
- ceilingsobject[]
Tightest inherited value per rule, and the parent it comes from.
4 fields
- pathstring
- labelstring
- valuestring
- sourceobject
5 fields
- policy_idId
- namestring
- kindPolicyScopeKind
"team""org""agent""tree" - scope_namestring
- version_numbernumber
- agentsobject[]
Agents this policy reaches (directly or through its scope).
3 fields
- idId
- namestring
- statusAgentStatus
"active""frozen""retired"
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X GET "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/inheritance" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01"{
"object": "policy_inheritance",
"policy_id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"parents": [
{
"policy": {
"id": "pol_01KYXCCRME9QXCXCFR6RPQ6HFG",
"name": "Acme Robotics org policy",
"scope": {
"kind": "org",
"id": "org_A99F918124609C9DAAACB209D8",
"name": "Acme Robotics"
}
},
"version": {
"id": "polv_01M4689JCEXN5J5CXANDR3RJMY",
"number": 3
},
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 40000000,
"asset": "USD"
},
"window": "month",
"time_zone": "America/Los_Angeles"
}
],
"limits": {
"per_payment": {
"amount": 1000000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 300000,
"asset": "USD"
},
"new_counterparty": true,
"assurance": "passkey",
"timeout_minutes": 240,
"on_timeout": "escalate"
},
"risk": {
"velocity_per_10m": 12,
"spike_multiplier": 4,
"confidence_floor": 0.6,
"off_hours": false
},
"categories": {
"block": [
"Gambling",
"Crypto exchanges"
]
},
"conditions": [
{
"name": "Large first payment",
"when": "counterparty.first_seen && payment.amount > 2000",
"then": "hold"
}
]
}
},
{
"policy": {
"id": "pol_01KZ2H66MEAZED81BW1S9F69WE",
"name": "Engineering team policy",
"scope": {
"kind": "team",
"id": "team_01K9GENJMEVBEKC6VV943H2JMP",
"name": "Engineering"
}
},
"version": {
"id": "polv_01M59ZJ1GE7X3VGDX6ENAPJ19W",
"number": 2
},
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 15000000,
"asset": "USD"
},
"window": "month",
"time_zone": "America/Los_Angeles"
}
],
"limits": {
"per_payment": {
"amount": 600000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 300000,
"asset": "USD"
},
"new_counterparty": true,
"route": {
"team_id": "team_01K9GENJMEVBEKC6VV943H2JMP",
"channels": [
"push",
"slack"
]
},
"assurance": "passkey",
"timeout_minutes": 120,
"on_timeout": "escalate"
},
"risk": {
"velocity_per_10m": 12,
"spike_multiplier": 4,
"confidence_floor": 0.6,
"off_hours": false
},
"conditions": [
{
"name": "Model spend near budget",
"when": "payment.rail == 'ai' && budget.used_ratio > 0.9",
"then": "notify"
}
]
}
}
],
"ceilings": [
{
"path": "budgets.month",
"label": "Monthly budget",
"value": "$150,000.00",
"source": {
"policy_id": "pol_01KZ2H66MEAZED81BW1S9F69WE",
"name": "Engineering team policy",
"kind": "team",
"scope_name": "Engineering",
"version_number": 2
}
},
{
"path": "limits.per_payment",
"label": "Per-payment limit",
"value": "$6,000.00",
"source": {
"policy_id": "pol_01KZ2H66MEAZED81BW1S9F69WE",
"name": "Engineering team policy",
"kind": "team",
"scope_name": "Engineering",
"version_number": 2
}
},
{
"path": "approvals.above",
"label": "Approval above",
"value": "$3,000.00",
"source": {
"policy_id": "pol_01KYXCCRME9QXCXCFR6RPQ6HFG",
"name": "Acme Robotics org policy",
"kind": "org",
"scope_name": "Acme Robotics",
"version_number": 3
}
}
],
"agents": [
{
"id": "agt_01KYW6M8REDTGCTQ2ZK0CMDADJ",
"name": "Cloud cost guard",
"status": "active"
}
]
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
List a policy's versions#
/v2/policies/{id}/versions- idIdrequired
A prefixed ID from this org.
- cursorstring
- limitnumber
1–200, default 50.
- qstring
Free-text search over names, ids and descriptors.
- sortstring
Sort field, prefix "-" for descending ("-created_at" is the default).
- created_gteTimestamp
created_at >= (ISO).
- created_lteTimestamp
created_at <= (ISO).
Returns a list envelope: object "list", data[], has_more, next_cursor (pass it back as cursor) and total when cheap to count. Items:
- idId
- object"policy_version"
- policy_idId
- numbernumber
- statusstring enum
"active""draft""superseded" - documentPolicyDocument
Agent spend policy document (backend plan §7). YAML or JSON; this is the JSON form.
PolicyDocument: 11 fields
- version"2026-11-01"
- budgetsobject[]optional
4 fields
- amountMoney
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- windowBudgetWindow
"day""week""month""quarter""total" - rollingbooleanoptional
- time_zonestringoptional
- limitsobjectoptional
2 fields
- per_paymentMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- per_day_countnumberoptional
- counterpartiesobjectoptional
2 fields
- allowstring[]optional
- blockstring[]optional
- categoriesobjectoptional
2 fields
- allowstring[]optional
- blockstring[]optional
- railsobjectoptional
1 field
- allowRail[]optional
"card""network_token""checkout_token""stablecoin""bank""ai""cloud"
- time_windowsobject[]optional
3 fields
- daysarray of string enum
"mon""tue""wed""thu""fri""sat""sun" - fromstring
- tostring
- approvalsobjectoptional
6 fields
- aboveMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- new_counterpartybooleanoptional
- routeobjectoptional
3 fields
- team_idIdoptional
- user_idsstring[]optional
- channelsarray of string enumoptional
"whatsapp""slack""push""email"
- assurancestring enumoptional
"passkey""any""dual" - timeout_minutesnumberoptional
- on_timeoutstring enumoptional
"reject""escalate"
- riskobjectoptional
4 fields
- velocity_per_10mnumberoptional
- spike_multipliernumberoptional
- confidence_floornumberoptional
- off_hoursbooleanoptional
- toleranceobject[]optional
2 fields
- mccstring
- percentnumber
- conditionsobject[]optional
CEL conditions: { when, then }.
3 fields
- namestring
- whenstring
- thenstring enum
"hold""decline""notify"
- document_yamlstring
The same document as YAML (what the code view edits).
- content_hashstring
- authorRef
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- created_atTimestamp
- activated_atTimestamp | null
- activated_byRef | null
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- validation_reportValidationReport
ValidationReport: 6 fields
- okboolean
- issuesValidationIssue[]
ValidationIssue: 6 fields
- severitystring enum
"error""info""warning" - codestring enum
"conflict""unreachable_rule""loosens_parent""not_enforceable_natively""schema""unknown_counterparty""unknown_field""invalid_condition" - messagestring
- pathstringoptional
JSON path in the document ("approvals.above", "conditions[1].when").
- connectionRef | nulloptional
For not_enforceable_natively: which connection can't express it.
Ref: 2 fields
- idId
- namestring
- parentobject | nulloptional
For loosens_parent: the parent policy whose rule this one loosens.
3 fields
- policy_idId
- namestring
- kindPolicyScopeKind
"team""org""agent""tree"
- projectionsPolicyProjection[]
Per connection: which rules become native limits, and which ndStill enforces alone.
PolicyProjection: 5 fields
- connectionRef
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- control_levelControlLevel
"authorize""issue""observe_stop" - railsRail[]optional
Rails the connection carries (for the rail icon).
"card""network_token""checkout_token""stablecoin""bank""ai""cloud" - nativestring[]
Rules written to the provider as native limits (a backstop if ndStill is unreachable).
- ndstill_onlystring[]
Rules only ndStill enforces, at decision time.
- compiled_atTimestamp
- changesPolicyChange[]optional
policies.validate only: field-level changes from the version the edit started from.
PolicyChange: 5 fields
- pathstring
- labelstring
- beforestring | null
- afterstring | null
- effectstring enum
tightens = fewer payments go through; loosens = more do.
"neutral""tightens""loosens"
- base_version_idId | nulloptional
- change_summarystring
Short human summary of what changed from the previous version.
- based_on_version_idId | nulloptional
The version this one was edited from (null for the first).
- changesPolicyChange[]optional
Field-level changes from `based_on_version_id` (or the previous number).
PolicyChange: 5 fields
- pathstring
- labelstring
- beforestring | null
- afterstring | null
- effectstring enum
tightens = fewer payments go through; loosens = more do.
"neutral""tightens""loosens"
- 400invalid_request
A query parameter is invalid.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X GET "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/versions" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01"{
"object": "list",
"data": [
{
"id": "polv_01M4AZBHWEX6BPNM85336FAQ45",
"object": "policy_version",
"policy_id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"number": 2,
"status": "active",
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 2500000,
"asset": "USD"
},
"window": "month",
"time_zone": "America/Los_Angeles"
}
],
"limits": {
"per_payment": {
"amount": 600000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 300000,
"asset": "USD"
},
"timeout_minutes": 240,
"on_timeout": "escalate"
},
"risk": {
"velocity_per_10m": 6,
"spike_multiplier": 4,
"confidence_floor": 0.6,
"off_hours": false
}
},
"document_yaml": "# Agent spend policy: Cloud cost guard policy\n# Amounts are in minor units (cents); the comment shows dollars.\nversion: \"2026-11-01\"\nbudgets:\n - amount: { amount: 2500000, asset: USD } # $25,000.00\n window: month\n time_zone: America/Los_Angeles\nlimits:\n per_payment: { amount: 600000, asset: USD } # $6,000.00\napprovals:\n above: { amount: 300000, asset: USD } # $3,000.00\n timeout_minutes: …",
"content_hash": "sha256:78c174d74c47376d44604b2f11c3d415e1dc74c750c820ddce7978ffa9800f65",
"author": {
"id": "usr_01KDY2H3MEZQFZQ0R60FFMFZ3X",
"name": "Leo Novak"
},
"created_at": "2026-10-07T10:43:11.374Z",
"activated_at": "2026-10-07T11:38:11.374Z",
"activated_by": {
"id": "usr_01K9R5VQME4Q4FSCTVNGTV56C2",
"name": "Priya Raman"
},
"validation_report": {
"ok": true,
"issues": [
{
"severity": "info",
"code": "not_enforceable_natively",
"message": "AWS billing (AWS org 4410-…-8812) reports usage after the fact. ndStill can stop the key once a limit is crossed, but can't block a single payment there.",
"path": "limits.per_payment",
"connection": {
"id": "con_01KZMHZ7MEQ9KST6799SP0GF4G",
"name": "AWS billing"
}
}
],
"projections": [
{
"connection": {
"id": "con_01KMRYA6ME05ZXF7TQQQSF14VK",
"name": "ndStill card program"
},
"control_level": "authorize",
"rails": [
"card",
"network_token"
],
"native": [
"Budget",
"Per-payment limit"
],
"ndstill_only": [
"Approval above an amount",
"Risk thresholds"
]
},
{
"connection": {
"id": "con_01KZMHZ7MEQ9KST6799SP0GF4G",
"name": "AWS billing"
},
"control_level": "observe_stop",
"rails": [
"cloud"
],
"native": [
"Budget"
],
"ndstill_only": [
"Per-payment limit",
"Approval above an amount",
"Risk thresholds"
]
}
],
"compiled_at": "2026-10-07T10:43:11.374Z"
},
"change_summary": "Tighter velocity limit after a retry loop",
"based_on_version_id": "polv_01M0EV3QREVJ5AK92RTQXN47WQ",
"changes": [
{
"path": "risk.velocity_per_10m",
"label": "Velocity limit",
"before": "12 in 10 minutes",
"after": "6 in 10 minutes",
"effect": "tightens"
}
]
},
{
"id": "polv_01M0EV3QREVJ5AK92RTQXN47WQ",
"object": "policy_version",
"policy_id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"number": 1,
"status": "superseded",
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 2500000,
"asset": "USD"
},
"window": "month",
"time_zone": "America/Los_Angeles"
}
],
"limits": {
"per_payment": {
"amount": 600000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 300000,
"asset": "USD"
},
"timeout_minutes": 240,
"on_timeout": "escalate"
},
"risk": {
"velocity_per_10m": 12,
"spike_multiplier": 4,
"confidence_floor": 0.6,
"off_hours": false
}
},
"document_yaml": "# Agent spend policy: Cloud cost guard policy\n# Amounts are in minor units (cents); the comment shows dollars.\nversion: \"2026-11-01\"\nbudgets:\n - amount: { amount: 2500000, asset: USD } # $25,000.00\n window: month\n time_zone: America/Los_Angeles\nlimits:\n per_payment: { amount: 600000, asset: USD } # $6,000.00\napprovals:\n above: { amount: 300000, asset: USD } # $3,000.00\n timeout_minutes: …",
"content_hash": "sha256:ef6b06267c85a691e3153a5afeb29a9dd182f73e88988d293e72be72f3c7ce35",
"author": {
"id": "usr_01KD1R56ME94CCHFNYQB1CC01H",
"name": "Aisha Bello"
},
"created_at": "2026-08-20T05:43:11.374Z",
"activated_at": "2026-08-20T06:15:11.374Z",
"activated_by": {
"id": "usr_01K8M49NMEY9DX1Y08XB7WT6RT",
"name": "Marcus Lee"
},
"validation_report": {
"ok": true,
"issues": [
{
"severity": "info",
"code": "not_enforceable_natively",
"message": "AWS billing (AWS org 4410-…-8812) reports usage after the fact. ndStill can stop the key once a limit is crossed, but can't block a single payment there.",
"path": "limits.per_payment",
"connection": {
"id": "con_01KZMHZ7MEQ9KST6799SP0GF4G",
"name": "AWS billing"
}
}
],
"projections": [
{
"connection": {
"id": "con_01KMRYA6ME05ZXF7TQQQSF14VK",
"name": "ndStill card program"
},
"control_level": "authorize",
"rails": [
"card",
"network_token"
],
"native": [
"Budget",
"Per-payment limit"
],
"ndstill_only": [
"Approval above an amount",
"Risk thresholds"
]
},
{
"connection": {
"id": "con_01KZMHZ7MEQ9KST6799SP0GF4G",
"name": "AWS billing"
},
"control_level": "observe_stop",
"rails": [
"cloud"
],
"native": [
"Budget"
],
"ndstill_only": [
"Per-payment limit",
"Approval above an amount",
"Risk thresholds"
]
}
],
"compiled_at": "2026-08-20T05:43:11.374Z"
},
"change_summary": "First version",
"based_on_version_id": null,
"changes": []
}
],
"has_more": false,
"next_cursor": null,
"total": 2
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
Get a policy version#
/v2/policies/{id}/versions/{version_id}- idIdrequired
A prefixed ID from this org.
- version_idIdrequired
A prefixed ID from this org.
- idId
- object"policy_version"
- policy_idId
- numbernumber
- statusstring enum
"active""draft""superseded" - documentPolicyDocument
Agent spend policy document (backend plan §7). YAML or JSON; this is the JSON form.
PolicyDocument: 11 fields
- version"2026-11-01"
- budgetsobject[]optional
4 fields
- amountMoney
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- windowBudgetWindow
"day""week""month""quarter""total" - rollingbooleanoptional
- time_zonestringoptional
- limitsobjectoptional
2 fields
- per_paymentMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- per_day_countnumberoptional
- counterpartiesobjectoptional
2 fields
- allowstring[]optional
- blockstring[]optional
- categoriesobjectoptional
2 fields
- allowstring[]optional
- blockstring[]optional
- railsobjectoptional
1 field
- allowRail[]optional
"card""network_token""checkout_token""stablecoin""bank""ai""cloud"
- time_windowsobject[]optional
3 fields
- daysarray of string enum
"mon""tue""wed""thu""fri""sat""sun" - fromstring
- tostring
- approvalsobjectoptional
6 fields
- aboveMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- new_counterpartybooleanoptional
- routeobjectoptional
3 fields
- team_idIdoptional
- user_idsstring[]optional
- channelsarray of string enumoptional
"whatsapp""slack""push""email"
- assurancestring enumoptional
"passkey""any""dual" - timeout_minutesnumberoptional
- on_timeoutstring enumoptional
"reject""escalate"
- riskobjectoptional
4 fields
- velocity_per_10mnumberoptional
- spike_multipliernumberoptional
- confidence_floornumberoptional
- off_hoursbooleanoptional
- toleranceobject[]optional
2 fields
- mccstring
- percentnumber
- conditionsobject[]optional
CEL conditions: { when, then }.
3 fields
- namestring
- whenstring
- thenstring enum
"hold""decline""notify"
- document_yamlstring
The same document as YAML (what the code view edits).
- content_hashstring
- authorRef
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- created_atTimestamp
- activated_atTimestamp | null
- activated_byRef | null
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- validation_reportValidationReport
ValidationReport: 6 fields
- okboolean
- issuesValidationIssue[]
ValidationIssue: 6 fields
- severitystring enum
"error""info""warning" - codestring enum
"conflict""unreachable_rule""loosens_parent""not_enforceable_natively""schema""unknown_counterparty""unknown_field""invalid_condition" - messagestring
- pathstringoptional
JSON path in the document ("approvals.above", "conditions[1].when").
- connectionRef | nulloptional
For not_enforceable_natively: which connection can't express it.
Ref: 2 fields
- idId
- namestring
- parentobject | nulloptional
For loosens_parent: the parent policy whose rule this one loosens.
3 fields
- policy_idId
- namestring
- kindPolicyScopeKind
"team""org""agent""tree"
- projectionsPolicyProjection[]
Per connection: which rules become native limits, and which ndStill enforces alone.
PolicyProjection: 5 fields
- connectionRef
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- control_levelControlLevel
"authorize""issue""observe_stop" - railsRail[]optional
Rails the connection carries (for the rail icon).
"card""network_token""checkout_token""stablecoin""bank""ai""cloud" - nativestring[]
Rules written to the provider as native limits (a backstop if ndStill is unreachable).
- ndstill_onlystring[]
Rules only ndStill enforces, at decision time.
- compiled_atTimestamp
- changesPolicyChange[]optional
policies.validate only: field-level changes from the version the edit started from.
PolicyChange: 5 fields
- pathstring
- labelstring
- beforestring | null
- afterstring | null
- effectstring enum
tightens = fewer payments go through; loosens = more do.
"neutral""tightens""loosens"
- base_version_idId | nulloptional
- change_summarystring
Short human summary of what changed from the previous version.
- based_on_version_idId | nulloptional
The version this one was edited from (null for the first).
- changesPolicyChange[]optional
Field-level changes from `based_on_version_id` (or the previous number).
PolicyChange: 5 fields
- pathstring
- labelstring
- beforestring | null
- afterstring | null
- effectstring enum
tightens = fewer payments go through; loosens = more do.
"neutral""tightens""loosens"
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id or version_id in this org.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X GET "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/versions/polv_01M4AZBHWEX6BPNM85336FAQ45" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01"{
"id": "polv_01M4AZBHWEX6BPNM85336FAQ45",
"object": "policy_version",
"policy_id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"number": 2,
"status": "active",
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 2500000,
"asset": "USD"
},
"window": "month",
"time_zone": "America/Los_Angeles"
}
],
"limits": {
"per_payment": {
"amount": 600000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 300000,
"asset": "USD"
},
"timeout_minutes": 240,
"on_timeout": "escalate"
},
"risk": {
"velocity_per_10m": 6,
"spike_multiplier": 4,
"confidence_floor": 0.6,
"off_hours": false
}
},
"document_yaml": "# Agent spend policy: Cloud cost guard policy\n# Amounts are in minor units (cents); the comment shows dollars.\nversion: \"2026-11-01\"\nbudgets:\n - amount: { amount: 2500000, asset: USD } # $25,000.00\n window: month\n time_zone: America/Los_Angeles\nlimits:\n per_payment: { amount: 600000, asset: USD } # $6,000.00\napprovals:\n above: { amount: 300000, asset: USD } # $3,000.00\n timeout_minutes: …",
"content_hash": "sha256:78c174d74c47376d44604b2f11c3d415e1dc74c750c820ddce7978ffa9800f65",
"author": {
"id": "usr_01KDY2H3MEZQFZQ0R60FFMFZ3X",
"name": "Leo Novak"
},
"created_at": "2026-10-07T10:43:11.374Z",
"activated_at": "2026-10-07T11:38:11.374Z",
"activated_by": {
"id": "usr_01K9R5VQME4Q4FSCTVNGTV56C2",
"name": "Priya Raman"
},
"validation_report": {
"ok": true,
"issues": [
{
"severity": "info",
"code": "not_enforceable_natively",
"message": "AWS billing (AWS org 4410-…-8812) reports usage after the fact. ndStill can stop the key once a limit is crossed, but can't block a single payment there.",
"path": "limits.per_payment",
"connection": {
"id": "con_01KZMHZ7MEQ9KST6799SP0GF4G",
"name": "AWS billing"
}
}
],
"projections": [
{
"connection": {
"id": "con_01KMRYA6ME05ZXF7TQQQSF14VK",
"name": "ndStill card program"
},
"control_level": "authorize",
"rails": [
"card",
"network_token"
],
"native": [
"Budget",
"Per-payment limit"
],
"ndstill_only": [
"Approval above an amount",
"Risk thresholds"
]
},
{
"connection": {
"id": "con_01KZMHZ7MEQ9KST6799SP0GF4G",
"name": "AWS billing"
},
"control_level": "observe_stop",
"rails": [
"cloud"
],
"native": [
"Budget"
],
"ndstill_only": [
"Per-payment limit",
"Approval above an amount",
"Risk thresholds"
]
}
],
"compiled_at": "2026-10-07T10:43:11.374Z"
},
"change_summary": "Tighter velocity limit after a retry loop",
"based_on_version_id": "polv_01M0EV3QREVJ5AK92RTQXN47WQ",
"changes": [
{
"path": "risk.velocity_per_10m",
"label": "Velocity limit",
"before": "12 in 10 minutes",
"after": "6 in 10 minutes",
"effect": "tightens"
}
]
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
Activate a policy#
/v2/policies/{id}/activateMake a version live for everything in the policy's scope. Needs a passkey step-up when the org requires it.
- idIdrequired
A prefixed ID from this org.
- version_idIdrequired
- step_upstring
The same Policy object as Create a policy.
- 400invalid_request
A field is missing or invalid; fields names each one.
- 400step_up_required
A person must confirm with a passkey first, when the org requires it.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 409conflict
The object changed or already exists, or the Idempotency-Key was reused with a different body.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X POST "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/activate" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"version_id": null
}'{
"object": "error",
"type": "invalid_request",
"code": "invalid_request",
"message": "Pick a version of this policy to activate.",
"request_id": "req_0d33363fe0cdb5dd2430",
"fields": {
"version_id": "Unknown version"
}
}The mock answered this sample with an error; its message says why. Adjust the request in Try it below.
Runs against the in-browser mock with a test key. Nothing leaves your browser.
Replay history against a policy version#
/v2/policies/{id}/replayRe-run a window of stored decisions (up to 92 days) against a candidate version and get the diff: newly held, newly declined, newly allowed.
- idIdrequired
A prefixed ID from this org.
- policy_version_idIdrequired
- fromTimestamprequired
- toTimestamprequired
- upload_idId | null
Optional uploaded CSV/provider export instead of stored decisions.
- idId
- object"replay"
- policy_idId
- policy_version_idId
- fromTimestamp
- toTimestamp
- decisions_replayednumber
- changednumber
- totalsobject
5 fields
- newly_heldnumber
- newly_declinednumber
- newly_allowednumber
- amount_blockedMoney
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- amount_newly_allowedMoney
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- samplesobject[]
7 fields
- intent_idId
- agentRef
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- counterpartystring
- amountMoney
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- beforeDecisionOutcome
"approve""hold""decline" - afterDecisionOutcome
"approve""hold""decline" - reasonstring
- created_atTimestamp
- upload_idId | nulloptional
Set when the replay ran over an uploaded CSV instead of stored decisions.
- 400invalid_request
A field is missing or invalid; fields names each one.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 409conflict
The object changed or already exists, or the Idempotency-Key was reused with a different body.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X POST "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/replay" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"policy_version_id": null,
"from": "2026-10-24T00:43:13.537Z",
"to": "2026-11-23T00:43:13.537Z"
}'{
"object": "error",
"type": "invalid_request",
"code": "invalid_request",
"message": "Pick a version of this policy to replay.",
"request_id": "req_b389ab9f9d3f70692f39",
"fields": {
"policy_version_id": "Required"
}
}The mock answered this sample with an error; its message says why. Adjust the request in Try it below.
Runs against the in-browser mock with a test key. Nothing leaves your browser.
Simulate a payment against a policy#
/v2/policies/{id}/simulate- idIdrequired
A prefixed ID from this org.
- agent_idIdrequired
- amountMoneyrequired
An amount: integer minor units + asset.
Money: 2 fields
- amountnumberrequired
- assetAssetCoderequired
"USD""USDC""EUR""GBP"
- counterpartystringrequired
- railstring enum
"card""network_token""checkout_token""stablecoin""bank""ai""cloud" - mandate_idId | null
- policy_version_idId | null
Evaluate against a policy version other than the active one.
- purposestring
- idId
- object"simulation"
- would_outcomeDecisionOutcome
"approve""hold""decline" - traceTraceEntry[]
TraceEntry: 5 fields
- stageStageId
"freeze""approval""policy""mandate""authenticate""entitlement""funding""counterparty""risk""budget""record" - resultTraceResult
"hold""decline""pass""skip" - detailstringoptional
Plain-language detail ("Within the $500 weekly budget").
- codestringoptional
Machine reason code when the stage held or declined.
- msnumberoptional
Time spent in the stage.
- reasonsReason[]
Reason: 5 fields
- codestring
- stagestring enumoptional
Pipeline stage that produced it (absent for post-decision reasons).
"freeze""approval""policy""mandate""authenticate""entitlement""funding""counterparty""risk""budget""record" - effectstring enumoptional
"hold" or "decline" (what this reason did on its own).
"hold""decline" - messagestringoptional
Server-written sentence; used when the client has no template for the code.
- paramsReasonParamsoptional
ReasonParams: 15 fields
- agent_namestringoptional
- scope_namestringoptional
Whose budget: "Travel desk", "Engineering team", "the org".
- windowstring enumoptional
"day""week""month""quarter""total" - amountMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- limitMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- over_byMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- thresholdMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- counterpartystringoptional
- categorystringoptional
- mandate_counterpartystringoptional
- mandate_maxMoneyoptional
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- countnumberoptional
- minutesnumberoptional
- by_personstringoptional
- notestringoptional
- railRail
"card""network_token""checkout_token""stablecoin""bank""ai""cloud" - budget_impactBudgetImpact[]
BudgetImpact: 7 fields
- budget_idId
- scopeScope
Scope: 3 fields
- kindScopeKind
"team""org""agent""credential""tree""funding_source" - idId
- namestring
- windowstring enum
"day""week""month""quarter""total" - limitMoney
An amount: integer minor units + asset.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- beforeMoney
Spent before this payment.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- reservedMoney
Reserved by this payment.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- afterMoney
Spent + reserved after.
Money: 2 fields
- amountnumber
- assetAssetCode
"USD""USDC""EUR""GBP"
- policy_version_hashstring
- latency_msnumber
- created_atTimestamp
- 400invalid_request
A field is missing or invalid; fields names each one.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 409conflict
The object changed or already exists, or the Idempotency-Key was reused with a different body.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X POST "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/simulate" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agt_01KYW6M8REDTGCTQ2ZK0CMDADJ",
"amount": {
"amount": 12000,
"asset": "USD"
},
"counterparty": "AWS",
"rail": "card"
}'{
"id": "sim_01M82XPRQXCKMD2QA28G8H1NQ9",
"object": "simulation",
"would_outcome": "hold",
"trace": [
{
"stage": "authenticate",
"result": "pass",
"detail": "Agent key acme-robotics-cloud_cost_guard-c255b9 verified",
"ms": 4
},
{
"stage": "entitlement",
"result": "pass",
"detail": "Live mode; plan limits OK",
"ms": 2
},
{
"stage": "freeze",
"result": "pass",
"detail": "No freeze on the agent, its tree, team, org or funding source",
"ms": 6
},
{
"stage": "funding",
"result": "pass",
"detail": "Agent spend (ndStill account)",
"ms": 0
},
{
"stage": "counterparty",
"result": "pass",
"detail": "AWS (confidence 0.95)",
"ms": 6
},
{
"stage": "mandate",
"result": "pass",
"detail": "No mandate needed under the policy's line",
"ms": 4
},
{
"stage": "policy",
"result": "hold",
"detail": "First payment to AWS; policy holds new sellers.",
"code": "first_time_counterparty",
"ms": 5
},
{
"stage": "risk",
"result": "pass",
"detail": "Normal pace (2 payments in 10 min)",
"ms": 4
},
{
"stage": "budget",
"result": "hold",
"detail": "This would use the last of Cloud cost guard's monthly budget.",
"code": "budget_nearly_exhausted",
"ms": 21
},
{
"stage": "approval",
"result": "pass",
"detail": "Below the $3,000.00 approval line",
"ms": 6
},
{
"stage": "record",
"result": "pass",
"detail": "Decision signed (held)",
"ms": 18
}
],
"reasons": [
{
"code": "first_time_counterparty",
"stage": "policy",
"effect": "hold",
"params": {
"counterparty": "AWS"
}
},
{
"code": "budget_nearly_exhausted",
"stage": "budget",
"effect": "hold",
"params": {
"scope_name": "Cloud cost guard",
"window": "month"
}
}
],
"rail": "card",
"budget_impact": [
{
"budget_id": "bud_01KQZY6YME39QMP0871KJS9W81",
"scope": {
"kind": "org",
"id": "org_A99F918124609C9DAAACB209D8",
"name": "Acme Robotics"
},
"window": "month",
"limit": {
"amount": 27467800,
"asset": "USD"
},
"before": {
"amount": 19463451,
"asset": "USD"
},
"reserved": {
"amount": 12000,
"asset": "USD"
},
"after": {
"amount": 19475451,
"asset": "USD"
}
},
{
"budget_id": "bud_01KQZY6YMEZ4DQCWDS001FJGC4",
"scope": {
"kind": "team",
"id": "team_01K8HHWYMEW49G6SJBNWRTEJCX",
"name": "Platform"
},
"window": "month",
"limit": {
"amount": 3523500,
"asset": "USD"
},
"before": {
"amount": 2981963,
"asset": "USD"
},
"reserved": {
"amount": 12000,
"asset": "USD"
},
"after": {
"amount": 2993963,
"asset": "USD"
}
},
{
"budget_id": "bud_01KQZY6YME7WQHES9NFH75E6KZ",
"scope": {
"kind": "agent",
"id": "agt_01KYW6M8REDTGCTQ2ZK0CMDADJ",
"name": "Cloud cost guard"
},
"window": "month",
"limit": {
"amount": 2500000,
"asset": "USD"
},
"before": {
"amount": 2328841,
"asset": "USD"
},
"reserved": {
"amount": 12000,
"asset": "USD"
},
"after": {
"amount": 2340841,
"asset": "USD"
}
}
],
"policy_version_hash": "sha256:78c174d74c47376d44604b2f11c3d415e1dc74c750c820ddce7978ffa9800f65",
"latency_ms": 76,
"created_at": "2026-11-23T00:43:13.533Z"
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
Validate a policy#
/v2/policies/{id}/validateCompile a draft without saving it: schema, conflicts, unreachable rules, loosening a parent, CEL errors, and which rules each connection can enforce natively.
- idIdrequired
A prefixed ID from this org.
- documentPolicyDocument
Agent spend policy document (backend plan §7). YAML or JSON; this is the JSON form.
PolicyDocument: 11 fields
- 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"
- document_yamlstring
- change_summarystring
- base_version_idId | null
The version the edit started from; the server refuses a save that changes nothing.
- okboolean
- issuesValidationIssue[]
ValidationIssue: 6 fields
- severitystring enum
"error""info""warning" - codestring enum
"conflict""unreachable_rule""loosens_parent""not_enforceable_natively""schema""unknown_counterparty""unknown_field""invalid_condition" - messagestring
- pathstringoptional
JSON path in the document ("approvals.above", "conditions[1].when").
- connectionRef | nulloptional
For not_enforceable_natively: which connection can't express it.
Ref: 2 fields
- idId
- namestring
- parentobject | nulloptional
For loosens_parent: the parent policy whose rule this one loosens.
3 fields
- policy_idId
- namestring
- kindPolicyScopeKind
"team""org""agent""tree"
- projectionsPolicyProjection[]
Per connection: which rules become native limits, and which ndStill enforces alone.
PolicyProjection: 5 fields
- connectionRef
Small reference used for denormalized names in lists (no N+1 lookups in tables).
Ref: 2 fields
- idId
- namestring
- control_levelControlLevel
"authorize""issue""observe_stop" - railsRail[]optional
Rails the connection carries (for the rail icon).
"card""network_token""checkout_token""stablecoin""bank""ai""cloud" - nativestring[]
Rules written to the provider as native limits (a backstop if ndStill is unreachable).
- ndstill_onlystring[]
Rules only ndStill enforces, at decision time.
- compiled_atTimestamp
- changesPolicyChange[]optional
policies.validate only: field-level changes from the version the edit started from.
PolicyChange: 5 fields
- pathstring
- labelstring
- beforestring | null
- afterstring | null
- effectstring enum
tightens = fewer payments go through; loosens = more do.
"neutral""tightens""loosens"
- base_version_idId | nulloptional
- 400invalid_request
A field is missing or invalid; fields names each one.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 409conflict
The object changed or already exists, or the Idempotency-Key was reused with a different body.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X POST "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/validate" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 200000,
"asset": "USD"
},
"window": "month"
}
],
"limits": {
"per_payment": {
"amount": 50000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 25000,
"asset": "USD"
}
}
}
}'{
"ok": true,
"issues": [],
"projections": [
{
"connection": {
"id": "con_01KMRYA6ME05ZXF7TQQQSF14VK",
"name": "ndStill card program"
},
"control_level": "authorize",
"rails": [
"card",
"network_token"
],
"native": [
"Budget",
"Per-payment limit"
],
"ndstill_only": [
"Approval above an amount"
]
}
],
"compiled_at": "2026-11-23T00:43:13.529Z",
"base_version_id": "polv_01M4AZBHWEX6BPNM85336FAQ45",
"changes": [
{
"path": "budgets.month",
"label": "Monthly budget",
"before": "$25,000.00",
"after": "$2,000.00",
"effect": "tightens"
},
{
"path": "limits.per_payment",
"label": "Per-payment limit",
"before": "$6,000.00",
"after": "$500.00",
"effect": "tightens"
},
{
"path": "approvals.above",
"label": "Approval above",
"before": "$3,000.00",
"after": "$250.00",
"effect": "tightens"
}
]
}Runs against the in-browser mock with a test key. Nothing leaves your browser.
Save a policy version#
/v2/policies/{id}/versions- idIdrequired
A prefixed ID from this org.
- documentPolicyDocument
Agent spend policy document (backend plan §7). YAML or JSON; this is the JSON form.
PolicyDocument: 11 fields
- 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"
- document_yamlstring
- change_summarystring
- base_version_idId | null
The version the edit started from; the server refuses a save that changes nothing.
The same PolicyVersion object as Get a policy version.
- 400invalid_request
A field is missing or invalid; fields names each one.
- 401authentication
The key or token is missing, expired or revoked.
- 403permission
The key's scopes or the person's role don't allow this.
- 404not_found
No object with that id in this org.
- 409conflict
The object changed or already exists, or the Idempotency-Key was reused with a different body.
- 429rate_limited
Slow down; retry after the Retry-After header.
curl -X POST "https://api.ndstill.com/v2/policies/pol_01KWG4F6ME9ZR9XNY1AVAY1JM2/versions" \
-H "Authorization: Bearer $NDSTILL_API_KEY" \
-H "Ndstill-Version: 2026-11-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 150000,
"asset": "USD"
},
"window": "month"
}
],
"limits": {
"per_payment": {
"amount": 40000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 20000,
"asset": "USD"
},
"new_counterparty": true
}
},
"change_summary": "Tighter limits from the docs"
}'{
"id": "polv_01M82XPRQT86A53RK11PRPX4H7",
"object": "policy_version",
"policy_id": "pol_01KWG4F6ME9ZR9XNY1AVAY1JM2",
"number": 3,
"status": "draft",
"document": {
"version": "2026-11-01",
"budgets": [
{
"amount": {
"amount": 150000,
"asset": "USD"
},
"window": "month"
}
],
"limits": {
"per_payment": {
"amount": 40000,
"asset": "USD"
}
},
"approvals": {
"above": {
"amount": 20000,
"asset": "USD"
},
"new_counterparty": true
}
},
"document_yaml": "# Agent spend policy: Cloud cost guard policy\n# Amounts are in minor units (cents); the comment shows dollars.\nversion: \"2026-11-01\"\nbudgets:\n - amount: { amount: 150000, asset: USD } # $1,500.00\n window: month\nlimits:\n per_payment: { amount: 40000, asset: USD } # $400.00\napprovals:\n above: { amount: 20000, asset: USD } # $200.00\n new_counterparty: true\n",
"content_hash": "sha256:22c65a03dc97ccdd10b55ceb33f017b5608b5ff3b5b36b2d8723907bb89294e5",
"author": {
"id": "usr_01K7WYQ6MEYNYVHTQCVYZCTCDX",
"name": "Dana Whitfield"
},
"created_at": "2026-11-23T00:43:13.530Z",
"activated_at": null,
"activated_by": null,
"validation_report": {
"ok": true,
"issues": [],
"projections": [
{
"connection": {
"id": "con_01KMRYA6ME05ZXF7TQQQSF14VK",
"name": "ndStill card program"
},
"control_level": "authorize",
"rails": [
"card",
"network_token"
],
"native": [
"Budget",
"Per-payment limit"
],
"ndstill_only": [
"Approval above an amount",
"Approval for new sellers"
]
}
],
"compiled_at": "2026-11-23T00:43:13.530Z"
},
"change_summary": "Tighter limits from the docs",
"based_on_version_id": "polv_01M4AZBHWEX6BPNM85336FAQ45",
"changes": [
{
"path": "budgets.month",
"label": "Monthly budget",
"before": "$25,000.00",
"after": "$1,500.00",
"effect": "tightens"
},
{
"path": "limits.per_payment",
"label": "Per-payment limit",
"before": "$6,000.00",
"after": "$400.00",
"effect": "tightens"
},
{
"path": "approvals.above",
"label": "Approval above",
"before": "$3,000.00",
"after": "$200.00",
"effect": "tightens"
}
]
}Runs against the in-browser mock with a test key. Nothing leaves your browser.