REST API Reference
Overview
Section titled “Overview”LokAI exposes a REST API at /api/v1 for third-party integrations, alongside a type-safe tRPC endpoint at /trpc for first-party clients (Studio, CLI).
Base URL: http://localhost:3000/api/v1
All requests must include an Authorization: Bearer <token> header.
Authentication
Section titled “Authentication”Current bearer token types:
- Supabase JWTs for human sessions
- personal access tokens (PATs)
- workspace access tokens (WATs)
PATs and WATs are both scope-aware machine identities. PATs are additionally bounded by the owning user's effective permissions.
Resources
Section titled “Resources”- Workspaces —
/workspaces - Access —
/workspaces/:workspaceId/roles,/workspaces/:workspaceId/capabilities,/workspaces/:workspaceId/grants - Projects —
/workspaces/:workspaceId/projects - Translation Keys —
/projects/:projectId/keys - Translations —
/keys/:keyId/translations - Glossary —
/workspaces/:workspaceId/glossary - Tenants —
/workspaces/:workspaceId/tenants - Export —
/projects/:projectId/export
Access endpoints
Section titled “Access endpoints”Current REST access surface:
GET /api/v1/workspaces/:workspaceId/rolesGET /api/v1/workspaces/:workspaceId/capabilitiesGET /api/v1/workspaces/:workspaceId/grantsPOST /api/v1/workspaces/:workspaceId/grantsPATCH /api/v1/workspaces/:workspaceId/grants/:grantIdDELETE /api/v1/workspaces/:workspaceId/grants/:grantIdGET /api/v1/workspaces/:workspaceId/audit/accessGET /api/v1/workspaces/:workspaceId/access-tokensPOST /api/v1/workspaces/:workspaceId/access-tokensPOST /api/v1/workspaces/:workspaceId/access-tokens/:id/rotateDELETE /api/v1/workspaces/:workspaceId/access-tokens/:id
GET /api/v1/me/effective-permissions?workspace_id=:workspaceIdGET /api/v1/me/access-tokens?workspace_id=:workspaceIdPOST /api/v1/me/access-tokensPOST /api/v1/me/access-tokens/:id/rotate?workspace_id=:workspaceIdDELETE /api/v1/me/access-tokens/:id?workspace_id=:workspaceIdCapabilities and quotas
Section titled “Capabilities and quotas”GET /api/v1/workspaces/:workspaceId/capabilities is the REST debugging surface for effective plan state.
The response includes:
capabilities[]for boolean feature gatesquotas.workspace[]alwaysquotas.projectwhenproject_idis suppliedquotas.tenantwhentenant_idis suppliedquotas.userwhenuser_idis supplied
This endpoint is especially useful for inspecting scoped limits such as:
keys_per_projectbase_languages_per_projectrules_per_tenantpats_per_user
Deferred areas
Section titled “Deferred areas”The data model already supports teams and custom roles, but the current shipped surface keeps those areas clearly deferred:
- no REST team CRUD
- no custom-role CRUD
- read-only role listing through
/roles
Export Endpoints
Section titled “Export Endpoints”Export routes live under:
/api/v1/workspaces/:workspaceId/projects/:projectId/exportGet Export Capabilities
Section titled “Get Export Capabilities”GET /api/v1/workspaces/:workspaceId/projects/:projectId/exportReturns supported formats and available query parameters.
Download a Single Export Result
Section titled “Download a Single Export Result”GET /api/v1/workspaces/:workspaceId/projects/:projectId/export/:formatIf the export resolves to a single file, the route may return that file directly. If multiple output files are generated, the response is a ZIP archive.
Download a ZIP Archive
Section titled “Download a ZIP Archive”GET /api/v1/workspaces/:workspaceId/projects/:projectId/export/bulk/:formatThis endpoint always returns a ZIP archive and is the preferred endpoint for automation.
Export Query Parameters
Section titled “Export Query Parameters”Core Parameters
Section titled “Core Parameters”| Parameter | Type | Description |
| --------------- | --------------------- | --------------------------------------------------------------------------------- |
| languages | string | Comma-separated language codes such as fr,de,ja |
| version | latest \| validated | Export the latest translation state or only validated/published content |
| status | legacy enum | Legacy alias. validated, approved, and published map to version=validated |
| namespace | string | Filter keys by namespace pattern |
| tags | string | Comma-separated tag filter |
| include_empty | true \| false | Include keys without translation text |
Content Shaping
Section titled “Content Shaping”| Parameter | Type | Description |
| -------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| content_mode | per_language \| multilingual | multilingual is currently supported for JSON and YAML only |
| structure_template | string | JSON-encoded template using placeholders, $for loops, and $if conditionals |
| include_metadata | true \| false | Supported for json, json-nested, and yaml; mainly affects the default export shape when no custom structure_template is used |
Archive Layout
Section titled “Archive Layout”| Parameter | Type | Description |
| --------------- | -------- | ---------------------------------------------------------------------------------------- |
| path_template | string | Archive path template using {language}, {variant}, {tenant}, {file}, and {ext} |
Tenant Variants
Section titled “Tenant Variants”| Parameter | Type | Description |
| ----------------- | --------------- | ----------------------------------- |
| tenant_id | string | Export a single tenant variant |
| tenant_ids | string | Comma-separated tenant IDs or all |
| include_vanilla | true \| false | Include the base non-tenant variant |
If tenant features are disabled on the workspace, the export route rejects tenant-specific parameters.
ZIP Naming
Section titled “ZIP Naming”Archive responses are named using:
{project-slug}-{latest|validated}-{YYYY-MM-DD}.zipPath Template Tokens
Section titled “Path Template Tokens”Supported tokens:
{language}{variant}{tenant}: alias for{variant}{file}{ext}
Examples:
{language}/{file}.{ext}{file}.{language}.{ext}{variant}/{language}/{file}.{ext}{language}/{variant}/{file}.{ext}{file}.{variant}.{language}.{ext}Multilingual Export Example
Section titled “Multilingual Export Example”GET /api/v1/workspaces/:workspaceId/projects/:projectId/export/bulk/yaml?languages=en,fr,es&content_mode=multilingualThis produces one YAML file per logical file path, with all selected languages embedded in the same document.
Advanced Structure Template Example
Section titled “Advanced Structure Template Example”{ "$for": "keys", "$as": "key", "$body": { "name": "{{key.name}}", "translations": { "$for": "key.translations", "$as": "translation", "$body": { "language": "{{translation.language}}", "text": "{{translation.text}}" } } }}Common Response Headers
Section titled “Common Response Headers”Successful file downloads typically include:
Content-TypeContent-DispositionCache-Control: no-store
For ZIP downloads, Content-Disposition contains the archive filename to use on disk.
Glossary Import/Export
Section titled “Glossary Import/Export”Glossary routes live under:
/api/v1/workspaces/:workspaceId/glossaryExport Glossary
Section titled “Export Glossary”GET /api/v1/workspaces/:workspaceId/glossary/export?format=json|yaml|csvReturns a downloadable attachment (Content-Disposition + format-specific Content-Type).
Import Glossary
Section titled “Import Glossary”POST /api/v1/workspaces/:workspaceId/glossary/importContent-Type: application/json{ "format": "json", "content": "{ \"entries\": [ ... ] }"}Response payload:
{ "success": true, "data": { "created": 2, "updated": 5, "failed": 0, "errors": [] }}