Managing keys
Three endpoints work on one key at a time, by name. For many keys at once, use the import.
| Endpoint | What it does |
|---|---|
POST /translation-keys | Creates one key, optionally with a description and its base-language source text. |
PATCH /translation-keys/{key} | Renames a key, replaces its description, or replaces its source text. |
POST /translation-keys/delete | Deletes up to 1000 keys. A dry run unless you say otherwise. |
All three need a write token whose creator is a manager or developer on the project, the people who manage keys in the dashboard. A read token gets 403. Each one behaves like the same action in the dashboard (a dry run writes nothing): it writes an audit-log entry naming the token’s creator and fires the key_created, key_updated or key_deleted webhook. The MCP tools create_key, update_key and delete_keys call the same code. See Connect your AI.
Create a key
curl -s "https://api-public-dev.localeo.app/v1/translation-keys" \ -H "Authorization: Bearer $LOCALEO_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "key": "checkout.pay_button", "description": "Label of the primary button on the payment step", "value": "Pay {amount:num} now" }'description and value are optional. value is the source text in the project’s base language, written as draft. Declare a placeholder’s type inline as {name:Type}, as in an import: this example stores Pay {amount} now with a parameter amount of type num.
The answer is 201 with the key in the same shape as GET /translation-keys/{key}. A key that already exists is 409 with translation key already exists; to change it, update it instead. The plan’s key limit is also a 409.
Update a key
Name the key in the path, percent-encoding a / as %2F. Send only the fields you want to change:
curl -s -X PATCH "https://api-public-dev.localeo.app/v1/translation-keys/checkout.pay_button" \ -H "Authorization: Bearer $LOCALEO_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "key": "checkout.pay_now", "value": "Pay {amount} today" }'| Field | Effect |
|---|---|
key | Renames the key. Its values in every language stay. |
description | Replaces the description. An empty string clears it. |
value | Replaces the base-language source text. |
The answer is 200 with the key under its new name.
Changing the source text marks the key’s other languages outdated. Their values stay, keep their status, and show as is_outdated: true until someone saves them again, so translators know to check them. A rename or a new description also changes what the translations were made from, and marks them outdated the same way.
An approved source text is never replaced. The answer is 409 with approved source text cannot be changed, the same lock the import applies. To change it, edit it in the dashboard. A rename or a new description still works on an approved key.
A new value also sets the key’s placeholders. A placeholder the new text no longer contains is removed, and a new one is a String unless annotated. An existing one keeps its type, unless the new text annotates it again with {name:Type}.
Delete keys
Deleting a key removes its value in every language. An app that still uses the key loses that text at the next published release, so this endpoint is built to be checked before it acts.
First, the dry run:
curl -s "https://api-public-dev.localeo.app/v1/translation-keys/delete" \ -H "Authorization: Bearer $LOCALEO_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "keys": ["checkout.old_banner", "checkout.typo"] }'{ "dry_run": true, "keys": [ { "key": "checkout.old_banner", "translations": 3, "languages": ["de", "en", "nl"] } ], "not_found": ["checkout.typo"]}translations is how many values the key has, and languages says in which languages. Check the list, then send the same keys with "dry_run": false:
{ "dry_run": false, "deleted": ["checkout.old_banner"], "not_found": ["checkout.typo"] }A name that matches no key is listed in not_found either way, and the other keys still go. Each deleted key gets its own audit-log entry and its own key_deleted webhook. Send at most 1000 keys per request; more is a 400.
Each key is deleted on its own, so a 500 on a real delete may have deleted some of the keys before the failure. Repeat the dry run to see which remain.
Errors
| Status | error | Cause |
|---|---|---|
400 | invalid key: … | The key name is empty, longer than 512 bytes, or contains a NUL character or invalid UTF-8. |
400 | invalid parameter: … | The value declares a {name:Type} with an unknown or conflicting type. |
400 | invalid text: … | The description or value contains a NUL character or invalid UTF-8, or an update sends an empty value. |
400 | nothing to update: … | An update sent none of key, description and value. |
400 | no keys given, at most 1000 keys per call | The delete’s keys is empty, or longer than 1000. |
404 | translation key not found | An update named a key the project does not have. |
409 | translation key already exists | A create, or a rename, used a name that is taken. |
409 | approved source text cannot be changed | An update tried to replace an approved source text. |
409 | translation key limit reached for this plan | Creating the key would exceed the plan’s limit. |
The general rules are in Errors. Branch on the status, not on the message.