- Docs
- Using the API
Headers
Authentication, actor attribution, and permission context headers for the LoonFS HTTP API.
This page explains the shared HTTP headers used across the LoonFS API for authentication, actor attribution, and permission checks.
LoonFS doesn’t manage user logins or group memberships. Your application authenticates your users, authenticates itself to LoonFS with a bearer token, and tells LoonFS on each request who is acting and which permissions apply. Each endpoint page in the API reference lists which of these headers the endpoint requires, and its curl examples include them.
Authentication
Section titled “Authentication”Include your deployment’s bearer token on every request:
Authorization: Bearer <your-token>The bearer token authenticates your application to the LoonFS server. It authorizes your application to call the API, while per-user access inside a namespace is controlled by the request context header described below.
Actor identity
Section titled “Actor identity”Include Loonfs-Actor on writes and upload-session requests to identify the user or background job responsible for the request:
Loonfs-Actor: user_123Use a stable, opaque ID from your application (1 to 256 printable ASCII characters) rather than an email address or display name, because emails and display names can change. LoonFS records this ID as created_by on namespaces and forks, records it as committed_by on commits, and checks that every call in an upload session uses the same actor ID that started the session.
Loonfs-Actor is for audit attribution and upload ownership, not authorization. It doesn’t grant permissions on its own, which lets a trusted backend job record a worker ID (such as Loonfs-Actor: document-importer) alongside Loonfs-Context: service, or lets a user request check grants across multiple group principals while attributing the commit to one user ID.
Request context
Section titled “Request context”Every request that reads or modifies a namespace’s contents must include one of two context headers:
Loonfs-Principals: checks file and folder permissions against the combined grants for the listed principals.Loonfs-Context: service: bypasses per-user permission checks and uses the bearer token’s full authority.
If a request includes both headers, or omits both on an endpoint that requires a context header, LoonFS returns invalid_request.
Acting for a user
Section titled “Acting for a user”Send a comma-separated list of opaque principal IDs (with no spaces) for the user and any groups the user belongs to:
Loonfs-Principals: user_123,team_designLoonFS evaluates permissions using the combined grants for every principal in the header. The server caps how many principals one request can include via access.max_principals_per_request (64 by default on the reference server). See Permissions for how grants and folder inheritance work.
Acting as the application
Section titled “Acting as the application”For trusted backend work such as indexing, migrations, or administrative jobs, send:
Loonfs-Context: serviceThe value must be lowercase service. Warning: never let an untrusted client set Loonfs-Context: service, because this header skips all per-user permission checks. The curl examples in the API reference use Loonfs-Context: service to keep the examples short, so replace that header with Loonfs-Principals when forwarding requests for a user.
Required headers by endpoint
Section titled “Required headers by endpoint”A write made on behalf of a user includes all three headers together:
Authorization: Bearer <your-token>Loonfs-Actor: user_123Loonfs-Principals: user_123,team_designFor a trusted service write, keep Loonfs-Actor (for example, Loonfs-Actor: document-importer) and replace Loonfs-Principals with Loonfs-Context: service.
| Operation | Loonfs-Actor | Loonfs-Principals or Loonfs-Context |
|---|---|---|
| Create namespace | Required | Ignored |
| Commits, merges, replays, forks, and rebase forks | Required | Required (one) |
| All upload-session endpoints | Required | Required (one) |
| Reads, downloads, trash, and search | Not required | Required (one) |
| Delete namespace, snapshots, changes, diffs, and merge ranges | Not required | Required (one) |
| Get namespace and get capabilities | Not required | Ignored |
When you use Loonfs-Principals, namespace-level operations such as forking, deleting a namespace, and managing snapshots require the admin right on the root folder.
Content type and presigned URLs
Section titled “Content type and presigned URLs”Send Content-Type: application/json for JSON request bodies and Content-Type: application/octet-stream for raw file bytes on service-proxied uploads.
When uploading or downloading directly through a presigned object-storage URL returned by LoonFS, use the exact HTTP method and headers returned in that presigned response. Warning: don’t forward your Authorization token or Loonfs-* headers to a presigned object-storage URL, because those headers leak credentials to the storage provider and can invalidate the presigned signature.
Headers specific to one endpoint, such as Range for partial file reads, are documented on that endpoint’s page.
Retries and header casing
Section titled “Retries and header casing”When you retry a commit with the same commit ID (commit_id), send the same Loonfs-Actor, context header, and request body. Reusing a commit_id with a different actor returns commit_id_reuse_conflict because the actor ID is part of the commit’s semantic fingerprint. Every request in an upload session must also use the same Loonfs-Actor that opened the session, so store the actor and context alongside any saved retry state.
Header names are case-insensitive, while header values are case-sensitive (for example, Loonfs-Context must be lowercase service).