Skip to content

Get started

Markdown

Authentication

Every call needs a TerraLab account, except the two public documents: /v1/openapi.json and /v1/meta/pricing. The TerraLab app in ChatGPT is the other exception today: it needs no TerraLab account. There are three ways to get access: an API key for code, OAuth 2.1 for agents with a browser, and a 6-digit code for agents without one.

API keys

Use a key for scripts, back ends and notebooks, anything that cannot open a browser to sign in.

  1. Sign in at terra-lab.ai/login.
  2. Open Dashboard, MCP, then Advanced, API keys.
  3. Name the key, accept the API terms and click Create key.
  4. Copy it at once. A key starts with tlk_, followed by 48 hexadecimal characters, and is shown only once: TerraLab stores a hash, never the key.

Send it in the Authorization header:

curl https://mcp.terra-lab.ai/v1/me \
  -H "Authorization: Bearer $TERRALAB_API_KEY"

Keys do not expire, and an account holds up to 20 live keys. Revoke one from the same page when it leaks or a project ends: the next call with it answers 401. Calls made with a key count against the account that created it.

Keep keys out of source control, front-end code and screenshots. Read them from an environment variable or a secret manager.

OAuth 2.1 for agents

AI agents sign in instead of using a key. When an agent first calls https://mcp.terra-lab.ai/mcp without a token, the server answers 401 with a WWW-Authenticate header that points to its metadata, and the agent opens the TerraLab sign-in in your browser. You approve once; the agent then holds a token.

WhatValue
Protected resource metadatahttps://mcp.terra-lab.ai/.well-known/oauth-protected-resource
Authorization serverhttps://terra-lab.ai
Server metadatahttps://terra-lab.ai/.well-known/oauth-authorization-server
GrantAuthorization code with PKCE (S256), public clients
Client registrationDynamic registration, or a client ID metadata document
Scopedata
Access token lifetime1 hour, renewed with a refresh token valid 30 days

Most agents handle all of this themselves: you only paste the server URL. See MCP server.

An OAuth access token also works on the REST API, as a Bearer token in the same header.

Agents without a browser

Some agents run where no browser can open: a terminal on a server, a scheduled job, a chat that cannot follow a redirect. They register with your email instead, following the auth.md protocol.

  1. The agent asks for the email of your TerraLab account.
  2. It shows you a link and a 6-digit code. TerraLab never sends this code by email.
  3. Open the link, sign in or sign up with that same email, check what the page says the agent will get, and type the code.
  4. The agent is connected. It appears under Connected apps like any other.

Confirm only a code from an agent you started yourself. If someone sends you a link or a code you did not ask for, press Cancel: confirming would let them use your account.

WhatValue
Registration endpointhttps://terra-lab.ai/agent/identity, type service_auth
Code lifetime10 minutes, 5 tries
Registration lifetime1 hour
Polling granturn:workos:agent-auth:grant-type:claim at https://terra-lab.ai/oauth/token
TokensSame as OAuth: 1 hour access token, 30 day refresh token, scope data

The full request and answer shapes for agent builders are in auth.md.

Let an agent check your account

A connected agent can read a short summary of the account it works for: the included calls left this month, the balance, and whether a top-up is needed. It never sees your email or your payment details.

WhatValue
EndpointGET https://terra-lab.ai/oauth/userinfo with Authorization: Bearer <access token>
Accepted tokensAny OAuth access token issued by TerraLab. An API key is refused.
Without a valid token401 with a WWW-Authenticate header that points to https://terra-lab.ai/.well-known/oauth-protected-resource

Disconnect an agent

Dashboard, MCP lists your Connected apps. Disconnect revokes that app's access: its next call answers 401 with access_revoked.

Updated 2026-11-15