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

# CLI Sessions

> Authenticate the Grantiva CLI via browser login

The CLI authentication flow creates a session, opens a browser for login, and polls until complete.

## Create a session

```
POST /api/v1/auth/cli/sessions
```

### Response

```json theme={null}
{
  "session_id": "uuid"
}
```

***

## Poll session status

```
GET /api/v1/auth/cli/sessions/:sessionId
```

### Response

```json theme={null}
{
  "status": "pending",
  "api_key": null,
  "email": null
}
```

Status values: `pending`, `active`, `expired`.

When `active`, the response includes the API key and email:

```json theme={null}
{
  "status": "active",
  "api_key": "aat_abc123...",
  "email": "user@example.com"
}
```

***

## Validate API key

```
GET /api/v1/auth/me
```

### Headers

| Header          | Required | Description        |
| --------------- | -------- | ------------------ |
| `Authorization` | Yes      | `Bearer <api_key>` |

### Response

```json theme={null}
{
  "email": "user@example.com",
  "api_key_prefix": "aat_abc1"
}
```
