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

# auth

> Autenticação e gerenciamento de credenciais.

## `zapsterapi auth login`

Salva um token Zapster em `~/.zapsterapi/credentials` para o perfil ativo.

```bash theme={null}
zapsterapi auth login --token <token> [--profile <nome>] [--base-url <url>]
```

| Flag               | Obrigatório | Descrição                                                                                      |
| ------------------ | ----------- | ---------------------------------------------------------------------------------------------- |
| `--token <token>`  | Sim         | Token de API gerado em [https://app.zapsterapi.com/tokens](https://app.zapsterapi.com/tokens). |
| `--profile <nome>` | Não         | Nome do perfil. Default: `default`.                                                            |
| `--base-url <url>` | Não         | API base URL alternativa (raramente necessária).                                               |

**Validação**: a CLI faz `GET /v1/wa/instances?per_page=1` antes de gravar o token. Se a API responder 401, o token não é persistido.

**Exemplo**:

```bash theme={null}
zapsterapi auth login --token zap_live_xxxxx --profile work
```

## `zapsterapi auth logout`

Remove credenciais do perfil ativo.

```bash theme={null}
zapsterapi auth logout [--profile <nome>]
```

Se for o único perfil no arquivo, o arquivo é apagado.

## `zapsterapi auth whoami`

Verifica o token do perfil ativo e mostra resumo.

```bash theme={null}
zapsterapi auth whoami [--profile <nome>] [--json]
```

Saída JSON:

```json theme={null}
{
  "ok": true,
  "data": {
    "profile": "default",
    "base_url": "https://api.zapsterapi.com",
    "token_suffix": "abcd",
    "valid": true
  }
}
```
