---
title: "Rotate API key"
method: PUT
path: "/auth/api_keys/{api_key_id}"
tags: ["API keys"]
---

# Rotate API key

`PUT /auth/api_keys/{api_key_id}`

Rotate an existing API Key, generating a new token. This invalidates the previous key.
Use PATCH to update settings without rotating the token.

## Path parameters

- `api_key_id` string, required

## Request body

- UpdateApiKey
  - `data` object
    - `id` string, (?-mix:^[a-zA-Z]+_[a-zA-Z0-9]+$)
    - `type` 'api_keys', required
    - `attributes` object
      - `name` string — Name of the API Key
      - `read_only` boolean — Whether the API Key is read-only. Read-only keys can only perform GET requests.
      - `allowed_ips` string[] — List of allowed IP addresses or CIDR ranges (e.g., "192.168.1.100", "10.0.0.0/24")

## Response `200`

Success

---

[API](https://skmtc.net/latitude/apis/latitude-sh-api.md) · [All operations](https://skmtc.net/latitude/apis/latitude-sh-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/latitude/latitude-sh-api/versions/7302d79e39bb/schema)
