# rotate_rule_secret

URL: https://codepanel.ai/docs/mcp-server/rotate_rule_secret

The CodePanel MCP tool that rotates the incoming webhook bearer token of a webhook autopilot rule, invalidating the previous token immediately.

`rotate_rule_secret` replaces the bearer signing token of an incoming `webhook` autopilot rule. The previous token stops working immediately, and the new plaintext token is returned once. It needs the `tasks:write` scope.

## When to call it

- **When a webhook token was leaked or rotated on a schedule**, or when you need a fresh token for an existing `webhook` rule without deleting and recreating it.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `ruleId` | string | yes | Id of a rule, from list_rules |

It writes: the server marks it `readOnlyHint: false` and `destructiveHint: true` (it can change what is already there), so a client that asks before writes asks here.

## What it returns

`{ rule, webhookSecret, webhookUrl }`, with the updated rule (carrying the new `webhookTokenPrefix`), the one-time bearer token `webhookSecret`, and the endpoint URL `webhookUrl`. Calling it on a non-webhook rule returns `precondition`; an unknown id returns `not_found`.

## The same step without MCP

| Surface | Form |
| --- | --- |
| HTTP API | `POST /autopilot/rules/rotate-secret` with the `tasks:write` scope |
| CLI | `codepanel rules rotate-secret <ruleId>` |
| Desktop app | Autopilot, Edit rule, Rotate secret |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Use it to replace the incoming webhook signing token of a webhook autopilot rule without deleting the rule. Invalidates the previous token immediately. Needs the tasks:write scope. Returns { rule, webhookSecret, webhookUrl } with the new one-time bearer token.

## Related

- [`create_rule`](/docs/mcp-server/create_rule): create a `webhook` rule and receive its initial token.
- [`update_rule`](/docs/mcp-server/update_rule): edit or pause the rule.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
