Get a user's usage
One end user's sessions and AI credits in this billing period.
curl https://api.muzekit.com/v1/users/user_42/usage \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY"const res = await fetch("https://api.muzekit.com/v1/users/user_42/usage", {
headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
});
const usage = await res.json();import os
import requests
usage = requests.get(
"https://api.muzekit.com/v1/users/user_42/usage",
headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json(){id} is the user's usr_… id or your own id for them, URL-encoded, as in Get a user.
The counts are for the editor's current billing period (period), in this key's environment:
sessions: editor sessions the user opened, each counted once however often they reloaded it, plus the sessions their AI app worked in.ai_credits_used: AI credits their AI actions spent.ai_credits_limitis what one user may spend a period (50 by default); past it their AI actions are refused with402 ai_user_limit_reached.
Renders aren't counted per user. For the whole editor's use, read Get the workspace (this period's pools) and Get usage (per day).
Examples
Warn a user before their AI credits run out
Check what is left before you show your own upgrade prompt, or turn AI features off in their next session's features.
curl -s https://api.muzekit.com/v1/users/user_42/usage \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
| jq '.ai_credits_limit - .ai_credits_used'const res = await fetch("https://api.muzekit.com/v1/users/user_42/usage", {
headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
});
const usage = await res.json();
const left = usage.ai_credits_limit - usage.ai_credits_used;
if (left < 10) {
// Show your own notice, or open the next session with
// features: { aiImages: false, agent: false }
}import os
import requests
usage = requests.get(
"https://api.muzekit.com/v1/users/user_42/usage",
headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()
left = usage["ai_credits_limit"] - usage["ai_credits_used"]Bill your heaviest users
Read each user's sessions at the end of the period, for example to charge per seat or per session in your own pricing. Use period.end to know when the counts start again.
for id in user_42 user_43; do
curl -s "https://api.muzekit.com/v1/users/$id/usage" \
-H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
| jq -r '[.external_id, .sessions] | @tsv'
donefor (const id of ["user_42", "user_43"]) {
const res = await fetch(`https://api.muzekit.com/v1/users/${id}/usage`, {
headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
});
const { external_id, sessions } = await res.json();
console.log(external_id, sessions);
}import os
import requests
for user_id in ["user_42", "user_43"]:
u = requests.get(
f"https://api.muzekit.com/v1/users/{user_id}/usage",
headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()
print(u["external_id"], u["sessions"])Response
{
"object": "user_usage",
"user": "usr_8fK2mQ1xZpR",
"external_id": "user_42",
"environment": "live",
"period": {
"start": "2026-11-01T00:00:00.000Z",
"end": "2026-12-01T00:00:00.000Z"
},
"sessions": 14,
"ai_credits_used": 32,
"ai_credits_limit": 50
}period.end is null when the editor has no billing period yet; the counts then start on the first of the month (UTC).