Authentication - Claude Code Docs
Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. Claude Code supports multiple authentication methods depending on your setup. Individual users can log in with a claude.ai account, while teams can use Claude for Teams or Enterprise, the Claude Console, or a cloud provider like Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry.
Log in to Claude Code After installing Claude Code , run claude in your terminal. Claude Code opens a browser window for you to log in on first launch, except in cases such as these, where it can skip the login prompt: API key : you’ve set the ANTHROPIC_API_KEY environment variable and you approve the key when Claude Code asks whether to use it Earlier sign-in : you ran claude auth login in your shell before your first session, or you rebuilt a dev container that keeps your credentials in a volume .
If you see the login prompt anyway, check what can cause it . If the browser doesn’t open automatically, press c to copy the login URL to your clipboard, then paste it into your browser. If your browser shows a login code instead of redirecting back after you sign in, paste it into the terminal at the Paste code here if prompted prompt. When login completes, the terminal shows Login successful and prompts you to press Enter to continue.
You can authenticate with any of these account types: Claude Pro, Max, or Ultra subscription : log in with your claude.ai account. Subscribe at claude.com/pricing . Claude for Teams or Enterprise : log in with the claude.ai account your team admin invited you to. Claude Console : log in with your Console credentials. Your admin must have invited you first. You can sign in with or without creating an API key . Cloud providers : if your organization uses Amazon Bedrock , Google Cloud’s Agent Platform , or Microsoft Foundry , set the required environment variables before running claude , or select 3rd-party platform at the login prompt, which launches an interactive setup wizard for Bedrock and Vertex AI.
No browser login is needed. Cloud gateway : if your organization runs a self-hosted Claude apps gateway , sign in with corporate SSO through /login or from VS Code . The gateway-issued token is the session’s only credential. Admins can direct which login method developers use and require claude.ai logins to belong to a specific organization; see Restrict login to your organization . To log out and re-authenticate, type /logout at the Claude Code prompt.
Logging out also resets your first-launch setup state, so the next time you run claude it walks you through login and setup again. If you’re having trouble logging in, see authentication troubleshooting . Login prompt still appears after an earlier sign-in If you signed in earlier and first-launch setup shows the login prompt instead of skipping it , check for causes such as these: Expired sign-in : your earlier sign-in expired and Claude Code can’t refresh it.
Log in again at the prompt. Login restricted to an organization : an administrator set forceLoginOrgUUID in managed settings to require logins from specific organizations . The prompt appears whether or not your account belongs to one of them. Log in with an account in a required organization. If you don’t have one, ask your administrator to add you. Required login method : your sign-in isn’t the kind that forceLoginMethod in a settings file requires.
With "claudeai" , an API key from an earlier Claude Console login doesn’t count as an existing sign-in. With "console" , a claude.ai account doesn’t. Log in with the kind of account that setting names. Older version : before v2.1.290, the prompt appeared during setup whether or not you were signed in. Update Claude Code to skip it. Log in with multiple accounts To stay signed in to multiple accounts at once, such as work and personal accounts, give each account its own configuration directory.
When you start claude , set the CLAUDE_CONFIG_DIR environment variable to the directory for the account you want to use. Each directory has its own settings, session history, and claude.ai login or API key. For example, in Bash or Zsh, add this alias to ~/.bashrc or ~/.zshrc so that claude-work uses your work account while claude keeps your personal one: alias claude-work = 'CLAUDE_CONFIG_DIR=~/.claude-work claude' After you open a new terminal and run claude-work for the first time, Claude Code walks you through login and setup for the new directory.
Separate directories don’t keep two Claude Console sign-ins without an API key apart, because Claude Code stores that kind of sign-in outside the configuration directory. Set up team authentication For teams and organizations, you can configure Claude Code access in one of these ways: Claude for Teams or Enterprise , recommended for most teams Claude Console Claude apps gateway , a self-hosted gateway that signs developers in with your IdP and routes inference to the cloud provider you configure Amazon Bedrock Google Cloud’s Agent Platform Microsoft Foundry Claude for Teams or Enterprise Claude for Teams and Claude for Enterprise provide the best experience for organizations using Claude Code.
Team members get access to both Claude Code and Claude on the web with centralized billing and team management. Claude for Teams : self-service plan with collaboration features, admin tools, SSO, billing management, and server-managed settings for organization-wide Claude Code configuration. Best for smaller teams. Claude for Enterprise : adds domain capture, role-based permissions, and the compliance API. Best for larger organizations with security and compliance requirements.
1 Subscribe Subscribe to Claude for Teams or contact sales for Claude for Enterprise . 2 Invite team members Invite team members from the admin dashboard. 3 Install and log in Team members install Claude Code and log in with their claude.ai accounts. Claude Console authentication For organizations that prefer API-based billing, you can set up access through the Claude Console. 1 Create or use a Console account Use your existing Claude Console account or create a new one.
2 Add users You can add users through either method: Bulk invite users from the Console’s Members page at platform.claude.com/settings/members : click Invite to organization Set up SSO 3 Assign roles When inviting users, assign one of: Claude Code role: users can only create Claude Code API keys Developer role: users can create any kind of API key 4 Users complete setup Each invited user needs to: Accept the Console invite Check system requirements Install Claude Code Log in with Console account credentials Sign in without an API key You can sign in to your Console account without creating an API key, even when your organization doesn’t let developers create them.
Choose the Anthropic Console account at the /login prompt and Claude Code asks how you want to sign in. Requires Claude Code v2.1.242 or later. Both routes sign you in to Console in the browser and differ in what Claude Code stores afterwards: Sign in with your Console account , labeled (recommended) : Claude Code keeps the OAuth token from that sign-in and stores it as an Anthropic profile . It creates no API key Create an API key , labeled (legacy) : Claude Code creates a Console API key for you and stores it with your other credentials In practice, the profile stores an OAuth login while an API key is a static credential.
Claude Code refreshes the profile’s login automatically, and when refresh fails, requests fail with an expired profile login error until you sign in again. You don’t get the choice on every machine. Claude Code creates an API key without asking in these cases: You run against a cloud provider, such as Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft
The rest of this page is on the live site.