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

# Authenticate

## What it does

Exchanges your registered credentials for an access token. This token must be sent in the `Authorization` header on every subsequent API call.

## Request Body

<ParamField body="vat_number" type="string" required>
  Your organization's 15-digit VAT registration number
</ParamField>

<ParamField body="username" type="string" required>
  API username assigned to your account
</ParamField>

<ParamField body="secret" type="string" required>
  API secret/password assigned to your account
</ParamField>

## Example Request

```bash theme={null}
curl -X POST https://api.einvoice.sa.com:9090/v1/e-invoicing/auth \
  -H "Content-Type: application/json" \
  -d '{
    "vat_number": "311262046600003",
    "username": "api",
    "secret": "YOUR_SECRET"
  }'
```

## Example Response

```json theme={null}
{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "expires_in": 3600
}
```

## Using the Token

Include the returned token on every following request:

```bash theme={null}
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
```

## Errors

| Code | Meaning                                 |
| ---- | --------------------------------------- |
| 401  | Invalid VAT number, username, or secret |
| 400  | Missing required field                  |
