Skip to content

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

Terminal window
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" }
}
]
}'
FieldDefaultMeaning
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.
overwritefalseReplace values that already exist. An approved value is never replaced.
statusdraftThe 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.

FieldCounts
created_keysKeys that did not exist and now do.
created_valuesValues written where the language had none.
updated_valuesExisting values replaced (only with overwrite: true).
skipped_valuesValues left alone: the key already had one and overwrite was false, or the value you sent was empty.
errorsEvery key or value that was not written, and why.
warningsValues 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 description replaces 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 an in_review value 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:

DeveloperManager
Create keys✓✓
Write base-language values✓✓
Write other languagesforbidden_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

CodeApplies toMeaning
invalid_keykeyThe 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_keykey or valueThe 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_languagevalueThe project has no such language.
forbidden_languagevalueA developer’s token wrote a language other than the base language.
forbidden_statusvalueA developer’s token asked for approved. If this refuses the base value of a new key, the key is not created.
approved_lockedvalueoverwrite: true, but the existing value is approved.
key_limit_reachedkeyCreating the key would exceed the plan’s translation-key limit.
invalid_parameterkey, reported against the base languageThe base value declares a {name:Type} with an unknown or conflicting type. Nothing for the key was written.
invalid_valuevalueThe value contains a NUL character or invalid UTF-8. If it is the base value of a new key, the key is not created.
conflictkeyAnother write changed the same key at the same moment. Nothing for the key was written; send it again.

Warnings: written, but check them

CodeApplies toMeaning
placeholder_mismatchvalueIts {name} placeholders differ from the base-language value’s.
missing_base_valuekeyThe 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:

StatuserrorCause
400invalid request bodyNot JSON, or no Content-Type: application/json.
400no keys to importkeys is empty or missing.
400too many keys in one importMore than 1000 keys. Split the request.
400status must be draft or approvedAny other status.
403token is read-onlyThe token’s scope is read.
403token owner no longer has write accessThe 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_created events. Release webhooks are unaffected: creating and publishing a release still fires release_created and release_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.

Terminal window
# Every key with its Dutch value, only the ones still missing a translation
curl -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%2Fb
curl -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:

Terminal window
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}'
done

Each chunk is one request against the rate limit, so even a 50,000-key project takes 50 of your 1000 hourly requests.