Skip to content
Product Docs

Create Api Key

POST/api/v1/beta/api-keys

Create an API key.

Scope it to a project with project_id, which requires read access to that project; omit it for a key that reaches every project you can read. A project-scoped or agent key cannot create an API key. The response carries the secret in redacted_api_key, and only this once.

Cookie ParametersExpand Collapse
session: optional string
Body ParametersJSONExpand Collapse
expires_at: optional string

When the API key should expire. If not set, the key never expires.

formatdate-time
key_type: optional "agent" or "user"
One of the following:
"agent"
"user"
name: optional string
project_id: optional string

The project ID to associate with the API key.

formatuuid
role: optional "admin" or "agent_viewer" or "viewer" or "viewer_v2"

Role capping what this key may do. A key can only ever be narrower than the user who created it, never broader. If not set, the key authorizes as its owner.

One of the following:
"admin"
"agent_viewer"
"viewer"
"viewer_v2"
ReturnsExpand Collapse
APIKey object { id, redacted_api_key, user_id, 8 more }

Schema for an API Key.

id: string

Unique identifier

formatuuid
redacted_api_key: string

The key with its middle masked, except on the create response, which returns the full secret once and never again.

user_id: string
created_at: optional string

Creation datetime

formatdate-time
expires_at: optional string

When the API key expires. Null if the key never expires.

formatdate-time
key_type: optional "agent" or "user"
One of the following:
"agent"
"user"
metadata: optional map[unknown]
name: optional string
project_id: optional string
role: optional "admin" or "agent_viewer" or "viewer" or "viewer_v2"

Role capping what this key may do. Null if the key authorizes as its owner.

One of the following:
"admin"
"agent_viewer"
"viewer"
"viewer_v2"
updated_at: optional string

Update datetime

formatdate-time

Create Api Key

curl https://api.cloud.llamaindex.ai/api/v1/beta/api-keys \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
    -d '{}'
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "redacted_api_key": "redacted_api_key",
  "user_id": "user_id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "expires_at": "2019-12-27T18:11:19.117Z",
  "key_type": "agent",
  "metadata": {
    "foo": "bar"
  },
  "name": "name",
  "project_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "role": "admin",
  "updated_at": "2019-12-27T18:11:19.117Z"
}
Returns Examples
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "redacted_api_key": "redacted_api_key",
  "user_id": "user_id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "expires_at": "2019-12-27T18:11:19.117Z",
  "key_type": "agent",
  "metadata": {
    "foo": "bar"
  },
  "name": "name",
  "project_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "role": "admin",
  "updated_at": "2019-12-27T18:11:19.117Z"
}