Skip to content

GraphQL API and API keys

The app, the CLI and the MCP server all use one GraphQL API at /api/graphql. The TypeScript SDK is the easiest way to use it. For anything else (a shell script, a home dashboard, another language), you can send raw GraphQL with a personal API key.

Open Settings → API keys in the app. Give the key a name, choose its access and its expiry, and select “Create key”.

  • A read-only key can run queries. The API refuses every mutation.
  • A read-and-write key can run queries and mutations.
  • The expiry is 30 days, 90 days, a year, or never.

The app shows the full key (it starts with gg_) once, right after you create it. gymgym stores only a hash of the key and its first characters, so copy it then. If you lose it, revoke it and create another one.

Send the key as a Bearer token:

Terminal window
curl -X POST https://app.gymgym.club/api/graphql \
-H "authorization: Bearer gg_your_key" \
-H "content-type: application/json" \
-d '{"query":"{ viewer { workouts(limit: 5) { date name } } }"}'

The header x-api-key: gg_your_key works too. On a self-hosted server, use its address. The GraphQL reference lists every query, mutation and type. The schema is in the repository at packages/sdk/schema.graphql, so code generators for other languages can use it.

A mutation with a write key looks like this:

Terminal window
curl -X POST https://app.gymgym.club/api/graphql \
-H "authorization: Bearer gg_your_key" \
-H "content-type: application/json" \
-d '{"query":"mutation($input: BodyweightInput!) { logBodyweight(input: $input) { date weight } }","variables":{"input":{"date":"2026-10-04","weight":72.5}}}'

A key acts as you, on your data only, with the same row rules as the app (see Data isolation). It is narrower than a sign-in on purpose:

  • It works only on /api/graphql. It is not a session for sign-in pages or for the MCP server.
  • It cannot create, list or revoke keys. It cannot manage connected apps or signed-in devices. It cannot use admin tools, even if you are an admin.
  • Each key can make 120 requests a minute. Above that, requests fail with the error code RATE_LIMITED until the minute is over.

A request with a revoked, expired or unknown key is answered as signed out: viewer is null and mutations fail with FORBIDDEN.

Settings → API keys lists each key with its name, its first characters, its access, and when it was created, last used and expires. “Revoke” deletes a key at once, and the next request with that key fails. When you delete your account, gymgym deletes its keys.

Settings → Signed-in devices lists every browser and command line that is signed in to your account. The CLI appears as “gymgym CLI”. “Sign out” ends that session, and the device must sign in again. A browser can keep a cached session for up to five minutes after you sign it out.