DocsREST API

Organizations

Organizations, members and roles, usage totals and the audit log.

On this page

An organization owns projects, members and webhooks. Every user gets a personal organization at sign-up and can create or be added to others. All routes on this page need a session token.

Roles

Role Can
viewer Read everything in the organization: projects, strings, usage, the audit log, webhooks and deliveries.
member Everything a viewer can, plus translate, edit, approve, upload files, edit instructions and the glossary, and publish.
admin Everything a member can, plus create and delete projects, change project settings, manage API keys, members, webhooks and organization settings.
owner Everything an admin can, plus delete the organization and add, change or remove owners.

A request that the caller’s role does not allow gets 403 permission_missing.

List and create organizations

GET /v1/orgs returns the organizations you belong to, each with your role.

POST /v1/orgs creates one; you become its owner.

curl -X POST https://generic-translation-api.jacobfv123.workers.dev/v1/orgs \
  -H "authorization: Bearer $GENERIC_TRANSLATION_SESSION" \
  -H "content-type: application/json" \
  -d '{ "name": "Analytical Engines" }'
{ "id": "org_77bqm…", "name": "Analytical Engines", "role": "owner", "createdAt": "2026-11-30T10:00:00.000Z", "updatedAt": "2026-11-30T10:00:00.000Z" }

Creating returns 201. A user who is not a member of an organization gets 404 not_found for it, so organization ids do not leak.

Get, rename or delete an organization

Route Role Notes
GET /v1/orgs/:orgId viewer
PATCH /v1/orgs/:orgId admin Body: { "name": "…" }.
DELETE /v1/orgs/:orgId owner Deletes the organization, its members, webhooks, audit log and usage history. It must have no projects: delete them first, otherwise 409 conflict. This cannot be undone.

Both PATCH and GET return the organization with your role; DELETE returns { "ok": true }.

Members

List members

GET /v1/orgs/:orgId/members

[
  { "userId": "usr_8f3k2…", "email": "ada@example.com", "name": "Ada", "role": "owner", "createdAt": "2026-11-30T10:00:00.000Z" },
  { "userId": "usr_2mm9a…", "email": "grace@example.com", "name": "Grace", "role": "member", "createdAt": "2026-11-30T11:00:00.000Z" }
]

Add a member

POST /v1/orgs/:orgId/members (admin)

{ "email": "grace@example.com", "role": "member" }

role is one of viewer, member, admin, owner and defaults to member. Only an owner can add an owner. The response (status 201) is the member record. The person must already have a Generic Translation account with that email. There are no email invitations during the preview: ask them to sign up first, then add them. An unknown email returns 404 not_found; someone who is already a member returns 409 conflict.

Change a role or remove a member

Route Body
PATCH /v1/orgs/:orgId/members/:userId { "role": "admin" }
DELETE /v1/orgs/:orgId/members/:userId none

Both need the admin role, with two exceptions: any member may remove themselves, and only an owner may change or remove an owner (otherwise 403 permission_missing). An organization must always keep at least one owner; a request that would demote or remove the last one is refused with 409 conflict. An unknown userId returns 404 not_found. PATCH returns the member record; DELETE returns { "ok": true }.

Usage

GET /v1/orgs/:orgId/usage?from=2026-11-01&to=2026-11-30

from and to are dates (YYYY-MM-DD, inclusive, UTC). to defaults to today and from to 29 days before to. A from after to returns 400 invalid_request. Viewer role.

{
  "from": "2026-11-01",
  "to": "2026-11-30",
  "totals": {
    "sourceTokens": 184220,
    "translatedStrings": 4310,
    "cachedStrings": 12877,
    "cdnRequests": 90412,
    "runtimeRequests": 356
  },
  "daily": [
    { "date": "2026-11-29", "sourceTokens": 9120, "translatedStrings": 212, "cachedStrings": 640, "cdnRequests": 3011, "runtimeRequests": 14 },
    { "date": "2026-11-30", "sourceTokens": 2204, "translatedStrings": 51, "cachedStrings": 702, "cdnRequests": 2876, "runtimeRequests": 9 }
  ],
  "byProject": [
    { "projectId": "prj_abc123", "name": "Web app", "sourceTokens": 150113, "translatedStrings": 3502, "cachedStrings": 11020, "cdnRequests": 88001, "runtimeRequests": 356 }
  ]
}
Counter Counts
sourceTokens An estimate of the source text sent to the model (characters divided by four, rounded up).
translatedStrings String × locale pairs the model translated successfully.
cachedStrings Pairs answered from an existing translation without calling the model (runtime requests and batch entries).
cdnRequests Successful requests to /cdn/… for the organization’s projects. Counted in buffered batches, so the figure can lag by seconds.
runtimeRequests Calls to POST /translate (calls where source and target are the same language count too).

See usage for how to read these.

Audit log

GET /v1/orgs/:orgId/audit?cursor=…&limit=50 (viewer)

A reverse-chronological record of changes in the organization.

{
  "items": [
    {
      "id": "128",
      "actor": { "type": "user", "id": "usr_8f3k2…", "name": "Ada" },
      "action": "project.published",
      "target": "prj_abc123",
      "metadata": { "locales": ["es", "fr"], "version": "v1x9k2" },
      "createdAt": "2026-11-30T10:15:00.000Z"
    }
  ],
  "nextCursor": "97"
}

id is a numeric string. actor is { type: "user" | "key" | "system", id, name, email? }: the user or API key that made the change. action names what happened, target is the id of what it happened to (a string), and metadata holds action-specific detail. Pass nextCursor as cursor for the next page; it is null on the last page.

Actions recorded include org.created, org.updated, member.added, member.role_changed, member.removed, project.created, project.updated, project.deleted, project.published, key.created, key.revoked, context.updated, glossary.created, glossary.updated, glossary.deleted, glossary.applied, translation.updated, translation.approved, translation.retranslated, string.deleted, file.uploaded, file.deleted, webhook.created, webhook.updated, webhook.deleted and webhook.tested.

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

Type to search the documentation.