# Using the API with AI agents (/ai-agents)

AI agents and coding assistants, such as ChatGPT, Claude and Cursor, can write code that uses the Ajour API. Give them the files below and one of the prompts on this page.

## Files for AI agents [#files-for-ai-agents]

| File | Use it for |
| --- | --- |
| [`/llms.txt`](/llms.txt) | A short index of this site, with a link to the Markdown of each page. |
| [`/llms-full.txt`](/llms-full.txt) | All guide pages in one text file. |
| [`/openapi/public-v1.json`](/openapi/public-v1.json) | The OpenAPI 3.0 description of every endpoint. Most agent tools can turn it into tools. |

Each page also has a **Copy page** button, and a menu to open the page in ChatGPT, Claude or Cursor.

## Agent skill [#agent-skill]

Coding agents such as Claude Code, Codex and Cursor can install the `ajour-api` skill. It teaches the agent the endpoints, conventions and safety rules, so you do not have to paste them each time.

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

See [Agent skills](/agent-skills/) for each agent and for the skill contents.

Ajour does not have an MCP server. Agents call the HTTP API directly, with the OpenAPI file as the description.

## Prompts [#prompts]

Start with the setup prompt. It tells the agent the rules of the API. Then use a task prompt below: copy it, change the dates and names, and paste it into your AI tool.

<AgentPrompt />

### Build a daily turnover export [#build-a-daily-turnover-export]

```text title="Prompt"
Read the Ajour Public API docs: https://docs.ajour.dk/llms-full.txt
and the OpenAPI file: https://docs.ajour.dk/openapi/public-v1.json

Write a Python script that:
- reads the API key from the AJOUR_API_KEY environment variable,
- calls GET /v1/sales/breakdown with groupBy=day for last month,
- saves date, quantity and turnover (DKK, including VAT) to turnover.csv,
- waits for Retry-After seconds and tries again if the API returns 429.
Do not put the API key in the code.
```

### Connect Power BI [#connect-power-bi]

```text title="Prompt"
Read the Ajour Public API docs: https://docs.ajour.dk/llms-full.txt

Write a Power Query (M) query for Power BI that:
- calls https://api.ajour.dk/v1/sales/breakdown with groupBy=location,
  from the first day of this month to today,
- sends the header Authorization: Bearer <key>, with the key as a parameter,
- returns a table with the columns key, label, quantity and turnover.
Explain where I paste it and which connection type to choose.
```

### Copy sales lines every night [#copy-sales-lines-every-night]

```text title="Prompt"
Read the Ajour Public API docs: https://docs.ajour.dk/llms-full.txt
and the OpenAPI file: https://docs.ajour.dk/openapi/public-v1.json

Write a script that copies new sales lines from GET /v1/sales to a SQLite database.
- Store the newest syncedAt value and pass it as syncedSince on the next run.
- Ask for the last 7 days with from and to, and follow nextCursor until it is null.
- Use limit=1000 and skip lines whose id is already in the database.
- Read the API key from the AJOUR_API_KEY environment variable.
```

### Answer a question about my sales [#answer-a-question-about-my-sales]

```text title="Prompt"
Use the Ajour Public API (docs: https://docs.ajour.dk/llms-full.txt).
The API key is in the AJOUR_API_KEY environment variable.

Which 10 products sold most in my shops in November 2026,
and how does that compare with November 2025?
Use GET /v1/sales/breakdown with groupBy=product, limit=10 and compare=previousYear.
Do not add up sales lines yourself.
```

## Facts an agent needs [#facts-an-agent-needs]

- Base URL: `https://api.ajour.dk/v1`. Only `GET` calls.
- Header: `Authorization: Bearer <key>`.
- Dates in `from` and `to` are local dates in Europe/Copenhagen. `to` is included.
- Money is in DKK. `vat=include` is the default.
- Lists return `{ "data": [...], "nextCursor": ... }`. Follow `nextCursor` until it is `null`.
- Use `/v1/sales/summary` and `/v1/sales/breakdown` for figures. They match the Ajour dashboard. Do not add up sales lines.
- On `429`, wait for `Retry-After` seconds.

## Keep the key safe [#keep-the-key-safe]

<Callout type="warn" title="Never paste an API key into a chat">
Give the key to the agent through an environment variable or a secret store.
</Callout>

- Give the agent a key with only the scopes it needs. For most questions about sales, `sales:read` is enough.
- Limit the key to the locations the agent needs.
- Revoke the key in **Settings → API keys** when you no longer need it.

Version 1 is read-only. An agent cannot change your data through the API.