Expand AI logo
DocsDocs
Glow Active
API Reference
Login

Documentation

Get started

IntroductionWhy ExpandQuickstartAuthenticationConnect your agent (MCP)

Products

OverviewFetching a URLBatched Fetch
API reference

SDKs & tools

TypeScript SDK
MCP tools & resourcesDocs for agents

Reference

API referenceErrors & retriesPricing & UsageLimitsConcurrency tiersFAQ
Browse docs

Get started

IntroductionWhy ExpandQuickstartAuthenticationConnect your agent (MCP)

Products

OverviewFetching a URLBatched Fetch
API reference

SDKs & tools

TypeScript SDK
MCP tools & resourcesDocs for agents

Reference

API referenceErrors & retriesPricing & UsageLimitsConcurrency tiersFAQ

Authentication & API keys

Sign in for the CLI and local tools, use an API key everywhere else, and send it the right way for each surface.

There are two ways to prove who you are to Expand.

UseWhen
Sign in with expandai loginYour own machine. The CLI and a local MCP server reuse the session, and there is no key to manage.
An API keyCI, servers, scripts, the TypeScript SDK, direct API calls, and MCP clients that cannot sign in.
Recommendation
Keep API keys on servers and in CI. On your own machine, sign in instead, so no key sits in a config file.

Sign in

Sign in once and the CLI keeps the session on your machine:

expandai login
expandai whoami

expandai login offers two choices: open the browser and approve, or paste an API key. expandai whoami shows your account, organization, and how you are authenticated. expandai logout clears the stored credentials.

A local MCP server started with expandai mcp run uses the same stored credentials as the CLI, so no API key goes into your agent's config. The hosted MCP server signs you in through the browser instead. See Connect your agent (MCP).

Create an API key

Create a key in the dashboard. Keys start with xpnd_.

Warning
The raw key is shown once, when you create it. Store it straight away.

Use the key

The CLI, the TypeScript SDK, and direct API calls all read EXPAND_API_KEY:

export EXPAND_API_KEY="xpnd_..."

How the key travels depends on where you call Expand:

SurfaceHow the key is sent
HTTP APIThe x-expand-api-key header.
TypeScript SDKnew ExpandClient() reads EXPAND_API_KEY and sends it as x-expand-api-key. Pass apiKey only when the key comes from somewhere else.
CLIEXPAND_API_KEY is used when there is no stored sign-in.
import { ExpandClient } from '@expandai/sdk'

const expand = new ExpandClient()

const markdown = await expand.fetch({ url: 'https://news.ycombinator.com' })
# The key is used when there is no stored sign-in.
expandai fetch https://news.ycombinator.com
curl https://api.expand.ai/v1/fetch \
  -H "x-expand-api-key: $EXPAND_API_KEY" \

Note
In the CLI, a stored sign-in from expandai login takes precedence over EXPAND_API_KEY. To use the key on a machine where you have signed in, run expandai logout first.

For an MCP client with no browser sign-in, send the key as a bearer token:

{
  "mcpServers": {
    "expand": {
      "url": "https://api.expand.ai/v1/mcp",
      "headers": {
        "Authorization": "Bearer xpnd_your_api_key"
      }
    }
  }
}
Warning
A config file that holds an API key is a secret. Treat it like one.

Environment and config

EXPAND_API_KEY is the only setting most setups need. The CLI's other environment variables and its config file location are on CLI: Commands, Environment and config.

Next steps

  • Quickstart: run your first Fetch.
  • Connect your agent (MCP): set up Expand in a coding agent.
  • TypeScript SDK: client options, including timeouts and retries.
  • Limits: what one key can do at a time.
PreviousQuickstart
NextConnect your agent (MCP)

On This Page

Sign inCreate an API keyUse the keyEnvironment and configNext steps
Hosted MCP serverAuthorization: Bearer xpnd_... in the client config.
-H "Content-Type: application/json" \
-d '{"url":"https://news.ycombinator.com"}'