Flixu

Translate Document

POST /v1/translate/document

Upload a document file via multipart form data and receive the fully translated document back. The original file structure, formatting, and layout are preserved. Supports 16 file formats including localization standards (XLIFF, PO, JSON, YAML) and office documents (DOCX).

Request (multipart/form-data)

FieldTypeRequiredDescription
filefileThe document file to translate. See supported formats for accepted types and size limits (5–20 MB).
source_langstringSource language code (ISO 639-1).
target_langstringTarget language code.
glossary_idsstringJSON-encoded array of glossary IDs. Example: ["gloss_abc123", "gloss_def456"]
brand_voice_idstringBrand voice profile ID for tone/style alignment.
tm_idstringTranslation memory ID for leveraging past translations.

Response

FieldTypeDescription
data.download_urlstringPre-signed S3 URL to download the translated file. Valid for 24 hours.
data.filenamestringOriginal filename of the uploaded document.
data.source_langstringSource language code.
data.target_langstringTarget language code.
data.character_countintegerTotal output characters translated.
data.credits_usedintegerCredits deducted for this translation.
data.quality_scoreinteger | nullAverage quality score across all segments (0100). null if scoring is unavailable.
data.file_datastringBase64-encoded translated file content for immediate use.
meta.request_idstringUnique request identifier (UUID).

Error responses

StatusCodeDescription
400bad_requestMissing file, unsupported format, empty source_lang or target_lang
400unsupported_formatFile extension not in supported formats
402insufficient_creditsNot enough credits
429rate_limit_exceededPlan rate limit hit

Request examples

curl -X POST https://api.flixu.ai/v1/translate/document \
  -H "Authorization: Bearer flx_your_api_key" \
  -F "file=@localization.xliff" \
  -F "source_lang=en" \
  -F "target_lang=de" \
  -F "tm_id=tm_abc123"
const formData = new FormData();
formData.append('file', fs.createReadStream('localization.xliff'));
formData.append('source_lang', 'en');
formData.append('target_lang', 'de');
formData.append('tm_id', 'tm_abc123');

const response = await fetch('https://api.flixu.ai/v1/translate/document', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer flx_your_api_key',
  },
  body: formData,
});

const { data } = await response.json();
console.log(`Translated ${data.character_count} chars, score: ${data.quality_score}`);

// Decode and save the translated file
const buffer = Buffer.from(data.file_data, 'base64');
fs.writeFileSync('localization_de.xliff', buffer);
import requests
import base64

with open('localization.xliff', 'rb') as f:
    response = requests.post(
        'https://api.flixu.ai/v1/translate/document',
        headers={'Authorization': 'Bearer flx_your_api_key'},
        files={'file': ('localization.xliff', f)},
        data={
            'source_lang': 'en',
            'target_lang': 'de',
            'tm_id': 'tm_abc123',
        },
    )

result = response.json()
print(f"Quality: {result['data']['quality_score']}")

# Save the translated file
file_bytes = base64.b64decode(result['data']['file_data'])
with open('localization_de.xliff', 'wb') as out:
    out.write(file_bytes)

Response example

{
  "data": {
    "download_url": "https://s3.amazonaws.com/flixu-translations/abc-localization.xliff?...",
    "filename": "localization.xliff",
    "source_lang": "en",
    "target_lang": "de",
    "character_count": 12450,
    "credits_used": 12450,
    "quality_score": 91,
    "file_data": "PD94bWwgdmVyc2lvbj0i..."
  },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "credits_used": 12450,
    "processing_time_ms": 8340
  }
}