# API overview (https://eulabel.eu/docs/api-reference/overview/introduction)

> 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.



The EUlabel API is JSON over HTTPS. Send an API key with each request, and start with [`POST /v1/passports`](https://eulabel.eu/docs/api-reference/endpoints/passports), which creates a Digital Product Passport (DPP) in one call.

**Video: How the API works** (https://pub-7ea90ccdf0f545b3ad4613d72e450782.r2.dev/api-overview.mp4). The base URL, a Bearer key on a first request, the error object, and the ID types.


```text
https://api.eulabel.eu/v1
```

## Authenticate with an API key
Create a key in the dashboard under **Settings > API keys**. Keys start `eul_`, and there are no separate test or live keys. Send the key as a Bearer token.

#### cURL


```bash
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.products[0]?.internalId ?? 'No products yet');
```

#### Python


```python
import os
import 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 RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
print(body["products"][0]["internalId"] if body["products"] else "No products yet")
```


```json
{
  "products": [
    {
      "internalId": "430ef167-9572-45c0-8d2d-1cf5b887d762",
      "tenantId": "ba94a986-cd52-4c3b-b4b2-07748e025685",
      "projectId": "d352097a-c49c-4dff-82ee-1b2877957e97",
      "gtin": "05601234001013",
      "sku": "QD-TINTO-22",
      "name": "Quinta Demo Tinto 2022",
      "category": "wine",
      "brand": "Quinta Demo",
      "links": []
    }
  ],
  "pagination": { "total": 335, "limit": 1, "offset": 0, "hasMore": true }
}
```

The sector catalogs under `/v1/profiles` are public and need no key. The `/v1/auth/api-keys` routes need a dashboard session and reject API keys.

## How a request is handled
```mermaid
flowchart TD
  A["API key: 401, 429"]:::blue --> B["Key scope: 403"]:::blue
  B --> C["Endpoint: 400, 403, 404, 409, 422"]:::purple
  C --> D["Success: 2xx"]:::green
```

## Read the error object
Errors from an endpoint have this shape. `type` always equals `code`. `param`, `suggestion` and `documentationUrl` appear when they apply. `requestId` repeats the response's `X-Request-Id` header. Quote it when you contact support.

```json
{
  "error": {
    "type": "validation_error",
    "message": "Say which sector this product belongs to.",
    "code": "validation_error",
    "param": "category",
    "suggestion": "Send projectId, or category as one of: wine, battery, textile, furniture, construction, toy, detergent, steel, tyre, mattress, aluminium, food, electronics.",
    "documentationUrl": "https://eulabel.eu/docs/api-reference/endpoints/passports",
    "requestId": "req_5dbfc9f862ac4aea9cb9b8494ba7477f"
  }
}
```

Two responses aren't JSON, so check `Content-Type` before you parse. An unknown path, such as `GET /v1/nope`, returns an HTML `404`. An unsupported method, such as `PUT /v1/passports`, returns an empty `405`.

The [error handling guide](https://eulabel.eu/docs/knowledge-base/guides/error-handling) lists every code with its cause and fix.

## Status codes
| Status | Meaning |
| --- | --- |
| `200` | Success. On `POST /v1/passports`, nothing changed. |
| `201` | Created. On `POST /v1/passports`, the data or status changed. |
| `202` | Company prefix claim filed for review. |
| `204` | Deleted. No body. |
| `400` | The body is not valid JSON, or a CSV import is empty. |
| `401` | The key is missing or invalid. |
| `403` | The key lacks the scope, is limited to another project, or the organization hasn't accepted the Terms. |
| `404` | Not found, or not in your organization. An unknown path returns HTML. |
| `405` | The route doesn't support this method. No body. |
| `409` | The request conflicts with the current state, or a request with the same `Idempotency-Key` is still running. |
| `422` | A field is missing or invalid. `param` names it. |
| `429` | Over the rate limit. Wait for `Retry-After`. |
| `500` | Unexpected failure. |
| `502` | The auth service failed. API key routes only. |

## Paginate lists
Two lists are paginated, with `limit` and `offset`. The results key differs by resource, and an out-of-range `limit` is clamped, not rejected.

| Endpoint | Results key | Default `limit` | Max `limit` |
| --- | --- | --- | --- |
| `GET /v1/products` | `products` | 50 | 100 |
| `GET /v1/products/{productId}/items` | `items` | 50 | 200 |

Both return `pagination: { total, limit, offset, hasMore }`. Keep requesting while `hasMore` is true, adding `limit` to `offset`. Other lists return everything at once.

## Rate limit
Each API key may send 600 requests per minute. Above that the API returns `429 rate_limited` with a `Retry-After` header in seconds. There are no `X-RateLimit-*` headers.

## Retry a POST safely
Send an `Idempotency-Key` header with a new UUID on each `POST`, and the same key when you retry it. For 24 hours, a retry returns the first successful response instead of acting twice. [Idempotency and deduplication](https://eulabel.eu/docs/knowledge-base/guides/idempotency-and-deduplication#retry-any-post-with-an-idempotency-key) covers the details.

## Trace a request
Every response carries an `X-Request-Id` header. Send your own `X-Request-Id`, 8 to 128 letters, digits, `.`, `_`, `:` or `-`, to keep one id across your logs and ours. Otherwise the API makes one.

## ID types
| ID | Example | Use |
| --- | --- | --- |
| UUID | `fecd7002-392c-46cf-9f00-1401254cc76c` | `productId` and every other ID in a path. A product calls it `internalId`. |
| `ps_` | `ps_1yp5fr6` | The `id` of a passport, for display only. |
| GTIN | `05609780067125` | The product's barcode number. Send any valid length. The API stores 14 digits. |

> **Warning**
> Don't put a `ps_` id in a path. No endpoint accepts it, and you get `404`. Use `productId` from the `POST /v1/passports` response.


