Importing translations
POST /translations/import creates keys and writes their values, in as many languages as you send, in one request.
It takes exactly one format: a JSON body. There is no XLIFF, gettext or Android XML parser. Converting a file into this shape is a small, mechanical job, and an AI assistant does it well. That is how Migrate with your AI works. The MCP tool import_translations is this same endpoint, calling the same code, so everything on this page applies to it too.
The request
curl -s "https://api-public-dev.localeo.app/v1/translations/import" \ -H "Authorization: Bearer $LOCALEO_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "overwrite": false, "status": "draft", "keys": [ { "key": "home.greeting", "description": "Greeting at the top of the home screen", "values": { "en": "Hello {name}", "nl": "Hallo {name}" } }, { "key": "checkout.pay", "values": { "en": "Pay now", "nl": "Nu betalen", "de": "Jetzt bezahlen" } } ] }'| Field | Default | Meaning |
|---|---|---|
keys | — | The keys to create or fill. At least one, at most 1000 per request. |
keys[].key | — | The full key name. Dots are only a naming convention; nothing is nested. |
keys[].description | "" | Context for translators. Optional. |
keys[].values | — | A value per language code. Send only the languages you have. |
overwrite | false | Replace values that already exist. An approved value is never replaced. |
status | draft | The status every value in this request is written with: draft or approved. |
Send the Content-Type: application/json header. Without it the body is not read, and the request fails with 400 invalid request body.
More than 1000 keys is refused as a whole, so split a large file into chunks. Importing a large file in chunks shows one way.
The response
A 200 means the request was read and applied as far as it could be. It does not mean every value was written.
{ "created_keys": 1, "created_values": 2, "updated_values": 0, "skipped_values": 2, "errors": [ { "key": "checkout.pay", "language": "de", "code": "unknown_language", "message": "language \"de\" is not a language of this project" } ], "warnings": []}This is the answer to the request above in a project with English and Dutch, where checkout.pay already had both values. home.greeting is new, so it and its two values are created. The two existing checkout.pay values are skipped. The project has no German, so de is an error.
| Field | Counts |
|---|---|
created_keys | Keys that did not exist and now do. |
created_values | Values written where the language had none. |
updated_values | Existing values replaced (only with overwrite: true). |
skipped_values | Values left alone: the key already had one and overwrite was false, or the value you sent was empty. |
errors | Every key or value that was not written, and why. |
warnings | Values that were written but look wrong. |
errors and warnings are always arrays, empty when there is nothing to report. Each entry has a key, a language when the problem is with one value rather than the whole key, a stable code and a human-readable message. Branch on code. The message may be reworded.
How values are applied
Each key stands on its own
Every key is written in its own transaction. A problem with one key never undoes another, so a request with one bad key out of 500 writes the other 499 and reports the one.
That also makes an import safe to send twice. Without overwrite, everything the first attempt wrote is skipped the second time. If a request fails half-way with a 500, the keys it already wrote stay written, and re-sending it fills in the rest.
Existing values are skipped by default
Without overwrite, an existing key keeps its description, its placeholders and every value it already has. What you sent for it is counted in skipped_values.
A language the existing key has no value in yet is still written, because there is nothing to skip. That includes the base language: an existing key with no base-language value gets the one you send, without overwrite. Replacing a base value the key already has, like changing its description, is what overwrite is for, because the base value is the key’s source.
With overwrite: true:
- An existing value is replaced, unless it is approved.
- A non-empty
descriptionreplaces the key’s description. An empty one leaves it alone. - A new base-language value re-derives the key’s placeholders.
- A changed base value or description changes the key’s source, so its other languages are marked outdated, exactly as when someone rewords the source in the dashboard. Values written in the same request are not: they were written against the new source.
- The replaced value takes the request’s
status. Overwriting anin_reviewvalue with"status": "draft"makes it a draft.
Approved values are never replaced
No import overwrites an approved value, at any role, with any flag. With overwrite: true an attempt is reported as approved_locked. Without it, the value is simply skipped, like any other existing value.
This is deliberate. An approved value has been checked by a person, and an import that silently replaced it would undo that review. To change one, edit it in the dashboard.
Status: draft unless you say otherwise
Values are written as draft unless you send "status": "approved". Only send approved for values that have already been reviewed: typically, translations you are moving over from another tool where they were live. Only a manager’s token may write approved; a developer’s gets forbidden_status on each value.
Language codes
Codes match the project’s languages case-insensitively, so NL, nl and Nl are the same. A code the project does not have is reported as unknown_language. An import never creates a language. Adding one is a decision with consequences for your team and your plan, so it stays in the dashboard. GET /project-languages lists what the project has.
An empty or whitespace-only value is skipped, not written, and is not an error. So converted files can leave a gap as "", but an import cannot clear a value.
What a developer may import
A token acts with its creator’s current role:
| Developer | Manager | |
|---|---|---|
| Create keys | ✓ | ✓ |
| Write base-language values | ✓ | ✓ |
| Write other languages | forbidden_language | ✓ |
"status": "approved" | forbidden_status | ✓ |
This mirrors the dashboard. Developers own the source text and the integration, and translating is a translator’s or manager’s job.
When a developer’s base value for a new key is refused, the key is not created: a key without its source would be an empty shell. The same goes for a new key whose every value was refused, such as a developer sending only other languages, or only languages the project does not have. The refusals are reported against those values as usual. A key sent with no values at all is still created.
The plan’s key limit
New keys count against the plan’s translation-key limit, as they do in the dashboard. A key that would exceed it is not created and is reported as key_limit_reached. Every later new key in the same request is refused the same way. Values for keys that already exist are still written.
Placeholders
Values are stored exactly as you send them. {name}, {{name}}, %s, %1$d and ICU {count, plural, …} all reach the published bundle byte for byte, because your app’s i18n library is what reads them. Never convert one placeholder syntax into another on the way in.
There is one exception, in the base language only. {name:Type} declares a typed parameter, as the dashboard’s CSV import does. The type is recorded on the key, and the value is stored as plain {name}:
{ "key": "cart.count", "values": { "en": "You have {count:int} items" } }is stored as You have {count} items, with a parameter count of type int. The types are String, int, double, num, DateTime and Object, and a plain {name} means String. Any other type, or the same name declared with two different types, fails the whole key as invalid_parameter, and none of that key’s values are written.
The placeholder check is a warning
Each non-base value written by the request is compared with the key’s base-language value. If the {name} placeholders differ, ignoring order, the value is still written and a placeholder_mismatch warning names it. Order is ignored because word order legitimately changes between languages. A value that was not written, because it was skipped or is approved, is not checked: the warning is about what you just wrote, never a reason to overwrite someone else’s value.
The check only understands {name}-style placeholders, which includes the inner part of i18next’s {{name}}. It does not parse printf %s or ICU syntax, so a printf placeholder is never flagged. Check those yourself.
ICU is not parsed, but parts of it look like placeholders. Any single-word branch (one {item} in a plural, male {He} in a select) reads as a placeholder named item or He, and its translation (one {artikel}) does not have it. So an ICU message can warn when nothing is wrong. Branches with a space or a #, such as {# items}, are ignored.
Codes
Errors: not written
| Code | Applies to | Meaning |
|---|---|---|
invalid_key | key | The key name is empty, only whitespace or longer than 512 bytes; the key or its description contains a NUL character or invalid UTF-8; or the database could not store the key, for example a placeholder name too long to index. Nothing for the key was written. |
duplicate_key | key or value | The key appears twice in the request, and only the first is imported. Or one key names the same language twice (nl and NL), and only one of them is imported. |
unknown_language | value | The project has no such language. |
forbidden_language | value | A developer’s token wrote a language other than the base language. |
forbidden_status | value | A developer’s token asked for approved. If this refuses the base value of a new key, the key is not created. |
approved_locked | value | overwrite: true, but the existing value is approved. |
key_limit_reached | key | Creating the key would exceed the plan’s translation-key limit. |
invalid_parameter | key, reported against the base language | The base value declares a {name:Type} with an unknown or conflicting type. Nothing for the key was written. |
invalid_value | value | The value contains a NUL character or invalid UTF-8. If it is the base value of a new key, the key is not created. |
conflict | key | Another write changed the same key at the same moment. Nothing for the key was written; send it again. |
Warnings: written, but check them
| Code | Applies to | Meaning |
|---|---|---|
placeholder_mismatch | value | Its {name} placeholders differ from the base-language value’s. |
missing_base_value | key | The key was created without a base-language value, so it has no source to translate from. |
Request failures: nothing written
These refuse the whole request, with the usual error shape:
| Status | error | Cause |
|---|---|---|
400 | invalid request body | Not JSON, or no Content-Type: application/json. |
400 | no keys to import | keys is empty or missing. |
400 | too many keys in one import | More than 1000 keys. Split the request. |
400 | status must be draft or approved | Any other status. |
403 | token is read-only | The token’s scope is read. |
403 | token owner no longer has write access | The token’s creator was deleted, left the project, or is no longer a manager or developer. |
What an import does not do
- It fires no webhooks. A 2,000-key migration would otherwise send 4,000
translation_createdevents. Release webhooks are unaffected: creating and publishing a release still firesrelease_createdandrelease_published. - It writes one audit-log entry per request when anything changed, with the counts, attributed to the token’s creator as
Ada Lovelace (token: ci-import). - It does not publish anything. Imported values reach your app only when someone publishes a release.
Reading translations back
Two read endpoints answer “what is there now”. Both work with a read token.
# Every key with its Dutch value, only the ones still missing a translationcurl -s "https://api-public-dev.localeo.app/v1/translations?language=nl&status=untranslated" \ -H "Authorization: Bearer $LOCALEO_TOKEN"
# One key in every language. Percent-encode the key: a/b becomes a%2Fbcurl -s "https://api-public-dev.localeo.app/v1/translation-keys/home.greeting" \ -H "Authorization: Bearer $LOCALEO_TOKEN"GET /translations takes language (required), status (all, untranslated, outdated, draft, in_review or approved), search, page and page_size (at most 100). Its status_counts cover the whole search, not just the page. On a regional variant such as nl-BE, a key the variant does not override but its parent language has is listed with status inherited and the parent’s text in inherited_value, because that is what the variant ships; only a key neither has is untranslated. The API reference has both responses in full.
Importing a large file in chunks
With a file already in the import shape, this sends it 1000 keys at a time and prints what each chunk did:
jq -c '.status as $s | .keys as $k | range(0; $k | length; 1000) | {status: $s, keys: $k[.:(. + 1000)]}' import.json |while read -r chunk; do curl -s "https://api-public-dev.localeo.app/v1/translations/import" \ -H "Authorization: Bearer $LOCALEO_TOKEN" \ -H "Content-Type: application/json" \ -d "$chunk" | jq '{created_keys, created_values, skipped_values, errors}'doneEach chunk is one request against the rate limit, so even a 50,000-key project takes 50 of your 1000 hourly requests.