Developers
REST API and access tokens
Read your analytics, goals and revenue from scripts with access tokens and the AnalyticsX REST API.
The AnalyticsX REST API lets your own scripts, dashboards and agents read your numbers: your websites, the key figures and charts, breakdowns by source, page or country, goals, and Stripe revenue. It can also create goals. Every request is signed with an access token you create in the app.
The same tokens also connect AI assistants through the MCP server; see Connect AI assistants (MCP).
Access tokens
There are two kinds of token. Both start with ax_ and work the same way on the API.
| Account tokens | Website keys | |
|---|---|---|
| Where | Account › API & MCP (/account/api) |
Site settings › API / MCP (/settings/api) |
| Websites | All your websites, or the ones you pick | One website |
| Permissions | The ones you pick | All: read everything, and create goals |
| Who | Any signed-in user, for websites they own | The website's owner only |
Tokens act as the account that owns the website. They can only reach websites you own: websites shared with you as a team member are never listed and can't be picked.
Create an account token
- Click API & MCP in the sidebar (or go to
/account/api). - Click New token.
- 1. Pick websites: All websites (including websites you add later) or Specific websites, then tick the ones the token may reach.
- 2. Choose permissions: tick Read or Write for each row. Write includes read. Select all read and Select all write in the table header tick a whole column.
- 3. Name it (optional): up to 60 characters, for example
CLI AI agent. - Click Create token.
The full token is shown once, under Copy your new token now. It's shown only once. Copy it and keep it
somewhere safe. AnalyticsX stores only a fingerprint of it, so it can't be shown again; the list shows just
its first and last characters (for example ax_1a2b…9z8y).
| Permission | Read | Write | Lets the token |
|---|---|---|---|
| Websites | yes | – | List websites |
| Analytics | yes | – | Read the overview and breakdowns |
| Goals | yes | yes | List goals (read); create goals (write) |
| Payments | yes | – | Read the Stripe revenue summary |
Create a website key
In Site settings › API / MCP, enter an optional Key name (up to 60 characters) and click Create key. The key is shown once, under Copy this key now. A website can have up to 20 keys. Only the owner sees this tab's keys; team members see Only the owner manages API keys.
Website keys are also listed, read only, under Website keys in Account › API & MCP, with a Manage button that opens that website's settings.
Edit, roll and delete
Each token in the list shows its name, the start and end of the token, and Last used (or Never used). Last use is updated at most once a minute.
- Edit permissions (account tokens only): open the token with the arrow next to its name, then change its websites, permissions or name and click Save permissions. The token itself does not change.
- Roll: makes a new secret with the same settings. The old one stops working right away, so update every script or agent that uses it.
- Delete: the token stops working immediately. This can't be undone.
Tokens don't expire. Roll or delete a token when you no longer need it or if it may have leaked. When you delete a website, it is removed from every token scoped to it; a token left with no websites reaches nothing. Tokens stop working while an account is suspended.
Note: a token can read your revenue and visitor numbers. Keep it on a server or in your local environment. Don't put it in front-end code that visitors can see.
Authentication
Base URL:
https://app.supametrics.io/api/v1
Send the token in the Authorization header on every request:
curl https://app.supametrics.io/api/v1/sites \
-H "Authorization: Bearer ax_YOUR_TOKEN"
Responses are JSON. Requests from browsers are allowed from any origin (CORS), but see the note above about keeping tokens private.
Machine-readable description
Tools and agents can read the API without these docs:
- OpenAPI 3.1:
https://app.supametrics.io/openapi.json(every endpoint, its parameters and permission). - API catalog (RFC 9727):
https://supametrics.io/.well-known/api-cataloglists the REST API and the MCP server with their descriptions, docs and status check. - Status check:
GET https://app.supametrics.io/api/healthanswers{"status": "ok"}without a token. - Agent skill:
https://supametrics.io/.well-known/agent-skills/index.jsonlists a skill that teaches AI agents to use this API and the MCP server.
Rate limit
Each token can make 300 requests per minute. Above that, requests answer 429 with
{"error": "rate limited"} until the minute is over. Create separate tokens for separate jobs if you need
more headroom.
Errors
| Status | Body | Meaning |
|---|---|---|
400 |
{"error": "..."} |
Bad input, for example an unknown breakdown dimension or an invalid goal. |
401 |
{"error": "unauthorized"} |
Missing, wrong, rolled or deleted token, or a suspended account. |
403 |
{"error": "This token needs analytics:read"} |
The token lacks the permission the endpoint needs. |
404 |
{"error": "site not found"} |
The website doesn't exist, isn't yours, or is outside the token's websites. |
404 |
{"error": "not found"} |
No such endpoint. |
429 |
{"error": "rate limited"} |
Over 300 requests in a minute for this token. |
Endpoints
| Method | Path | Permission |
|---|---|---|
GET |
/sites |
Websites: read |
GET |
/sites/{id}/overview |
Analytics: read |
GET |
/sites/{id}/breakdown |
Analytics: read |
GET |
/sites/{id}/goals |
Goals: read |
POST |
/sites/{id}/goals |
Goals: write |
GET |
/sites/{id}/revenue |
Payments: read |
{id} is the website's id from GET /sites (not the public site ID in the tracking snippet).
Money and time
- Money amounts are whole numbers in the minor unit of the website's currency (cents for USD).
decimalsin the answer says how many decimal places the currency has:12900withdecimals: 2is 129.00. - Revenue counts only payments in the website's currency. Renewals, refunds and excluded products follow the website's settings in Site settings › Revenue.
- Timestamps (
from,to,createdAt,tsand so on) are Unix time in milliseconds. - Periods and chart buckets follow the website's timezone.
List websites
GET /sites
The websites the token can reach, in your dashboard order.
{
"sites": [
{
"id": "k3j9x0a1b2c3d4e5f6g7h8i9",
"name": "Example",
"domain": "example.com",
"timezone": "Europe/London",
"currency": "USD",
"firstEventAt": 1760000000000,
"createdAt": 1759990000000
}
]
}
firstEventAt is when the first visit was accepted, or null if the script isn't verified yet.
Period parameters
overview and breakdown accept these query parameters:
| Parameter | Default | Values |
|---|---|---|
period |
30d |
now (last 30 minutes), today, yesterday, 24h, 48h, 7d, 30d, 90d, 3m, 6m, 12m, wtd (week to date, from Monday), mtd, ytd, all, custom |
from, to |
YYYY-MM-DD, with period=custom. Both days are included. |
|
granularity |
automatic | minute, hour, day, week, month for the chart buckets. Too-fine choices over long periods fall back to automatic. |
compare_from, compare_to |
the period before | YYYY-MM-DD: a custom comparison period (overview). |
filters |
none | A JSON list, URL-encoded (see below). |
Filters keep only visits, and their revenue, that match every filter (up to 10):
filters=[{"d":"channel","o":"is","v":"Organic Search"},{"d":"page","o":"contains","v":"/blog"}]
d(dimension):channel,source,campaign,keyword,utm_source,utm_medium,utm_content,ref,hostname,entry_page,exit_page,country,region,city,browser,os,device,page(any page viewed in the visit),goal(completed in the visit),exit_link, orvisits(the visit's number for its visitor; 1 is a first visit).o(operator):is(default),is_not,contains,not_contains. Forvisits:is,is_not,gte(at least),lte(at most), andvmust be a whole number.v(value): text up to 500 characters. An empty string means "(none)".
Unknown dimensions and operators are ignored. Any filter drops unattributed payments, since they have no visit. See Date ranges, filters, segments and notes.
Overview
GET /sites/{id}/overview?period=7d
Key figures for the period and the period before it, the chart series for both, and visitors online now.
{
"range": { "from": 1762992000000, "to": 1763596800000, "granularity": "day" },
"previousRange": { "from": 1762387200000, "to": 1762992000000 },
"currency": "USD",
"decimals": 2,
"stripeConnected": true,
"current": {
"visitors": 1840, "sessions": 2310, "pageviews": 5120,
"bounceRate": 0.41, "sessionSeconds": 96,
"revenue": 129000, "newRevenue": 99000, "renewalRevenue": 30000, "refunds": 0,
"attributedRevenue": 120000, "unattributedRevenue": 9000,
"payments": 14, "payingVisitors": 12,
"conversionRate": 0.0065, "revenuePerVisitor": 70.1
},
"previous": { "visitors": 1702, "...": "same fields as current" },
"online": 7,
"series": [
{
"bucket": "2025-11-14",
"visitors": 260, "newVisitors": 210, "returningVisitors": 50,
"pageviews": 730, "bounceRate": 0.4, "sessionSeconds": 92,
"revenue": 19000, "revenueNew": 15000, "revenueRenewal": 4000, "revenueRefunds": 0,
"payers": 2, "sessions": 330, "payments": 2
}
],
"previousSeries": [ { "bucket": "2025-11-07", "...": "same fields" } ],
"imported": null,
"importedExcluded": false
}
- Rates (
bounceRate,conversionRate) are fractions:0.41is 41%. conversionRateis paying visitors divided by visitors.revenuePerVisitoris in the minor unit.onlinecounts visitors active in the last 5 minutes.importedis set when the figures include history imported from DataFast:{ "source": "datafast", "from", "until", "lastDay", "revenue", "running" }.importedExcludedistruewhen imported days fall in the period but the filters can't be applied to them, so they were left out. Breakdowns of source, channel, page, country, UTM source, campaign and device include imported values the same way. See Import from DataFast.bucketlabels areYYYY-MM-DDTHH:MM(minute),YYYY-MM-DDTHH:00(hour),YYYY-MM-DD(day, and week: the Monday), orYYYY-MM(month), in the website's timezone.
Definitions of every figure: Metrics glossary.
Breakdown
GET /sites/{id}/breakdown?dim=source&period=30d&limit=20
Visitors and revenue split by one dimension, most visitors first.
| Parameter | Default | Notes |
|---|---|---|
dim |
source |
Any filter dimension except visits: channel, source, campaign, keyword, utm_source, utm_medium, utm_content, ref, hostname, entry_page, exit_page, country, region, city, browser, os, device, page, goal, exit_link. |
limit |
50 |
Rows to return, at most 100. |
Plus the period parameters. The answer is a list:
[
{
"label": "Google",
"visitors": 820, "sessions": 1010, "pageviews": 2400,
"bounceRate": 0.38, "sessionSeconds": 104,
"revenue": 64000, "refunds": 0, "payers": 6, "payments": 7,
"conversionRate": 0.0073,
"completions": 41, "converters": 37
},
{ "label": "Unattributed", "visitors": 0, "revenue": 9000, "...": "..." }
]
labelisnullwhen the value is missing (for example visits with no campaign).completionsandconvertersare goal completions and visitors who completed a goal.regionandcityrows also havecountry(a two-letter code).exit_linkrows haveexits.- With revenue in the period that has no visit, an
Unattributedrow comes last so the revenue column adds up to the total.pageandgoalrows credit a payment to every page viewed or goal completed in the paying visit, so those columns can add up to more than the total. - An unknown
dimanswers400with{"error": "unknown dimension ..."}.
What each dimension means: Sources, pages, locations and devices.
List goals
GET /sites/{id}/goals
All goals of the website, oldest first, with completions and unique visitors over the last 30 days.
[
{
"id": "a1b2c3d4e5f6g7h8",
"site_id": "k3j9x0a1b2c3d4e5f6g7h8i9",
"name": "Signup",
"type": "event",
"match": "signup",
"enabled": 1,
"description": null,
"color": null,
"hidden": 0,
"kpi": 0,
"last_completed_at": 1763590000000,
"last_completed_path": "/welcome",
"created_at": 1760000000000,
"completions": 58,
"visitors": 55
}
]
type is path (URL path), click (element click, match is a CSS selector) or event (JavaScript
event). enabled is 1 or 0. Goal field names use underscores, unlike the other endpoints.
Create a goal
POST /sites/{id}/goals with a JSON body. Needs Goals: write.
curl https://app.supametrics.io/api/v1/sites/SITE_ID/goals \
-H "Authorization: Bearer ax_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Signup", "type": "event", "match": "signup"}'
| Field | Required | Rules |
|---|---|---|
name |
yes | 1 to 64 characters. |
type |
yes | path, click or event. |
match |
yes | 1 to 300 characters. A path starts with / (a trailing slash is removed). An event name is at most 64 characters. A click match is a CSS selector. |
enabled |
no | false creates the goal turned off. Default true. |
description |
no | Up to 300 characters. |
color |
no | One of the goal colors the app offers, or null. |
The answer is 201 with the new goal in the same shape as the list, with completions and visitors at
0. A website can have up to 50 goals; the 51st answers 400 with
{"error": "A website can have up to 50 goals."}. Like goals made in the app, a new goal counts only visits
from the moment it is created. See Goals.
Revenue
GET /sites/{id}/revenue
Stripe revenue over the last 30 days, the Stripe connection status, and the 10 latest payments.
{
"currency": "USD",
"decimals": 2,
"connected": true,
"lastEventAt": 1763590000000,
"lastEventType": "checkout.session.completed",
"lastErrorAt": null,
"lastError": null,
"payments": 31,
"revenue": 412000,
"refunds": 0,
"unattributedPayments": 3,
"unattributedRevenue": 27000,
"unattributedShare": 0.0655,
"otherCurrencyPayments": 0,
"testPayments": 0,
"testCounted": false,
"recent": [
{
"checkout_session_id": "cs_live_...",
"ts": 1763590000000,
"amount": 12900,
"currency": "usd",
"status": "attributed",
"source": "Google",
"visitor_id": "6f1c...",
"livemode": 1
}
]
}
revenueis net ofrefundswhen the website subtracts refunds (otherwiserefundsis0).otherCurrencyPaymentsare payments in another currency; they are stored but not counted.- Stripe test-mode payments count only until the website's first live payment;
testCountedsays whether they still do. recentlists the latest payments of any age and currency, refunds left out.
Background: Connect Stripe and Revenue and attribution.
Common questions
Can a token read a website someone shared with me? No. Tokens act as the owner and reach only websites you own. Ask the owner to create a token or website key.
Can I change what a website key may do? No. Website keys always have every permission, for one website. For fewer permissions, create an account token in Account › API & MCP and pick Specific websites.
Is there an endpoint for visitors, funnels or exporting raw events? Not yet. The endpoints above are the whole API today.