---
title: "Commands"
description: "Commands for updating an editor's content protection policy."
canonical_url: "https://tiptap.dev/docs/composable-docs/content-protection/api-reference/commands"
---

# Commands

Commands for updating an editor's content protection policy.

Add the [Content Protection extension](https://tiptap.dev/docs/composable-docs/content-protection/api-reference/extension.md) before using this command.

## `setContentProtectionPolicy`

Validates and replaces the active policy.

```ts
editor.commands.setContentProtectionPolicy({ policy })
```

### Parameters

- `policy` (`ContentProtectionPolicy`): The complete replacement [policy](https://tiptap.dev/docs/composable-docs/content-protection/api-reference/policy.md#contentprotectionpolicy).

### Returns (`boolean`)

- `true`: The policy is valid, including when it is unchanged.
- `false`: The policy is invalid or the transaction also changes document content.

A direct `editor.commands.setContentProtectionPolicy({ policy })` call is synchronous: when it returns, the accepted policy and `policyRevision` are installed. With `editor.chain()`, installation happens when `.run()` dispatches the transaction. The `contentProtectionPolicyUpdate` notification is queued as a microtask after installation; it does not run before the command returns.

### Behavior

- A changed policy increments `policyRevision` and emits `contentProtectionPolicyUpdate`.
- An identical policy has no effect and emits no event.
- Invalid input keeps the previous policy and emits `contentProtectionPolicyError`.
- The extension copies the policy. Mutating the supplied object has no effect.
- Policy changes do not change document content or enter undo history.
- Selection-only chaining is allowed. Replace the policy separately from content edits.
- `editor.can().setContentProtectionPolicy({ policy })` validates without changing state or emitting events.
