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

# Authentication

> How to authenticate Nozle Routing API requests with the X-API-Key header, request an API key, and handle invalid or revoked credentials.

All Nozle Routing API endpoints require authentication via an API key passed in the `X-API-Key` header.

## Getting an API Key

Contact us at [rohan.iyer@nozlerouting.com](mailto:rohan.iyer@nozlerouting.com) to request a key. Keys are issued per partner and can be rate-limited or revoked independently.

## Making Authenticated Requests

Include your API key in the `X-API-Key` header on every request:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.nozlerouting.com/v1/routes \
    -H "X-API-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"origin": "...", "destination": "..."}'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.nozlerouting.com/v1/routes',
      headers={'X-API-Key': 'YOUR_API_KEY'},
      json={'origin': '...', 'destination': '...'},
  )
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.nozlerouting.com/v1/routes', {
    method: 'POST',
    headers: {
      'X-API-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ origin: '...', destination: '...' }),
  });
  ```
</CodeGroup>

## Errors

Requests without a valid API key receive a `403 Forbidden` response:

```json theme={null}
{
  "error_code": "AUTHENTICATION_FAILED",
  "message": "Invalid or missing API key",
  "request_id": "req_..."
}
```

## Security Best Practices

<Warning>
  Never commit API keys to version control or expose them in client-side code. Use environment variables or secret management systems.
</Warning>

* Store API keys in environment variables, not source code
* Use different keys for development and production environments
* Rotate keys periodically
* Contact us immediately if you suspect a key has been compromised
