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

# Updating policies

> Replace your policy set with a new proposal.

## What is a policy?

Policies govern what transactions are allowed, who can initiate or
approve them, and any limits or conditions that apply. In this guide, we’ll
show how to update existing policies by submitting a policy update proposal.

## 1) Set up the client

Create the SDK client used to propose policy updates.

```typescript theme={null}
import { DenClient } from "@onchainden/mls-sdk-ts";

const client = new DenClient({
  apiKey: process.env.DEN_API_KEY!,
  baseUrl: process.env.DEN_API_BASE_URL!,
});
```

## 2) Build the updated policy set

Provide full policy objects for each policy you want to update, including the `id` of the policy to update.

```typescript theme={null}
const policies = [
  {
    id: "pol_123",
    name: "Auto-approve Small Transfers",
    description: "Auto-approve USDC transfers under $2000",
    type: "AUTO_APPROVAL",
    transactionType: "TOKEN_TRANSFER",
    networkId: 1,
    accountIds: ["acc_1", "acc_2"],
    limitation: {
      hours: 24,
      initiatorScope: "PER_ITEM",
      sourceAccountScope: "PER_ITEM",
      destinationScope: "ALL_ITEMS",
    },
    initiatorSetting: { type: "group", groupId: "grp_finance" },
    approverSetting: null,
    tokenTransferCondition: {
      tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      amountThreshold: "2000000000",
      destinationAddresses: [],
    },
  },
];
```

## 3) Propose, sign, and execute

Submit the proposal, collect approvals, and execute the update.

```typescript theme={null}
const { data: proposal } = await client.createPolicyUpdateProposal({ policies });

await client.signPolicyProposal(proposal.id, {
  type: "approve",
  signature: "0x...",
});

await client.executePolicyProposal(proposal.id, {
  type: "approve",
});
```

## Full example

```typescript theme={null}
import { DenClient } from "@onchainden/mls-sdk-ts";

// 1) Set up the client.
const client = new DenClient({
  apiKey: process.env.DEN_API_KEY!,
  baseUrl: process.env.DEN_API_BASE_URL!,
});

// 2) Build the updated policy set.
const policies = [
  {
    id: "pol_123",
    name: "Auto-approve Small Transfers",
    description: "Auto-approve USDC transfers under $2000",
    type: "AUTO_APPROVAL",
    transactionType: "TOKEN_TRANSFER",
    networkId: 1,
    accountIds: ["acc_1", "acc_2"],
    limitation: {
      hours: 24,
      initiatorScope: "PER_ITEM",
      sourceAccountScope: "PER_ITEM",
      destinationScope: "ALL_ITEMS",
    },
    initiatorSetting: { type: "group", groupId: "grp_finance" },
    approverSetting: null,
    tokenTransferCondition: {
      tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      amountThreshold: "2000000000",
      destinationAddresses: [],
    },
  },
];

// 3) Propose, sign, and execute.
const { data: proposal } = await client.createPolicyUpdateProposal({ policies });

await client.signPolicyProposal(proposal.id, {
  type: "approve",
  signature: "0x...",
});

await client.executePolicyProposal(proposal.id, {
  type: "approve",
});
```
