---
title: "Replace an ingest key's value, keeping the same row and scope."
method: POST
path: "/projects/{project_id}/analytics/ingest-keys/{key_id}/rotate"
tags: ["Analytics Ingest Keys"]
---

# Replace an ingest key's value, keeping the same row and scope.

`POST /projects/{project_id}/analytics/ingest-keys/{key_id}/rotate`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/analytics/ingest-keys/{key_id}/rotate`
- Auth: HTTP bearer

The previous value stops working immediately — the resolution cache entry
for it is evicted synchronously rather than left to expire. Any client still
sending the old value will start receiving 401s, so roll out the new value
before rotating.

## Path parameters

- `project_id` integer, required
- `key_id` integer, required

## Response `200`

Ingest key rotated

- AnalyticsIngestKey: An analytics ingest key as returned by the admin API. `public_key` is present in full on every response — see the module docs.
  - `allowed_origins` string[], nullable: Exact origins (`scheme://host[:port]`) permitted to use this key from a browser. `None` or `[]` means any origin. This is a browser-enforced convenience control, not authentication — a non-browser client ignores `Origin` entirely.
  - `created_at` string, date-time, required
  - `created_by_user_id` integer, nullable
  - `environment_id` integer, nullable: `None` means the key is scoped to the whole project. An environment-scoped key additionally attributes ingested data to that environment's current deployment, when it has one.
  - `event_count` integer, required
  - `id` integer, required
  - `is_active` boolean, required
  - `last_used_at` string, date-time, nullable
  - `name` string, required: Operator-facing label.
  - `project_id` integer, required
  - `public_key` string, required: The ingest key itself, `pa_` + 64 hex characters. **Not a secret.** It is designed to ship in client-side JavaScript and is returned unmasked so operators can copy it. See the module docs.
  - `rate_limit_per_minute` integer, nullable: `None` or `<= 0` means unlimited.
  - `revoked_at` string, date-time, nullable
  - `updated_at` string, date-time, required

## Other responses

- `400`: The key is revoked and cannot be rotated
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Ingest key not found in this project
- `500`: Internal server error

## Changes

- **2026-09-07** `c2a1f69745e7`: 1 info
  - endpoint added
- **2026-09-07** `7a3103561bd0`: 1 breaking
  - api path removed without deprecation
- **2026-09-07** `7fcff272f099`: 1 info
  - endpoint added
- **2026-09-07** `c1fa498b6377`: 1 breaking
  - api path removed without deprecation
- **2026-09-07** `c43de0e360be`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/analytics/ingest-keys/:key_id/rotate/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
