Follow Discord
Sweep 03 Dec 2026 · 19:13Z Build v2.1.336 553 read Stable v2.1.332 Latest v2.1.336 Next v2.1.336 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

On a remote host without a browser: changedcli-sdks-libraries/cli/authentication

Nearest release: v2.1.333, published 4 hours after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+63added
Lines−33removed
From line 1 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits14to this page, all time

## Interactive sign-in ## Interactive login

The whole hunk

from line 1, old and new numbered
/
lines
from line 1
11---
22title: CLI authentication options
33url: https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication
4description: Authenticate the ant CLI with interactive login, API keys, named profiles, and Workload Identity Federation.
4description: Authenticate the ant CLI with interactive sign-in, API keys, named profiles, and Workload Identity Federation.
55---
66 
7The `ant` CLI supports several credential sources. The [CLI quickstart](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart#authentication) covers the one-command login (`ant auth login`). This page covers every option in full.
7The `ant` CLI supports several credential sources. The [CLI quickstart](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart#authentication) covers the one-command sign-in (`ant auth login`). This page covers every option in full.
88 
9## Interactive login
9## Interactive sign-in
1010 
1111`ant auth login` lets you call the API without creating or managing an API key. It opens a browser-based OAuth flow against the Claude Console and stores the resulting credentials under `$ANTHROPIC_CONFIG_DIR` (see [Configuration directory](https://platform.claude.com/docs/en/manage-claude/wif-reference#configuration-directory) for the OS-specific default). On a remote host or in any environment without a local browser, pass `--no-browser` to print the authorize URL and paste the returned code back into the terminal.
1212 
from line 16
1616# On a remote host without a browser:
1717ant auth login --no-browser
1818 
19# Bind to a specific workspace and skip the browser picker:
19# Select a specific workspace and skip the browser picker:
2020ant auth login --workspace-id wrkspc_01...
2121 
2222# If the profile that you name with --profile doesn't exist,
23# the login creates it.
23# the sign-in creates it.
2424ant auth login --profile work
2525```
2626 
27The CLI stores each login under a profile. The first time you log in under a profile, you select a [workspace](https://platform.claude.com/docs/en/manage-claude/workspaces) in the browser. If you belong to more than one Claude Console organization, you select the organization first. The issued token is [scoped to that workspace](https://platform.claude.com/docs/en/manage-claude/workspaces#api-keys-and-resource-scoping), so the CLI can only see resources that belong to it. Pass `--workspace-id` to bind directly to a workspace and skip the workspace picker.
27The CLI stores each sign-in under a profile. The first time you sign in under a profile, you select a [workspace](https://platform.claude.com/docs/en/manage-claude/workspaces) in the browser. If you belong to more than one Claude Console organization, you select the organization first. The issued token is [scoped to that workspace](https://platform.claude.com/docs/en/manage-claude/workspaces#api-keys-and-resource-scoping), so the CLI can only see resources that belong to it. Pass `--workspace-id` to select a workspace directly and skip the workspace picker.
2828 
29The profile keeps that organization and workspace for its later logins. To work in another organization or workspace, log in under a new profile (see [Switch between workspaces](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication#switch-between-workspaces)).
29The profile keeps that organization and workspace for its later sign-ins. To work in another organization or workspace, sign in under a new profile (see [Switch between workspaces](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication#switch-between-workspaces)). You can also change the profile’s organization or workspace and sign in again (see [Manage profiles](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication#manage-profiles)).
3030 
31Interactive login is intended for local development and scripting on your own machine. For non-interactive workloads such as CI, servers, and containers, use [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) instead.
31Interactive sign-in is intended for local development and scripting on your own machine. For non-interactive workloads such as CI, servers, and containers, use [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) instead.
3232 
33Login writes credentials to `credentials/<profile>.json`. The first login for a profile also creates `configs/<profile>.json`.
33Signing in writes credentials to `credentials/<profile>.json`. The first sign-in for a profile also creates `configs/<profile>.json`.
3434 
35A login that names a profile, with `--profile` or `ANTHROPIC_PROFILE`, makes that profile the [active profile](https://platform.claude.com/docs/en/manage-claude/wif-reference#active-profile). Any command that doesn’t name a profile, a login included, uses the active profile. Until you make another profile active, that’s `default`.
35A sign-in that names a profile, with `--profile` or `ANTHROPIC_PROFILE`, makes that profile the [active profile](https://platform.claude.com/docs/en/manage-claude/wif-reference#active-profile). Any command that doesn’t name a profile, a sign-in included, uses the active profile. Until you make another profile active, that’s `default`.
3636 
3737To remove the active profile’s stored credentials, run `ant auth logout`. The profile keeps its organization and workspace. To clear every profile, those settings included, run `ant auth logout --all`.
3838 
3939## Admin access
4040 
41By default, `ant auth login` requests a workspace-scoped token. To manage the resources documented on the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) page, request the `org:admin` scope under a dedicated profile. The login makes that profile active, so the example ends by switching back to your day-to-day profile:
41To manage your organization, such as with the organization commands for the [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api), you need the latest version of `ant`. To install `ant`, see [Installation](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart#installation) in the CLI quickstart. To sign in with the `org:admin` scope, you need the admin role (see the Admin API page’s [Organization roles and permissions](https://platform.claude.com/docs/en/manage-claude/admin-api#organization-roles-and-permissions) section).
4242 
43Unlike a usual sign-in, which works in one workspace, an admin sign-in can make changes across your organization.
44 
45The following commands change environment variables, so run them in a shell that you keep for administration. They list your profiles, unset `ANTHROPIC_API_KEY`, sign in under a separate profile with the `org:admin` scope, and export the token. The `--admin` flag in the `ant auth login` command adds the `org:admin` scope to the scopes that a sign-in already requests.
46 
47The sign-in also makes the `admin` profile the CLI’s active profile. Your other shells use it too. Until you switch back, clients in those shells that use the active profile, such as the `ant` CLI, can run as an admin.
48 
4349```bash CLI
44ant auth login --profile admin --scope "org:admin"
50# List your profiles. An asterisk marks the active one.
51# Note it, so that you can switch back later:
52ant profile list
4553 
46# Print a bearer token for Authorization headers:
47ant auth print-credentials --profile admin --access-token
54# Unset the API key variable.
55# While that variable is set, the SDK and the CLI use the key and not the token:
56unset ANTHROPIC_API_KEY
4857 
49# Switch back to your day-to-day profile, the one that was active
50# before the login, such as default:
51ant profile activate default
58ant auth login --profile admin --admin
59export ANTHROPIC_AUTH_TOKEN=$(ant auth print-credentials \
60 --profile admin --access-token)
5261```
5362 
54Anthropic grants the `org:admin` scope only to users and service accounts with the admin role. The issued token has organization-wide access, and any workspace binding on the profile does not constrain it. Keep the admin profile separate from your day-to-day profile so routine commands never run with elevated access.
63In this shell, the SDK and the `ant` CLI send the exported token on every call, whichever profile is active.
5564 
65For organization webhooks, sign in another way, as the [Sign in for organization webhooks](https://platform.claude.com/docs/en/manage-claude/admin-api-keys#sign-in-for-organization-webhooks) section describes.
66 
67In this shell, run organization commands. For example, `ant organization:users list` lists your organization’s members.
68 
69The token in `ANTHROPIC_AUTH_TOKEN` is short-lived, and nothing renews it there. When requests start to return 401, follow these steps:
70 
711. Rerun the `export` command, which gets a new token if the old one has expired.
722. If requests still return 401, sign in again with the same `ant auth login` command that you used, and rerun the `export` command.
73 
74When you finish your admin work, undo what the sign-in commands changed. What to run for the active profile depends on whether you have a profile other than the one you signed in under:
75 
76* **You have another profile:** Switch back to the profile that was active before you signed in. If it was `default`, run `ant profile activate default`.
77* **You have no other profile:** `ant auth logout --all` revokes the tokens on the server and removes every profile and credential. Run it so that the profile you signed in under doesn’t stay the active one.
78 
79If you switched back, the profile you signed in under keeps its credential on disk. If you won’t need that credential for your next admin session, run `ant auth logout --profile` with the profile’s name, such as `admin`. That revokes its tokens on the server and deletes the credential.
80 
81The `unset` and `export` commands changed environment variables only in the shell where you ran them. To undo them, do one of these:
82 
83* Close that shell.
84* To keep using the shell, unset `ANTHROPIC_AUTH_TOKEN`, and set `ANTHROPIC_API_KEY` again if you use it.
85 
5686## API key
5787 
5888The CLI also reads your API key from the `ANTHROPIC_API_KEY` environment variable. Get a key from the [Claude Console](https://platform.claude.com/settings/keys).
from line 113
83113 
84114To override the key for a single run, pass [`--api-key-stdin`](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/using#global-flags) and pipe the key to the command. To point at a different API host, set `ANTHROPIC_BASE_URL` or pass `--base-url`.
85115 
86If you are using a [personal or service account key](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) that isn’t scoped to a workspace, you must [specify the workspace](https://platform.claude.com/docs/en/manage-claude/authentication#select-a-workspace) to run your command in. Do this by setting an `ANTHROPIC_WORKSPACE_ID` environment variable, which the CLI reads automatically, or by using the [`--workspace-id` flag](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/using#global-flags). The value must be a `wrkspc_...` ID.
116If you use a [personal or service account key](https://platform.claude.com/docs/en/manage-claude/api-keys#key-types) scoped to the organization, [specify the workspace](https://platform.claude.com/docs/en/manage-claude/api-keys#select-a-workspace) to run your command in. Set the `ANTHROPIC_WORKSPACE_ID` environment variable, which the CLI reads automatically, or use the [`--workspace-id` flag](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/using#global-flags). The value must be a `wrkspc_...` ID.
87117 
88118```bash CLI
89119ant messages create \
from line 134
104134 
105135## Check authentication status
106136 
107`ant auth status` prints the credential source the CLI selected (API key environment variable, OAuth login, federation, Google Cloud, or profile), the active profile, the workspace the active token is bound to, and the configuration directory paths. Use it to diagnose why a workload picked the wrong credential or workspace.
137`ant auth status` prints the credential source the CLI selected (API key environment variable, OAuth sign-in, federation, Google Cloud, or profile), the active profile, the workspace the active token is scoped to, and the configuration directory paths. Use it to diagnose why a workload picked the wrong credential or workspace.
108138 
109139```bash CLI
110140ant auth status
from line 158
128158 
129159## Switch between workspaces
130160 
131An interactive-login token is bound to a single workspace. To use the CLI against more than one workspace, log in to each under its own named profile, then switch between them:
161A token from an interactive sign-in is scoped to one workspace at most. To use the CLI against more than one workspace, sign in to each under its own named profile, then switch between them:
132162 
133163```bash CLI
134164# 1. Create the profile (interactive; pick the other workspace in the
from line 165
135165# browser, or pass --workspace-id to skip the picker):
136166# ant auth login --profile other-ws
137167 
138# 2. The login made other-ws active. Switch back to your day-to-day
168# 2. The sign-in made other-ws active. Switch back to your day-to-day
139169# profile, such as default:
140170ant profile activate default
141171 
Feedback