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

# Authentication

> Login, signup, and token management

## Login

```bash theme={null}
POST /api/auth/login
```

```json theme={null}
{
  "email": "user@company.com",
  "password": "your-password"
}
```

**Response:**

```json theme={null}
{
  "token": "tok_abc123...",
  "email": "user@company.com",
  "tenantId": "uuid-here",
  "expiresAt": "2026-03-16T20:00:00Z"
}
```

## Signup

```bash theme={null}
POST /api/auth/signup
```

```json theme={null}
{
  "company": "Acme Corp",
  "email": "admin@acme.com",
  "password": "min-8-characters"
}
```

**Response:**

```json theme={null}
{
  "status": "created",
  "tenantId": "uuid-here",
  "email": "admin@acme.com",
  "plan": "trial",
  "apiKey": "cg_abc123...",
  "token": "tok_xyz789...",
  "message": "Welcome to ChangeGuard! Save your API key — it cannot be retrieved again."
}
```

<Warning>The `apiKey` is returned only once. Save it immediately.</Warning>

## Verify Token

```bash theme={null}
POST /api/auth/verify
```

```json theme={null}
{ "token": "tok_abc123..." }
```

## Refresh Token

```bash theme={null}
POST /api/auth/refresh
```

```json theme={null}
{ "token": "tok_abc123..." }
```

Returns a new token. The old token is revoked. Sessions last 8 hours and auto-refresh when less than 10 minutes remain.

## Change Password

```bash theme={null}
POST /api/auth/password
Authorization: Bearer TOKEN
```

```json theme={null}
{
  "currentPassword": "old-password",
  "newPassword": "new-password-min-8"
}
```
