Skip to content

Authentication and access

API keys, the /auth/me check, and the access groups that document access lists name. For setting authentication up, see Authentication; for document permissions, see Permissions.

Paths are relative to /api/v1. The examples use BASE=http://localhost:8000/api/v1 and an API key in $KEY (an admin key for the key and group endpoints).

Sending a key

With AUTH_ENABLED=true, every endpoint except GET /api/v1/, GET /api/v1/health (and the /docs page) needs a key, sent in either header:

curl "$BASE/projects" -H "Authorization: Bearer pl_..."
curl "$BASE/projects" -H "X-API-Key: pl_..."

No key, or an unknown or expired one, gives 401 with WWW-Authenticate: Bearer. With authentication off, every request is anonymous and allowed everything.

The first admin key is ADMIN_API_KEY from the settings. Use it to create the other keys, which are stored hashed in Postgres.

Scopes

Scope Allows
read GET endpoints, plus retrieval (POST .../retrieve, POST /retrieve), POST /rerank and POST /embeddings, which only read
write Everything read allows, plus creating, changing and deleting projects and documents, ingestion, re-indexing, graph builds, jobs, LLM and evaluation calls
admin Everything, plus API keys (/auth/keys), access groups (/access) and the raw vector DB API (/vectordb)

An endpoint needs read for GET, HEAD and OPTIONS, and write for other methods, unless it says otherwise. A key with too small a scope gets 403: This key has the 'read' scope; this endpoint needs 'write'.

Two more limits a key can carry:

  • Projects (project_ids): the key can only use paths with one of its projects, and POST /retrieve with only its projects; others give 403. GET /projects lists only its projects, and it can't create projects.
  • A user (user_id, read keys only): every request made with it sees only the documents that user, or the user's stored groups, may see. It can't send another user or any groups (403), and it can't use the jobs endpoints, graph build or graph delete (403). Give such keys to end-user apps. See Searching as a user.

GET /auth/me

The key this request was made with. Any scope.

Response: 200

Field Type
auth_enabled boolean
kind string api_key, admin_key (ADMIN_API_KEY) or anonymous (authentication is off)
scope string read, write or admin
project_ids list of integers or null null: every project
key_id integer or null The stored key's id
name string or null
user_id string or null The user the key is bound to
curl "$BASE/auth/me" -H "Authorization: Bearer $KEY"
{"auth_enabled": true, "kind": "api_key", "scope": "read", "project_ids": [1, 4],
 "key_id": 7, "name": "support-bot", "user_id": null}

The key object

Field Type
id integer
name string
prefix string The start of the key (pl_ and 8 more characters), to recognize it
scope string read, write or admin
project_ids list of integers or null null: every project
user_id string or null The user it is bound to
created_at datetime
expires_at datetime or null null: never
last_used_at datetime or null Updated at most once a minute
expired boolean

POST /auth/keys

Create an API key. Needs admin.

Body (JSON):

Field Type Required Allowed values Default
name string yes 1 to 128 characters, not blank What the key is for, such as the app that uses it
scope string no read, write, admin read
project_ids list of integers no 1 to 1000 existing project ids every project Limit the key to these projects. Not for admin keys
expires_in_days integer no 1 to 3650 never
user_id string no 1 to 256 characters, no control characters unbound Bind the key to a user. read keys only

Response: 201 with the key object plus key: the key itself (pl_ and 43 URL-safe characters). It is shown only this once; only its hash is stored.

Errors:

Status When
400 project_ids on an admin key, user_id on a key that is not read, or a bad user_id
403 The caller is not admin
404 One of project_ids does not exist
422 A field is invalid
# A read key for one app, limited to two projects, for 90 days
curl -X POST "$BASE/auth/keys" -H "Authorization: Bearer $ADMIN_KEY" \
     -H 'Content-Type: application/json' \
     -d '{"name": "support-bot", "scope": "read", "project_ids": [1, 4], "expires_in_days": 90}'

# A key an end-user app searches with: it sees only what ana may see
curl -X POST "$BASE/auth/keys" -H "Authorization: Bearer $ADMIN_KEY" \
     -H 'Content-Type: application/json' \
     -d '{"name": "portal: ana", "user_id": "ana@acme.com"}'
{
  "id": 7, "name": "support-bot", "prefix": "pl_3fK9a1Qz", "scope": "read",
  "project_ids": [1, 4], "user_id": null,
  "created_at": "2026-12-01T08:00:00Z", "expires_at": "2027-03-01T08:00:00Z",
  "last_used_at": null, "expired": false,
  "key": "pl_3fK9a1Qz..."
}

GET /auth/keys

The API keys, newest first, without the keys themselves. Needs admin.

Query: page (1 or more, default 1), page_size (1 to 200, default 50).

Response: 200 with {"keys": [...], "total", "page", "page_size"}.

curl "$BASE/auth/keys?page_size=100" -H "Authorization: Bearer $ADMIN_KEY"

GET /auth/keys/{key_id}

One key. Needs admin. Response: 200 with the key object; 404 when it does not exist.

DELETE /auth/keys/{key_id}

Revoke a key: requests made with it fail (401) from now on. Needs admin. Response: 204; 404 when it does not exist.

curl -X DELETE "$BASE/auth/keys/7" -H "Authorization: Bearer $ADMIN_KEY"

Access groups

Named sets of users that document access lists can name (groups in a document's access). A request for a user adds the stored groups they are in. Groups decide what users see in every project, so every /access endpoint needs admin.

You don't have to store groups: callers can also send the groups a user is in with each request (user.groups, or ?groups= on reads), for example from your identity provider's token. Stored groups and sent groups add up.

Names: a group name is 1 to 128 characters: letters, digits and . _ - : @ /, starting with a letter or digit (legal, drive:team-a). A user id is 1 to 256 characters (an email, a subject claim, ...), without control characters or surrounding spaces. Both are case-sensitive.

The group object

Field Type
name string
description string or null
member_count integer
members list of strings or null The user ids. Only in single-group responses, null in the list
created_at, updated_at datetime

PUT /access/groups/{name}

Create a group, or update it. Made for sync jobs (from Google Drive, Confluence, your identity provider, ...) that send each group's full member list on every run.

Body (JSON, unknown fields refused):

Field Type Allowed values
description string up to 1000 characters Omitted: unchanged (null for a new group)
members list of strings up to 100000 user ids Replaces the group's members. Omitted: the members are left as they are

Response: 201 when the group is new, 200 when it existed: the group with its members, plus created (boolean).

Errors: 400 (a bad group name or user id), 403, 422.

curl -X PUT "$BASE/access/groups/legal" -H "Authorization: Bearer $ADMIN_KEY" \
     -H 'Content-Type: application/json' \
     -d '{"description": "Legal team", "members": ["ana@acme.com", "omar@acme.com"]}'
{"name": "legal", "description": "Legal team", "member_count": 2,
 "members": ["ana@acme.com", "omar@acme.com"],
 "created_at": "2026-12-01T08:00:00Z", "updated_at": "2026-12-01T08:00:00Z", "created": true}

GET /access/groups

The groups, by name, with their member counts (members is null).

Query: page (1 or more, default 1), page_size (1 to 200, default 50).

Response: 200 with {"groups": [...], "total", "page", "page_size"}.

GET /access/groups/{name}

A group with its members. Response: 200 with the group; 404 when it does not exist.

DELETE /access/groups/{name}

Delete a group and its members. Documents whose access lists name it keep the entry, which then lets no one in through it (members a caller sends in groups still count); put the group back to restore access. Response: 204; 404 when it does not exist.

POST /access/groups/{name}/members

Add users to a group.

Body: {"users": [...]}, 1 to 10000 user ids.

Response: 200 with {"name", "changed"}: changed counts the users added (users already in the group are not counted). Errors: 400 (a bad user id), 404 (no group), 422.

curl -X POST "$BASE/access/groups/legal/members" -H "Authorization: Bearer $ADMIN_KEY" \
     -H 'Content-Type: application/json' -d '{"users": ["lea@acme.com"]}'
{"name": "legal", "changed": 1}

POST /access/groups/{name}/members/remove

Remove users from a group. Same body and response as adding; changed counts the users removed.

GET /access/users/{user_id}/groups

The stored groups a user is in: what a request for this user adds.

Response: 200 with {"user_id": "ana@acme.com", "groups": ["legal", "staff"]}. A user in no group gets an empty list.

curl "$BASE/access/users/ana@acme.com/groups" -H "Authorization: Bearer $ADMIN_KEY"