Skip to main content
This page is the one reference for SiteGPT credentials. It covers API tokens for API v2, the SDKs, and the CLI. It also covers OAuth device login and the legacy API key. For MCP connections, see MCP server.

Credential types

Send API tokens and the legacy API key in the Authorization header:

API tokens

API tokens authenticate API v2 requests. Treat each token as an opaque secret. Do not check for a fixed token format in your code. API access is available on the Growth plan and above. See Plans and limits. This applies to API tokens, CLI logins, and MCP. On a lower plan, you cannot create or rotate a token. Requests with an existing token fail with 403 PLAN_UPGRADE_REQUIRED. If you downgrade, your tokens stop working until you upgrade again. The SiteGPT iPhone app is not affected.

Create a token

  1. In the top navigation, select Agents.
  2. In Create API token, enter a Token name. Name it after the tool that uses it.
  3. Choose when the token Expires: 30, 90, 180, or 365 days. The default is 90 days.
  4. Choose an Access level. See Access levels.
  5. Under Chatbot access, choose All accessible chatbots or Specific chatbots.
  6. Select Create token.
  7. Copy the token and store it in a safe place. SiteGPT shows it only once. Then select I saved this token.

Access levels

A token never gets more access than you have. SiteGPT gives only the scopes that your dashboard role allows on the chatbots you select. If your role does not allow some permissions, the Agents page tells you.
  • Billing scopes need an account owner.
  • chatbots:write for all chatbots needs an account owner.

Chatbot access

Use Specific chatbots for tools that work on one chatbot.

Manage tokens

The API Tokens list on the Agents page shows each token, its source, its scopes, and its status. The source is Manual token, Device login, or Onboarding token.
  • Rotate creates a new token value with the same settings. The old value stops working.
  • Revoke stops the token at once.
  • Select Show revoked to see revoked tokens. This option shows only when you have revoked tokens.
You can also manage tokens with the API: GET and POST /api/v2/tokens, DELETE /api/v2/tokens/{tokenId}, and POST /api/v2/tokens/{tokenId}/rotate. These need the tokens:read and tokens:write scopes.

Scopes

A scope allows one kind of action on one area. read lets the token view data. write lets it create and change data. delete lets it delete data. Each API v2 operation lists the scopes it needs in the API reference. A request with a token that lacks a needed scope fails with 403 and the code TOKEN_SCOPE_NOT_ALLOWED.

OAuth device login

Device login lets a CLI, script, or local AI agent get an API token after you approve it in the browser. You do not paste a token into the tool. sitegpt login uses this flow. See Install and log in. Use the endpoints below only if you build your own tool. Otherwise use sitegpt login.

How it works

  1. The tool sends a request to POST https://sitegpt.ai/oauth/device_authorization.
  2. SiteGPT returns a device code, a login code, and a link.
  3. You open the link and sign in. The Approve device login page shows the tool name and the access it asks for.
  4. You can narrow the access. Under Grant, choose Everything requested, Read only (shown when the request includes read scopes), or Choose specific. Then choose All chatbots or Specific chatbots.
  5. Under Token lifetime, keep the default As requested, or choose a shorter lifetime. Then select Approve or Deny.
  6. The tool polls POST https://sitegpt.ai/oauth/token until you approve. It then gets an API token.
The token shows on the Agents page with the source Device login. You can rotate or revoke it there. If your plan does not include API access, the approval page shows “API access needs the Growth plan or above.” instead of the Approve and Deny buttons. The request stays pending. You can approve it after you upgrade, if the code has not expired.

Token lifetime

The tool asks for a token lifetime in days. The CLI asks for 90 days by default. A tool can ask for up to 365 days. On the approval page, Token lifetime shows these choices:
  • As requested, with the requested number of days, for example As requested (90d). This is the default.
  • 90 days, 30 days, and 7 days. Only the choices that are shorter than the request show.
You can only make the lifetime shorter. You cannot make it longer than the tool asked for. For a default CLI login, you see As requested (90d), 30 days, and 7 days.

Start the request

Send a form-encoded request:
Response:
Open verification_uri_complete in a browser. The device code expires after 15 minutes.

Poll for the token

Wait at least interval seconds (2 seconds) between polls. After approval, the response has the token:
Use access_token as a bearer token for API v2.

Device login errors

Errors come back as { "error": "...", "error_description": "..." }.

Discovery

Tools can find the device login endpoints in the OAuth metadata:
The metadata also describes agent sign-up without an account. See Agent-first onboarding.

Legacy API key

The legacy API key works with the legacy API v0 and v1 and with widget identity verification. It does not work with API v2, except for GET /api/v2/me, which returns a warning. For new work, use an API token.
  • Plan: Growth plan and above. See Plans and limits.
  • Where to find it: Open the Billing page. The key shows in the line “Your API Key is …”. It shows only when your plan includes API access.
  • Creation: SiteGPT creates the key for you when your plan includes API access. The key does not change on its own. You cannot create or rotate it yourself.
  • Access: The key acts as your user in the legacy API. It has no scopes, and you cannot limit it to some chatbots.
If your plan includes API access but you do not see a key, contact support.

Security

  • Store tokens and keys in environment variables or a secret manager. Do not put them in source code, chat prompts, or logs.
  • Give each tool its own token, with the smallest access that works.
  • Use Specific chatbots for tools that work on one chatbot.
  • Revoke tokens after a demo or when someone leaves your team.
  • Never use the legacy API key in browser code.

Errors

A 401 response from API v2 includes a WWW-Authenticate header that points to the OAuth metadata. For all API v2 error codes, see API conventions.