v14

latestOpenAPI 3.0.32026-08-04377889.4 MB

post/api-keys

Request body

purposestring required

The API key's purpose, which restricts how it can be used.

projectIdstring

An optional project to restrict the API key to.

namestring

An optional name for the API key.

expiresAtnumber

The API key's expiration, expressed as a UNIX timestamp in milliseconds.

metadataobject

Optional generic metadata for the API key. The accepted shape depends on the key's purpose and is validated on creation; for ai-gateway keys this accepts environment.

Example request

{
  "projectId": "prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
  "name": "API Key for App 123"
}

Response

Successfully created an API key.

apiKeyStringstring required

The API key's actual value. This value is only provided in this response, and can never be retrieved again in the future. Be sure to save it somewhere safe!

Example response

{
  "apiKeyString": "uRKJSTt0L4RaSkiMj41QTkxM",
  "apiKey": {
    "id": "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
    "name": "API Key for AI Gateway",
    "partialKey": "t7V",
    "teamId": "team_123a6c5209bc3778245d011443644c8d27dc2c50",
    "purpose": "ai-gateway",
    "projectId": "prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
    "expiresAt": 1632816536002,
    "activeAt": 1632816536002,
    "createdAt": 1632816536002,
    "createdBy": "ZspSRT4ljIEEmMHgoDwKWDei",
    "leakedAt": 1632816536002
  }
}