The read API goes one way, from Lantern to your files. A token with write permissions can also push the other way — ideal for an AI agent that drafts translations, or a CI step that registers the new keys it finds in your code. Write calls use the same Bearer token as reads.
Scopes#
Grant scopes when you create the token:
| Scope | Allows |
|---|---|
key:create | Create translation keys |
key:edit | Rename a key, or change its namespace, description or tags |
translation:edit | Set or overwrite translation values |
language:manage | Create a missing target language on push |
Create a key#
POST /api/v1/projects/<slug>/keys
Authorization: Bearer lk_… (needs key:create)
{ "key": "home.title", "description": "Landing headline", "tags": ["landing"] }
→ 201 { "id": "…", "key": "home.title", "created": true, "placeholders": {} } (409 if it exists)Returns 201 with the new key, or 409 if a key with that path already exists.
Rename or edit a key#
PATCH /api/v1/projects/<slug>/keys
Authorization: Bearer lk_… (needs key:edit)
{ "key": "home.title", "namespace": "home", "name": "headline" }
→ 200 { "id": "…", "key": "home.headline", "updated": true } (409 if it collides)Identify the key by its current dotted key path or by keyId. The other fields — name, namespace, description, tags — are the new values, and any you leave out keep their current value.
The update is by id, so the key’s translations, statuses and comments survive a rename. There is no delete-and-recreate. A rename that collides with another key returns 409.
Tags#
Tags are free-form labels on a key — handy for a CI step that registers keys and marks where they came from. Both key calls accept them as an array of strings.
Tags are trimmed, de-duplicated without regard to case, and capped at 20 per key. On PATCH, a tags array replaces the whole set ([] clears it); leave the field out to keep the current tags.
Placeholder notes#
Both key calls also accept placeholders: a note for translators per placeholder.
{ "placeholders": { "{name}": { "description": "user's first name", "example": "Alice" } } }Notes are trimmed and capped in length, and empty ones are dropped. Both responses return the stored placeholders. On PATCH, a placeholders object replaces all the notes ({} clears them); leave it out to keep them.
Push translations#
PUT /api/v1/projects/<slug>/translations
Authorization: Bearer lk_… (needs translation:edit)
{ "locale": "fr", "createMissingKeys": true,
"entries": [ { "key": "home.title", "value": "Bienvenue" } ] }
→ 200 { "updated": 1, "created": 0, "skipped": 0, "warnings": [] }createMissingKeys also needs key:create. Pushing to a locale that doesn’t exist yet needs language:manage; without it the request fails with 400 Unknown locale.
Add "plurals": "i18next" to the body to fold i18next plural keys (key_one, key_other…) into one plural key before they are written.
Changes made with a token show up in the project’s activity feed under the token’s name.
Placeholder warnings#
PUT …/translations and the MCP set_translations tool also return warnings: every value written whose placeholders don’t match the project’s default language, for the placeholder formats the project has turned on.
Each entry is { "key", "locale", "missing": [...], "extra": [...] }. A placeholder used twice in the source but once in the translation appears once in missing.
→ 200 { "updated": 1, "created": 0, "skipped": 0,
"warnings": [ { "key": "port.range", "locale": "fr",
"missing": ["{{1}}"], "extra": [] } ] }Field limits#
Keys written through the API go through the same checks as the editor: name up to 200 characters, namespace up to 100 and description up to 500, all three trimmed. A value that breaks a limit returns 400 with a readable error and a fields map you can branch on:
{ "error": "Key name must be at most 200 characters.",
"fields": { "name": ["Key name must be at most 200 characters."] } }Errors#
| Status | Meaning |
|---|---|
401 | Bad token |
403 | Missing scope, or the token doesn’t belong to this project |
400 | Bad body, a field too long, or an unknown locale |
409 | The key already exists, or a rename collides with another key |