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

# Errors

> How Notvis Connect API handles and reports errors.

## Error Format

All errors are returned as JSON with the following structure:

```json theme={null}
{
  "code": 400,
  "message": "validation failed",
  "details": {
    "from": "from email is required",
    "subject": "subject is required"
  }
}
```

| Field     | Type    | Description                                         |
| --------- | ------- | --------------------------------------------------- |
| `code`    | integer | HTTP status code                                    |
| `message` | string  | Human-readable error message                        |
| `details` | object  | Field-level validation errors (only for 400 errors) |

## HTTP Status Codes

| Code  | Description                                      |
| ----- | ------------------------------------------------ |
| `200` | Success                                          |
| `201` | Created (push registration)                      |
| `202` | Accepted — message queued for delivery           |
| `400` | Bad Request — invalid JSON or validation failure |
| `401` | Unauthorized — invalid or missing API key        |
| `405` | Method Not Allowed — wrong HTTP method           |
| `500` | Internal Server Error                            |

## Validation Errors

When a request fails validation, the response includes a `details` object mapping each invalid field to its error message:

```json theme={null}
{
  "code": 400,
  "message": "validation failed",
  "details": {
    "to": "at least one recipient is required",
    "body": "at least one of body_html or body_text is required"
  }
}
```

## Authentication Errors

```json theme={null}
{
  "code": 401,
  "message": "invalid or missing API key"
}
```

Ensure your API key is valid, active, and not expired. Check that you're using the correct header format: `Authorization: Bearer your_key` or `X-API-Key: your_key`.
