# Agent skills (/agent-skills)

An **agent skill** is a folder with instructions that a coding agent loads when it needs them. The `ajour-api` skill teaches an agent the Ajour API: authentication, endpoints, conventions, errors, rate limits and recipes. It also tells the agent to keep your API key secret and that the API is read-only.

The skill follows the open [Agent Skills format](https://agentskills.io), so it works in Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode and many other agents.

## Install with the skills CLI [#install-with-the-skills-cli]

The [`skills` CLI](https://github.com/vercel-labs/skills) installs the skill from this site. It needs Node.js 22.20 or newer. Run it in your project folder:

```bash
npx skills add https://docs.ajour.dk
```

The CLI asks which agents to install the skill for. To choose one agent and skip the questions:

<Tabs items={["Claude Code","Codex","Cursor","GitHub Copilot","Gemini CLI"]}>
<Tab value="Claude Code">
```bash
npx skills add https://docs.ajour.dk --skill ajour-api -a claude-code -y
```
</Tab>

<Tab value="Codex">
```bash
npx skills add https://docs.ajour.dk --skill ajour-api -a codex -y
```
</Tab>

<Tab value="Cursor">
```bash
npx skills add https://docs.ajour.dk --skill ajour-api -a cursor -y
```
</Tab>

<Tab value="GitHub Copilot">
```bash
npx skills add https://docs.ajour.dk --skill ajour-api -a github-copilot -y
```
</Tab>

<Tab value="Gemini CLI">
```bash
npx skills add https://docs.ajour.dk --skill ajour-api -a gemini-cli -y
```
</Tab>
</Tabs>

Add `-g` to install the skill for all your projects instead of one. Run `npx skills update` later to get a newer version.

## Install by hand [#install-by-hand]

The skill is three files. Copy them to the skills folder of your agent, for example for Claude Code:

```bash
mkdir -p ~/.claude/skills/ajour-api/references
cd ~/.claude/skills/ajour-api
curl -fsSO https://docs.ajour.dk/skills/ajour-api/SKILL.md
curl -fsS -o references/endpoints.md https://docs.ajour.dk/skills/ajour-api/references/endpoints.md
curl -fsS -o references/recipes.md https://docs.ajour.dk/skills/ajour-api/references/recipes.md
```

| File | What it has |
| --- | --- |
| [`SKILL.md`](/skills/ajour-api/SKILL.md) | Safety rules, authentication, endpoints, conventions, errors and limits |
| [`references/endpoints.md`](/skills/ajour-api/references/endpoints.md) | Parameters and response fields of every endpoint |
| [`references/recipes.md`](/skills/ajour-api/references/recipes.md) | CSV export, retries, nightly copy, report download, Power BI |

The list of skills on this site is [`/.well-known/agent-skills/index.json`](/.well-known/agent-skills/index.json).

## Use the skill [#use-the-skill]

1. Set `AJOUR_API_KEY` in the environment where the agent runs. See [Authentication](/authentication/).
2. Ask the agent about your Ajour data, for example "Save last month's turnover per day as CSV". The agent loads the skill when the task is about Ajour.

<Callout type="warn" title="Never paste an API key into a chat">
The skill tells the agent to read the key from `AJOUR_API_KEY` and never to print it.
</Callout>

## The skill [#the-skill]

````md title="SKILL.md"
---
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).
````