Groundfloor Docs

M2M API

M2M clients, and exchanging their credentials for a short-lived token for Coderunners, CI and servers.

Machine sign-in for Coderunners, CI and servers. Create a client (its secret is shown once), then exchange client_id and client_secret for a short-lived token.

See also: M2M tokens · Developers

POST …/m2m/token is unauthenticated. All other M2M routes need a team token. Do not put the secret in a browser bundle.

An M2M client acts as a Writer in its workspace: Data Vault (collection grants don't apply) and Files. It cannot administer members, App authentication, Vault ACL, LLM virtual keys, or reserved secrets (DATAPLANE_SERVICE_API_KEY), and it can't write apps, app sign-in settings, Shell releases, managed databases, memberships or the default app (403, X-Groundfloor-Reason: m2m_not_allowed). It cannot read Secrets unless the client holds the secrets:read scope, and it can never write, delete, or promote Secrets. It cannot manage Coderunners unless it holds coderunners:deploy, and it can never mint a Coderunner developer token. M2M is not an Access subject.

Exchange secret for a JWT

POST /v1/workspaces/{workspace_id}/m2m/token

Auth: none. Two independent rate limits, either of which returns 429: per workspace_id + client_id (default 20/minute) and per source IP (default 20/minute).

Request body

FieldTypeRequired
client_idstringYes (1–63)
client_secretstringYes (min 16)
export WORKSPACE_ID="<workspace uuid>"

curl -sS -X POST "https://platform.groundfloor.cloud/v1/workspaces/$WORKSPACE_ID/m2m/token" \
  -H "Content-Type: application/json" \
  -d "{\"client_id\":\"$GROUNDFLOOR_M2M_CLIENT_ID\",\"client_secret\":\"$GROUNDFLOOR_M2M_CLIENT_SECRET\"}"

gf m2m token is the same exchange.

Response 200

{
  "access_token": "<jwt>",
  "token_type": "Bearer",
  "expires_in": 300,
  "m2m_client_id": "<uuid>",
  "workspace_id": "<workspace uuid>",
  "controlplane_url": "https://platform.groundfloor.cloud"
}

expires_in is in seconds (300 by default). Use access_token as the bearer token:

curl -sS -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://platform.groundfloor.cloud/v1/workspaces/$WORKSPACE_ID/vault/collections"

Cache access_token for expires_in seconds — never mint per request. This endpoint is rate-limited per client (and per IP), default 20/minute each; calling it once per incoming request instead of reusing the JWT will exceed that limit under normal traffic and return 429 instead of a token. Store the token and its expiry, refresh proactively (e.g. at ~80% of expires_in, not on every call), and handle 429/401 from the mint call as retryable — a naive integration that lets this exception propagate unhandled can crash the whole process on every request once the limit is hit.

JWT claims include typ=m2m, aud=groundfloor-portal, sub=m2m:{client uuid}, workspace_id, m2m_client_id, client_id, and scopes (array, empty unless granted). Issuer is {controlplane}/v1/public/m2m.

Errors

StatusMeaning
401Unknown client_id, wrong secret, or client disabled
422Validation (secret too short, missing fields)
429Rate limit — usually means the caller is minting a token per request instead of caching it; see the caching note above

Invalid credentials always return the same 401 detail (Invalid client credentials).

List clients

GET /v1/workspaces/{workspace_id}/m2m/clients

Permission: read

Returns metadata only — no secrets.

{
  "clients": [
    {
      "id": "<uuid>",
      "workspace_id": "<workspace uuid>",
      "name": "catalog-bff",
      "client_id": "catalog-bff",
      "disabled": false,
      "scopes": [],
      "created_by": "<user uuid>",
      "created_at": "2026-09-11T12:00:00Z",
      "updated_at": "2026-09-11T12:00:00Z"
    }
  ]
}

Create a client

POST /v1/workspaces/{workspace_id}/m2m/clients

Permission: administer · 201

{ "name": "catalog-bff", "client_id": "catalog-bff" }
FieldTypeRequired
namestringYes (1–120)
client_idstringNo — slug from the name if omitted (^[a-z0-9][a-z0-9-]*$, max 63)
scopesstring[]No — default []. See Scopes

Response is the client plus client_secret (shown once). Store it as GROUNDFLOOR_M2M_CLIENT_ID / GROUNDFLOOR_M2M_CLIENT_SECRET.

Get / update a client

GET /v1/workspaces/{workspace_id}/m2m/clients/{client_uuid}
PATCH /v1/workspaces/{workspace_id}/m2m/clients/{client_uuid}

Permission: read / administer

PATCH body (partial): name, disabled, scopes (replaces the list; [] removes all), confirm_code_provenance. Disabling a client makes POST …/m2m/token return 401.

Adding a scope to a client that's attached to Coderunners is refused with 409 and X-Groundfloor-Reason: m2m_code_provenance_confirm_required when a Coderunner's deployed or latest version, or its Git source, came from an M2M client with narrower scopes (or has no supplier record). The detail names what's affected. Send the request again with confirm_code_provenance: true to go ahead; see Code provenance. Removing a scope never asks.

Scopes

Scopes add permissions within the client's Team Writer grant; they never go beyond it. Valid values are secrets:read and coderunners:deploy. Unknown scopes are rejected with 422. Only a workspace administrator can grant them. In the Client Portal they are the Can read secrets and Can deploy services switches on Access → Machine clients.

ScopeGrants
secrets:readSecrets list, compare, and reveal (plaintext value) — every environment in the workspace.
coderunners:deployCreate, change, upload code to, deploy, stop, promote and delete Coderunners in the workspace, including app-level Coderunners and Git sources. For CI pipelines only: never give it to a client attached to a Coderunner
(none)No Secrets access: list, compare, and reveal return 403. Coderunner management returns 403 with X-Groundfloor-Reason: m2m_scope_required

Even with coderunners:deploy, a client can't change the code of a Coderunner that is bound to a workload identity, or whose attached M2M client holds a scope the caller lacks, unless the caller is that attached client: 403, X-Groundfloor-Reason: m2m_scope_escalation. coderunners:deploy is checked on every request, so removing it takes effect on the client's next call.

Secrets upsert, delete, and promote are 403 for every M2M client, with or without the scope. The reserved DATAPLANE_SERVICE_API_KEY stays blocked.

A secrets:read change applies on the client's next minted token (tokens live expires_in seconds). Reveals by an M2M client are audited as secret.revealed with the M2M client id as actor.

Rotate secret

POST /v1/workspaces/{workspace_id}/m2m/clients/{client_uuid}/rotate

Permission: administer

Returns a new client_secret (shown once). Redeploy attached Coderunners so they pick up the injected secret.

Delete a client

DELETE /v1/workspaces/{workspace_id}/m2m/clients/{client_uuid}

Permission: administer · 204

Attach to a Coderunner

PUT /v1/workspaces/{workspace_id}/coderunners/{coderunner_id}/m2m

Permission: administer

{ "m2m_client_id": "<client uuid>" }

Set m2m_client_id to null to detach. Optional confirm_code_provenance: true: required when attaching would give the Coderunner's existing code wider credentials than whoever supplied it (otherwise 409, X-Groundfloor-Reason: m2m_code_provenance_confirm_required). See Code provenance.

At the next deploy, the workload receives the client's credentials as two secrets filled by the platform, GROUNDFLOOR_M2M_CLIENT_ID and GROUNDFLOOR_M2M_CLIENT_SECRET, and CONTROLPLANE_URL as a plain environment variable. You never set these yourself, and GROUNDFLOOR_* names can't be used as your own variables. Both secrets reach the container without appearing in the deployment's configuration. With the client's token, the workload reads your other secrets at runtime; see Secret references (removed). The Coderunner's secrets and platform_environment fields list them by name with an empty value; see Secrets and platform variables.

The workload exchanges them at POST {CONTROLPLANE_URL}/v1/workspaces/{workspace_id}/m2m/token, then calls the Data Vault and Files APIs with the token. Do not inject DATAPLANE_SERVICE_API_KEY.