DocsOpen Moon AI
Browse the docs

Usage and audit log through the API

Read usage by member, by group and by model, export it as CSV, then read, filter and export the organization’s audit log through the API.

On this page

All routes live under https://chat.realmoon.ai/api/v1/orgs/{org_id}. Scopes: usage:read for usage, audit:read for the audit log. These areas have no write scope.

UsageLink to the Usage section

What is countedLink to the What is counted section

MeasureDescription
requestsRequests: one per chat response, image, video or service (web search, computer, voice, music). Background tasks (titles, suggestions) do not count.
tokens_in, tokens_out, tokensTokens of the model responses: input, output, total. Images, videos and services have none.
share, token_share, request_shareShare, as a percentage, of the usage of the organization (or of the selected groups).
month_pctShare of their monthly limit the member has already used, as of now, whatever period you ask for.

usage_scope is workspace when the organization counts its members’ usage, and personal when each member uses their own allowance: the figures are then empty.

Period and scopeLink to the Period and scope section

ParameterDescription
date_from, date_toUnix seconds; date_to is excluded. Defaults to the last 30 days. 366 days at most.
group_idOnly count the members of this group (except for /usage/groups).

An invalid period returns 400 invalid_request with the message Période invalide : 366 jours au plus. (invalid period, 366 days at most). Responses return the effective date_from and date_to, and scope: org (the whole organization), managed_groups (the groups the key’s creator manages, without email addresses) or self (the creator only).

Period totalsLink to the Period totals section

GET /usage/summary · usage:read

cURL
curl "https://chat.realmoon.ai/api/v1/orgs/$ORG_ID/usage/summary?date_from=1759622400&date_to=1762214400" \
  -H "Authorization: Bearer $MOONAI_ADMIN_KEY"
Python
import os
import time
import requests

now = int(time.time())
r = requests.get(
    f"https://chat.realmoon.ai/api/v1/orgs/{os.environ['ORG_ID']}/usage/summary",
    headers={"Authorization": f"Bearer {os.environ['MOONAI_ADMIN_KEY']}"},
    params={"date_from": now - 30 * 86400, "date_to": now},
    timeout=30,
)
r.raise_for_status()
summary = r.json()
print(summary["current"]["requests"], summary["near_limit"])
JavaScript
const now = Math.floor(Date.now() / 1000);
const url = new URL(`https://chat.realmoon.ai/api/v1/orgs/${process.env.ORG_ID}/usage/summary`);
url.search = new URLSearchParams({ date_from: now - 30 * 86400, date_to: now });
const r = await fetch(url, { headers: { Authorization: `Bearer ${process.env.MOONAI_ADMIN_KEY}` } });
if (!r.ok) throw new Error(await r.text());
const summary = await r.json();
console.log(summary.current.requests, summary.near_limit);
JSON
{
  "date_from": 1759622400,
  "date_to": 1762214400,
  "current": { "members": 380, "active_members": 295, "requests": 18422, "tokens_in": 91200000, "tokens_out": 6100000, "tokens": 97300000 },
  "previous": { "members": 379, "active_members": 280, "requests": 17003, "tokens_in": 85000000, "tokens_out": 5700000, "tokens": 90700000 },
  "month_pct_avg": 37.4,
  "near_limit": 4,
  "days": [{ "day": "2026-10-05", "requests": 512, "active": 81, "tokens_in": 2500000, "tokens_out": 170000 }],
  "usage_scope": "workspace",
  "scope": "org",
  "can_export": true
}

previous covers the preceding period of the same length. near_limit counts the members at 90% or more of their monthly limit. days (days in Paris time) is only returned for a period of 92 days or less.

By memberLink to the By member section

GET /usage · usage:read

ParameterDescription
qPart of the name or address.
sortrequests (default), usage, month_pct, name, last_request or tokens.
page, limit50 by default, 200 at most.

Each item has user_id, name, email, profile_image_url, role, last_active_at, last_request_at, requests, share, month_pct, tokens_in, tokens_out, tokens and token_share. The response adds totals for the whole scope.

By groupLink to the By group section

GET /usage/groups · usage:read

Parameters: q, sort (requests, usage, tokens, active, members, name), page, limit. Each item has id, name, kind (static or dynamic), members, active_members, requests, share, tokens_in, tokens_out, tokens and token_share. A member of several groups counts in each of them: the shares can add up to more than 100.

By modelLink to the By model section

GET /usage/models · usage:read

Up to 100 models, with model_id (the model that answered), name, kind, requests, share, request_share and the tokens. model_id is image or video (kind: "media") for generated images and videos; services are not listed here.

Export as CSVLink to the Export as CSV section

GET /usage/export?view=members · usage:read

view is members (default), groups or models; date_from, date_to and group_id apply. The file is UTF-8 with a BOM, comma-separated; a cell that starts with =, +, - or @ is prefixed with an apostrophe. Email addresses are only included with an org scope. The export is recorded in the audit log.

Audit logLink to the Audit log section

Every admin action is recorded in the organization’s audit log, with its author: a member, an admin key (api_key:<id>) or Moon AI.

FiltersLink to the Filters section

ParameterDescription
actionOne or more action codes, separated by commas (50 at most).
actor_idA member, api_key:<id>, or __platform__ for Moon AI.
target_idThe person targeted, or any ID that appears in the details (group, label, role).
qText searched in the details and in the name or address of the person targeted.
date_from, date_toUnix seconds; date_to is excluded.
include_switchestrue to also see workspace switches (hidden by default).

Read the audit logLink to the Read the audit log section

GET /audit · audit:read

cURL
curl "https://chat.realmoon.ai/api/v1/orgs/$ORG_ID/audit?action=org_member_remove&limit=20" \
  -H "Authorization: Bearer $MOONAI_ADMIN_KEY"
Python
import os
import requests

r = requests.get(
    f"https://chat.realmoon.ai/api/v1/orgs/{os.environ['ORG_ID']}/audit",
    headers={"Authorization": f"Bearer {os.environ['MOONAI_ADMIN_KEY']}"},
    params={"action": "org_member_remove", "limit": 20},
    timeout=30,
)
r.raise_for_status()
for line in r.json()["items"]:
    print(line["created_at"], line["actor"]["name"], line["action"])
JavaScript
const url = new URL(`https://chat.realmoon.ai/api/v1/orgs/${process.env.ORG_ID}/audit`);
url.search = new URLSearchParams({ action: 'org_member_remove', limit: 20 });
const r = await fetch(url, { headers: { Authorization: `Bearer ${process.env.MOONAI_ADMIN_KEY}` } });
if (!r.ok) throw new Error(await r.text());
for (const line of (await r.json()).items) console.log(line.created_at, line.actor.name, line.action);
JSON
{
  "items": [
    {
      "id": 918273,
      "action": "org_group_members_add",
      "created_at": 1762209000,
      "actor": { "id": "api_key:7c1e2a4b-6d8f-4a0c-9e2b-4d6f8a0c2e4b", "name": "Synchro annuaire", "email": null, "kind": "api_key" },
      "target": null,
      "object": { "type": "group", "id": "<group id>", "name": "Professeurs" },
      "count": 3,
      "changes": null,
      "before": null,
      "after": { "group_id": "<group id>", "user_ids": ["<id 1>", "<id 2>", "<id 3>"] },
      "ip": "203.0.113.10",
      "user_agent": "curl/8.5.0",
      "people": [{ "id": "<id 1>", "name": "Léa Dupont" }]
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 50,
  "can_export": true
}
FieldDescription
actor.kindmember, api_key, platform (Moon AI) or system (automated task).
targetThe person targeted; deleted: true if their account no longer exists.
objectThe object affected: group, label, role, member, rules, domain, MCP server, model or resource.
changesA list of {path, before, after} (40 at most) for rules, settings, roles and statuses.
before, afterThe raw details of the action.
peopleThe first 5 people affected, when the action targets several.

For actions a member takes on their own account, the IP address, the browser and the details are not returned. Lines written by Moon AI have no IP address.

Actions and authors presentLink to the Actions and authors present section

GET /audit/facets · audit:read

Returns actions (each code present and its number of lines) and actors (200 authors at most, most active first), so you can build filters.

Export the audit logLink to the Export the audit log section

GET /audit/export · audit:read

A CSV of the lines that match the filters, 50,000 at most, most recent first. Columns: Date, Action, Libellé, Auteur, E-mail de l'auteur, Personne visée, Objet, Détails, Adresse IP (date, action, label, author, author’s email, person targeted, object, details, IP address). The export itself is recorded in the audit log.

See alsoLink to the See also section

Moon AI

Moon AI in action

0:00

Explore

Screenshots of chat.realmoon.ai taken on October 29, 2026, with fictional data.

Moon AI

Your preferences

Visits counted without cookies.

Our server counts visits without cookies or trackers. Your theme and your answer about ad measurement are remembered on this device.

Ad measurement

With your consent, our ad networks’ trackers (Google) measure our ads, from the visit to the sign-up and then to the first subscription and its amount, and may show you our ads. Your answer is valid for 13 months; you can change it here at any time.

No answer saved on this device.

After you decline, no tag is loaded anymore and the site deletes the cookies they had set on realmoon.ai. Those on the ad networks’ own domains are managed with them or in your browser.

The Moon AI app has its own privacy settings.