# Authentication (https://eulabel.eu/docs/documentation/get-started/authentication)

> Fetch the complete documentation index at: https://eulabel.eu/docs/llms.txt
> Use this file to discover all available pages before exploring further.
> Full content: https://eulabel.eu/docs/llms-full.txt
> Append .md to any page URL for markdown, or send Accept: text/markdown.



Send your API key as a Bearer token on every request. Keys start `eul_`, and there are no separate test or live keys.

**Video: Create, copy and revoke an API key** (https://pub-7ea90ccdf0f545b3ad4613d72e450782.r2.dev/api-keys.mp4). You create an API key in the dashboard, see that it is shown only once, and revoke it.

## Authenticate a request
#### cURL


```bash
export EULABEL_API_KEY="eul_..."

curl "https://api.eulabel.eu/v1/products?limit=1" \
  -H "Authorization: Bearer $EULABEL_API_KEY"
```

#### JavaScript


```javascript
const res = await fetch('https://api.eulabel.eu/v1/products?limit=1', {
  headers: { Authorization: `Bearer ${process.env.EULABEL_API_KEY}` },
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message}`);

console.log(body.pagination);
```

#### Python


```python
import os, requests

res = requests.get(
    "https://api.eulabel.eu/v1/products",
    params={"limit": 1},
    headers={"Authorization": f"Bearer {os.environ['EULABEL_API_KEY']}"},
)
body = res.json()
if not res.ok:
    raise SystemExit(f"{body['error']['code']}: {body['error']['message']}")

print(body["pagination"])
```

A missing or wrong key returns:

```json
{
  "error": {
    "type": "authentication_required",
    "message": "Missing or invalid authentication",
    "code": "authentication_required",
    "documentationUrl": "https://eulabel.eu/docs/documentation/get-started/authentication"
  }
}
```


> **Error**
> Keep keys on your server. Never put one in browser code, a mobile app or a public repository.

## Authentication errors
| Status | Code | Cause | Fix |
| --- | --- | --- | --- |
| 401 | `authentication_required` | Key missing, wrong or revoked | Check the `Authorization` header |
| 403 | `insufficient_permissions` | The key lacks the scope this call needs | Use a key with that scope |
| 403 | `scope_violation` | A project key touched another project, or an action reserved for organization keys | Use the right project, or an organization key |
| 403 | `terms_not_accepted` | The organization hasn't accepted the Terms and Data Processing Agreement | An owner or admin accepts them in the dashboard |
| 403 | `csrf_origin_mismatch` | A cookie request without a trusted `Origin` or `Referer` | Send it from a trusted origin |
| 429 | `rate_limited` | More than 600 requests in a minute on this key | Wait for the seconds in `Retry-After` |

## Scopes
Keys created in the dashboard hold every scope below except `api_keys:manage`. To issue a narrower key, see [API keys](https://eulabel.eu/docs/api-reference/endpoints/api-keys) in the API reference.

| Scope | Allows |
| --- | --- |
| `products:read` | Read products, items, passports and QR codes |
| `products:write` | Create and update products and items, import CSV |
| `passports:read` | List access grants |
| `passports:write` | Create, publish and withdraw passports, issue access grants |
| `projects:read`, `projects:write` | Read, create, archive and delete projects |
| `suppliers:read`, `suppliers:write` | Read and write suppliers |
| `domains:read`, `domains:write` | Read, register and verify custom domains |
| `analytics:read` | Read scan analytics |
| `api_keys:manage` | Manage API keys, from a signed-in session only |

## Session cookies
The dashboard signs people in with email and password, a magic link, a passkey, or Google or Microsoft where enabled, with optional two-factor authentication. Sessions use a cookie, not a key.

The `/v1/auth/api-keys` routes accept a session only, so an API key can't mint more keys.

## Next steps
- [API keys](https://eulabel.eu/docs/documentation/get-started/api-keys) — Create, rotate and revoke keys.
- [Quickstart](https://eulabel.eu/docs/documentation/get-started/quickstart) — Publish a passport with your key.

