Skip to content
Start here

Spend Policies

List Spend Policies
GET/accounts/{account_id}/billing/spend-policies
Create Spend Policy
POST/accounts/{account_id}/billing/spend-policies
Get Spend Policy
GET/accounts/{account_id}/billing/spend-policies/{policy_id}
Update Spend Policy
PUT/accounts/{account_id}/billing/spend-policies/{policy_id}
Delete Spend Policy
DELETE/accounts/{account_id}/billing/spend-policies/{policy_id}
ModelsExpand Collapse
SpendPolicyListResponse object { id, account_id, action, 7 more }

A spend policy.

id: string

The unique identifier of the spend policy.

formatuuid
account_id: number

Internal numeric ID of the account that owns the policy. This is not the account tag used in the path.

formatint64
action: "notification" or "usage_block"

The action taken when the threshold is reached. notification sends an email to notification_email. usage_block blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.

One of the following:
"notification"
"usage_block"
enabled: boolean

Whether the policy is evaluated.

name: string

Display name of the policy.

notification_email: string

Email address that receives notifications. An empty string when none is set.

product_id: "workers" or "durable_objects"

The product the policy applies to: workers or durable_objects. Each product’s balance and policies are separate. Both products support notification and usage_block policies on create and update.

One of the following:
"workers"
"durable_objects"
threshold_cents: number

The spend threshold for the current billing period, in US cents.

formatint64
version: number

Optimistic-concurrency version. It starts at 1 and goes up by one on every update or delete. This value is also returned in ETag.

formatint64
minimum1
current_state: optional object { balance_cents, billing_period_end, billing_period_start, 3 more }

Read-only state on list/get responses, evaluated from the latest owning projector snapshot at request time, independently of the API replica. Configuration enabled/version/ETag do not change when a cycle rolls over. Audit history remains unchanged. Missing during a rolling upgrade or on mutation responses; clients must treat missing state as unavailable. Balances are asynchronous estimates, not a synchronous usage read.

balance_cents: number
formatint64
billing_period_end: string
formatdate-time
billing_period_start: string
formatdate-time
enforcement: object { applied_generation, delivery_status, desired_generation, 2 more }

Durable desired cap and delivery bookkeeping for this policy, or null if no owned effect exists. Separate from threshold evaluation: pending/leased/retry can lag the new billing period. Succeeded with equal generations means delivery completed, not an EWC readback.

applied_generation: number
formatint64
delivery_status: "pending" or "leased" or "retry" or "succeeded"
One of the following:
"pending"
"leased"
"retry"
"succeeded"
desired_generation: number
formatint64
desired_state: "active" or "inactive"
One of the following:
"active"
"inactive"
expires_at: string
formatdate-time
evaluated_at: string

Evaluation time; not the timestamp of the latest usage event.

formatdate-time
status: "disabled" or "no_current_period" or "unavailable" or 3 more

Threshold evaluation, not proof of an edge cap. No current active period yields no_current_period for enabled policies; failed aggregate reads yield unavailable for enabled policies. Disabled policies report disabled. Neither no_current_period nor unavailable implies a zero balance or below-limit state. Operators may disable current-state reads, in which case current_state is omitted.

One of the following:
"disabled"
"no_current_period"
"unavailable"
"below_limit"
"approaching_limit"
"limit_reached"
SpendPolicyCreateResponse object { id, account_id, action, 7 more }

A spend policy.

id: string

The unique identifier of the spend policy.

formatuuid
account_id: number

Internal numeric ID of the account that owns the policy. This is not the account tag used in the path.

formatint64
action: "notification" or "usage_block"

The action taken when the threshold is reached. notification sends an email to notification_email. usage_block blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.

One of the following:
"notification"
"usage_block"
enabled: boolean

Whether the policy is evaluated.

name: string

Display name of the policy.

notification_email: string

Email address that receives notifications. An empty string when none is set.

product_id: "workers" or "durable_objects"

The product the policy applies to: workers or durable_objects. Each product’s balance and policies are separate. Both products support notification and usage_block policies on create and update.

One of the following:
"workers"
"durable_objects"
threshold_cents: number

The spend threshold for the current billing period, in US cents.

formatint64
version: number

Optimistic-concurrency version. It starts at 1 and goes up by one on every update or delete. This value is also returned in ETag.

formatint64
minimum1
current_state: optional object { balance_cents, billing_period_end, billing_period_start, 3 more }

Read-only state on list/get responses, evaluated from the latest owning projector snapshot at request time, independently of the API replica. Configuration enabled/version/ETag do not change when a cycle rolls over. Audit history remains unchanged. Missing during a rolling upgrade or on mutation responses; clients must treat missing state as unavailable. Balances are asynchronous estimates, not a synchronous usage read.

balance_cents: number
formatint64
billing_period_end: string
formatdate-time
billing_period_start: string
formatdate-time
enforcement: object { applied_generation, delivery_status, desired_generation, 2 more }

Durable desired cap and delivery bookkeeping for this policy, or null if no owned effect exists. Separate from threshold evaluation: pending/leased/retry can lag the new billing period. Succeeded with equal generations means delivery completed, not an EWC readback.

applied_generation: number
formatint64
delivery_status: "pending" or "leased" or "retry" or "succeeded"
One of the following:
"pending"
"leased"
"retry"
"succeeded"
desired_generation: number
formatint64
desired_state: "active" or "inactive"
One of the following:
"active"
"inactive"
expires_at: string
formatdate-time
evaluated_at: string

Evaluation time; not the timestamp of the latest usage event.

formatdate-time
status: "disabled" or "no_current_period" or "unavailable" or 3 more

Threshold evaluation, not proof of an edge cap. No current active period yields no_current_period for enabled policies; failed aggregate reads yield unavailable for enabled policies. Disabled policies report disabled. Neither no_current_period nor unavailable implies a zero balance or below-limit state. Operators may disable current-state reads, in which case current_state is omitted.

One of the following:
"disabled"
"no_current_period"
"unavailable"
"below_limit"
"approaching_limit"
"limit_reached"
SpendPolicyGetResponse object { id, account_id, action, 7 more }

A spend policy.

id: string

The unique identifier of the spend policy.

formatuuid
account_id: number

Internal numeric ID of the account that owns the policy. This is not the account tag used in the path.

formatint64
action: "notification" or "usage_block"

The action taken when the threshold is reached. notification sends an email to notification_email. usage_block blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.

One of the following:
"notification"
"usage_block"
enabled: boolean

Whether the policy is evaluated.

name: string

Display name of the policy.

notification_email: string

Email address that receives notifications. An empty string when none is set.

product_id: "workers" or "durable_objects"

The product the policy applies to: workers or durable_objects. Each product’s balance and policies are separate. Both products support notification and usage_block policies on create and update.

One of the following:
"workers"
"durable_objects"
threshold_cents: number

The spend threshold for the current billing period, in US cents.

formatint64
version: number

Optimistic-concurrency version. It starts at 1 and goes up by one on every update or delete. This value is also returned in ETag.

formatint64
minimum1
current_state: optional object { balance_cents, billing_period_end, billing_period_start, 3 more }

Read-only state on list/get responses, evaluated from the latest owning projector snapshot at request time, independently of the API replica. Configuration enabled/version/ETag do not change when a cycle rolls over. Audit history remains unchanged. Missing during a rolling upgrade or on mutation responses; clients must treat missing state as unavailable. Balances are asynchronous estimates, not a synchronous usage read.

balance_cents: number
formatint64
billing_period_end: string
formatdate-time
billing_period_start: string
formatdate-time
enforcement: object { applied_generation, delivery_status, desired_generation, 2 more }

Durable desired cap and delivery bookkeeping for this policy, or null if no owned effect exists. Separate from threshold evaluation: pending/leased/retry can lag the new billing period. Succeeded with equal generations means delivery completed, not an EWC readback.

applied_generation: number
formatint64
delivery_status: "pending" or "leased" or "retry" or "succeeded"
One of the following:
"pending"
"leased"
"retry"
"succeeded"
desired_generation: number
formatint64
desired_state: "active" or "inactive"
One of the following:
"active"
"inactive"
expires_at: string
formatdate-time
evaluated_at: string

Evaluation time; not the timestamp of the latest usage event.

formatdate-time
status: "disabled" or "no_current_period" or "unavailable" or 3 more

Threshold evaluation, not proof of an edge cap. No current active period yields no_current_period for enabled policies; failed aggregate reads yield unavailable for enabled policies. Disabled policies report disabled. Neither no_current_period nor unavailable implies a zero balance or below-limit state. Operators may disable current-state reads, in which case current_state is omitted.

One of the following:
"disabled"
"no_current_period"
"unavailable"
"below_limit"
"approaching_limit"
"limit_reached"
SpendPolicyUpdateResponse object { id, account_id, action, 7 more }

A spend policy.

id: string

The unique identifier of the spend policy.

formatuuid
account_id: number

Internal numeric ID of the account that owns the policy. This is not the account tag used in the path.

formatint64
action: "notification" or "usage_block"

The action taken when the threshold is reached. notification sends an email to notification_email. usage_block blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.

One of the following:
"notification"
"usage_block"
enabled: boolean

Whether the policy is evaluated.

name: string

Display name of the policy.

notification_email: string

Email address that receives notifications. An empty string when none is set.

product_id: "workers" or "durable_objects"

The product the policy applies to: workers or durable_objects. Each product’s balance and policies are separate. Both products support notification and usage_block policies on create and update.

One of the following:
"workers"
"durable_objects"
threshold_cents: number

The spend threshold for the current billing period, in US cents.

formatint64
version: number

Optimistic-concurrency version. It starts at 1 and goes up by one on every update or delete. This value is also returned in ETag.

formatint64
minimum1
current_state: optional object { balance_cents, billing_period_end, billing_period_start, 3 more }

Read-only state on list/get responses, evaluated from the latest owning projector snapshot at request time, independently of the API replica. Configuration enabled/version/ETag do not change when a cycle rolls over. Audit history remains unchanged. Missing during a rolling upgrade or on mutation responses; clients must treat missing state as unavailable. Balances are asynchronous estimates, not a synchronous usage read.

balance_cents: number
formatint64
billing_period_end: string
formatdate-time
billing_period_start: string
formatdate-time
enforcement: object { applied_generation, delivery_status, desired_generation, 2 more }

Durable desired cap and delivery bookkeeping for this policy, or null if no owned effect exists. Separate from threshold evaluation: pending/leased/retry can lag the new billing period. Succeeded with equal generations means delivery completed, not an EWC readback.

applied_generation: number
formatint64
delivery_status: "pending" or "leased" or "retry" or "succeeded"
One of the following:
"pending"
"leased"
"retry"
"succeeded"
desired_generation: number
formatint64
desired_state: "active" or "inactive"
One of the following:
"active"
"inactive"
expires_at: string
formatdate-time
evaluated_at: string

Evaluation time; not the timestamp of the latest usage event.

formatdate-time
status: "disabled" or "no_current_period" or "unavailable" or 3 more

Threshold evaluation, not proof of an edge cap. No current active period yields no_current_period for enabled policies; failed aggregate reads yield unavailable for enabled policies. Disabled policies report disabled. Neither no_current_period nor unavailable implies a zero balance or below-limit state. Operators may disable current-state reads, in which case current_state is omitted.

One of the following:
"disabled"
"no_current_period"
"unavailable"
"below_limit"
"approaching_limit"
"limit_reached"
SpendPolicyDeleteResponse object { id }
id: string

The unique identifier of the spend policy.

formatuuid

Spend PoliciesAudit

List Spend Policy Audit Entries
GET/accounts/{account_id}/billing/spend-policies/{policy_id}/audit
ModelsExpand Collapse
AuditListResponse object { action, balance_cents, billing_period_end, 7 more }

A state transition recorded when the policy was evaluated against the account’s balance.

action: "notification" or "usage_block"

The action taken when the threshold is reached. notification sends an email to notification_email. usage_block blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.

One of the following:
"notification"
"usage_block"
balance_cents: number

The account’s balance for the product at evaluation time, in US cents.

formatint64
billing_period_end: string

Exclusive end of the billing period that was evaluated.

formatdate-time
billing_period_start: string

Inclusive start of the billing period that was evaluated.

formatdate-time
created_at: string

When the entry was recorded.

formatdate-time
policy_version: number

The policy version that was evaluated.

formatint64
reason: string

A human-readable explanation of the trigger.

source: "kafka" or "policy_revision"

What caused the evaluation. kafka means a balance update. policy_revision means a change to the policy.

One of the following:
"kafka"
"policy_revision"
threshold_cents: number

The policy threshold at evaluation time, in US cents.

formatint64
trigger: "approaching_limit" or "limit_reached"

The state the balance moved into. approaching_limit means the balance is at least 80% of the threshold (rounded up to a whole cent), but below the threshold. limit_reached means the balance reached or exceeded the threshold.

One of the following:
"approaching_limit"
"limit_reached"

Spend PoliciesActivity

List Spend Policy Activity
GET/accounts/{account_id}/billing/spend-policies/activity
ModelsExpand Collapse
ActivityListResponse object { id, action, actor, 5 more }
id: string
action: "created" or "updated" or "enabled" or 2 more
One of the following:
"created"
"updated"
"enabled"
"disabled"
"deleted"
actor: string

Verified actor identifier, unknown when absent, or trusted internal actor.

details: object { after, before }
after: optional object { id, account_id, action, 7 more }

A spend policy.

id: string

The unique identifier of the spend policy.

formatuuid
account_id: number

Internal numeric ID of the account that owns the policy. This is not the account tag used in the path.

formatint64
action: "notification" or "usage_block"

The action taken when the threshold is reached. notification sends an email to notification_email. usage_block blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.

One of the following:
"notification"
"usage_block"
enabled: boolean

Whether the policy is evaluated.

name: string

Display name of the policy.

notification_email: string

Email address that receives notifications. An empty string when none is set.

product_id: "workers" or "durable_objects"

The product the policy applies to: workers or durable_objects. Each product’s balance and policies are separate. Both products support notification and usage_block policies on create and update.

One of the following:
"workers"
"durable_objects"
threshold_cents: number

The spend threshold for the current billing period, in US cents.

formatint64
version: number

Optimistic-concurrency version. It starts at 1 and goes up by one on every update or delete. This value is also returned in ETag.

formatint64
minimum1
current_state: optional object { balance_cents, billing_period_end, billing_period_start, 3 more }

Read-only state on list/get responses, evaluated from the latest owning projector snapshot at request time, independently of the API replica. Configuration enabled/version/ETag do not change when a cycle rolls over. Audit history remains unchanged. Missing during a rolling upgrade or on mutation responses; clients must treat missing state as unavailable. Balances are asynchronous estimates, not a synchronous usage read.

balance_cents: number
formatint64
billing_period_end: string
formatdate-time
billing_period_start: string
formatdate-time
enforcement: object { applied_generation, delivery_status, desired_generation, 2 more }

Durable desired cap and delivery bookkeeping for this policy, or null if no owned effect exists. Separate from threshold evaluation: pending/leased/retry can lag the new billing period. Succeeded with equal generations means delivery completed, not an EWC readback.

applied_generation: number
formatint64
delivery_status: "pending" or "leased" or "retry" or "succeeded"
One of the following:
"pending"
"leased"
"retry"
"succeeded"
desired_generation: number
formatint64
desired_state: "active" or "inactive"
One of the following:
"active"
"inactive"
expires_at: string
formatdate-time
evaluated_at: string

Evaluation time; not the timestamp of the latest usage event.

formatdate-time
status: "disabled" or "no_current_period" or "unavailable" or 3 more

Threshold evaluation, not proof of an edge cap. No current active period yields no_current_period for enabled policies; failed aggregate reads yield unavailable for enabled policies. Disabled policies report disabled. Neither no_current_period nor unavailable implies a zero balance or below-limit state. Operators may disable current-state reads, in which case current_state is omitted.

One of the following:
"disabled"
"no_current_period"
"unavailable"
"below_limit"
"approaching_limit"
"limit_reached"
before: optional object { id, account_id, action, 7 more }

Prior configuration; null on creation or if a previous revision is unavailable.

id: string

The unique identifier of the spend policy.

formatuuid
account_id: number

Internal numeric ID of the account that owns the policy. This is not the account tag used in the path.

formatint64
action: "notification" or "usage_block"

The action taken when the threshold is reached. notification sends an email to notification_email. usage_block blocks further usage of the product until the end of the billing period. Raising the threshold above the current balance, disabling the policy, or deleting it lifts the block early.

One of the following:
"notification"
"usage_block"
enabled: boolean

Whether the policy is evaluated.

name: string

Display name of the policy.

notification_email: string

Email address that receives notifications. An empty string when none is set.

product_id: "workers" or "durable_objects"

The product the policy applies to: workers or durable_objects. Each product’s balance and policies are separate. Both products support notification and usage_block policies on create and update.

One of the following:
"workers"
"durable_objects"
threshold_cents: number

The spend threshold for the current billing period, in US cents.

formatint64
version: number

Optimistic-concurrency version. It starts at 1 and goes up by one on every update or delete. This value is also returned in ETag.

formatint64
minimum1
current_state: optional object { balance_cents, billing_period_end, billing_period_start, 3 more }

Read-only state on list/get responses, evaluated from the latest owning projector snapshot at request time, independently of the API replica. Configuration enabled/version/ETag do not change when a cycle rolls over. Audit history remains unchanged. Missing during a rolling upgrade or on mutation responses; clients must treat missing state as unavailable. Balances are asynchronous estimates, not a synchronous usage read.

balance_cents: number
formatint64
billing_period_end: string
formatdate-time
billing_period_start: string
formatdate-time
enforcement: object { applied_generation, delivery_status, desired_generation, 2 more }

Durable desired cap and delivery bookkeeping for this policy, or null if no owned effect exists. Separate from threshold evaluation: pending/leased/retry can lag the new billing period. Succeeded with equal generations means delivery completed, not an EWC readback.

applied_generation: number
formatint64
delivery_status: "pending" or "leased" or "retry" or "succeeded"
One of the following:
"pending"
"leased"
"retry"
"succeeded"
desired_generation: number
formatint64
desired_state: "active" or "inactive"
One of the following:
"active"
"inactive"
expires_at: string
formatdate-time
evaluated_at: string

Evaluation time; not the timestamp of the latest usage event.

formatdate-time
status: "disabled" or "no_current_period" or "unavailable" or 3 more

Threshold evaluation, not proof of an edge cap. No current active period yields no_current_period for enabled policies; failed aggregate reads yield unavailable for enabled policies. Disabled policies report disabled. Neither no_current_period nor unavailable implies a zero balance or below-limit state. Operators may disable current-state reads, in which case current_state is omitted.

One of the following:
"disabled"
"no_current_period"
"unavailable"
"below_limit"
"approaching_limit"
"limit_reached"
occurred_at: string
formatdate-time
policy_id: string

The unique identifier of the spend policy.

formatuuid
policy_version: number
formatint64
minimum1
product_id: string