> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keystoneos.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> List and inspect settlement templates.

Templates are read-only definitions that configure the settlement state machine, required roles, leg types, compliance providers, and action handlers.

## list

```typescript theme={null}
const { items: templates } = await client.templates.list();

for (const template of templates) {
  console.log(`${template.slug}: ${template.name}`);
  console.log(`  Roles: ${template.config.requiredRoles.join(", ")}`);
  console.log(`  States: ${template.config.states.length}`);
}
```

| Field    | Type     | Default | Description        |
| -------- | -------- | ------- | ------------------ |
| `limit`  | `number` | `50`    | Max items per page |
| `offset` | `number` | `0`     | Items to skip      |

***

## get

```typescript theme={null}
const template = await client.templates.get("template-uuid");

console.log(template.config.initialState);    // "INSTRUCTED"
console.log(template.config.terminalStates);  // ["FINALIZED", "ROLLED_BACK", "TIMED_OUT"]
```

### SettlementTemplateRead

| Field         | Type             | Description                                       |
| ------------- | ---------------- | ------------------------------------------------- |
| `id`          | `string`         | Template UUID                                     |
| `slug`        | `string`         | URL-friendly identifier (e.g., `"dvp-bilateral"`) |
| `name`        | `string`         | Human-readable name                               |
| `description` | `string \| null` | Template description                              |
| `config`      | `TemplateConfig` | State machine definition                          |
| `version`     | `number`         | Current version                                   |
| `isActive`    | `boolean`        | Whether the template is available                 |
| `createdAt`   | `string`         | Creation timestamp                                |
| `updatedAt`   | `string`         | Last update timestamp                             |

### TemplateConfig

| Field            | Type                             | Description                                      |
| ---------------- | -------------------------------- | ------------------------------------------------ |
| `states`         | `string[]`                       | All possible states in the lifecycle             |
| `initialState`   | `string`                         | Starting state for new settlements               |
| `terminalStates` | `string[]`                       | States that end the settlement                   |
| `failureStates`  | `string[]`                       | Subset of terminal states indicating failure     |
| `transitions`    | `Record<string, TransitionRule>` | Which states can transition to which             |
| `requiredRoles`  | `string[]`                       | Party roles needed (e.g., `["seller", "buyer"]`) |
| `compliance`     | `ComplianceConfig`               | Compliance provider configuration                |
| `actions`        | `Record<string, ActionConfig>`   | Action handlers per state                        |

### TransitionRule

```typescript theme={null}
{ allowedNext: string[] }
```

### ComplianceConfig

| Field             | Type       | Description                                        |
| ----------------- | ---------- | -------------------------------------------------- |
| `entityProviders` | `string[]` | KYC/AML providers (e.g., `["lseg_worldcheck"]`)    |
| `walletProviders` | `string[]` | Wallet screening providers (e.g., `["cipherowl"]`) |
| `recheckAtStates` | `string[]` | States where compliance is re-verified             |

### ActionConfig

| Field            | Type     | Description                                                             |
| ---------------- | -------- | ----------------------------------------------------------------------- |
| `type`           | `string` | Action type (e.g., `"compliance_check"`, `"noop"`, `"register_escrow"`) |
| `provider`       | `string` | Provider handling this action                                           |
| `resolution`     | `string` | `"immediate"`, `"webhook"`, `"poll"`, or `"manual"`                     |
| `timeoutSeconds` | `number` | Max time for the action to complete                                     |
| `params`         | `object` | Action-specific configuration                                           |
