---
name: ajour-api
description: Use the read-only Ajour Public API (api.ajour.dk/v1) to read a company's locations, products, sales key figures, sales breakdowns, sales lines and report files. Use when the user mentions Ajour, Ajour sales or turnover, Ajour reports, an AJOUR_API_KEY, or wants to export Ajour data to a spreadsheet, Power BI, a database or another system.
---

# Ajour Public API

The Ajour Public API is a read-only HTTP API. It returns one company's data: locations, product groups, products, sales figures, sales lines and report files. Every number matches the Ajour dashboard and reports.

- Docs: https://docs.ajour.dk (for agents: https://docs.ajour.dk/llms-full.txt)
- OpenAPI file: https://docs.ajour.dk/openapi/public-v1.json
- Base URL: `https://api.ajour.dk/v1`. Every call is a `GET`.

## Safety rules

- The API key is a secret. Read it from the `AJOUR_API_KEY` environment variable. Never print it, log it, put it in a URL, write it to a file in the repository, or show it in your answer.
- If there is no key, tell the user to create one in the Ajour back office under **Settings → API keys** and to set `AJOUR_API_KEY`. Do not ask them to paste the key into the chat.
- The API cannot change data. Do not promise to change products, prices or menus through it.

## Authentication

```bash
curl https://api.ajour.dk/v1/company \
  -H "Authorization: Bearer $AJOUR_API_KEY"
```

Always start with `GET /v1/company`. It shows the company, the key's scopes and the key's locations (`key.locationIds`, `null` = all locations).

| Scope | Gives access to |
| --- | --- |
| `catalog:read` | locations, product groups, products |
| `sales:read` | sales summary, breakdown, sales lines, salesperson names |
| `reports:read` | report files (PDF, Excel) |
| `customers:read` | reports with customer card data (off by default) |

A location outside the key returns `404`, not `403`.

## Endpoints

| Path | Scope | Use it for |
| --- | --- | --- |
| `/company` | any | the company and the key |
| `/locations` | `catalog:read` | locations, with `lastSyncedAt` (data freshness) |
| `/product-groups` | `catalog:read` | product groups (id = POS number) |
| `/products`, `/products/{productId}` | `catalog:read` | products with prices (id = POS number) |
| `/salespersons` | `sales:read` | names for the `salesperson` filter (last 13 months) |
| `/sales/summary` | `sales:read` | key figures for a period (dashboard cards) |
| `/sales/breakdown` | `sales:read` | figures grouped by `productGroup`, `product`, `location`, `salesperson`, `hour`, `weekday`, `day` or `month` |
| `/sales` | `sales:read` | raw receipt lines (max 92 days) |
| `/reports`, `/reports/{reportType}` | `reports:read` | report types, and a report as `pdf` or `xlsx` |

Parameters and response fields: [references/endpoints.md](references/endpoints.md).

## Conventions

- `from` and `to` are required for sales calls. They are local dates (`YYYY-MM-DD`) in Europe/Copenhagen. `to` is included. Summary and breakdown allow 366 days at most.
- Money is in DKK with 2 decimals; responses have `"currency": "DKK"`. Amounts include VAT unless you pass `vat=exclude`.
- Lists return `{ "data": [...], "nextCursor": "..." }`. Pass `nextCursor` as `cursor` until it is `null`. `limit` is 100 by default, 1000 at most.
- Repeat a parameter for more values: `locationId=1031&locationId=1032`.
- Products and product groups use POS numbers as string ids. Locations use numeric ids.
- Use `updatedSince` (products, product groups) and `syncedSince` (sales lines) to copy only changes.
- Ignore response fields you do not know. v1 only adds fields.

## Pick the right call

- A total or a key figure → `/sales/summary`. Add `compare=previousYear` for last year.
- A table or chart → `/sales/breakdown?groupBy=...`. Use `limit=10` for a top 10.
- Raw rows for a warehouse → `/sales` with paging.
- Do not add up sales lines to get figures. The summary and breakdown already match the dashboard.

## Errors and limits

Errors are Problem Details (`application/problem+json`) with `type`, `title`, `status`, `detail`, `requestId` and sometimes `errors` per parameter.

| Status | Meaning | Do |
| --- | --- | --- |
| 400 | wrong parameter format, key in the URL (`key-in-url`), or the `Impersonation-Company-Id` header | fix the request; a key sent in a URL must be revoked |
| 401 | missing, wrong, revoked or expired key | check `AJOUR_API_KEY` |
| 403 | missing scope, inactive company, or a report that needs a key for all locations | ask for a key with the scope or without a location limit |
| 404 | unknown id, or location outside the key | check ids with `/locations` |
| 422 | `to` before `from`, period too long, or a report call without exactly one `locationId` for a key with several locations | fix the dates, split the period, or pass one `locationId` |
| 429 | rate limit | wait `Retry-After` seconds, then retry |
| 503 | report took more than 90 seconds | ask for a shorter period |

Limits: 120 requests per minute per key, 10 report files per minute. Responses have `RateLimit-Limit` and `RateLimit-Remaining`. Make calls one after another.

## Recipes

Code for a CSV export, Power BI, a nightly copy and report downloads: [references/recipes.md](references/recipes.md).
