# Authentication

> Where Atracode API keys come from, how the CLI, SDKs and MCP server use them, and how to keep them secret and rotate them.

> Preview: the commands, tools and API shapes on this page may change before launch.

Source: https://atracode.com/docs/authentication

The compiler runs only on Atracode's infrastructure, and every request to it is authenticated. The CLI, the SDKs and the MCP server all authenticate with an API key from your workspace.

## Get an API key

API keys belong to your workspace. There is no separate sign-up form: your account and workspace are created when you pick a plan on the [pricing page](/pricing) or sign in. You can sign in with Google, GitHub, an email link or SAML SSO.

Once you have picked a plan, including the free Community plan, you copy your API key from your workspace. Because the compiler is not live yet, keys that call it are issued at platform launch.

## Key format

Every key starts with `atc_live_`:

```text
atc_live_xxxxxxxxxxxx
```

The prefix makes keys easy to spot in config files, logs and secret scanners. If you find a string starting with `atc_live_` somewhere it should not be, treat the key as exposed and rotate it.

## Use the key

### Environment variable

The CLI, every SDK and the MCP server read the key from `ATRACODE_API_KEY`:

```shell
export ATRACODE_API_KEY=atc_live_xxxxxxxxxxxx
```

This is the right choice for CI, servers and MCP clients. The MCP server takes it in the `env` block of your client's config; see [MCP server](/docs/mcp-server).

### atracode login

On your own machine, you can sign in through the browser instead:

```shell
atracode login
```

This opens your browser, you sign in to your workspace, and the CLI is authenticated. You do not need to copy a key by hand.

### Bearer header

Under the hood, the key travels in the `Authorization` header of each request:

```text
Authorization: Bearer atc_live_xxxxxxxxxxxx
```

The CLI, SDKs and MCP server set this header for you. If you write your own client, send the same header.

A missing, malformed or revoked key gets an authentication error (HTTP 401). See [Errors](/docs/errors).

## Keep keys secret

An API key can spend your workspace's compilations and, on paid plans, run up over-quota charges. Treat it like a password:

- Keep keys out of source control. Read them from the environment or from your CI system's secret store.
- Do not paste keys into prompts, issues or chat. Give an agent the key through its MCP config, not in conversation.
- Do not ship keys in client-side code such as a web page or mobile app. Call the compiler from a server you control.
- Use a separate key for each machine, CI system or agent setup, so you can rotate one without breaking the others.

> **Warning:** If a key is exposed, rotate it right away. Anyone holding it can compile against your workspace's quota.

## Rotate a key

Rotating replaces a key with a new one and stops the old one working. To rotate:

1. Create a new key in your workspace.
2. Update `ATRACODE_API_KEY` everywhere the old key is used: shells, CI secrets and MCP client configs.
3. Restart MCP clients so the server picks up the new key.
4. Revoke the old key.

Rotate keys on a schedule, when someone leaves your team, and any time you suspect a key has leaked.

## Account security

Your API keys are only as safe as the account that issues them. Turn on authenticator-app [two-factor authentication](/docs/two-factor) on the Account page: scan the QR code with your authenticator app and enter the 6-digit code.

## Next steps

- [CLI](/docs/cli): install and sign in
- [SDKs](/docs/sdks): use the key from code
- [Two-factor authentication](/docs/two-factor): protect the account behind your keys
- [Errors](/docs/errors): what an authentication failure looks like
