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

# Autenticazione

> Autentica ogni richiesta all'Aniva Partner API con la tua chiave API partner nell'header x-api-key e tieni la chiave fuori dal codice del browser.

Tutte le richieste all'Aniva Partner API devono includere la tua chiave API partner nell'header di richiesta `x-api-key`.

```http theme={null}
x-api-key: your-api-key-here
```

> [!NOTE]
>
> Contatta Aniva per ottenere la tua chiave API. Le chiavi vengono rilasciate per singolo account partner.

## Invio di richieste autenticate

Includi l'header `x-api-key` in ogni richiesta che invii all'API.

```bash cURL theme={null}
curl https://anivahealth.com/api/v1/locations \
  -H "x-api-key: YOUR_API_KEY"
```

```javascript JavaScript theme={null}
const response = await fetch('https://anivahealth.com/api/v1/locations', {
  headers: {
    'x-api-key': 'YOUR_API_KEY',
  },
});

const data = await response.json();
```

## Risposte di errore

Se la tua richiesta non ha l'header `x-api-key`, l'API risponde con `401 Unauthorized`.

```json theme={null}
{
  "error": "This endpoint requires API key authentication"
}
```

Se la chiave API non è valida, l'API risponde con `401 Unauthorized`.

```json theme={null}
{
  "error": "Invalid API key"
}
```

Se la chiave è valida ma non ha lo scope per l'endpoint, l'API risponde con `403 Forbidden`.

```json theme={null}
{
  "error": "Insufficient permissions: requires appointments_schedule scope"
}
```

Se ricevi uno di questi errori, verifica che:

1. La tua richiesta includa l'header `x-api-key`.
2. Il valore della chiave API sia corretto e non sia stato ruotato.
3. La tua chiave abbia lo scope richiesto dall'endpoint. Ogni endpoint nel riferimento API indica il proprio scope.

> [!WARNING]
>
> Non esporre mai la tua chiave API nel codice lato client o in repository pubblici. Trattala come una password.

Contatta Aniva per ruotare una chiave compromessa o per richiedere modifiche ai permessi della tua chiave API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.