Skip to content

REST API Reference

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:

https://api.lokai.cloud/api/v1

All requests must include an Authorization: Bearer <token> header.

Tokens are obtained via Supabase Auth. Pass the JWT as a Bearer token on every request.

  • Workspaces/workspaces
  • 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

Export routes live under:

/api/v1/workspaces/:workspaceId/projects/:projectId/export
GET /api/v1/workspaces/:workspaceId/projects/:projectId/export

Returns supported formats and available query parameters.

GET /api/v1/workspaces/:workspaceId/projects/:projectId/export/:format

If 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.

GET /api/v1/workspaces/:workspaceId/projects/:projectId/export/bulk/:format

This endpoint always returns a ZIP archive and is the preferred endpoint for automation.

ParameterTypeDescription
languagesstringComma-separated language codes such as fr,de,ja
versionlatest | validatedExport the latest translation state or only validated/published content
statuslegacy enumLegacy alias. validated, approved, and published map to version=validated
namespacestringFilter keys by namespace pattern
tagsstringComma-separated tag filter
include_emptytrue | falseInclude keys without translation text
ParameterTypeDescription
content_modeper_language | multilingualmultilingual is currently supported for JSON and YAML only
structure_templatestringJSON-encoded template using placeholders, $for loops, and $if conditionals
include_metadatatrue | falseSupported for json, json-nested, and yaml; mainly affects the default export shape when no custom structure_template is used
ParameterTypeDescription
path_templatestringArchive path template using {language}, {variant}, {tenant}, {file}, and {ext}
ParameterTypeDescription
tenant_idstringExport a single tenant variant
tenant_idsstringComma-separated tenant IDs or all
include_vanillatrue | falseInclude the base non-tenant variant

If tenant features are disabled on the workspace, the export route rejects tenant-specific parameters.

Archive responses are named using:

{project-slug}-{latest|validated}-{YYYY-MM-DD}.zip

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}
GET /api/v1/workspaces/:workspaceId/projects/:projectId/export/bulk/yaml?languages=en,fr,es&content_mode=multilingual

This produces one YAML file per logical file path, with all selected languages embedded in the same document.

{
"$for": "keys",
"$as": "key",
"$body": {
"name": "{{key.name}}",
"translations": {
"$for": "key.translations",
"$as": "translation",
"$body": {
"language": "{{translation.language}}",
"text": "{{translation.text}}"
}
}
}
}

Successful file downloads typically include:

  • Content-Type
  • Content-Disposition
  • Cache-Control: no-store

For ZIP downloads, Content-Disposition contains the archive filename to use on disk.

Glossary routes live under:

/api/v1/workspaces/:workspaceId/glossary
GET /api/v1/workspaces/:workspaceId/glossary/export?format=json|yaml|csv

Returns a downloadable attachment (Content-Disposition + format-specific Content-Type).

POST /api/v1/workspaces/:workspaceId/glossary/import
Content-Type: application/json
{
"format": "json",
"content": "{ \"entries\": [ ... ] }"
}

Response payload:

{
"success": true,
"data": {
"created": 2,
"updated": 5,
"failed": 0,
"errors": []
}
}