Regenerate an API key ("same key, new secret")
Issues a replacement credential under the same name and scope, then revokes the original. Returns 201 with the plaintext replacement key exactly once, the same one-time delivery POST /api/v1/api-keys uses.
Order: the replacement is created FIRST, then the original is deleted — the reverse would lose the caller's access entirely if creation failed.
Expiry policy, not remaining time: a key that never expired stays non-expiring; a key that had any expiry gets a fresh 90-day window from now, not the old key's remaining balance.
Non-cascading: unlike DELETE /api/v1/api-keys/{id}, this does NOT revoke keys the original minted. Regenerating is "same key, new secret", not "this credential and everything descended from it is dead": keys the original minted stay alive with a null created_by_key_id.
A key belonging to another project is indistinguishable from a missing one — both return 404.
Requires admin scope, the same tier as the other three /api/v1/api-keys routes: key management is the one capability that lets a compromised credential outlive its own revocation.
Caller caps, when the caller is itself an API key (the key creation rule, extended to key rotation): the replacement's expires_at is capped to the caller key's own expiry (silently — whichever is earlier of the policy-derived value above and the caller's own ceiling, "never" acting as +infinity), and the replacement's scope must not exceed the caller key's own scope — that one is refused outright (403, not silently narrowed) rather than handing back a less powerful key than the target had. A session-authenticated caller (the dashboard) gets neither cap.
The MCP tool regenerate_api_key calls this route. Terraform has no equivalent, deliberately: its model for rotating a key it manages is taint/recreate.
Request
- Base URL: https://app.lastping.dev
- URL: https://app.lastping.dev/api/v1/api-keys/{id}/regenerate
- Auth: API key in header X-Api-Key
Response
Replacement key created. The original has been revoked unless old_key_revoked is false.
Example response
{
"id": "e1d2c3b4-0000-0000-0000-000000000001",
"name": "github-actions",
"prefix": "lp_Wwut111",
"created_at": "2026-07-01T12:00:00Z",
"expires_at": "2026-12-31T00:00:00Z",
"last_used_at": "2026-08-01T09:30:00Z",
"last_used_surface": "mcp",
"scope": "write",
"check_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"created_by_key_id": "e1d2c3b4-0000-0000-0000-000000000002",
"key": "lp_Nyrz222g_kIqphznbRMh6M20-NvXdWWZ",
"old_key_revoked": true
}Changes
No recorded changes to this operation across all 2 revisions of this API.