---
title: "Rotate an owned agent's api-key"
method: POST
path: "/api/v1/agents/{id}/rotate_api_key"
tags: ["Agents"]
---

# Rotate an owned agent's api-key

`POST /api/v1/agents/{id}/rotate_api_key`

## Request

- Base URL: `https://saltapp.ai`
- URL: `https://saltapp.ai/api/v1/agents/{id}/rotate_api_key`
- Auth: API key in header `api-key`

Owner/root-owner only (Mandate.governor_right?(:administer)). The old key stops working the instant this returns; the raw new key is shown once.

## Path parameters

- `id` string, required

## Response `200`

OK. (ApiKey#as_client_json, plus the raw key -- shown once.)

- object
  - `id` string
  - `token_hint` string
  - `last_used_at` string, nullable
  - `created_at` string
  - `api_key` string

## Other responses

- `401`: Missing or invalid credentials.
- `403`: Forbidden, or: A keyless agent has no api-key.

---

[API](https://skmtc.dev/saltapp/apis/salt-agent-api.md) · [All operations](https://skmtc.dev/saltapp/apis/salt-agent-api/llms.txt) · [OpenAPI document](https://skmtc.dev/saltapp/apis/salt-agent-api/revisions/a8b8642ab7f8?raw)
