> For the complete documentation index, see [llms.txt](https://docs.carto.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.carto.com/carto-for-agents/cli/command-reference/auth.md).

# auth

Personal authentication to CARTO. Manage login sessions, named profiles, and view current user information.

For an overview of the OAuth flow, profiles, and re-authentication behavior, see [Authentication & profiles](/carto-for-agents/cli/authentication.md).

## `carto auth login [profile]`

Open a browser-based OAuth 2.0 + PKCE login flow and store the resulting credentials.

```bash
carto auth login                              # Login to default profile
carto auth login staging                      # Login to a named profile
carto auth login --organization-name "ACME"   # Organization-specific login (SSO or standard)
carto auth login acme-prod --organization-name "ACME Corporation"
```

**Arguments:**

* `[profile]` — Optional profile name. If omitted, an auto-generated name `tenant_id/org_name/user@email.com` is used.

**Options:**

| Option                       | Description                                                                                            |
| ---------------------------- | ------------------------------------------------------------------------------------------------------ |
| `--env <environment>`        | Auth environment: `production`, `staging`, `local`, `dedicated-NN`. Only set if instructed by support. |
| `--organization-name <name>` | Organization name for SSO login. Use quotes if it contains spaces.                                     |
| `--organization-id <id>`     | Organization ID for SSO login (future support).                                                        |

## `carto auth logout [profile]`

Remove stored credentials.

```bash
carto auth logout                   # Logout from default profile
carto auth logout staging           # Logout from named profile
```

## `carto auth status [profile]`

Show authentication status, token expiration, and the full tenant → organization → user hierarchy. With no arguments, also lists every available profile and marks the current default.

```bash
carto auth status
carto auth status production
```

## `carto auth use <profile>`

Set the given profile as the current default. Subsequent commands will use it unless overridden by `--profile` or `CARTO_PROFILE`.

```bash
carto auth use production
```

## `carto auth whoami`

Show the authenticated user's profile (user ID, name, email, account info, roles).

```bash
carto auth whoami
```

On an M2M profile there is no user profile to show, so `whoami` reports the service identity instead: client id, account id, the user the client acts on behalf of, API base URL and token expiry. API access tokens created from an M2M session are attributed to that acting user.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.carto.com/carto-for-agents/cli/command-reference/auth.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
