> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abacatepay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Autenticação & Perfis

> Comandos de login, logout, perfis múltiplos e gerenciamento de autenticação na AbacatePay CLI.

Comandos para gerenciar a autenticação e sessão na AbacatePay CLI.

***

### `abacatepay login`

Realiza a autenticação na AbacatePay. Abre o navegador para login via OAuth ou permite autenticação direta com API key.

```bash theme={null}
abacatepay login [flags]
```

| Flag      | Alias | Descrição                   | Padrão  |
| --------- | ----- | --------------------------- | ------- |
| `--name`  | -     | Nome do perfil a ser criado | `""`    |
| `--key`   | -     | Sua API key da AbacatePay   | `""`    |
| `--local` | `-l`  | Usa servidor de teste       | `false` |

<Tip>
  Use `--name` para criar múltiplos perfis e alternar entre diferentes contas ou ambientes.
</Tip>

**Exemplos:**

```bash theme={null}
# Login interativo via navegador
abacatepay login

# Login com API key específica
abacatepay login --key "abc_prod_xxxxx"

# Login criando um perfil nomeado
abacatepay login --name producao --key "abc_prod_xxxxx"
```

<CodeGroup>
  ```text text theme={null}
  ╭────────────────────────────╮
  │                            │
  │  🥑 Signed in successfully │
  │                            │
  │  Profile: default          │
  │  User: João Silva          │
  │  Email: joao@empresa.com   │
  │                            │
  ╰────────────────────────────╯
  ```

  ```json json theme={null}
  {
    "profile": "default",
    "user": "João Silva",
    "email": "joao@empresa.com",
    "status": "authenticated"
  }
  ```

  ```text table theme={null}
  ┌─────────┬──────────────────┐
  │ Profile │ default          │
  │ User    │ João Silva       │
  │ Email   │ joao@empresa.com │
  │ Status  │ Authenticated    │
  └─────────┴──────────────────┘
  ```
</CodeGroup>

***

### `abacatepay logout`

Encerra a sessão atual e remove as credenciais do perfil ativo.

```bash theme={null}
abacatepay logout
```

<CodeGroup>
  ```text text theme={null}
  ╭─────────────────────────────╮
  │                             │
  │  🥑 Signed out successfully │
  │                             │
  │  Profile: default           │
  │                             │
  ╰─────────────────────────────╯
  ```

  ```json json theme={null}
  {
    "title": "Signed out successfully",
    "profile": "default"
  }
  ```
</CodeGroup>

<Warning>
  Após o logout, você precisará fazer login novamente para usar comandos que requerem autenticação.
</Warning>

***

### `abacatepay whoami`

Exibe informações do usuário autenticado e o perfil ativo.

```bash theme={null}
abacatepay whoami
```

<CodeGroup>
  ```text text theme={null}
  ╭───────────────────────────╮
  │                           │
  │  🥑 User Information      │
  │                           │
  │  Status: Authenticated    │
  │  Profile: salve3          │
  │  User: Mock User          │
  │  Email: mock@example.com  │
  │                           │
  │                           │
  ╰───────────────────────────╯
  ```

  ```json json theme={null}
  {
    "profile": "salve3",
    "user": "Mock User",
    "email": "mock@example.com",
    "status": "authenticated"
  }
  ```

  ```text table theme={null}
  ┌─────────┬──────────────────┐
  │ Profile │ salve3           │
  │ User    │ Mock User        │
  │ Email   │ mock@example.com │
  │ Status  │ Authenticated    │
  └─────────┴──────────────────┘
  ```
</CodeGroup>

***

### `abacatepay status`

Verifica o status da conexão e autenticação com a AbacatePay.

```bash theme={null}
abacatepay status
```

<Tip>
  Use `abacatepay status` como diagnóstico rápido quando encontrar problemas de conectividade.
</Tip>

<CodeGroup>
  ```text text theme={null}
  ╭────────────────────────────╮
  │                            │
  │  🥑 Connected successfully │
  │                            │
  │  Profile: default          │
  │  Status: Online            │
  │                            │
  ╰────────────────────────────╯
  ```

  ```json json theme={null}
  {
    "profile": "default",
    "status": "online"
  }
  ```

  ```text table theme={null}
  ┌─────────┬─────────┐
  │ Profile │ default │
  |─────────|─────────|
  │ Status  │ Online  │
  └─────────┴─────────┘
  ```
</CodeGroup>

***

## Perfis

Comandos para gerenciar múltiplos perfis de autenticação.

***

### `abacatepay profile list`

Lista todos os perfis configurados na máquina.

```bash theme={null}
abacatepay profile list
```

<CodeGroup>
  ```text text theme={null}
  ✓ Configured Profiles

    * default (active)
      producao
      staging
  ```

  ```json json theme={null}
  {
    "profiles": [
      {
        "name": "default",
        "key": "abc_prod..."
      },
      {
        "name": "producao",
        "key": "abc_prod..."
      },
      {
        "name": "staging",
        "key": "abc_dev..."
      }
    ],
    "active": "default"
  }
  ```

  ```text table theme={null}
  ┌───────────┬────────────┬────────┐
  │ Name      │ API Key    │ Active │
  ├───────────┼────────────┼────────┤
  │ default   │ abc_prod...│ 🥑     │
  │ producao  │ abc_prod...│        │
  │ staging   │ abc_dev... │        │
  └───────────┴────────────┴────────┘
  ```
</CodeGroup>

***

### `abacatepay profile delete`

Remove um perfil salvo. Não é possível remover o perfil ativo.

```bash theme={null}
abacatepay profile delete <name>
```

```bash theme={null}
abacatepay profile delete staging
```

```text theme={null}
Profile 'staging' successfully removed.
```

<Warning>
  Não é possível deletar o perfil ativo. Use `abacatepay switch` para mudar para outro perfil antes de deletar.
</Warning>

***

### `abacatepay switch`

Alterna para outro perfil existente.

```bash theme={null}
abacatepay switch <name>
```

<Tip>
  Requer conexão com a internet para verificar o status online.
</Tip>

```bash theme={null}
abacatepay switch producao
```

```text theme={null}
Now using profile: producao
```

***
