# Get usage

> What end users did in the editor, per day in the editor's time zone.

<Endpoint method="GET" path="/v1/usage" />

<CodeTabs>

```bash tab="cURL"
curl "https://api.muzekit.com/v1/usage?days=30" \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY"
```

```javascript tab="Node"
const res = await fetch("https://api.muzekit.com/v1/usage?days=30", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
});
const usage = await res.json();
```

```python tab="Python"
import os
import requests

usage = requests.get(
    "https://api.muzekit.com/v1/usage",
    params={"days": 30},
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()
```

</CodeTabs>

`days` is 1 to 90 (default 30); a larger number is read as 90. A key reads its own environment's usage. Sessions opened from the Muzekit dashboard are not counted. `active_users` is how many different users did something in the editor. `days` lists every day in the range, oldest first, with zeros on quiet days, and `date` is the day in the editor's `timezone`.

`sessions` here counts every time the editor opened. Your plan counts a user reopening the same template in the same browser within 10 minutes as one session, so for the number your plan meters, read `plan.period.sessions_used` from [GET /v1/workspace](/docs/api-reference/workspace-get).

The numbers are totals across all your users. For one user's activity (to bill your own customers per use, say), listen for the `session.started` and `template.updated` [webhooks](/docs/webhooks): each carries the user's `external_user_id`.

## Examples

### Show the last 7 days in your admin

`days=7` gives today and the six days before it, one row each, ready for a chart or a table.

<CodeTabs>

```bash tab="cURL"
curl -s "https://api.muzekit.com/v1/usage?days=7" \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq -r '.days[] | [.date, .active_users, .sessions, .downloads] | @tsv'
```

```javascript tab="Node"
const usage = await fetch("https://api.muzekit.com/v1/usage?days=7", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
}).then((r) => r.json());

const chart = usage.days.map((d) => ({ x: d.date, y: d.active_users }));
const weekSessions = usage.total.sessions;
```

```python tab="Python"
import os
import requests

usage = requests.get(
    "https://api.muzekit.com/v1/usage",
    params={"days": 7},
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()

for d in usage["days"]:
    print(d["date"], d["active_users"], d["sessions"], d["downloads"])
```

</CodeTabs>

### Store yesterday's numbers each night

Run a daily job after midnight in the editor's time zone. Ask for `days=2`: the first row is yesterday, complete, and the second is today so far.

<CodeTabs>

```bash tab="cURL"
curl -s "https://api.muzekit.com/v1/usage?days=2" \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" | jq '.days[0]'
```

```javascript tab="Node"
const usage = await fetch("https://api.muzekit.com/v1/usage?days=2", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
}).then((r) => r.json());

const [yesterday] = usage.days;
await db.editorUsage.upsert({ date: yesterday.date, ...yesterday });
```

```python tab="Python"
import os
import requests

usage = requests.get(
    "https://api.muzekit.com/v1/usage",
    params={"days": 2},
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()

yesterday = usage["days"][0]
db.editor_usage.upsert(yesterday)  # keyed by yesterday["date"]
```

</CodeTabs>

Store rows by `date`, so a rerun of the job replaces the day instead of adding it twice.

### See how often a session ends in a download

Over the longest range (90 days), divide `downloads` by `sessions` in `total` to see whether your users get to a finished design. Use `templates_saved` the same way for how many keep working on one.

<CodeTabs>

```bash tab="cURL"
curl -s "https://api.muzekit.com/v1/usage?days=90" \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq '.total | if .sessions > 0 then .downloads / .sessions else 0 end'
```

```javascript tab="Node"
const { total } = await fetch("https://api.muzekit.com/v1/usage?days=90", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
}).then((r) => r.json());

const downloadsPerSession = total.sessions ? total.downloads / total.sessions : 0;
```

```python tab="Python"
import os
import requests

total = requests.get(
    "https://api.muzekit.com/v1/usage",
    params={"days": 90},
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()["total"]

downloads_per_session = total["downloads"] / total["sessions"] if total["sessions"] else 0
```

</CodeTabs>

A Test key reads Test usage only. Use your Live key for what your real users do.

## Response

```json
{
  "object": "usage",
  "environment": "live",
  "timezone": "America/New_York",
  "total": {
    "active_users": 412,
    "sessions": 1380,
    "templates_created": 96,
    "templates_saved": 2210,
    "downloads": 640
  },
  "days": [
    {
      "date": "2026-10-16",
      "active_users": 38,
      "sessions": 120,
      "templates_created": 7,
      "templates_saved": 190,
      "downloads": 51
    }
  ]
}
```
