Skip to main content

Translate and sync

Two routes put source strings into a project and queue their AI translation. POST /translate takes strings one by one, for an app that extracts them from code. POST /sync takes a whole translation file, for an app that keeps a catalog. Both answer at once with a cost estimate and a trackingToken, and the translation runs in the background.

All paths below are under https://api.easyi18n.com/v1/projects/{projectId}. The key needs the translate scope, or write to register without a translation and to write translations back; see authentication.

Push strings​

Send up to 500 units per request, each a source of at most 5,000 characters. Price the push first with ?dryRun=true, which writes nothing:

curl -X POST "https://api.easyi18n.com/v1/projects/$PROJECT_ID/translate?dryRun=true" \
-H "Authorization: Bearer $EASYI18N_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"units": [
{"source": "Welcome back, {name}", "key": "home.welcome"},
{"source": "Sign out", "ctx": "account menu"}
]
}'

The preview reports estimatedCredits and the workspace balance, both in millicredits, and accepted: whether the real push would fit the balance and the plan's key limit. Send the same body without the query parameter to run it:

{
"trackingToken": "8Zk2pW5nYc",
"estimatedCredits": 1240,
"balance": 498760,
"baseCode": "en",
"targetLangs": ["es", "fr"],
"units": [
{
"key": "home.welcome",
"token": "3f9a…",
"outcome": "created",
"translated": [],
"pending": ["es", "fr"]
}
]
}

What a unit can carry:

  • source, or forms for a plural: an object keyed by CLDR category (one, other and so on) where other is required. A source can carry {name} placeholders.
  • ctx, a disambiguation context. Two identical sources with a different ctx are different units.
  • key, a preferred name for a new key: dot-separated segments of letters, digits and underscores, such as home.welcome. Any other shape is 400 invalid_key and the whole request is refused. Without it the key is named from the source.
  • previousSource (with previousCtx), when you edited the wording of a string. The unit keeps the existing key instead of creating a new one.

langs at the top level restricts the target languages. Without it the push covers every target language of the project. A language set to manual translation is never an AI target.

A push is idempotent. Sending a source the project already translated reports it with outcome: matched, queues nothing and returns trackingToken: null. Each unit's outcome is created, matched, carriedOver or contended. A contended unit lost a race with a concurrent write and nothing was written for it: push it again.

Two flags mean a unit was accepted but not translated, at no cost. gated means the project has automatic source review on and this source is not reviewed yet. disabled means the key is switched off in the dashboard, and pushing does not switch it back on. The response counts them in skippedGated and skippedDisabled; report those numbers, because the push otherwise looks complete.

Register without a translation​

When your own AI translates, send "fill": false in the body of POST /translate or POST /sync. The route registers the strings, or reconciles the file, and queues nothing: trackingToken is null, estimatedCredits is 0 and the workspace balance does not move. A dry run with the same body also prices 0.

curl -X POST "https://api.easyi18n.com/v1/projects/$PROJECT_ID/translate" \
-H "Authorization: Bearer $EASYI18N_TOKEN" \
-H "Content-Type: application/json" \
-d '{"fill": false, "units": [{"source": "Welcome back, {name}", "key": "home.welcome"}]}'

A unit's pending lists only languages an earlier push already has in flight, and a sync answers fillableLangs: []. A project whose languages are all set to manual translation accepts the push too.

A key with write and without translate can send only this body: omitting fill, or sending true, is 403 scope_insufficient and writes nothing. An agent key needs no operation for it, since nothing costs credits. fill takes a JSON boolean; the string "false" is 400 invalid_argument.

Poll the translation​

Poll the job with the token. This read accepts the read or the translate scope:

curl "https://api.easyi18n.com/v1/projects/$PROJECT_ID/translations?trackingToken=8Zk2pW5nYc" \
-H "Authorization: Bearer $EASYI18N_TOKEN"
{
"trackingToken": "8Zk2pW5nYc",
"status": "done",
"estimatedCredits": 1240,
"creditsCharged": 1105,
"summary": {"total": 2, "translated": 2, "pending": 0, "failed": 0}
}

queued and running mean keep polling. done, failed, aborted_no_credits and cancelled are final. done says the job finished, not that every pair was translated: read summary.failed and summary.pending. After aborted_no_credits the job never resumes. Add credits and push the same strings again, which starts a new job with a new token.

To read one key, pass its name as ref, and optionally lang:

curl "https://api.easyi18n.com/v1/projects/$PROJECT_ID/translations?ref=home.welcome" \
-H "Authorization: Bearer $EASYI18N_TOKEN"
{
"key": "home.welcome",
"translations": {
"es": {"status": "translated", "value": "Bienvenido de nuevo, {name}"},
"fr": {"status": "pending"}
}
}

These reads return the live translations. Apps receive a translation once it is in a published version.

List the live keys​

GET /keys returns the project's keys as they are now, in key order, with the state of each target language. A client that translates with its own AI reads it to find the cells that are missing. The read accepts the read or the translate scope:

curl "https://api.easyi18n.com/v1/projects/$PROJECT_ID/keys?lang=es&status=untranslated" \
-H "Authorization: Bearer $EASYI18N_TOKEN"
{
"keys": [
{
"key": "home.welcome",
"catalogKey": "homeWelcome",
"source": "Welcome back, {name}",
"isPlural": false,
"description": null,
"disabled": false,
"translations": {"es": {"status": "untranslated"}}
}
],
"nextCursor": null
}

A translated cell also carries its value: the string the json output format writes for it. A plural comes as its ICU message, {count, plural, one{…} other{…}}, so once a publish includes the cell, the value matches the file pull writes byte for byte. catalogKey is the key's spelling in the file it was synced from, when it came from one. A deleted key is not listed; a key a sync disabled is, with disabled: true.

ParameterEffect
langOnly this target language. Any other code, the base language included, is 400 invalid_argument.
statustranslated, pending, failed or untranslated. With lang, that cell decides; without it, a key stays when any target language has the state, and the row carries all of them.
updatedSinceKeys changed at or after this instant, including a translation by the AI fill. It needs a UTC offset, as in 2026-11-01T09:00:00Z.
cursorThe nextCursor of the previous page.

A page examines 500 keys and the filters apply within them, so a page can come back with fewer rows, or none, and still carry a nextCursor. Keep passing cursor until nextCursor is null.

Write translations back​

PUT /translations writes target-language cells, each named by the key's slug or its catalogKey and by the language, as GET /keys lists them. A client that translates with its own AI stores the result this way. It costs no credits and queues no translation. The key needs the write scope, and an agent key needs no operation:

curl -X PUT "https://api.easyi18n.com/v1/projects/$PROJECT_ID/translations" \
-H "Authorization: Bearer $EASYI18N_TOKEN" \
-H "Content-Type: application/json" \
-d '{"translations": [
{"key": "home.welcome", "lang": "es", "value": "Hola de nuevo, {name}"},
{"key": "cart.items", "lang": "es",
"value": "{count, plural, one{{count} artículo} other{{count} artículos}}"}
]}'
{"written": 2, "unchanged": 0, "conflicts": [], "conflictsTotal": 0, "failedEntries": []}

A request takes up to 500 cells. Each one lands with the translated stage and shows as Imported in the dashboard. The route does not change a key's source, description or disabled flag, and it does not publish: pull and GET /translations serve the published version until the next publish.

catalogKey is the key's spelling in the file pull wrote, so a pulled json file goes back as it is, even after a key was renamed:

{"translations": [
{"catalogKey": "homeWelcome", "lang": "es", "value": "Hola de nuevo, {name}"}
]}

A cell carries key or catalogKey, not both. The spelling is compared as written against the live keys that are not disabled, and an old slug from a rename is not followed.

A text key takes a string as sent. A plural key takes its ICU message, over the parameter pull writes and without offset:, or a map of plural forms such as {"one": "…", "other": "…"}. The value replaces the forms stored before. A Markdown cell sent back as pull wrote it, with two spaces before each line break, counts as unchanged.

A refused cell comes back in failedEntries with its key, lang, code and reason, plus its catalogKey when it named one, and the rest of the request is applied:

codeCause
unknown_keyNo live key has this slug, or no live key that is not disabled has this catalogKey. The reason names a disabled one; write it by key.
ambiguous_keyTwo or more keys share this catalogKey. The reason names them; send the cell by key.
shape_mismatchThe value does not fit the key: a map on a text key, or on a plural key a string that is not its ICU message.
string_too_longA text or a plural form is over 10,000 characters.
fill_pendingAn AI translation is filling the cell, and GET /keys reports it pending. Send the cell again once it settles.
invalid_argumentA language that is not a target of the project, an empty value, both key and catalogKey or neither, another field, or a cell the request names twice, by slug or by spelling.
contendedThe write was not confirmed. Send the cell again.

A value that easyi18n produced or that a person signed in the dashboard is kept, the rule POST /sync follows with onConflict: server, the default. Send "onConflict": "file" to overwrite it. Either way the cell is listed in conflicts with its origin, stage, updatedAt and resolution (kept or overwritten), up to 50 rows, and conflictsTotal counts them all. An AI translation whose source changed after it was made is overwritten without a row. A cell whose stored value already matches counts as unchanged.

The body takes translations and, optionally, onConflict and a requestId. Any other field, another onConflict or a list that is empty or longer than 500 is 400 invalid_argument, and nothing is written. A body over 4 MiB is 413.

A workspace writes at most 20,000 cells per minute through this route, counted by the cells each request sends, refused ones included. The request that would pass it is 429 rate_limited with Retry-After: 60, and writes nothing. A resent requestId is answered before the budget.

Recover a lost response​

If the connection drops after you send a push, you do not know whether it ran. Add a requestId of your own to the body, 1 to 128 characters of letters, digits, _ and - (a UUID fits). The API records it before it writes anything else:

  • Sending the same requestId with the same body within 24 hours returns the response of the first run, trackingToken included, and writes nothing.
  • The same requestId with a different body is 409 request_mismatch.
  • While the first request is still running, a repeat is 409 request_in_progress with leaseUntil, the time to check again.
  • After 24 hours a repeat is 409 request_expired. Do not resend it.

GET /requests/{requestId} reads the record without sending the body again. Its state is unknown (no such request under this key), processing, done (with the response), failed (with the status and body of the refusal) or expired (with stateWas and the trackingToken, if any). A request that failed is sent again under a new requestId.

POST /sync and PUT /translations follow the same contract.

Sync a whole file​

POST /sync uploads one file, base64-encoded, and reconciles the project with it. It accepts three kinds of file:

  • An Apple String Catalog (xcstrings), which holds every language.
  • A base-language catalog in json, nested_json, angular_json, android_xml, yaml or resx: the one file per locale that Transloco, ngx-translate and i18next read, the file ng extract-i18n --format=json writes, an Android values/strings.xml, a Rails config/locales/en.yml, or a .NET Resources/Strings.resx.
  • An Android values-<qualifier>/strings.xml, a Rails es.yml or a .NET Strings.es.resx sent with "lang", the language it holds. It stores that language's translations of keys the project already has: it creates no key, changes no source and queues no translation. A key the project lacks is a failedEntries row with code unknown_key. Sync the base file first.

Any other format, or a single target-language file of another format, is 400 format_not_syncable. A catalog's declared source language must match the project's base language, or the request is 400 source_language_mismatch. A fileName whose values-<qualifier>, or whose .resx culture (Strings.es.resx), names a target language needs lang, and a lang that contradicts it is 400 invalid_argument. A Rails YAML file names its language in its root (es:): a target root without lang, or a lang that contradicts the root, is 400 invalid_argument. In a file with several roots, the root lang names is read, or the base language's without lang. A file holds at most 1,000 entries.

curl -X POST "https://api.easyi18n.com/v1/projects/$PROJECT_ID/sync?dryRun=true" \
-H "Authorization: Bearer $EASYI18N_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"fileName\": \"en.json\", \"format\": \"json\", \"contentBase64\": \"$(base64 < public/i18n/en.json | tr -d '\n')\"}"

The answer counts what the sync did, or would do under dryRun: created, updatedSources, matchedSources, updatedTranslations, disabledOrphans and reenabled, plus estimatedCredits, balance and the trackingToken of the queued translation.

The file is the project's whole catalog. A key the file no longer carries is disabled: it stays in the project, out of published versions and out of AI translation, and it comes back when the file carries it again. Check disabledOrphans in the preview before the real run.

Translations the file already carries are stored as they are and never charged. A stored translation that a person edited or approved, or that the AI produced, is not overwritten in silence. By default it is kept and the pair is listed under conflicts with resolution: kept. Send "onConflict": "file" to let the file win. The list holds the first 50 pairs and conflictsTotal the real count.

To protect source text edited in the dashboard, send pulledAt: the snapshotAt that GET /translations returned with the files you are syncing back. A source the project changed after that instant is reported as a conflict in the base language and kept, unless onConflict is file.

Read diagnostics too. A LANG_NOT_IN_FILE row names a target language the file does not carry. On a dry run its plannedPairs says how many translations the run would queue for that language.

Capture untranslated strings at runtime​

POST /capture registers strings the project does not have yet. A runtime SDK reports, from debug builds, the strings it had to show untranslated; the WordPress plugin sends the strings of the theme and plugins from the live site. The project registers each unknown one as a captured key for review in the dashboard. Captured keys are not translated and nothing is charged.

curl -X POST "https://api.easyi18n.com/v1/projects/$PROJECT_ID/capture" \
-H "Authorization: Bearer $EASYI18N_CAPTURE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"units": [{"source": "Sign out", "ctx": "account menu"}]}'
{"captured": 1, "skipped": 0}

A batch holds up to 200 units, and a project accepts 5,000 new captured keys per day. Use a key with the capture scope alone and keep it out of release builds.

Add a language or an output format​

Two routes with the write scope prepare a project without the dashboard. Neither spends credits.

curl -X POST "https://api.easyi18n.com/v1/projects/$PROJECT_ID/languages" \
-H "Authorization: Bearer $EASYI18N_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code": "pt-BR"}'
{"code": "pt-br", "isBase": false, "fillMode": "ai"}

Adding a language that is already there changes nothing. Send "fillMode": "manual" to keep it out of AI translation.

POST /output-formats with {"format": "arb"} adds a file format the project publishes: json, nested_json, angular_json, arb, po, xcstrings, ios_strings, android_xml, yaml or resx. The workspace plan sets how many stacks of a project write files: two on Free and during the Pro trial, five on Pro and Team. Past that number the request answers 409 too_many_formats, and the message names the plan and its number.

When a push or a sync is refused​

StatuserrorWhat to do
400too_many_units, source_too_long, too_many_entriesSplit the request.
400fill_mode_manuallangs names a language set to manual translation. Remove it.
402insufficient_creditsThe estimate is above the balance. availableCredits says what a new job may spend. Add credits and push again.
402spend_cap_exceededThe workspace's monthly spending cap refused it. capRemaining says what is left under the cap.
402plan_limitThe push would pass the plan's key limit. details names the limit.
403scope_insufficientThe key has write but not translate. Send "fill": false to register without a translation, or use a key with translate.
403authorization_requiredThe key is an agent key and the work costs credits. Request an operation for estimatedCredits.
503unavailable, contendedRun the push or the sync again.