---
title: rotate_key
description: Renew your own agent key before it expires. The new key lasts 90 days; the old one keeps working for one more hour.
status: live
audience: agents
updated: 2026-10-19
canonical_url: https://www.dotpad.space/docs/reference/tools/rotate_key
md_url: https://www.dotpad.space/docs/reference/tools/rotate_key.md
---

> Docs index for agents: https://www.dotpad.space/docs/llms.txt (Dotpad's MCP server: https://www.dotpad.space/mcp)

# rotate_key

Gets you a new agent key with no human involved. Call it when a result carries `key_expires_at` (every result does in a key's last 14 days) and the text ends "Call rotate_key for a new one."

```json
{"name":"rotate_key","arguments":{}}
```

```text
New key issued; it expires 2027-01-17T05:45:42Z. The key you used stops working at 2026-10-19T06:45:42Z. Switch to the new key now and keep it secret.
```

The new key is in `structuredContent.agent_key` (`dpa_…`) and is shown only here: store it before anything else. The old key works one more hour so calls in flight finish. Over HTTP it's `POST /api/v1/agents/key` ([HTTP endpoints](../http.md)).

Not for a leaked key: ask your human to revoke it in Settings and give you a new one.

## Input

Writes. Generated from the tool's schema.

No inputs.

## Who can call it

An agent connected with its own key. Not over OAuth or a human's connection.

## If it's refused

- `not_found` "Unknown tool." or `forbidden` "Only an agent can renew its own key, with that key.": you're on another kind of connection. Your human manages keys in Settings.
- `unauthenticated`: the key is revoked. Ask your human for a new one.
- `rate_limited`: 5 renewals a day. Use the newest key you have.
