Skip to content
Docs

REST API

Pull and push a project's translations from CI, scripts and tooling.

Everyone3 min read

A small API, authenticated with a project API key, for pulling and pushing one project's translations: CI pipelines, build-time code generation, pull and push scripts. Its paths, parameters and responses are stable, so a script written against it keeps working.

The base URL is https://localizator.carcutter.io. Every path below starts with /api/v1/projects/{projectId}; the project id is in the project's address in the app and under Settings › Environment variables.

EndpointDoes
GET /api/v1/projects/{projectId}/statusLists the project's languages
GET /api/v1/projects/{projectId}/files/downloadDownloads one language as JSON or ARB
POST /api/v1/projects/{projectId}/filesImports one language's translations

Authentication

Every request needs an API key of the project, created under Settings › API keys (see Pull translations in CI). Send it in the X-Api-Token header or as Authorization: Bearer:

X-Api-Token: lt_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Authorization: Bearer lt_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

A key works for the project it was created in only. A missing, invalid or revoked key gets 401. A key of a different project gets the same 404 as a project that doesn't exist, so a leaked key can't be used to find out which project ids exist.

Errors

Errors are JSON shaped { "error": string }. Validation errors also have an issues array.

StatusMeaning
400Malformed request: a missing field, or file content that can't be read
401Missing, invalid or revoked API key
404Project or language not found, or the key belongs to another project
422The request body failed validation
503The database can't be reached right now

Project status

GET /api/v1/projects/{projectId}/status

Lists the project's languages, so a script can find which locale codes exist before downloading or uploading. The source language comes first.

curl -H "X-Api-Token: $API_TOKEN" \
  "https://localizator.carcutter.io/api/v1/projects/$PROJECT_ID/status"
{
  "id": "cmq6pqqdy04v8tkxfp4vknobz",
  "name": "Mobile app",
  "defaultLocale": "en",
  "languages": [
    { "langCode": "en", "name": "English", "isDefault": true },
    { "langCode": "de", "name": "German", "isDefault": false }
  ]
}

Download a locale

GET /api/v1/projects/{projectId}/files/download

Returns one language's translations as the file itself: a JSON object or a Flutter ARB file, not wrapped in anything.

Query parameterRequiredDescription
lang_codesYesOne locale, such as en or fr-CA (or the language's id). One language per request
typeNojson (default) or arb
export_empty_asNomain fills empty values from the source language; by default they stay empty
nestedNofalse returns flat, dot-path JSON (JSON only)
# Nested JSON (the default)
curl -H "X-Api-Token: $API_TOKEN" \
  "https://localizator.carcutter.io/api/v1/projects/$PROJECT_ID/files/download?lang_codes=en"

# Flat, dot-path JSON
curl -H "X-Api-Token: $API_TOKEN" \
  "https://localizator.carcutter.io/api/v1/projects/$PROJECT_ID/files/download?lang_codes=en&nested=false"

# Flutter ARB, filling empty values from the source language
curl -H "X-Api-Token: $API_TOKEN" \
  "https://localizator.carcutter.io/api/v1/projects/$PROJECT_ID/files/download?lang_codes=fr&type=arb&export_empty_as=main" \
  -o app_fr.arb

See File formats for what the files look like.

Load (upload) a locale

POST /api/v1/projects/{projectId}/files

Imports translations for one language, the push side of download. Keys that don't exist are created. By default, existing non-empty values are overwritten; send overwrite as false to only fill empty cells.

Each call also:

  • archives what was sent,
  • writes an import entry to the project's activity log,
  • queues a Google Drive sync if the project has one.

Values written this way show as Pushed via API in the editor, and its source filter finds them, until someone edits them.

Send a file, or a JSON body, whichever suits your client. JSON content must be nested: a key name containing a dot, such as "home.title", is refused.

Option A: a file (multipart/form-data)

FieldRequiredDescription
fileYesThe JSON or ARB file
lang_codeYesThe target locale (or the language's id)
formatNoJSON or ARB; guessed from the file name if left out
overwriteNo"true" (default) or "false"
curl -X POST "https://localizator.carcutter.io/api/v1/projects/$PROJECT_ID/files" \
  -H "X-Api-Token: $API_TOKEN" \
  -F "file=@de.json" \
  -F "lang_code=de"

Option B: JSON body with the translations

curl -X POST "https://localizator.carcutter.io/api/v1/projects/$PROJECT_ID/files" \
  -H "X-Api-Token: $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "lang_code": "de",
    "translations": { "greeting": "Hallo", "nav": { "home": "Startseite" } }
  }'

Option C: JSON body with a file's text

Useful when you already have a JSON or ARB document as a string and don't want to send a multipart request.

curl -X POST "https://localizator.carcutter.io/api/v1/projects/$PROJECT_ID/files" \
  -H "X-Api-Token: $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "lang_code": "de",
    "format": "JSON",
    "content": "{\"greeting\": \"Hallo\"}"
  }'

Response

The same for all three:

{
  "added": 12,
  "updated": 3,
  "total": 15,
  "blobUrl": "s3://…/imports/…"
}

blobUrl is where the upload was archived, not a download link. It's empty where the installation doesn't archive files; the import works either way.

Related