DocsREST API
Files
Upload a file for translation, list files, download translated content and delete files.
The files endpoints translate whole documents while preserving their structure. See files for what each format keeps and translates.
Upload a file
POST /v1/projects/:projectId/files (files:write)
curl -X POST https://generic-translation-api.jacobfv123.workers.dev/v1/projects/current/files \
-H "authorization: Bearer $GENERIC_TRANSLATION_API_KEY" \
-H "content-type: application/json" \
-d "$(jq -n --rawfile content docs/guide.md \
'{ fileName: "docs/guide.md", fileFormat: "md", content: $content, locales: ["de", "ja"] }')"
| Field | Type | Required | Notes |
|---|---|---|---|
fileName |
string | yes | A name or relative path, up to 500 characters. Used for display and as the downloaded file name. |
fileFormat |
string | yes | One of json, yaml, md, mdx, txt, html, srt, po, strings, androidxml, resx, xliff, csv. |
content |
string | yes | The file’s text, UTF-8, up to 1 MB. The body is JSON, so the content is a JSON string, not a multipart upload. A leading byte-order mark is preserved. |
locales |
string[] | no | Target locales. Defaults to the project’s locales. |
sourceLocale |
string | no | Defaults to the project’s defaultLocale. |
{ "fileId": "fil_k20sd…", "jobId": "job_5hh1p…" }
The response status is 202. The job has type: "file". Poll it with GET /v1/jobs/:jobId.
Each upload creates a new file record; uploading the same fileName again does not replace the earlier one (delete the old one if you do not need it). Because translation is cached per segment, segments that were already translated are not translated again, so re-uploading a lightly edited file only costs the changed segments.
Errors: 400 invalid_request for an unknown fileFormat, content over 1 MB, or content that does not parse as that format; 403 permission_missing.
List files
GET /v1/projects/:projectId/files (files:read)
[
{
"id": "fil_k20sd…",
"fileName": "docs/guide.md",
"fileFormat": "md",
"sourceLocale": "en",
"jobId": "job_5hh1p…",
"locales": [
{ "locale": "de", "status": "ready" },
{ "locale": "ja", "status": "pending" }
],
"createdAt": "2026-11-30T10:00:00.000Z",
"updatedAt": "2026-11-30T10:00:00.000Z"
}
]
Download content
GET /v1/projects/:projectId/files/:fileId/content?locale=de (files:read)
{
"status": "ready",
"content": "# Leitfaden\n\nWillkommen …",
"fileName": "docs/guide.md"
}
- With
locale, you get the translated file.statusis"pending"andcontentis absent while the translation is still in progress. Segments with no translation are left in the source language. - Without
locale(or with the source locale), you get the source file as uploaded. - A locale that was not requested at upload returns
404 not_found. If the translation job failed entirely the call returns409 conflict; upload the file again to retry. files:readis the permission needed.
curl -s "https://generic-translation-api.jacobfv123.workers.dev/v1/projects/current/files/fil_k20sd/content?locale=de" \
-H "authorization: Bearer $GENERIC_TRANSLATION_API_KEY" | jq -r .content > docs/de/guide.md
Delete a file
DELETE /v1/projects/:projectId/files/:fileId (files:write)
Removes the file and its translated versions, and returns { "ok": true }. Translations of its segments stay cached for later reuse.
From the CLI
You rarely need to call these by hand. Declare file globs under files in generic-translation.config.json and the CLI uploads sources, waits, and writes each locale’s file to the matching path.
Something wrong or unclear on this page? Open an issue.