# Quick start (/quick-start)

<Steps>
<Step>
### Create an API key [#create-an-api-key]

Sign in to the Ajour back office. Go to **Settings → API keys** and select **Create key**. Give the key a name, choose its scopes, and choose the locations it can see. For this guide, select `catalog:read` and `sales:read`.

Copy the key. Ajour shows it **one time only**. It looks like this:

```text
ajr_live_7Kq2Vx9b_Q3n8...
```
</Step>

<Step>
### Keep the key in an environment variable [#keep-the-key-in-an-environment-variable]

```bash
export AJOUR_API_KEY="ajr_live_7Kq2Vx9b_Q3n8..."
```

Do not put the key in source code, a URL or an e-mail.
</Step>

<Step>
### Check the key [#check-the-key]

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

The response shows your company and the key's scopes and locations:

```json
{
  "id": 412,
  "name": "Café Nørrebro ApS",
  "cvr": "12345678",
  "currency": "DKK",
  "timeZone": "Europe/Copenhagen",
  "workHours": { "start": "07:00", "end": "23:00" },
  "key": { "keyId": "7Kq2Vx9b", "scopes": ["catalog:read", "sales:read"], "locationIds": null }
}
```
</Step>

<Step>
### List your locations [#list-your-locations]

```bash
curl https://api.ajour.dk/v1/locations \
  -H "Authorization: Bearer $AJOUR_API_KEY"
```
</Step>

<Step>
### Get the key figures for a period [#get-the-key-figures-for-a-period]

<Tabs items={["curl","Python","JavaScript"]}>
<Tab value="curl">
```bash
curl "https://api.ajour.dk/v1/sales/summary?from=2026-11-01&to=2026-11-21" \
  -H "Authorization: Bearer $AJOUR_API_KEY"
```
</Tab>

<Tab value="Python">
```python
import os, requests

response = requests.get(
    "https://api.ajour.dk/v1/sales/summary",
    params={"from": "2026-11-01", "to": "2026-11-21"},
    headers={"Authorization": f"Bearer {os.environ['AJOUR_API_KEY']}"},
    timeout=60,
)
response.raise_for_status()
print(response.json()["metrics"]["totalTurnover"])
```
</Tab>

<Tab value="JavaScript">
```js
const url = new URL('https://api.ajour.dk/v1/sales/summary');
url.search = new URLSearchParams({ from: '2026-11-01', to: '2026-11-21' });

const response = await fetch(url, {
  headers: { Authorization: `Bearer ${process.env.AJOUR_API_KEY}` },
});
if (!response.ok) throw new Error(`Ajour API error ${response.status}`);
const summary = await response.json();
console.log(summary.metrics.totalTurnover);
```
</Tab>
</Tabs>

```json
{
  "period": { "from": "2026-11-01", "to": "2026-11-21" },
  "currency": "DKK",
  "vat": "include",
  "metrics": {
    "totalTurnover": 486210.50,
    "posTurnover": 451900.00,
    "onlineTurnover": 34310.50,
    "transactions": 6120,
    "averageTransaction": 79.45,
    "discount": 8120.00,
    "returns": 1340.00,
    "contributionMargin": 301455.20,
    "contributionMarginPercent": 62.0
  }
}
```

These are the same figures as the key figure cards on your Ajour dashboard.
</Step>

<Step>
### Get sales per product group [#get-sales-per-product-group]

```bash
curl "https://api.ajour.dk/v1/sales/breakdown?groupBy=productGroup&from=2026-11-01&to=2026-11-21" \
  -H "Authorization: Bearer $AJOUR_API_KEY"
```
</Step>
</Steps>

## Next steps [#next-steps]

<Cards>
<Card title="Authentication" href="/authentication/">
Scopes, location limits and how to revoke a key.
</Card>

<Card title="Conventions" href="/conventions/">
Dates, money, paging and ids.
</Card>

<Card title="Recipes" href="/recipes/">
Spreadsheets, Power BI and nightly copies.
</Card>

<Card title="API reference" href="/api-reference/">
Every endpoint, parameter and response.
</Card>
</Cards>