Skip to content

docs(openapi): add API key rotate endpoint and document reset_usage update flow#134

Merged
sk-portkey merged 2 commits intomasterfrom
openapi-spec/4432-admin-api-upgrade
Apr 7, 2026
Merged

docs(openapi): add API key rotate endpoint and document reset_usage update flow#134
sk-portkey merged 2 commits intomasterfrom
openapi-spec/4432-admin-api-upgrade

Conversation

@akhilmmenon
Copy link
Copy Markdown

@akhilmmenon akhilmmenon commented Apr 7, 2026

Summary

  • Add OpenAPI documentation for POST /api-keys/{id}/rotate.
  • Define rotate request/response schemas:
    • RotateApiKeyRequest (key_transition_period_ms)
    • RotateApiKeyResponse (id, key, key_transition_expires_at)
  • Add code samples for rotate (curl, python, javascript; cloud + self-hosted).
  • Keep and validate reset_usage documentation on PUT /api-keys/{id} (schema + request examples), including minimal {"reset_usage": true} usage.

Why

API key rotation is implemented in backend routes but was not available in OpenAPI docs. This PR makes the rotate endpoint discoverable and testable in the API reference, while preserving the already-documented reset_usage update flow.

Scope

  • Repo: Portkey-AI/openapi
  • Branch: openapi-spec/4432-admin-api-upgrade
  • File changed: openapi.yaml

Test Plan

  • Open OpenAPI reference and verify POST /api-keys/{id}/rotate is present.
  • Confirm rotate request schema includes optional key_transition_period_ms with minimum 1800000.
  • Confirm rotate success response includes id, key, and key_transition_expires_at.
  • Confirm rotate code samples render for curl/python/javascript (default + self-hosted).
  • Confirm PUT /api-keys/{id} still includes reset_usage in schema/examples.

Merge Timing

Keep this PR open and merge after the rotate endpoint is Generally Available.

Related

  • Companion docs-core changes are in branch: docs-update/4432-admin-api-upgrade

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds OpenAPI documentation so API key rotation is discoverable in the API reference, while improving/validating the existing reset_usage update flow documentation.

Changes:

  • Adds POST /api-keys/{id}/rotate with request/response schemas and code samples (default + self-hosted).
  • Adds explicit request examples for PUT /api-keys/{id}, including a minimal {"reset_usage": true} example.
  • Extends UpdateApiKeyObject to include reset_usage and fixes the curl method for the update endpoint samples (GET → PUT).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18062 to +18070
/api-keys/{id}/rotate:
servers: *ControlPlaneServers
post:
tags:
- Api-Keys
summary: Rotate API Key
description: |
Rotates an existing API key and returns a newly generated key value.
The previous key remains valid during the transition period and expires at `key_transition_expires_at`.
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new POST /api-keys/{id}/rotate operation does not define an operationId and is not added to the x-code-samples.groups navigation list. Since this spec’s header note says new endpoints must also be added to the groups section (see openapi.yaml:139-141), this endpoint may not show up in the rendered API reference navigation.

Suggestion: add a stable operationId (e.g., rotateApiKey) and include it under the appropriate group/section in x-code-samples.groups so it becomes discoverable in the docs UI.

Copilot uses AI. Check for mistakes.
@sk-portkey sk-portkey merged commit 92a7bb1 into master Apr 7, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants