My App
API ReferenceAPI Keys

Create Api Key

Generate a new API key for programmatic access.

Use this to authenticate the Logfire SDK or to interact with Blue Guardrails from your code.

Key types:

  • User-scoped (scope="user"): Access all your workspaces and application-scoped resources.
  • Workspace-scoped (scope="workspace"): Access resources in one workspace only. Requires workspace_id.

Important: The full key is returned only once. Store it securely—you can't retrieve it later.

POST
/v1/api-keys

Request Body

application/json

name*string

Human-readable name for the API key

Length1 <= length <= 255
expires_in_days*integer

Number of days until expiration (1-365)

Range1 <= value <= 365
scope*string

Key scope: 'workspace' for workspace-scoped, 'user' for user-level

Value in"workspace" | "user"
workspace_id?|

Workspace ID (required for scope='workspace', ignored for scope='user')

Response Body

application/json

application/json

curl -X POST "https://loading/v1/api-keys" \  -H "Content-Type: application/json" \  -d '{    "name": "string",    "expires_in_days": 1,    "scope": "workspace"  }'
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string",
  "key": "string",
  "key_prefix": "string",
  "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9",
  "scope": "workspace",
  "expires_at": "2019-08-24T14:15:22Z",
  "created_at": "2019-08-24T14:15:22Z"
}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}