> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://docs.prividium.com/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# policy

Governance policy endpoints

## Get the active ruleset

`GET /organizations/{id}/policy/ruleset`

Get the active policy ruleset for an organization

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `ruleset` `object` _(required)_: The published ruleset, or null when no ruleset has been published.
  - `id` `string` _(required)_: The ruleset ID.
  - `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
  - `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
  - `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
  - `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
    - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
    - `name` `string` _(required)_: Display name of the rule.
    - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
    - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
    - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
    - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
    - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
      - `users` `string[]`: User IDs whose operations match.
      - `m2mApps` `string[]`: M2M application IDs whose operations match.
      - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
    - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
      - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
      - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
    - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
      - `addresses` `string[]`: Destination addresses that match.
      - `contracts` `string[]`: Contract addresses that match as the destination.
      - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
    - `method` `object`: Matches a contract call by its function selector.
      - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
    - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
      - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
    - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
    - `asset` `object`: Matches the asset the operation moves.
      - `native` `boolean`: Set to `true` to match operations that move the native token.
      - `addresses` `string[]`: Token contract addresses that match.
    - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
      - `min` `string`: Inclusive lower bound in base units, as a decimal string.
      - `max` `string`: Inclusive upper bound in base units, as a decimal string.
    - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
      - `max` `string` _(required)_: Allowance in base units, as a decimal string.
      - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
      - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
    - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
    - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
      - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
      - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
        - `roleId` `string` _(required)_: Role whose holders can approve for this group.
        - `threshold` `integer` _(required)_: Number of approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
      - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
  - `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
  - `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
  - `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
  - `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
  - `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
  - `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
  - `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
  - `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
  - `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `rules` `object[]` _(required)_: The active rules, empty when no ruleset has been published.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, true when no ruleset has been published.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/ruleset
```

```ts
fetch('/api/organizations/string/policy/ruleset')
```

## List ruleset versions

`GET /organizations/{id}/policy/rulesets`

List the policy ruleset versions for an organization, newest first, including the draft and superseded versions

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `items` `object[]` _(required)_: The items on this page.
  - `id` `string` _(required)_: The ruleset ID.
  - `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
  - `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
  - `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
  - `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
    - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
    - `name` `string` _(required)_: Display name of the rule.
    - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
    - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
    - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
    - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
    - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
      - `users` `string[]`: User IDs whose operations match.
      - `m2mApps` `string[]`: M2M application IDs whose operations match.
      - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
    - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
      - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
      - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
    - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
      - `addresses` `string[]`: Destination addresses that match.
      - `contracts` `string[]`: Contract addresses that match as the destination.
      - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
    - `method` `object`: Matches a contract call by its function selector.
      - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
    - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
      - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
    - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
    - `asset` `object`: Matches the asset the operation moves.
      - `native` `boolean`: Set to `true` to match operations that move the native token.
      - `addresses` `string[]`: Token contract addresses that match.
    - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
      - `min` `string`: Inclusive lower bound in base units, as a decimal string.
      - `max` `string`: Inclusive upper bound in base units, as a decimal string.
    - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
      - `max` `string` _(required)_: Allowance in base units, as a decimal string.
      - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
      - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
    - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
    - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
      - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
      - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
        - `roleId` `string` _(required)_: Role whose holders can approve for this group.
        - `threshold` `integer` _(required)_: Number of approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
      - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
  - `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
  - `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
  - `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
  - `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
  - `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
  - `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
  - `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
  - `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
  - `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `pagination` `object` _(required)_: Paging details for the result.
  - `currentPage` `number` _(required)_: The 1-based number of this page.
  - `totalPages` `number` _(required)_: The number of pages at the current limit.
  - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
  - `limit` `number` _(required)_: The maximum number of items per page.
  - `offset` `number` _(required)_: The number of items skipped before this page.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/organizations/string/policy/rulesets?limit=10&offset=0'
```

```ts
fetch('/api/organizations/string/policy/rulesets?limit=10&offset=0')
```

## Get the draft ruleset

`GET /organizations/{id}/policy/draft`

Get the editable policy draft for an organization

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The ruleset ID.
- `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
- `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
- `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
- `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
- `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
- `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
- `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
- `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
- `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
- `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
- `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
- `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `outdated` `boolean` _(required)_: Whether the draft was saved against an older rule schema and must be saved again before publishing.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/draft
```

```ts
fetch('/api/organizations/string/policy/draft')
```

## Save the draft ruleset

`PUT /organizations/{id}/policy/draft`

Create or replace the policy draft for an organization

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Request body (required) (`application/json`)

- `rules` `object[]` _(required)_: The complete ordered rule list, which replaces the rules in the draft.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean`: Whether the default rule blocks operations no rule matches, true when omitted.
- `note` `string`: A free-text note for the draft, up to 500 characters.
- `baseDigest` `string | null`: The rulesDigest of the draft the edit started from, or null for no draft, and the save fails with 409 when the stored draft differs from it.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The ruleset ID.
- `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
- `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
- `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
- `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
- `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
- `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
- `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
- `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
- `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
- `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
- `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
- `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/draft \
  --request PUT \
  --header 'Content-Type: application/json' \
  --data '{
  "rules": [
    {
      "id": "string",
      "name": "string",
      "group": "string",
      "enabled": true,
      "action": "allow",
      "operation": "deploy",
      "initiator": {
        "users": [
          "string"
        ],
        "m2mApps": [
          "string"
        ],
        "roles": [
          "string"
        ]
      },
      "source": {
        "wallets": [
          "string"
        ],
        "roles": [
          "string"
        ]
      },
      "destination": {
        "addresses": [
          "string"
        ],
        "contracts": [
          "string"
        ],
        "classification": [
          "contract"
        ]
      },
      "method": {
        "selectors": [
          "string"
        ]
      },
      "typedMessage": {
        "primaryTypes": [
          "string"
        ]
      },
      "params": [
        {
          "index": 0,
          "kind": "address_in",
          "values": []
        }
      ],
      "asset": {
        "native": true,
        "addresses": [
          "string"
        ]
      },
      "amount": {
        "min": "string",
        "max": "string"
      },
      "spendOver": {
        "max": "string",
        "windowSeconds": 0,
        "scopeBy": [
          "initiator"
        ]
      },
      "approval": {
        "logic": "and",
        "groups": [
          {
            "roleId": "string",
            "threshold": 0
          }
        ],
        "initiatorMayApprove": true,
        "allowMachineApprovers": true,
        "expirySeconds": 0
      }
    }
  ],
  "terminalDenyEnabled": true,
  "note": "string",
  "baseDigest": "string"
}'
```

```ts
fetch('/api/organizations/string/policy/draft', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    rules: [
      {
        id: 'string',
        name: 'string',
        group: 'string',
        enabled: true,
        action: 'allow',
        operation: 'deploy',
        initiator: {
          users: ['string'],
          m2mApps: ['string'],
          roles: ['string']
        },
        source: {
          wallets: ['string'],
          roles: ['string']
        },
        destination: {
          addresses: ['string'],
          contracts: ['string'],
          classification: ['contract']
        },
        method: {
          selectors: ['string']
        },
        typedMessage: {
          primaryTypes: ['string']
        },
        params: [
          {
            index: 0,
            kind: 'address_in',
            values: []
          }
        ],
        asset: {
          native: true,
          addresses: ['string']
        },
        amount: {
          min: 'string',
          max: 'string'
        },
        spendOver: {
          max: 'string',
          windowSeconds: 0,
          scopeBy: ['initiator']
        },
        approval: {
          logic: 'and',
          groups: [
            {
              roleId: 'string',
              threshold: 0
            }
          ],
          initiatorMayApprove: true,
          allowMachineApprovers: true,
          expirySeconds: 0
        }
      }
    ],
    terminalDenyEnabled: true,
    note: 'string',
    baseDigest: 'string'
  })
})
```

## Discard the draft ruleset

`DELETE /organizations/{id}/policy/draft`

Discard the policy draft for an organization

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Responses

#### `204`: Default Response

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/draft \
  --request DELETE
```

```ts
fetch('/api/organizations/string/policy/draft', {
  method: 'DELETE'
})
```

## Validate the draft ruleset

`GET /organizations/{id}/policy/draft/validation`

Validate the policy draft, reporting reference and structural issues and whether it can be published

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `issues` `object[]` _(required)_: Every issue found in the draft.
  - `severity` `string` _(required)_: How serious the issue is: an error blocks publication and a warning does not.
  - `code` `string` _(required)_: The kind of issue: the unknown_ codes name a reference that does not exist, spend_limit_without_amount and inapplicable_condition flag a condition the operation cannot carry, approval_threshold_unreachable flags a group with fewer role members than its threshold, unconditional_rule flags a rule that constrains nothing, unregistered_asset flags a token that is not a registered contract, and terminal_deny_disabled flags the default rule being off.
  - `message` `string` _(required)_: A human-readable explanation of the issue.
  - `ruleId` `string` _(required)_: The ID of the rule the issue concerns, or policy.default_deny for the default rule.
- `publishable` `boolean` _(required)_: Whether the draft has no error-severity issues.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/draft/validation
```

```ts
fetch('/api/organizations/string/policy/draft/validation')
```

## Compare the draft and active rulesets

`GET /organizations/{id}/policy/draft/diff`

Compare the policy draft against the active ruleset

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `changes` `object[]` _(required)_: One entry per rule in the draft or the active ruleset, followed by an entry for the default rule when its setting changed.
  - `kind` `string` _(required)_: How the rule differs: added is only in the draft, removed is only in the active ruleset, changed differs in at least one field, and unchanged is identical.
  - `ruleId` `string` _(required)_: The ID of the rule, or policy.default_deny for a change to the default rule.
  - `name` `string` _(required)_: The rule name.
  - `previousPosition` `integer`: The rule position in the active ruleset, which the diff does not currently set.
  - `position` `integer`: The rule position in the draft, which the diff does not currently set.
  - `changedFields` `object[]`: The fields that differ, present when kind is changed.
    - `field` `string` _(required)_: The name of the rule field that differs.
    - `before` `unknown`: The field value in the active ruleset, absent when it is unset there.
    - `after` `unknown`: The field value in the draft, absent when it is unset there.
  - `moved` `boolean`: Whether the rule was reordered, which the diff does not currently set.
- `identical` `boolean` _(required)_: Whether the draft and the active ruleset have the same rules and default-rule setting, ignoring rule order.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/draft/diff
```

```ts
fetch('/api/organizations/string/policy/draft/diff')
```

## Load a version into the draft

`POST /organizations/{id}/policy/draft/rollback`

Load a previous ruleset version into the draft so it can be reviewed and republished

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Request body (required) (`application/json`)

- `versionId` `string` _(required)_: The ID of the ruleset version whose rules and default-rule setting are copied into the draft.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The ruleset ID.
- `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
- `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
- `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
- `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
- `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
- `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
- `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
- `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
- `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
- `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
- `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
- `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/draft/rollback \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "versionId": "string"
}'
```

```ts
fetch('/api/organizations/string/policy/draft/rollback', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    versionId: 'string'
  })
})
```

## Publish the draft ruleset

`POST /organizations/{id}/policy/draft/publish`

Request publication of the policy draft. The draft publishes immediately when the caller satisfies the threshold.

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Request body (required) (`application/json`)

- `reviewedDigest` `string` _(required)_: The rulesDigest of the draft the caller reviewed, which must match the current draft.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `status` `string` _(required)_: Always published, meaning the draft is now the active ruleset.
- `request` `object` _(required)_: The publication request, now approved.
  - `id` `string` _(required)_: The approval request ID.
  - `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
  - `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
  - `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
  - `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
  - `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
  - `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
  - `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
    - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
      - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
      - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
        - `roleId` `string` _(required)_: The role whose holders can approve for the group.
        - `threshold` `integer` _(required)_: How many approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
      - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
  - `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
  - `createdAt` `string <date-time>` _(required)_: When the request was opened.
  - `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `ruleset` `object` _(required)_: The newly published ruleset.
  - `id` `string` _(required)_: The ruleset ID.
  - `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
  - `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
  - `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
  - `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
    - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
    - `name` `string` _(required)_: Display name of the rule.
    - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
    - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
    - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
    - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
    - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
      - `users` `string[]`: User IDs whose operations match.
      - `m2mApps` `string[]`: M2M application IDs whose operations match.
      - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
    - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
      - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
      - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
    - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
      - `addresses` `string[]`: Destination addresses that match.
      - `contracts` `string[]`: Contract addresses that match as the destination.
      - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
    - `method` `object`: Matches a contract call by its function selector.
      - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
    - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
      - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
    - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
    - `asset` `object`: Matches the asset the operation moves.
      - `native` `boolean`: Set to `true` to match operations that move the native token.
      - `addresses` `string[]`: Token contract addresses that match.
    - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
      - `min` `string`: Inclusive lower bound in base units, as a decimal string.
      - `max` `string`: Inclusive upper bound in base units, as a decimal string.
    - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
      - `max` `string` _(required)_: Allowance in base units, as a decimal string.
      - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
      - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
    - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
    - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
      - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
      - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
        - `roleId` `string` _(required)_: Role whose holders can approve for this group.
        - `threshold` `integer` _(required)_: Number of approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
      - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
  - `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
  - `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
  - `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
  - `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
  - `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
  - `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
  - `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
  - `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
  - `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `supersededId` `string`: The ID of the ruleset version this one replaced, absent on the first publication.

#### `202`: Default Response

Body (`application/json`):

- `status` `string` _(required)_: Always pending_approval, meaning the draft is published once the request gathers enough approvals.
- `request` `object` _(required)_: The open publication request.
  - `id` `string` _(required)_: The approval request ID.
  - `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
  - `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
  - `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
  - `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
  - `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
  - `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
  - `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
    - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
      - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
      - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
        - `roleId` `string` _(required)_: The role whose holders can approve for the group.
        - `threshold` `integer` _(required)_: How many approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
      - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
  - `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
  - `createdAt` `string <date-time>` _(required)_: When the request was opened.
  - `updatedAt` `string <date-time>` _(required)_: When the request was last updated.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/draft/publish \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "reviewedDigest": "string"
}'
```

```ts
fetch('/api/organizations/string/policy/draft/publish', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    reviewedDigest: 'string'
  })
})
```

## Get publication settings

`GET /organizations/{id}/policy/publication-settings`

Read how many approvals a policy ruleset needs before it takes effect

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
- `id` `string | null` _(required)_: The settings ID, or null while the defaults apply and no settings were saved.
- `pending` `object` _(required)_: Saved settings that weaken the gate and take effect at effectiveAt, or null when none are waiting.
  - `threshold` `integer` _(required)_: How many approvals publication needs.
  - `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
  - `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
  - `effectiveAt` `string <date-time>` _(required)_: When the pending settings take effect, 24 hours after they were saved.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/publication-settings
```

```ts
fetch('/api/organizations/string/policy/publication-settings')
```

## Update publication settings

`PUT /organizations/{id}/policy/publication-settings`

Set how many approvals a policy ruleset needs before it takes effect

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Request body (required) (`application/json`)

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
- `id` `string | null` _(required)_: The settings ID, or null while the defaults apply and no settings were saved.
- `pending` `object` _(required)_: Saved settings that weaken the gate and take effect at effectiveAt, or null when none are waiting.
  - `threshold` `integer` _(required)_: How many approvals publication needs.
  - `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
  - `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
  - `effectiveAt` `string <date-time>` _(required)_: When the pending settings take effect, 24 hours after they were saved.

#### `202`: Default Response

Body (`application/json`):

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
- `id` `string | null` _(required)_: The settings ID, or null while the defaults apply and no settings were saved.
- `pending` `object` _(required)_: Saved settings that weaken the gate and take effect at effectiveAt, or null when none are waiting.
  - `threshold` `integer` _(required)_: How many approvals publication needs.
  - `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
  - `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
  - `effectiveAt` `string <date-time>` _(required)_: When the pending settings take effect, 24 hours after they were saved.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/publication-settings \
  --request PUT \
  --header 'Content-Type: application/json' \
  --data '{
  "threshold": 0,
  "approverRoleIds": [
    "string"
  ],
  "expirySeconds": 0
}'
```

```ts
fetch('/api/organizations/string/policy/publication-settings', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    threshold: 0,
    approverRoleIds: ['string'],
    expirySeconds: 0
  })
})
```

## Simulate an operation

`POST /organizations/{id}/policy/simulate`

Evaluate a sample operation against the active or draft ruleset without recording a decision

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Request body (`application/json`)

### Responses

#### `200`: Default Response

Body (`application/json`):

- `intent` `unknown` _(required)_: The normalized operation the server built from the request.
- `intentDigest` `string` _(required)_: A digest of the normalized operation.
- `rulesetId` `string | null` _(required)_: The ID of the ruleset simulated against, or null when none exists.
- `rulesetVersion` `integer` _(required)_: The version of the ruleset simulated against, or null when none exists.
- `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
- `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
- `trace` `object[]` _(required)_: One entry per rule in order, plus a default-rule entry when no rule matched.
  - `ruleId` `string` _(required)_: The ID of the rule visited.
  - `ruleName` `string` _(required)_: The rule name.
  - `matched` `boolean` _(required)_: Whether the operation met every condition of the rule.
  - `failedCondition` `string`: The first condition the operation failed, absent when the rule matched or was skipped.
  - `skipped` `string`: Set to disabled when the rule was skipped because it is disabled.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/simulate \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "against": "active",
  "kind": "transaction",
  "source": "string",
  "destination": "string",
  "value": "0",
  "calldata": "0x"
}'
```

```ts
fetch('/api/organizations/string/policy/simulate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    against: 'active',
    kind: 'transaction',
    source: 'string',
    destination: 'string',
    value: '0',
    calldata: '0x'
  })
})
```

## List policy decisions

`GET /organizations/{id}/policy/decisions`

List recorded policy decisions for an organization, newest first

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.
- `matchedRuleId` `string`: Return only decisions the rule with this ID decided.
- `outcome` `string`: Return only decisions with this outcome.
- `search` `string`: An exact wallet address, matched as source or destination, or an exact decision ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `items` `object[]` _(required)_: The items on this page.
  - `id` `string` _(required)_: The decision ID.
  - `organizationId` `string | null` _(required)_: The organization the decision belongs to, or null for the zone policy.
  - `rulesetId` `string` _(required)_: The ID of the ruleset version that produced the decision.
  - `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
  - `chargedRuleIds` `string[]` _(required)_: The IDs of every rule whose cumulative spending limit this decision counts against.
  - `countedRuleIds` `string[]` _(required)_: The IDs of every rule with an amount bound this decision counts toward, so a transaction split across calls is measured as a whole.
  - `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
  - `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
  - `intentDigest` `string` _(required)_: A digest of the normalized operation the decision was made for.
  - `operation` `string` _(required)_: The operation type the server derived from the request.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the user or machine-to-machine application that asked for the decision.
  - `sourceAddress` `string` _(required)_: The wallet address that sends or signs the operation.
  - `destinationAddress` `string | null` _(required)_: The recipient or target contract address, or null when the operation has none.
  - `assetAddress` `string | null` _(required)_: The token contract the operation moves, or null when it moves native value or no token.
  - `amount` `string | null` _(required)_: The amount the operation moves, as a base-unit integer string, or null when it moves none.
  - `correlationId` `string | null` _(required)_: The correlation ID the caller supplied, or null.
  - `heldUntil` `string <date-time>` _(required)_: When the hold on this decision for its bound transaction lapses, or null when it is not held or the transaction is confirmed.
  - `confirmedAt` `string <date-time>` _(required)_: When the transaction that spent this decision was confirmed, or null.
  - `chargedAt` `string <date-time>` _(required)_: The time this decision counts from in cumulative limit windows.
  - `admittedAt` `string <date-time>` _(required)_: When the chain boundary first admitted a transaction under this decision, or null.
  - `admittedTxHash` `unknown` _(required)_: The hash of the transaction the chain boundary bound this decision to, or null.
  - `createdAt` `string <date-time>` _(required)_: When the decision was recorded.
- `pagination` `object` _(required)_: Paging details for the result.
  - `currentPage` `number` _(required)_: The 1-based number of this page.
  - `totalPages` `number` _(required)_: The number of pages at the current limit.
  - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
  - `limit` `number` _(required)_: The maximum number of items per page.
  - `offset` `number` _(required)_: The number of items skipped before this page.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/organizations/string/policy/decisions?limit=10&offset=0&matchedRuleId=string&outcome=allowed&search=string'
```

```ts
fetch('/api/organizations/string/policy/decisions?limit=10&offset=0&matchedRuleId=string&outcome=allowed&search=string')
```

## Get a policy decision

`GET /organizations/{id}/policy/decisions/{decisionId}`

Read a recorded policy decision, including the rule-by-rule evaluation trace

### Path parameters

- `id` `string` _(required)_: The organization ID.
- `decisionId` `string` _(required)_: The policy decision ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The decision ID.
- `organizationId` `string | null` _(required)_: The organization the decision belongs to, or null for the zone policy.
- `rulesetId` `string` _(required)_: The ID of the ruleset version that produced the decision.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
- `chargedRuleIds` `string[]` _(required)_: The IDs of every rule whose cumulative spending limit this decision counts against.
- `countedRuleIds` `string[]` _(required)_: The IDs of every rule with an amount bound this decision counts toward, so a transaction split across calls is measured as a whole.
- `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
- `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
- `intentDigest` `string` _(required)_: A digest of the normalized operation the decision was made for.
- `intent` `unknown` _(required)_: The normalized operation the decision was made for, as the server built it.
- `evaluationTrace` `object[]` _(required)_: One entry per rule in order, plus a default-rule entry when no rule matched.
  - `ruleId` `string` _(required)_: The ID of the rule visited.
  - `ruleName` `string` _(required)_: The rule name.
  - `matched` `boolean` _(required)_: Whether the operation met every condition of the rule.
  - `failedCondition` `string`: The first condition the operation failed, absent when the rule matched or was skipped.
  - `skipped` `string`: Set to disabled when the rule was skipped because it is disabled.
- `operation` `string` _(required)_: The operation type the server derived from the request.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the user or machine-to-machine application that asked for the decision.
- `sourceAddress` `string` _(required)_: The wallet address that sends or signs the operation.
- `destinationAddress` `string | null` _(required)_: The recipient or target contract address, or null when the operation has none.
- `assetAddress` `string | null` _(required)_: The token contract the operation moves, or null when it moves native value or no token.
- `amount` `string | null` _(required)_: The amount the operation moves, as a base-unit integer string, or null when it moves none.
- `correlationId` `string | null` _(required)_: The correlation ID the caller supplied, or null.
- `heldUntil` `string <date-time>` _(required)_: When the hold on this decision for its bound transaction lapses, or null when it is not held or the transaction is confirmed.
- `confirmedAt` `string <date-time>` _(required)_: When the transaction that spent this decision was confirmed, or null.
- `chargedAt` `string <date-time>` _(required)_: The time this decision counts from in cumulative limit windows.
- `admittedAt` `string <date-time>` _(required)_: When the chain boundary first admitted a transaction under this decision, or null.
- `admittedTxHash` `unknown` _(required)_: The hash of the transaction the chain boundary bound this decision to, or null.
- `createdAt` `string <date-time>` _(required)_: When the decision was recorded.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/decisions/string
```

```ts
fetch('/api/organizations/string/policy/decisions/string')
```

## Evaluate an operation

`POST /organizations/{id}/policy/evaluate`

Evaluate an operation against the active policy ruleset and record the decision

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Request body (`application/json`)

### Responses

#### `200`: Default Response

Body (`application/json`):

- `decisionId` `string` _(required)_: The ID of the recorded decision.
- `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
- `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
- `intentDigest` `string` _(required)_: A digest of the normalized operation the decision was made for.
- `rulesetId` `string` _(required)_: The ID of the active ruleset version that produced the decision.
- `reused` `boolean` _(required)_: Whether an earlier decision with the same correlationId and operation was returned.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/evaluate \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "correlationId": "string",
  "kind": "transaction",
  "source": "string",
  "destination": "string",
  "value": "0",
  "calldata": "0x"
}'
```

```ts
fetch('/api/organizations/string/policy/evaluate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    correlationId: 'string',
    kind: 'transaction',
    source: 'string',
    destination: 'string',
    value: '0',
    calldata: '0x'
  })
})
```

## List approval requests

`GET /organizations/{id}/policy/approvals`

List policy approval requests for an organization

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.
- `state` `string`: Return only requests in this state, where a pending request past its expiry counts as expired.
- `subject` `string`: Return only requests with this subject.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `items` `object[]` _(required)_: The items on this page.
  - `id` `string` _(required)_: The approval request ID.
  - `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
  - `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
  - `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
  - `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
  - `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
  - `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
  - `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
    - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
      - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
      - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
        - `roleId` `string` _(required)_: The role whose holders can approve for the group.
        - `threshold` `integer` _(required)_: How many approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
      - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
  - `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
  - `createdAt` `string <date-time>` _(required)_: When the request was opened.
  - `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
  - `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
  - `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
  - `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
  - `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
  - `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
  - `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
  - `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
    - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
    - `approverId` `string` _(required)_: The ID of the approver.
    - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
- `pagination` `object` _(required)_: Paging details for the result.
  - `currentPage` `number` _(required)_: The 1-based number of this page.
  - `totalPages` `number` _(required)_: The number of pages at the current limit.
  - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
  - `limit` `number` _(required)_: The maximum number of items per page.
  - `offset` `number` _(required)_: The number of items skipped before this page.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/organizations/string/policy/approvals?limit=10&offset=0&state=pending&subject=operation'
```

```ts
fetch('/api/organizations/string/policy/approvals?limit=10&offset=0&state=pending&subject=operation')
```

## Get an approval request

`GET /organizations/{id}/policy/approvals/{requestId}`

Read an approval request with its quorum progress and votes cast

### Path parameters

- `id` `string` _(required)_: The organization ID.
- `requestId` `string` _(required)_: The approval request ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The approval request ID.
- `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
- `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
- `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
- `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
- `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
- `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
- `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
  - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
  - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
    - `roleId` `string` _(required)_: The role whose holders can approve for the group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
  - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
  - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
  - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
- `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
- `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
- `createdAt` `string <date-time>` _(required)_: When the request was opened.
- `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
- `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
- `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
- `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
- `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
- `progress` `object` _(required)_: The quorum progress, computed from the votes cast.
  - `state` `string` _(required)_: The quorum state: pending while unmet, approved once every requirement is met, and rejected after any rejection.
  - `groups` `object[]` _(required)_: Progress for each approver group in every requirement.
    - `roleId` `string` _(required)_: The role whose holders form the approver group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `approvals` `integer` _(required)_: How many approvals from currently eligible approvers count toward the group.
    - `satisfied` `boolean` _(required)_: Whether the group has reached its threshold.
- `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
  - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
  - `approverId` `string` _(required)_: The ID of the approver.
  - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
  - `reason` `string | null` _(required)_: The reason the approver gave, or null.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/approvals/string
```

```ts
fetch('/api/organizations/string/policy/approvals/string')
```

## Vote on an approval request

`POST /organizations/{id}/policy/approvals/{requestId}/decision`

Approve or reject an approval request

### Path parameters

- `id` `string` _(required)_: The organization ID.
- `requestId` `string` _(required)_: The approval request ID.

### Request body (required) (`application/json`)

- `verdict` `string` _(required)_: The vote: approve counts toward the quorum, and reject rejects the request outright.
- `reason` `string`: A reason for the vote, up to 500 characters.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The approval request ID.
- `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
- `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
- `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
- `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
- `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
- `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
- `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
  - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
  - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
    - `roleId` `string` _(required)_: The role whose holders can approve for the group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
  - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
  - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
  - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
- `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
- `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
- `createdAt` `string <date-time>` _(required)_: When the request was opened.
- `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
- `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
- `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
- `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
- `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
- `progress` `object` _(required)_: The quorum progress, computed from the votes cast.
  - `state` `string` _(required)_: The quorum state: pending while unmet, approved once every requirement is met, and rejected after any rejection.
  - `groups` `object[]` _(required)_: Progress for each approver group in every requirement.
    - `roleId` `string` _(required)_: The role whose holders form the approver group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `approvals` `integer` _(required)_: How many approvals from currently eligible approvers count toward the group.
    - `satisfied` `boolean` _(required)_: Whether the group has reached its threshold.
- `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
  - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
  - `approverId` `string` _(required)_: The ID of the approver.
  - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
  - `reason` `string | null` _(required)_: The reason the approver gave, or null.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/approvals/string/decision \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "verdict": "approve",
  "reason": "string"
}'
```

```ts
fetch('/api/organizations/string/policy/approvals/string/decision', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    verdict: 'approve',
    reason: 'string'
  })
})
```

## Cancel an approval request

`POST /organizations/{id}/policy/approvals/{requestId}/cancel`

Cancel an open approval request

### Path parameters

- `id` `string` _(required)_: The organization ID.
- `requestId` `string` _(required)_: The approval request ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The approval request ID.
- `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
- `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
- `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
- `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
- `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
- `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
- `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
  - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
  - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
    - `roleId` `string` _(required)_: The role whose holders can approve for the group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
  - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
  - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
  - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
- `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
- `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
- `createdAt` `string <date-time>` _(required)_: When the request was opened.
- `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
- `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
- `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
- `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
- `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
- `progress` `object` _(required)_: The quorum progress, computed from the votes cast.
  - `state` `string` _(required)_: The quorum state: pending while unmet, approved once every requirement is met, and rejected after any rejection.
  - `groups` `object[]` _(required)_: Progress for each approver group in every requirement.
    - `roleId` `string` _(required)_: The role whose holders form the approver group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `approvals` `integer` _(required)_: How many approvals from currently eligible approvers count toward the group.
    - `satisfied` `boolean` _(required)_: Whether the group has reached its threshold.
- `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
  - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
  - `approverId` `string` _(required)_: The ID of the approver.
  - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
  - `reason` `string | null` _(required)_: The reason the approver gave, or null.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/approvals/string/cancel \
  --request POST
```

```ts
fetch('/api/organizations/string/policy/approvals/string/cancel', {
  method: 'POST'
})
```

## Get cumulative limit usage

`GET /organizations/{id}/policy/limits`

Read how much of each cumulative limit an organization's active ruleset has consumed

### Path parameters

- `id` `string` _(required)_: The organization ID.

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.
- `holder` `string | string[]`: Up to 25 initiator IDs or wallet addresses whose allowances are returned in named.
- `ruleId` `string | string[]`: Up to 25 limit rule IDs that narrow the allowances listed, all limits when omitted.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `rulesetId` `string | null` _(required)_: The ID of the active ruleset, or null when none has been published.
- `asOf` `string` _(required)_: The instant the usage was computed, as an ISO 8601 timestamp.
- `limits` `object[]` _(required)_: Every enabled cumulative limit in the active ruleset, whatever the ruleId filter.
  - `ruleId` `string` _(required)_: The ID of the rule that sets the limit.
  - `ruleName` `string` _(required)_: The rule name.
  - `max` `string` _(required)_: The maximum base-unit amount per window, as an integer string.
  - `windowSeconds` `integer` _(required)_: The length of the rolling window, in seconds.
  - `scopeBy` `string[]` _(required)_: The dimensions that key each allowance, where an empty list means one shared allowance.
- `allowances` `object` _(required)_: A page of allowances, ordered by rule position and then by amount spent, largest first.
  - `items` `object[]` _(required)_: The items on this page.
    - `ruleId` `string` _(required)_: The ID of the limit rule the allowance belongs to.
    - `spent` `string` _(required)_: The base-unit amount charged within the current window, as an integer string.
    - `remaining` `string` _(required)_: The base-unit amount left before the limit is reached, as an integer string.
    - `charges` `integer` _(required)_: The number of decisions charged within the current window.
    - `windowFreesAt` `string | null` _(required)_: When the earliest charge leaves the window and frees room, or null when nothing is charged.
    - `scope` `object` _(required)_: The holder of the allowance, with a key for each dimension the limit is scoped by.
      - `initiator` `string`: The initiator ID, present when the limit is scoped by initiator.
      - `source` `string`: The source wallet address, present when the limit is scoped by source.
      - `destination` `string | null`: The destination address, present when the limit is scoped by destination, and null for operations with no destination.
  - `pagination` `object` _(required)_: Paging details for the result.
    - `currentPage` `number` _(required)_: The 1-based number of this page.
    - `totalPages` `number` _(required)_: The number of pages at the current limit.
    - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
    - `limit` `number` _(required)_: The maximum number of items per page.
    - `offset` `number` _(required)_: The number of items skipped before this page.
- `named` `object[]` _(required)_: The allowances of the holders named in the holder parameter, whichever page they fall on.
  - `ruleId` `string` _(required)_: The ID of the limit rule the allowance belongs to.
  - `spent` `string` _(required)_: The base-unit amount charged within the current window, as an integer string.
  - `remaining` `string` _(required)_: The base-unit amount left before the limit is reached, as an integer string.
  - `charges` `integer` _(required)_: The number of decisions charged within the current window.
  - `windowFreesAt` `string | null` _(required)_: When the earliest charge leaves the window and frees room, or null when nothing is charged.
  - `scope` `object` _(required)_: The holder of the allowance, with a key for each dimension the limit is scoped by.
    - `initiator` `string`: The initiator ID, present when the limit is scoped by initiator.
    - `source` `string`: The source wallet address, present when the limit is scoped by source.
    - `destination` `string | null`: The destination address, present when the limit is scoped by destination, and null for operations with no destination.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/organizations/string/policy/limits?limit=20&offset=0&holder=string&ruleId=string'
```

```ts
fetch('/api/organizations/string/policy/limits?limit=20&offset=0&holder=string&ruleId=string')
```

## Get token decimals and symbol

`GET /organizations/{id}/policy/assets/{address}`

Read the decimals and symbol of a registered contract an organization's policy can name, so its amounts can be shown in the token's own unit

### Path parameters

- `id` `string` _(required)_: The organization ID.
- `address` `string` _(required)_: The address of a registered contract.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `decimals` `integer` _(required)_: The token decimals, or null when the contract does not answer decimals() the way an ERC-20 does.
- `symbol` `string | null` _(required)_: The token symbol, or null when the contract returns none or one unfit for display.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/organizations/string/policy/assets/string
```

```ts
fetch('/api/organizations/string/policy/assets/string')
```

## Get the active ruleset

`GET /policy/ruleset`

Get the active policy ruleset for the zone

### Responses

#### `200`: Default Response

Body (`application/json`):

- `ruleset` `object` _(required)_: The published ruleset, or null when no ruleset has been published.
  - `id` `string` _(required)_: The ruleset ID.
  - `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
  - `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
  - `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
  - `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
    - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
    - `name` `string` _(required)_: Display name of the rule.
    - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
    - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
    - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
    - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
    - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
      - `users` `string[]`: User IDs whose operations match.
      - `m2mApps` `string[]`: M2M application IDs whose operations match.
      - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
    - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
      - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
      - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
    - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
      - `addresses` `string[]`: Destination addresses that match.
      - `contracts` `string[]`: Contract addresses that match as the destination.
      - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
    - `method` `object`: Matches a contract call by its function selector.
      - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
    - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
      - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
    - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
    - `asset` `object`: Matches the asset the operation moves.
      - `native` `boolean`: Set to `true` to match operations that move the native token.
      - `addresses` `string[]`: Token contract addresses that match.
    - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
      - `min` `string`: Inclusive lower bound in base units, as a decimal string.
      - `max` `string`: Inclusive upper bound in base units, as a decimal string.
    - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
      - `max` `string` _(required)_: Allowance in base units, as a decimal string.
      - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
      - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
    - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
    - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
      - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
      - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
        - `roleId` `string` _(required)_: Role whose holders can approve for this group.
        - `threshold` `integer` _(required)_: Number of approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
      - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
  - `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
  - `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
  - `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
  - `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
  - `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
  - `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
  - `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
  - `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
  - `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `rules` `object[]` _(required)_: The active rules, empty when no ruleset has been published.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, true when no ruleset has been published.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/ruleset
```

```ts
fetch('/api/policy/ruleset')
```

## List ruleset versions

`GET /policy/rulesets`

List the policy ruleset versions for the zone, newest first, including the draft and superseded versions

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `items` `object[]` _(required)_: The items on this page.
  - `id` `string` _(required)_: The ruleset ID.
  - `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
  - `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
  - `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
  - `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
    - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
    - `name` `string` _(required)_: Display name of the rule.
    - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
    - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
    - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
    - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
    - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
      - `users` `string[]`: User IDs whose operations match.
      - `m2mApps` `string[]`: M2M application IDs whose operations match.
      - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
    - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
      - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
      - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
    - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
      - `addresses` `string[]`: Destination addresses that match.
      - `contracts` `string[]`: Contract addresses that match as the destination.
      - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
    - `method` `object`: Matches a contract call by its function selector.
      - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
    - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
      - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
    - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
    - `asset` `object`: Matches the asset the operation moves.
      - `native` `boolean`: Set to `true` to match operations that move the native token.
      - `addresses` `string[]`: Token contract addresses that match.
    - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
      - `min` `string`: Inclusive lower bound in base units, as a decimal string.
      - `max` `string`: Inclusive upper bound in base units, as a decimal string.
    - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
      - `max` `string` _(required)_: Allowance in base units, as a decimal string.
      - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
      - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
    - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
    - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
      - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
      - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
        - `roleId` `string` _(required)_: Role whose holders can approve for this group.
        - `threshold` `integer` _(required)_: Number of approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
      - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
  - `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
  - `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
  - `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
  - `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
  - `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
  - `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
  - `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
  - `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
  - `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `pagination` `object` _(required)_: Paging details for the result.
  - `currentPage` `number` _(required)_: The 1-based number of this page.
  - `totalPages` `number` _(required)_: The number of pages at the current limit.
  - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
  - `limit` `number` _(required)_: The maximum number of items per page.
  - `offset` `number` _(required)_: The number of items skipped before this page.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/policy/rulesets?limit=10&offset=0'
```

```ts
fetch('/api/policy/rulesets?limit=10&offset=0')
```

## Get the draft ruleset

`GET /policy/draft`

Get the editable policy draft for the zone

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The ruleset ID.
- `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
- `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
- `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
- `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
- `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
- `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
- `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
- `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
- `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
- `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
- `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
- `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `outdated` `boolean` _(required)_: Whether the draft was saved against an older rule schema and must be saved again before publishing.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/draft
```

```ts
fetch('/api/policy/draft')
```

## Save the draft ruleset

`PUT /policy/draft`

Create or replace the policy draft for the zone

### Request body (required) (`application/json`)

- `rules` `object[]` _(required)_: The complete ordered rule list, which replaces the rules in the draft.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean`: Whether the default rule blocks operations no rule matches, true when omitted.
- `note` `string`: A free-text note for the draft, up to 500 characters.
- `baseDigest` `string | null`: The rulesDigest of the draft the edit started from, or null for no draft, and the save fails with 409 when the stored draft differs from it.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The ruleset ID.
- `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
- `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
- `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
- `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
- `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
- `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
- `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
- `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
- `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
- `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
- `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
- `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/draft \
  --request PUT \
  --header 'Content-Type: application/json' \
  --data '{
  "rules": [
    {
      "id": "string",
      "name": "string",
      "group": "string",
      "enabled": true,
      "action": "allow",
      "operation": "deploy",
      "initiator": {
        "users": [
          "string"
        ],
        "m2mApps": [
          "string"
        ],
        "roles": [
          "string"
        ]
      },
      "source": {
        "wallets": [
          "string"
        ],
        "roles": [
          "string"
        ]
      },
      "destination": {
        "addresses": [
          "string"
        ],
        "contracts": [
          "string"
        ],
        "classification": [
          "contract"
        ]
      },
      "method": {
        "selectors": [
          "string"
        ]
      },
      "typedMessage": {
        "primaryTypes": [
          "string"
        ]
      },
      "params": [
        {
          "index": 0,
          "kind": "address_in",
          "values": []
        }
      ],
      "asset": {
        "native": true,
        "addresses": [
          "string"
        ]
      },
      "amount": {
        "min": "string",
        "max": "string"
      },
      "spendOver": {
        "max": "string",
        "windowSeconds": 0,
        "scopeBy": [
          "initiator"
        ]
      },
      "approval": {
        "logic": "and",
        "groups": [
          {
            "roleId": "string",
            "threshold": 0
          }
        ],
        "initiatorMayApprove": true,
        "allowMachineApprovers": true,
        "expirySeconds": 0
      }
    }
  ],
  "terminalDenyEnabled": true,
  "note": "string",
  "baseDigest": "string"
}'
```

```ts
fetch('/api/policy/draft', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    rules: [
      {
        id: 'string',
        name: 'string',
        group: 'string',
        enabled: true,
        action: 'allow',
        operation: 'deploy',
        initiator: {
          users: ['string'],
          m2mApps: ['string'],
          roles: ['string']
        },
        source: {
          wallets: ['string'],
          roles: ['string']
        },
        destination: {
          addresses: ['string'],
          contracts: ['string'],
          classification: ['contract']
        },
        method: {
          selectors: ['string']
        },
        typedMessage: {
          primaryTypes: ['string']
        },
        params: [
          {
            index: 0,
            kind: 'address_in',
            values: []
          }
        ],
        asset: {
          native: true,
          addresses: ['string']
        },
        amount: {
          min: 'string',
          max: 'string'
        },
        spendOver: {
          max: 'string',
          windowSeconds: 0,
          scopeBy: ['initiator']
        },
        approval: {
          logic: 'and',
          groups: [
            {
              roleId: 'string',
              threshold: 0
            }
          ],
          initiatorMayApprove: true,
          allowMachineApprovers: true,
          expirySeconds: 0
        }
      }
    ],
    terminalDenyEnabled: true,
    note: 'string',
    baseDigest: 'string'
  })
})
```

## Discard the draft ruleset

`DELETE /policy/draft`

Discard the policy draft for the zone

### Responses

#### `204`: Default Response

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/draft \
  --request DELETE
```

```ts
fetch('/api/policy/draft', {
  method: 'DELETE'
})
```

## Validate the draft ruleset

`GET /policy/draft/validation`

Validate the policy draft, reporting reference and structural issues and whether it can be published

### Responses

#### `200`: Default Response

Body (`application/json`):

- `issues` `object[]` _(required)_: Every issue found in the draft.
  - `severity` `string` _(required)_: How serious the issue is: an error blocks publication and a warning does not.
  - `code` `string` _(required)_: The kind of issue: the unknown_ codes name a reference that does not exist, spend_limit_without_amount and inapplicable_condition flag a condition the operation cannot carry, approval_threshold_unreachable flags a group with fewer role members than its threshold, unconditional_rule flags a rule that constrains nothing, unregistered_asset flags a token that is not a registered contract, and terminal_deny_disabled flags the default rule being off.
  - `message` `string` _(required)_: A human-readable explanation of the issue.
  - `ruleId` `string` _(required)_: The ID of the rule the issue concerns, or policy.default_deny for the default rule.
- `publishable` `boolean` _(required)_: Whether the draft has no error-severity issues.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/draft/validation
```

```ts
fetch('/api/policy/draft/validation')
```

## Compare the draft and active rulesets

`GET /policy/draft/diff`

Compare the policy draft against the active ruleset

### Responses

#### `200`: Default Response

Body (`application/json`):

- `changes` `object[]` _(required)_: One entry per rule in the draft or the active ruleset, followed by an entry for the default rule when its setting changed.
  - `kind` `string` _(required)_: How the rule differs: added is only in the draft, removed is only in the active ruleset, changed differs in at least one field, and unchanged is identical.
  - `ruleId` `string` _(required)_: The ID of the rule, or policy.default_deny for a change to the default rule.
  - `name` `string` _(required)_: The rule name.
  - `previousPosition` `integer`: The rule position in the active ruleset, which the diff does not currently set.
  - `position` `integer`: The rule position in the draft, which the diff does not currently set.
  - `changedFields` `object[]`: The fields that differ, present when kind is changed.
    - `field` `string` _(required)_: The name of the rule field that differs.
    - `before` `unknown`: The field value in the active ruleset, absent when it is unset there.
    - `after` `unknown`: The field value in the draft, absent when it is unset there.
  - `moved` `boolean`: Whether the rule was reordered, which the diff does not currently set.
- `identical` `boolean` _(required)_: Whether the draft and the active ruleset have the same rules and default-rule setting, ignoring rule order.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/draft/diff
```

```ts
fetch('/api/policy/draft/diff')
```

## Load a version into the draft

`POST /policy/draft/rollback`

Load a previous ruleset version into the draft so it can be reviewed and republished

### Request body (required) (`application/json`)

- `versionId` `string` _(required)_: The ID of the ruleset version whose rules and default-rule setting are copied into the draft.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The ruleset ID.
- `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
- `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
- `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
- `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
  - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
  - `name` `string` _(required)_: Display name of the rule.
  - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
  - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
  - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
  - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
  - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
    - `users` `string[]`: User IDs whose operations match.
    - `m2mApps` `string[]`: M2M application IDs whose operations match.
    - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
  - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
    - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
    - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
  - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
    - `addresses` `string[]`: Destination addresses that match.
    - `contracts` `string[]`: Contract addresses that match as the destination.
    - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
  - `method` `object`: Matches a contract call by its function selector.
    - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
  - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
    - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
  - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
  - `asset` `object`: Matches the asset the operation moves.
    - `native` `boolean`: Set to `true` to match operations that move the native token.
    - `addresses` `string[]`: Token contract addresses that match.
  - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
    - `min` `string`: Inclusive lower bound in base units, as a decimal string.
    - `max` `string`: Inclusive upper bound in base units, as a decimal string.
  - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
    - `max` `string` _(required)_: Allowance in base units, as a decimal string.
    - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
    - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
  - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
  - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
    - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
    - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
      - `roleId` `string` _(required)_: Role whose holders can approve for this group.
      - `threshold` `integer` _(required)_: Number of approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
    - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
- `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
- `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
- `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
- `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
- `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
- `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
- `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
- `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
- `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/draft/rollback \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "versionId": "string"
}'
```

```ts
fetch('/api/policy/draft/rollback', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    versionId: 'string'
  })
})
```

## Publish the draft ruleset

`POST /policy/draft/publish`

Request publication of the policy draft. The draft publishes immediately when the caller satisfies the threshold.

### Request body (required) (`application/json`)

- `reviewedDigest` `string` _(required)_: The rulesDigest of the draft the caller reviewed, which must match the current draft.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `status` `string` _(required)_: Always published, meaning the draft is now the active ruleset.
- `request` `object` _(required)_: The publication request, now approved.
  - `id` `string` _(required)_: The approval request ID.
  - `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
  - `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
  - `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
  - `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
  - `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
  - `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
  - `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
    - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
      - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
      - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
        - `roleId` `string` _(required)_: The role whose holders can approve for the group.
        - `threshold` `integer` _(required)_: How many approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
      - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
  - `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
  - `createdAt` `string <date-time>` _(required)_: When the request was opened.
  - `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `ruleset` `object` _(required)_: The newly published ruleset.
  - `id` `string` _(required)_: The ruleset ID.
  - `organizationId` `string | null` _(required)_: The organization that owns the ruleset, or null for the zone policy.
  - `version` `integer` _(required)_: The version number, one higher than the highest existing version when the draft was created.
  - `status` `string` _(required)_: The lifecycle state: draft is the editable draft, published is the active ruleset, and superseded is a version a later publication replaced.
  - `rules` `object[]` _(required)_: The rules in the order they are stored and evaluated.
    - `id` `string` _(required)_: Rule ID, unique within the ruleset. IDs starting with `policy.` are reserved.
    - `name` `string` _(required)_: Display name of the rule.
    - `group` `string`: Folder the Admin Panel files the rule under. Evaluation ignores it.
    - `enabled` `boolean` _(required)_: Whether the rule is evaluated. A disabled rule never matches.
    - `action` `string` _(required)_: Verdict when the rule matches: `allow`, `block`, or `require_approval`. The strictest verdict across matching rules decides.
    - `operation` `string` _(required)_: Kind of operation the rule applies to. `raw` and `typed_message` are signing requests that never reach the chain.
    - `initiator` `object`: Matches the user or M2M application that sent the operation. Any listed entry is enough.
      - `users` `string[]`: User IDs whose operations match.
      - `m2mApps` `string[]`: M2M application IDs whose operations match.
      - `roles` `string[]`: Role IDs. An initiator holding any of them matches.
    - `source` `object`: Matches the wallet that signs the operation. Any listed entry is enough.
      - `wallets` `string[]`: Wallet addresses. An operation signed by any of them matches.
      - `roles` `string[]`: Role IDs. A signing wallet whose user holds any of them matches.
    - `destination` `object`: Matches the address the operation is sent to. Any listed entry is enough.
      - `addresses` `string[]`: Destination addresses that match.
      - `contracts` `string[]`: Contract addresses that match as the destination.
      - `classification` `string[]`: Destination classes that match: `contract` for a registered contract, `wallet` for an associated wallet, `unknown` for anything else.
    - `method` `object`: Matches a contract call by its function selector.
      - `selectors` `string[]` _(required)_: 4-byte function selectors that match.
    - `typedMessage` `object`: Matches a typed-message signing request by its EIP-712 primary type.
      - `primaryTypes` `string[]` _(required)_: EIP-712 primary type names that match.
    - `params` `object[]`: Constraints on decoded call arguments. Every constraint has to hold.
    - `asset` `object`: Matches the asset the operation moves.
      - `native` `boolean`: Set to `true` to match operations that move the native token.
      - `addresses` `string[]`: Token contract addresses that match.
    - `amount` `object`: Matches the amount the operation moves, in base units of the asset.
      - `min` `string`: Inclusive lower bound in base units, as a decimal string.
      - `max` `string`: Inclusive upper bound in base units, as a decimal string.
    - `spendOver` `object`: Spending limit. The rule matches once an operation would take the amount spent in the window past `max`.
      - `max` `string` _(required)_: Allowance in base units, as a decimal string.
      - `windowSeconds` `integer` _(required)_: Length of the rolling window the allowance covers, in seconds.
      - `scopeBy` `string[]` _(required)_: Keeps a separate allowance per initiator, source wallet or destination. An empty list shares one allowance across all matching operations.
    - `cumulative` `unknown`: Removed field, refused when set. Use `spendOver`.
    - `approval` `object`: Approval quorum. Required on `require_approval` rules and refused on others.
      - `logic` `string` _(required)_: `and` requires every group to reach its threshold. `or` requires any one group.
      - `groups` `object[]` _(required)_: Approver groups, each drawn from one role.
        - `roleId` `string` _(required)_: Role whose holders can approve for this group.
        - `threshold` `integer` _(required)_: Number of approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the operation can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether M2M applications can approve.
      - `expirySeconds` `integer` _(required)_: Seconds an approval request stays open before it expires.
  - `terminalDenyEnabled` `boolean` _(required)_: Whether the default rule blocks operations no rule matches, which are allowed when it is false.
  - `rulesDigest` `string` _(required)_: A SHA-256 digest of the rules and terminalDenyEnabled, which draft saves and publication compare to detect changes.
  - `schemaFingerprint` `string` _(required)_: A fingerprint of the rule schema the ruleset was saved against, which must match the current schema to publish.
  - `note` `string | null` _(required)_: A free-text note saved with the draft, or null.
  - `authorId` `string | null` _(required)_: The ID of the user who last saved the draft, or null when none is recorded.
  - `reviewerId` `string | null` _(required)_: The ID of the user whose approval completed publication, or null before publication.
  - `publishedAt` `string <date-time>` _(required)_: When the ruleset was published, or null if it has not been published.
  - `createdAt` `string <date-time>` _(required)_: When the ruleset was created.
  - `updatedAt` `string <date-time>` _(required)_: When the ruleset was last updated.
- `supersededId` `string`: The ID of the ruleset version this one replaced, absent on the first publication.

#### `202`: Default Response

Body (`application/json`):

- `status` `string` _(required)_: Always pending_approval, meaning the draft is published once the request gathers enough approvals.
- `request` `object` _(required)_: The open publication request.
  - `id` `string` _(required)_: The approval request ID.
  - `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
  - `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
  - `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
  - `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
  - `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
  - `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
  - `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
    - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
      - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
      - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
        - `roleId` `string` _(required)_: The role whose holders can approve for the group.
        - `threshold` `integer` _(required)_: How many approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
      - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
  - `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
  - `createdAt` `string <date-time>` _(required)_: When the request was opened.
  - `updatedAt` `string <date-time>` _(required)_: When the request was last updated.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/draft/publish \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "reviewedDigest": "string"
}'
```

```ts
fetch('/api/policy/draft/publish', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    reviewedDigest: 'string'
  })
})
```

## Get publication settings

`GET /policy/publication-settings`

Read how many approvals a policy ruleset needs before it takes effect

### Responses

#### `200`: Default Response

Body (`application/json`):

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
- `id` `string | null` _(required)_: The settings ID, or null while the defaults apply and no settings were saved.
- `pending` `object` _(required)_: Saved settings that weaken the gate and take effect at effectiveAt, or null when none are waiting.
  - `threshold` `integer` _(required)_: How many approvals publication needs.
  - `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
  - `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
  - `effectiveAt` `string <date-time>` _(required)_: When the pending settings take effect, 24 hours after they were saved.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/publication-settings
```

```ts
fetch('/api/policy/publication-settings')
```

## Update publication settings

`PUT /policy/publication-settings`

Set how many approvals a policy ruleset needs before it takes effect

### Request body (required) (`application/json`)

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
- `id` `string | null` _(required)_: The settings ID, or null while the defaults apply and no settings were saved.
- `pending` `object` _(required)_: Saved settings that weaken the gate and take effect at effectiveAt, or null when none are waiting.
  - `threshold` `integer` _(required)_: How many approvals publication needs.
  - `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
  - `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
  - `effectiveAt` `string <date-time>` _(required)_: When the pending settings take effect, 24 hours after they were saved.

#### `202`: Default Response

Body (`application/json`):

- `threshold` `integer` _(required)_: How many approvals publication needs.
- `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
- `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
- `id` `string | null` _(required)_: The settings ID, or null while the defaults apply and no settings were saved.
- `pending` `object` _(required)_: Saved settings that weaken the gate and take effect at effectiveAt, or null when none are waiting.
  - `threshold` `integer` _(required)_: How many approvals publication needs.
  - `approverRoleIds` `string[]` _(required)_: At most one role ID whose holders, along with zone operators, can approve publication, or an empty list for every user holding admin_write.
  - `expirySeconds` `integer` _(required)_: How long a publication request stays open, in seconds, up to 604800.
  - `effectiveAt` `string <date-time>` _(required)_: When the pending settings take effect, 24 hours after they were saved.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/publication-settings \
  --request PUT \
  --header 'Content-Type: application/json' \
  --data '{
  "threshold": 0,
  "approverRoleIds": [
    "string"
  ],
  "expirySeconds": 0
}'
```

```ts
fetch('/api/policy/publication-settings', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    threshold: 0,
    approverRoleIds: ['string'],
    expirySeconds: 0
  })
})
```

## Simulate an operation

`POST /policy/simulate`

Evaluate a sample operation against the active or draft ruleset without recording a decision

### Request body (`application/json`)

### Responses

#### `200`: Default Response

Body (`application/json`):

- `intent` `unknown` _(required)_: The normalized operation the server built from the request.
- `intentDigest` `string` _(required)_: A digest of the normalized operation.
- `rulesetId` `string | null` _(required)_: The ID of the ruleset simulated against, or null when none exists.
- `rulesetVersion` `integer` _(required)_: The version of the ruleset simulated against, or null when none exists.
- `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
- `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
- `trace` `object[]` _(required)_: One entry per rule in order, plus a default-rule entry when no rule matched.
  - `ruleId` `string` _(required)_: The ID of the rule visited.
  - `ruleName` `string` _(required)_: The rule name.
  - `matched` `boolean` _(required)_: Whether the operation met every condition of the rule.
  - `failedCondition` `string`: The first condition the operation failed, absent when the rule matched or was skipped.
  - `skipped` `string`: Set to disabled when the rule was skipped because it is disabled.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/simulate \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "against": "active",
  "kind": "transaction",
  "source": "string",
  "destination": "string",
  "value": "0",
  "calldata": "0x"
}'
```

```ts
fetch('/api/policy/simulate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    against: 'active',
    kind: 'transaction',
    source: 'string',
    destination: 'string',
    value: '0',
    calldata: '0x'
  })
})
```

## List policy decisions

`GET /policy/decisions`

List recorded policy decisions for the zone, newest first

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.
- `matchedRuleId` `string`: Return only decisions the rule with this ID decided.
- `outcome` `string`: Return only decisions with this outcome.
- `search` `string`: An exact wallet address, matched as source or destination, or an exact decision ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `items` `object[]` _(required)_: The items on this page.
  - `id` `string` _(required)_: The decision ID.
  - `organizationId` `string | null` _(required)_: The organization the decision belongs to, or null for the zone policy.
  - `rulesetId` `string` _(required)_: The ID of the ruleset version that produced the decision.
  - `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
  - `chargedRuleIds` `string[]` _(required)_: The IDs of every rule whose cumulative spending limit this decision counts against.
  - `countedRuleIds` `string[]` _(required)_: The IDs of every rule with an amount bound this decision counts toward, so a transaction split across calls is measured as a whole.
  - `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
  - `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
  - `intentDigest` `string` _(required)_: A digest of the normalized operation the decision was made for.
  - `operation` `string` _(required)_: The operation type the server derived from the request.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the user or machine-to-machine application that asked for the decision.
  - `sourceAddress` `string` _(required)_: The wallet address that sends or signs the operation.
  - `destinationAddress` `string | null` _(required)_: The recipient or target contract address, or null when the operation has none.
  - `assetAddress` `string | null` _(required)_: The token contract the operation moves, or null when it moves native value or no token.
  - `amount` `string | null` _(required)_: The amount the operation moves, as a base-unit integer string, or null when it moves none.
  - `correlationId` `string | null` _(required)_: The correlation ID the caller supplied, or null.
  - `heldUntil` `string <date-time>` _(required)_: When the hold on this decision for its bound transaction lapses, or null when it is not held or the transaction is confirmed.
  - `confirmedAt` `string <date-time>` _(required)_: When the transaction that spent this decision was confirmed, or null.
  - `chargedAt` `string <date-time>` _(required)_: The time this decision counts from in cumulative limit windows.
  - `admittedAt` `string <date-time>` _(required)_: When the chain boundary first admitted a transaction under this decision, or null.
  - `admittedTxHash` `unknown` _(required)_: The hash of the transaction the chain boundary bound this decision to, or null.
  - `createdAt` `string <date-time>` _(required)_: When the decision was recorded.
- `pagination` `object` _(required)_: Paging details for the result.
  - `currentPage` `number` _(required)_: The 1-based number of this page.
  - `totalPages` `number` _(required)_: The number of pages at the current limit.
  - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
  - `limit` `number` _(required)_: The maximum number of items per page.
  - `offset` `number` _(required)_: The number of items skipped before this page.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/policy/decisions?limit=10&offset=0&matchedRuleId=string&outcome=allowed&search=string'
```

```ts
fetch('/api/policy/decisions?limit=10&offset=0&matchedRuleId=string&outcome=allowed&search=string')
```

## Get a policy decision

`GET /policy/decisions/{decisionId}`

Read a recorded policy decision, including the rule-by-rule evaluation trace

### Path parameters

- `decisionId` `string` _(required)_: The policy decision ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The decision ID.
- `organizationId` `string | null` _(required)_: The organization the decision belongs to, or null for the zone policy.
- `rulesetId` `string` _(required)_: The ID of the ruleset version that produced the decision.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
- `chargedRuleIds` `string[]` _(required)_: The IDs of every rule whose cumulative spending limit this decision counts against.
- `countedRuleIds` `string[]` _(required)_: The IDs of every rule with an amount bound this decision counts toward, so a transaction split across calls is measured as a whole.
- `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
- `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
- `intentDigest` `string` _(required)_: A digest of the normalized operation the decision was made for.
- `intent` `unknown` _(required)_: The normalized operation the decision was made for, as the server built it.
- `evaluationTrace` `object[]` _(required)_: One entry per rule in order, plus a default-rule entry when no rule matched.
  - `ruleId` `string` _(required)_: The ID of the rule visited.
  - `ruleName` `string` _(required)_: The rule name.
  - `matched` `boolean` _(required)_: Whether the operation met every condition of the rule.
  - `failedCondition` `string`: The first condition the operation failed, absent when the rule matched or was skipped.
  - `skipped` `string`: Set to disabled when the rule was skipped because it is disabled.
- `operation` `string` _(required)_: The operation type the server derived from the request.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the user or machine-to-machine application that asked for the decision.
- `sourceAddress` `string` _(required)_: The wallet address that sends or signs the operation.
- `destinationAddress` `string | null` _(required)_: The recipient or target contract address, or null when the operation has none.
- `assetAddress` `string | null` _(required)_: The token contract the operation moves, or null when it moves native value or no token.
- `amount` `string | null` _(required)_: The amount the operation moves, as a base-unit integer string, or null when it moves none.
- `correlationId` `string | null` _(required)_: The correlation ID the caller supplied, or null.
- `heldUntil` `string <date-time>` _(required)_: When the hold on this decision for its bound transaction lapses, or null when it is not held or the transaction is confirmed.
- `confirmedAt` `string <date-time>` _(required)_: When the transaction that spent this decision was confirmed, or null.
- `chargedAt` `string <date-time>` _(required)_: The time this decision counts from in cumulative limit windows.
- `admittedAt` `string <date-time>` _(required)_: When the chain boundary first admitted a transaction under this decision, or null.
- `admittedTxHash` `unknown` _(required)_: The hash of the transaction the chain boundary bound this decision to, or null.
- `createdAt` `string <date-time>` _(required)_: When the decision was recorded.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/decisions/string
```

```ts
fetch('/api/policy/decisions/string')
```

## Evaluate an operation

`POST /policy/evaluate`

Evaluate an operation against the active policy ruleset and record the decision

### Request body (`application/json`)

### Responses

#### `200`: Default Response

Body (`application/json`):

- `decisionId` `string` _(required)_: The ID of the recorded decision.
- `outcome` `string` _(required)_: The verdict: allowed lets the operation proceed, blocked refuses it, and approval_required holds it until an approval request is approved.
- `ruleId` `string` _(required)_: A machine-readable reason code for the outcome, such as policy.rule.allow or policy.default_deny.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the outcome, or null when no rule matched and the default rule decided.
- `intentDigest` `string` _(required)_: A digest of the normalized operation the decision was made for.
- `rulesetId` `string` _(required)_: The ID of the active ruleset version that produced the decision.
- `reused` `boolean` _(required)_: Whether an earlier decision with the same correlationId and operation was returned.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `422`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/evaluate \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "correlationId": "string",
  "kind": "transaction",
  "source": "string",
  "destination": "string",
  "value": "0",
  "calldata": "0x"
}'
```

```ts
fetch('/api/policy/evaluate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    correlationId: 'string',
    kind: 'transaction',
    source: 'string',
    destination: 'string',
    value: '0',
    calldata: '0x'
  })
})
```

## List approval requests

`GET /policy/approvals`

List policy approval requests for the zone

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.
- `state` `string`: Return only requests in this state, where a pending request past its expiry counts as expired.
- `subject` `string`: Return only requests with this subject.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `items` `object[]` _(required)_: The items on this page.
  - `id` `string` _(required)_: The approval request ID.
  - `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
  - `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
  - `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
  - `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
  - `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
  - `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
  - `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
  - `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
  - `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
    - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
      - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
      - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
        - `roleId` `string` _(required)_: The role whose holders can approve for the group.
        - `threshold` `integer` _(required)_: How many approvals the group needs.
      - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
      - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
      - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
  - `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
  - `createdAt` `string <date-time>` _(required)_: When the request was opened.
  - `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
  - `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
  - `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
  - `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
  - `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
  - `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
  - `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
  - `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
    - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
    - `approverId` `string` _(required)_: The ID of the approver.
    - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
- `pagination` `object` _(required)_: Paging details for the result.
  - `currentPage` `number` _(required)_: The 1-based number of this page.
  - `totalPages` `number` _(required)_: The number of pages at the current limit.
  - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
  - `limit` `number` _(required)_: The maximum number of items per page.
  - `offset` `number` _(required)_: The number of items skipped before this page.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/policy/approvals?limit=10&offset=0&state=pending&subject=operation'
```

```ts
fetch('/api/policy/approvals?limit=10&offset=0&state=pending&subject=operation')
```

## Get an approval request

`GET /policy/approvals/{requestId}`

Read an approval request with its quorum progress and votes cast

### Path parameters

- `requestId` `string` _(required)_: The approval request ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The approval request ID.
- `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
- `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
- `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
- `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
- `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
- `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
- `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
  - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
  - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
    - `roleId` `string` _(required)_: The role whose holders can approve for the group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
  - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
  - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
  - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
- `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
- `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
- `createdAt` `string <date-time>` _(required)_: When the request was opened.
- `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
- `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
- `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
- `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
- `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
- `progress` `object` _(required)_: The quorum progress, computed from the votes cast.
  - `state` `string` _(required)_: The quorum state: pending while unmet, approved once every requirement is met, and rejected after any rejection.
  - `groups` `object[]` _(required)_: Progress for each approver group in every requirement.
    - `roleId` `string` _(required)_: The role whose holders form the approver group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `approvals` `integer` _(required)_: How many approvals from currently eligible approvers count toward the group.
    - `satisfied` `boolean` _(required)_: Whether the group has reached its threshold.
- `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
  - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
  - `approverId` `string` _(required)_: The ID of the approver.
  - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
  - `reason` `string | null` _(required)_: The reason the approver gave, or null.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/approvals/string
```

```ts
fetch('/api/policy/approvals/string')
```

## Vote on an approval request

`POST /policy/approvals/{requestId}/decision`

Approve or reject an approval request

### Path parameters

- `requestId` `string` _(required)_: The approval request ID.

### Request body (required) (`application/json`)

- `verdict` `string` _(required)_: The vote: approve counts toward the quorum, and reject rejects the request outright.
- `reason` `string`: A reason for the vote, up to 500 characters.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The approval request ID.
- `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
- `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
- `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
- `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
- `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
- `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
- `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
  - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
  - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
    - `roleId` `string` _(required)_: The role whose holders can approve for the group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
  - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
  - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
  - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
- `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
- `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
- `createdAt` `string <date-time>` _(required)_: When the request was opened.
- `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
- `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
- `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
- `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
- `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
- `progress` `object` _(required)_: The quorum progress, computed from the votes cast.
  - `state` `string` _(required)_: The quorum state: pending while unmet, approved once every requirement is met, and rejected after any rejection.
  - `groups` `object[]` _(required)_: Progress for each approver group in every requirement.
    - `roleId` `string` _(required)_: The role whose holders form the approver group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `approvals` `integer` _(required)_: How many approvals from currently eligible approvers count toward the group.
    - `satisfied` `boolean` _(required)_: Whether the group has reached its threshold.
- `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
  - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
  - `approverId` `string` _(required)_: The ID of the approver.
  - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
  - `reason` `string | null` _(required)_: The reason the approver gave, or null.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/approvals/string/decision \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "verdict": "approve",
  "reason": "string"
}'
```

```ts
fetch('/api/policy/approvals/string/decision', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    verdict: 'approve',
    reason: 'string'
  })
})
```

## Cancel an approval request

`POST /policy/approvals/{requestId}/cancel`

Cancel an open approval request

### Path parameters

- `requestId` `string` _(required)_: The approval request ID.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `id` `string` _(required)_: The approval request ID.
- `organizationId` `string | null` _(required)_: The organization the request belongs to, or null for the zone policy.
- `subject` `string` _(required)_: What the request gates: operation is a policy decision that needs approval, and publication is a draft ruleset waiting to be published.
- `decisionId` `string | null` _(required)_: The ID of the decision the request gates, or null for a publication request.
- `rulesetId` `string | null` _(required)_: For an operation, the ruleset that decided it, and for a publication, the draft to publish, which is null once the draft is discarded.
- `initiatorType` `string` _(required)_: Whether the initiator is a user or an m2m_app (machine-to-machine application).
- `initiatorId` `string` _(required)_: The ID of the initiator, which for a publication request is the draft author.
- `state` `string` _(required)_: The request state: pending awaits votes, approved and rejected were settled by votes, expired passed expiresAt, cancelled was withdrawn or lost its draft, and invalidated was overtaken by a new publication or draft change.
- `intentDigest` `string` _(required)_: The digest of the gated operation, or the rulesDigest of the draft for a publication request.
- `approvalSpec` `object` _(required)_: The approval requirements, fixed when the request was opened.
  - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
  - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
    - `roleId` `string` _(required)_: The role whose holders can approve for the group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
  - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
  - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
  - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
  - `alsoRequired` `object[]`: The requirements of every other approval rule the operation matched, each of which must also be met.
    - `logic` `string` _(required)_: How the groups combine: and needs every group satisfied, or needs any one group satisfied.
    - `groups` `object[]` _(required)_: The approver groups, each a role and the number of its holders who must approve.
      - `roleId` `string` _(required)_: The role whose holders can approve for the group.
      - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `initiatorMayApprove` `boolean` _(required)_: Whether the initiator of the request can approve it.
    - `allowMachineApprovers` `boolean` _(required)_: Whether machine-to-machine applications can approve.
    - `expirySeconds` `integer` _(required)_: How long the request stays open, in seconds.
- `expiresAt` `string <date-time>` _(required)_: When the request expires if it is still pending.
- `resolvedAt` `string <date-time>` _(required)_: When the request left the pending state, or null while it is pending.
- `createdAt` `string <date-time>` _(required)_: When the request was opened.
- `updatedAt` `string <date-time>` _(required)_: When the request was last updated.
- `operation` `string` _(required)_: The operation type of the gated decision, or null for a publication request.
- `sourceAddress` `string | null` _(required)_: The source wallet address of the gated decision, or null for a publication request.
- `destinationAddress` `string | null` _(required)_: The destination address of the gated decision, or null when it has none.
- `assetAddress` `string | null` _(required)_: The token contract of the gated decision, or null when it moves no token.
- `amount` `string | null` _(required)_: The base-unit amount of the gated decision as an integer string, or null when it has none.
- `matchedRuleId` `string | null` _(required)_: The ID of the rule that decided the gated operation, or null for a publication request.
- `progress` `object` _(required)_: The quorum progress, computed from the votes cast.
  - `state` `string` _(required)_: The quorum state: pending while unmet, approved once every requirement is met, and rejected after any rejection.
  - `groups` `object[]` _(required)_: Progress for each approver group in every requirement.
    - `roleId` `string` _(required)_: The role whose holders form the approver group.
    - `threshold` `integer` _(required)_: How many approvals the group needs.
    - `approvals` `integer` _(required)_: How many approvals from currently eligible approvers count toward the group.
    - `satisfied` `boolean` _(required)_: Whether the group has reached its threshold.
- `votes` `object[]` _(required)_: The votes cast so far, in the order they were cast.
  - `approverType` `string` _(required)_: Whether the approver is a user or an m2m_app.
  - `approverId` `string` _(required)_: The ID of the approver.
  - `verdict` `string` _(required)_: Whether the approver approved or rejected the request.
  - `reason` `string | null` _(required)_: The reason the approver gave, or null.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `409`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/approvals/string/cancel \
  --request POST
```

```ts
fetch('/api/policy/approvals/string/cancel', {
  method: 'POST'
})
```

## Get cumulative limit usage

`GET /policy/limits`

Read how much of each cumulative limit the zone's active ruleset has consumed

### Query parameters

- `limit` `integer`: The maximum number of items to return.
- `offset` `integer`: The number of items to skip before the first returned item.
- `holder` `string | string[]`: Up to 25 initiator IDs or wallet addresses whose allowances are returned in named.
- `ruleId` `string | string[]`: Up to 25 limit rule IDs that narrow the allowances listed, all limits when omitted.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `rulesetId` `string | null` _(required)_: The ID of the active ruleset, or null when none has been published.
- `asOf` `string` _(required)_: The instant the usage was computed, as an ISO 8601 timestamp.
- `limits` `object[]` _(required)_: Every enabled cumulative limit in the active ruleset, whatever the ruleId filter.
  - `ruleId` `string` _(required)_: The ID of the rule that sets the limit.
  - `ruleName` `string` _(required)_: The rule name.
  - `max` `string` _(required)_: The maximum base-unit amount per window, as an integer string.
  - `windowSeconds` `integer` _(required)_: The length of the rolling window, in seconds.
  - `scopeBy` `string[]` _(required)_: The dimensions that key each allowance, where an empty list means one shared allowance.
- `allowances` `object` _(required)_: A page of allowances, ordered by rule position and then by amount spent, largest first.
  - `items` `object[]` _(required)_: The items on this page.
    - `ruleId` `string` _(required)_: The ID of the limit rule the allowance belongs to.
    - `spent` `string` _(required)_: The base-unit amount charged within the current window, as an integer string.
    - `remaining` `string` _(required)_: The base-unit amount left before the limit is reached, as an integer string.
    - `charges` `integer` _(required)_: The number of decisions charged within the current window.
    - `windowFreesAt` `string | null` _(required)_: When the earliest charge leaves the window and frees room, or null when nothing is charged.
    - `scope` `object` _(required)_: The holder of the allowance, with a key for each dimension the limit is scoped by.
      - `initiator` `string`: The initiator ID, present when the limit is scoped by initiator.
      - `source` `string`: The source wallet address, present when the limit is scoped by source.
      - `destination` `string | null`: The destination address, present when the limit is scoped by destination, and null for operations with no destination.
  - `pagination` `object` _(required)_: Paging details for the result.
    - `currentPage` `number` _(required)_: The 1-based number of this page.
    - `totalPages` `number` _(required)_: The number of pages at the current limit.
    - `totalItems` `number` _(required)_: The number of items that match the query across all pages.
    - `limit` `number` _(required)_: The maximum number of items per page.
    - `offset` `number` _(required)_: The number of items skipped before this page.
- `named` `object[]` _(required)_: The allowances of the holders named in the holder parameter, whichever page they fall on.
  - `ruleId` `string` _(required)_: The ID of the limit rule the allowance belongs to.
  - `spent` `string` _(required)_: The base-unit amount charged within the current window, as an integer string.
  - `remaining` `string` _(required)_: The base-unit amount left before the limit is reached, as an integer string.
  - `charges` `integer` _(required)_: The number of decisions charged within the current window.
  - `windowFreesAt` `string | null` _(required)_: When the earliest charge leaves the window and frees room, or null when nothing is charged.
  - `scope` `object` _(required)_: The holder of the allowance, with a key for each dimension the limit is scoped by.
    - `initiator` `string`: The initiator ID, present when the limit is scoped by initiator.
    - `source` `string`: The source wallet address, present when the limit is scoped by source.
    - `destination` `string | null`: The destination address, present when the limit is scoped by destination, and null for operations with no destination.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl '/api/policy/limits?limit=20&offset=0&holder=string&ruleId=string'
```

```ts
fetch('/api/policy/limits?limit=20&offset=0&holder=string&ruleId=string')
```

## Get token decimals and symbol

`GET /policy/assets/{address}`

Read the decimals and symbol of a registered contract the zone's policy can name, so its amounts can be shown in the token's own unit

### Path parameters

- `address` `string` _(required)_: The address of a registered contract.

### Responses

#### `200`: Default Response

Body (`application/json`):

- `decimals` `integer` _(required)_: The token decimals, or null when the contract does not answer decimals() the way an ERC-20 does.
- `symbol` `string | null` _(required)_: The token symbol, or null when the contract returns none or one unfit for display.

#### `401`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `403`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

#### `404`: Default Response

Body (`application/json`):

- `error` `object` _(required)_: Details of the error.
  - `code` `string` _(required)_: A machine-readable error code.
  - `message` `string` _(required)_: A human-readable description of the error.
  - `issues` `unknown[]`: Validation issues, present when the request failed validation.

### Example request

```bash
curl /api/policy/assets/string
```

```ts
fetch('/api/policy/assets/string')
```
