DocsREST API
API overview
Base URL, authentication, permissions, error format, ids, rate limits and conventions shared by every REST endpoint.
On this page
The Generic Translation REST API is what the CLI, libraries and dashboard all talk to. Everything they can do, you can do with HTTP.
Base URL
https://generic-translation-api.jacobfv123.workers.dev
A self-hosted deployment has its own base URL. Versioned endpoints live under /v1. The CDN lives under /cdn.
Three unauthenticated service endpoints describe the API itself:
| Endpoint | Returns |
|---|---|
GET / |
{ "name", "version", "docs", "openapi", "models", "defaultModel" } |
GET /health |
{ "ok": true, "time": "<ISO timestamp>" } |
GET /openapi.json |
An OpenAPI 3.1 document describing the API’s routes. Feed it to a client generator or an API explorer. |
curl https://generic-translation-api.jacobfv123.workers.dev/
{
"name": "generic-translation-api",
"version": "0.1.0",
"docs": "https://generic-translation.pages.dev/docs",
"openapi": "https://generic-translation-api.jacobfv123.workers.dev/openapi.json",
"models": ["@cf/meta/llama-3.3-70b-instruct-fp8-fast", "@cf/meta/llama-4-scout-17b-16e-instruct", "..."],
"defaultModel": "@cf/meta/llama-3.3-70b-instruct-fp8-fast"
}
models lists the model ids a project may select with the model field (see the project object); the exact list depends on the deployment.
Conventions
- Request and response bodies are JSON. Send
content-type: application/jsonwith every body. - Timestamps are ISO 8601 strings in UTC.
- Unknown routes return
404 not_found. A body that is not valid JSON returns400 invalid_request. - CORS is open: every origin is allowed, with the
authorizationandcontent-typerequest headers. That does not make it safe to call authenticated endpoints from a browser; see API keys. - List endpoints that page use
cursorandlimit(1 to 200, default 50) query parameters and returnnextCursor. Pass it back to get the next page; it isnullon the last page. - Responses expose the
ETagandRetry-Afterheaders to browsers. - Unlike the other routes, a few list routes (organizations, members, projects, keys, glossary, files, jobs) return a bare JSON array rather than an object.
Authentication
Send a bearer token:
Authorization: Bearer gt-api-…
There are two kinds of token.
| Token | Prefix | Who uses it | Access |
|---|---|---|---|
| Session token | gt-sess- |
People, through the dashboard. Returned by signup and login. | Everything the user’s role allows in each of their organizations. |
| Project API key | gt-api- |
Machines: the CLI, CI, your servers. Created per project. | One project only, limited to the key’s permissions. |
Session tokens last 30 days or until you log out. Keys are shown once at creation and stored hashed. If you lose one, delete it and create another.
current as a project id
With a project API key, any route containing :projectId accepts the literal current, which resolves to the key’s own project. This lets tools work from a key alone:
curl https://generic-translation-api.jacobfv123.workers.dev/v1/projects/current \
-H "authorization: Bearer $GENERIC_TRANSLATION_API_KEY"
A key used against any other project’s id gets 403 permission_missing.
Permissions
A project API key carries a list of permissions. Each endpoint’s reference page names the one it needs.
| Permission | Allows |
|---|---|
project:read |
Read the project, its stats, strings, string history, jobs and latest translations. |
project:write |
Change project settings. |
files:read |
List files and download their content. |
files:write |
Upload and delete files. |
context:read |
Read project instructions and the glossary. |
context:write |
Change project instructions and the glossary. |
translations:generate |
Runtime translation: POST /translate. |
translations:enqueue |
Batch translation: POST /entries. |
translations:write |
Edit, approve, retranslate and delete strings; publish. |
Organization-level routes (members, usage, audit log, webhooks), project creation and deletion, and API key management are for session tokens only. A project API key cannot create other keys, and a request to a session-only route with a key returns 403 permission_missing. GET /v1/jobs/:jobId accepts any key of the job’s project. With a session token, the caller’s organization role decides instead of key permissions.
Errors
Any non-2xx response has this body:
{ "error": "Project not found", "code": "not_found" }
error is a human-readable sentence that may change. code is stable; branch on it.
| Status | Code | When |
|---|---|---|
| 400 | invalid_request |
The body, query or path failed validation. The message says which field. |
| 400 | invalid_signature |
A POST /webhooks/stripe or /webhooks/github request failed signature verification. |
| 400 | incompatible_message |
A translation’s variables or tags do not match its source, or the text is empty. See strings. |
| 401 | unauthenticated |
Missing, malformed, expired or revoked token; wrong email or password. |
| 403 | permission_missing |
The token is valid but the role or key permission does not allow this. |
| 404 | not_found |
No such resource, or it is not visible to you. |
| 402 | credits_insufficient |
Billing is switched on and the organization has used its free allowance and has no credits. Sent for work that would call the model (uncached translate, entries, files, retranslate); see billing. |
| 403 | sso_required |
Password login for a member of an organization that enforces SSO. See SSO. |
| 409 | conflict |
The request conflicts with current state, such as signing up with an email that is already registered. |
| 429 | rate_limited |
Too many requests. Wait and retry. |
| 502 | translation_failed |
Returned by single-string retranslate when the model could not produce a valid translation. Retry later. |
| 501 | billing_not_configured, sso_not_configured, github_not_configured |
The instance does not have the secrets that feature needs (Stripe, ENCRYPTION_KEY, or a GitHub App). The matching GET status routes answer normally with configured: false. |
| 502 | billing_provider_error, github_error |
Stripe or GitHub could not be reached or rejected the request. |
| 500 | internal |
Something failed on our side. Safe to retry with backoff. |
Validation errors may carry a details array of the underlying issues next to error and code. The incompatible_message error carries details.problems.
Rate limits
Two limits are enforced, each in fixed one-minute windows:
| Limit | Applies to | Default |
|---|---|---|
| Authentication | POST /v1/auth/signup and /login, per client IP address |
30 per minute |
| Runtime translation | POST /v1/projects/:projectId/translate, per API key (or per user for sessions) |
300 per minute |
These are the defaults of the code in the repository; a hosted or self-hosted deployment may configure different numbers, and the preview’s numbers may change. Other routes are not rate limited today.
When you exceed a limit you get 429 with code rate_limited and a Retry-After header in seconds. To stay well under the limits:
- Use batch jobs for anything larger than a screenful of strings, not a loop over the runtime endpoint.
- Serve translations to users from the CDN or bundled files, not by calling the API per request.
Ids
Ids are opaque strings with a type prefix. Do not parse them beyond the prefix.
| Prefix | Resource |
|---|---|
usr_ |
User |
org_ |
Organization |
prj_ |
Project |
key_ |
API key |
job_ |
Job |
fil_ |
File |
whk_ |
Webhook |
gls_ |
Glossary term |
evt_ |
Webhook event (also the generic-translation-delivery header value) |
dlv_ |
Webhook delivery record |
Strings are identified by their 32-character content hash, not by an id.
Route index
| Area | Routes | Page |
|---|---|---|
| Accounts | /v1/auth/*, /v1/me |
Auth and account |
| Organizations | /v1/orgs, members, usage, audit |
Organizations |
| Projects | /v1/orgs/:orgId/projects, /v1/projects/:projectId, stats, keys, context, glossary |
Projects |
| Translation | /translate, /entries, /v1/jobs/:jobId, /jobs, /translations/:locale |
Translate |
| Editor | /strings and below |
Strings |
| Files | /files and below |
Files |
| Delivery | /publish, /cdn/* |
Publish and CDN |
| Webhooks | /v1/orgs/:orgId/webhooks and below |
Webhooks |
| Billing | /v1/orgs/:orgId/billing and below, /webhooks/stripe |
Billing |
| SSO and SCIM | /v1/orgs/:orgId/sso, /v1/auth/sso/*, /v1/orgs/:orgId/scim/token, /scim/v2/:orgId/* |
SSO and SCIM |
| GitHub agent | /v1/github/app, /v1/orgs/:orgId/github/installations, /v1/projects/:projectId/github*, /webhooks/github |
GitHub agent |
Using the client instead
From JavaScript or TypeScript, the GenericTranslation class in @generic-translation/core wraps the endpoints most integrations need, with types.
Something wrong or unclear on this page? Open an issue.