DocsREST API

Publish and CDN

Publish a snapshot of translations and read it back from the public CDN endpoints.

On this page

Publish

POST /v1/projects/:projectId/publish (translations:write)

Takes a snapshot of the current translations and makes it available on the CDN.

curl -X POST https://generic-translation-api.jacobfv123.workers.dev/v1/projects/current/publish \
  -H "authorization: Bearer $GENERIC_TRANSLATION_API_KEY" \
  -H "content-type: application/json" \
  -d '{ "locales": ["es", "fr"] }'
Field Type Required Notes
locales string[] no Locales to publish. Defaults to all of the project’s locales.
{ "published": ["es", "fr"], "version": "v1x9k2m3", "publishedAt": "2026-11-30T10:15:00.000Z" }

version is an opaque string that is different for every publish; it also appears in the manifest and in the x-generic-translation-version header of CDN responses. Publishing writes a new snapshot of each requested locale and replaces the previous one.

What goes into each map:

  • If the project’s requiresReview is false: every current translation of every string submitted to the project.
  • If requiresReview is true: only translations with status approved.

The CDN map is not branch-filtered: it contains strings from every branch.

Publishing triggers the project.published webhook.

Errors: 400 invalid_request if the project has no target locales or a locale is invalid, 403 permission_missing. Publishing is allowed even when cdnEnabled is false (the files are stored but not served until it is turned on).

CDN: locale map

GET /cdn/:projectId/:locale.json

Public. No authentication, open CORS. Use the real project id here; current has no meaning without a key.

curl -i https://generic-translation-api.jacobfv123.workers.dev/cdn/prj_abc123/es.json
HTTP/2 200
content-type: application/json; charset=utf-8
etag: "…"
cache-control: public, max-age=60, stale-while-revalidate=600
access-control-allow-origin: *
x-generic-translation-version: v1x9k2m3
{
  "5d1e7c2a90b34f6e8d1a0c3b5e7f9a24": "¡Hola, <0>{name}</0>!",
  "0b8f3a6d2c1e4f7a9b5d8e0c2a4f6b81": "Cerrar la sesión"
}

Conditional requests are supported:

curl -i https://generic-translation-api.jacobfv123.workers.dev/cdn/prj_abc123/es.json -H 'if-none-match: "…"'
# HTTP/2 304

Returns 404 not_found when the project does not exist, has cdnEnabled: false, or has never published that locale. A 304 response carries no body. Each successful request (200 or 304) counts toward cdnRequests in usage.

CDN: manifest

GET /cdn/:projectId/manifest.json

{
  "projectId": "prj_abc123",
  "defaultLocale": "en",
  "locales": ["es", "fr"],
  "version": "v1x9k2m3",
  "publishedAt": "2026-11-30T10:15:00.000Z"
}

locales lists the locales that have been published (cumulatively across publishes, limited to the project’s current locales). The manifest is served with the same cache headers as locale maps.

Turning the CDN off

curl -X PATCH https://generic-translation-api.jacobfv123.workers.dev/v1/projects/current \
  -H "authorization: Bearer $GENERIC_TRANSLATION_API_KEY" \
  -H "content-type: application/json" \
  -d '{ "cdnEnabled": false }'

All /cdn/ URLs for the project then return 404. Clients that cached a map keep using it until their cache expires (the default max-age is 60 seconds, plus a ten-minute stale window). Use this when you ship translations as local files and do not want a public copy.

See also: CDN concepts and publishing in the dashboard.

Something wrong or unclear on this page? Open an issue.

Type to search the documentation.