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

# Policy template

> Save reusable configuration for new Swig wallets.

## Introduction

A policy template stores the initial authority and actions used when creating a
wallet. Use it when your application creates many wallets with the same setup.
The Developer Portal calls this **Wallet templates**.

A template is saved configuration. Editing it does not change permissions on
an existing wallet; use [Role](https://build.onswig.com/developer-sdk/add-roles-and-permissions.md) for that.

## SDK examples

### Create a wallet from a template

Template creation is a portal action. Use the saved policy ID with the SDK to
prepare a wallet. This example assumes the template asks for an Ed25519 initial
user. Omit that authority when the template already supplies it.

```typescript TypeScript theme={null}
const created = await swig.wallets.create({
  feePayer,
  policyId,
  initialUser: { ed25519: { publicKey: userPublicKey } },
});
```

```python Python theme={null}
created = await swig.wallets.create(
    fee_payer=fee_payer,
    policy_id=policy_id,
    initial_user={"ed25519": {"publicKey": user_public_key}},
)
```

```rust Rust theme={null}
use swig_developer_sdk::{PrepareCreateWalletArgs, WalletAuthority};

let created = wallet.prepare_create_wallet(PrepareCreateWalletArgs {
    fee_payer,
    policy_id: Some(policy_id),
    initial_user: Some(WalletAuthority::Ed25519 {
        public_key: user_public_key,
    }),
}).await?;
```

Use the clients from [Client setup](https://build.onswig.com/developer-sdk/integration-paths.md).
[Sign and submit the creation plan](https://build.onswig.com/developer-sdk/create-wallets.md), then add each
additional role and verify its confirmed permissions. To inspect saved template
metadata, use [Fetch template](https://build.onswig.com/examples/dev-portal/fetch-policy.md).

### Inspect the template

Fetch saved metadata to verify the template selected by your application.

```typescript TypeScript theme={null}
const template = await swig.wallets.getPolicy(policyId);
```

```python Python theme={null}
template = await swig.wallets.get_policy(policy_id)
```

```rust Rust theme={null}
let template = wallet.get_policy(&policy_id).await?;
```

## Input

| Field | Required | Description |
| :- | :- | :- |
| Name | Yes | Identifies the template |
| Description | No | Explains its purpose |
| Initial authority | Yes, now or at wallet creation | Choose the public-key type; save a key or let the application supply it later |
| Additional user | No | Public key and at least one allowed action; provision this role separately after wallet creation |

The portal gives the initial user full root access (`All`). Its form does not
provide an initial-user spending-limit editor. Additional users saved in the
template are **not automatically added** by Developer SDK wallet creation.

Open **Wallet templates** in the [Developer Portal](https://dashboard.onswig.com),
select **New template**, enter the fields above, and save the policy ID.
Recovery-guardian setup in that form is currently unavailable; see
[Guardian recovery](https://build.onswig.com/developer-sdk/use-cases/guardian-recovery.md).

## Errors

| Error | Meaning |
| :- | :- |
| Template lookup is denied or missing | The policy ID is unavailable to the server API key. Check the ID and resource access using Fetch template. |
| Initial authority missing at creation | The template expects the application to supply its key. Set initialUser / initial\_user when preparing the wallet. |
| Additional role absent after creation | Stored additional users are not provisioned by template-based creation. Add each role after wallet creation confirms, then inspect its permissions. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.