GraphQL APIAuthentication

Authentication

The PlentyLabs API is authenticated with workspace API keys. A key belongs to one workspace and never has more access than the person who created it.

API keys

Only a workspace owner can create a key.

  1. In PlentyLabs, open Settings, then Developers, then API keys.
  2. Name the key.
  3. Optionally, choose an expiry: 30 days, 90 days or 1 year.
  4. Copy the key. It starts with plenty_sk_ and is shown once.

Never commit the key or send it to a browser.

Sending the key

Pass the key in the Authorization header as a bearer token on every request:

export PLENTY_API_KEY=plenty_sk_...

curl https://api.plentylabs.com/graphql \
  -H "Authorization: Bearer $PLENTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "query GetWorkspace { workspace { id name } }" }'

Workspace scope

A key works only in its own workspace. Any other workspace id is refused, even one the key's creator belongs to. Get the workspaceId every list query needs from workspace, called without an id.

Access

A key acts as its creator, with the creator's current role. It follows changes to that role and stops working when the creator leaves the workspace.

A key can use only what the published schema holds. Anything else returns FORBIDDEN. Account and key management are not available to keys.

Expiry and revocation

Revoke a key in Settings, Developers, API keys. Revocation takes effect on the next request. The key's usage history is kept, and the same page shows each key's credit usage.