# 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
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
