Create an API key
Creates a new API key for the authenticated project. The plaintext key is returned exactly once, in this response — it is never stored, logged, or retrievable again through any other endpoint. Store it immediately.
expires_at, when supplied, must be in the future; a past value is rejected with 400 rather than silently minting an already-dead key.
A key minted by a key can never outlive its creator. If this request is authenticated with an API key that itself has an expiry, an explicit expires_at later than that key's own is rejected with 400 (expires_at may not exceed the creating key's own expiry). The problem body carries max_expires_at, the latest value this caller may ask for, so a client can retry correctly on its first attempt rather than guessing. This cap does not apply to session-authenticated (dashboard) requests, or when the authenticating key itself never expires.
An omitted expires_at follows the same rule, and it is in force: under a creating key that itself expires, omitting the field inherits that key's own expiry rather than meaning "never". A short-lived key therefore cannot mint a permanent one, whether it omits the field or asks for too much.
Nothing here changes for the other callers: under a creating key with no expiry of its own, and for session-authenticated (dashboard) requests, an omitted expires_at still means "never".
A client that wants to choose a lifetime rather than inherit one should send an explicit expires_at and retry at max_expires_at if refused, which is what the MCP create_api_key tool does.
A key may not be given a higher scope than its creator either. The same shape as the expiry cap above: an explicit scope that outranks the authenticating key's own is rejected with 400 (scope may not exceed the creating key's own scope), and the problem body carries max_scope. An omitted scope is always write, which no key can fail to grant except a read key — and a read key cannot reach this operation at all.
Request
- Base URL: https://app.lastping.dev
- URL: https://app.lastping.dev/api/v1/api-keys
- Auth: API key in header X-Api-Key
Request body
Example request
{
"name": "github-actions",
"expires_at": "2026-12-31T00:00:00Z",
"scope": "write",
"check_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
}Response
API key created. key is the plaintext credential — shown exactly once.
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_Wwut111f_jHpogymaQLg5L19-MuWcVVY"
}Changes
No recorded changes to this operation across all 2 revisions of this API.