DocsPlatform

API keys and permissions

Project API keys, the nine permissions, the current alias, how keys differ from sessions, and which key to use where.

On this page

An API key lets a machine, such as your server, CI job or the CLI, act on one project. Keys look like gt-api- followed by 40 random characters. They are created by a signed-in admin on a project’s API keys page, or with POST /v1/projects/:projectId/keys.

  • The full key is shown once, at creation. Generic Translation stores only a hash and the first 12 characters (shown as the prefix so you can tell keys apart).
  • A key works only on its own project. Using it on another project returns 403 permission_missing.
  • Revoking a key (deleting it) stops it working immediately.
  • lastUsedAt shows when a key was last used (updated at most every five minutes), which helps you find keys that can be retired.
  • A key cannot create or list keys, manage organizations, members, webhooks, or delete the project. Those routes need a user session.

Permissions

Every route names the permission it needs. A key holds a list of them.

Permission Allows
project:read Read the project and its stats, list strings and their history, list jobs, read the latest translation maps.
project:write Change project settings (name, locales, model, CDN, review).
files:read List files, download their translated content.
files:write Upload and delete files.
context:read Read style instructions and the glossary.
context:write Change instructions and the glossary, apply the glossary.
translations:generate POST /translate, runtime translation.
translations:enqueue POST /entries, batch translation.
translations:write Edit, approve, retranslate and delete strings; publish.

Reading a job (GET /v1/jobs/:jobId) works with any key of the job’s project.

When you create a key through the API without permissions, it gets all nine. The dashboard pre-selects project:read, translations:generate, translations:enqueue and translations:write. Always grant the least that works.

Recipes

Where the key lives Permissions
A production server using runtime translation (tx, Tx) translations:generate only
A production server that only loads translations from the CDN None: the CDN is public, so it needs no key
CI that extracts strings, translates and writes files project:read, translations:enqueue
CI that also publishes add translations:write
File translation in CI files:read, files:write

A key in a browser bundle is public to every visitor. The libraries are designed so that browsers read published translations from the CDN without a key. Never give a browser a key with more than translations:generate, and prefer proxying runtime translation through your own server. See Next.js and the Node reference.

The current alias

With a key, :projectId in any URL may be the literal current, meaning the key’s own project. That lets tools work from the key alone:

curl https://generic-translation-api.jacobfv123.workers.dev/v1/projects/current/stats \
  -H "authorization: Bearer $GENERIC_TRANSLATION_API_KEY"

current only works with a key. With a session token it returns 400 invalid_request. The public CDN has no current alias: use the real prj_… id there.

Using a key

Set it in the environment, never in source control:

export GENERIC_TRANSLATION_API_KEY=gt-api-…
export GENERIC_TRANSLATION_PROJECT_ID=prj_…

The CLI, @generic-translation/core and @generic-translation/node read GENERIC_TRANSLATION_API_KEY, GENERIC_TRANSLATION_PROJECT_ID and GENERIC_TRANSLATION_API_URL. Over raw HTTP, send Authorization: Bearer gt-api-….

Sessions versus keys

Session token (gt-sess-…) API key (gt-api-…)
Represents A person A project integration
Scope All organizations the person belongs to One project
Limited by The person’s role The key’s permissions
Expires After 30 days or on logout Never; revoke it
Can manage keys, members, webhooks By role No

If a key leaks, delete it from the API keys page and create a new one. The audit log records key.created and key.revoked with who did it.

See API overview for the request format and errors for what a missing permission looks like.

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

Type to search the documentation.