REST API
Read stats and manage sites from code, with an API key.
The REST API lives under /api/v1 on the dashboard's URL:
https://app.pageflock.com/api/v1It has the same operations as the MCP server, and returns JSON.
API keys
Owners and admins create keys under Settings, API and MCP. A key belongs to one workspace, starts with pageflock_, and is shown once: Pageflock only stores a hash of it.
| Access | Scopes | Can |
|---|---|---|
| Read only | stats:read, sites:read | Read stats, list sites, check installations |
| Read and write | also sites:write | Also create sites and change their settings |
Send it as a bearer token:
curl https://app.pageflock.com/api/v1/sites \
-H "Authorization: Bearer $PAGEFLOCK_API_KEY"Each key may make 600 requests an hour.
Endpoints
| Method | Path | |
|---|---|---|
GET | /workspaces | The key's workspace, as a list |
GET | /sites | Sites in the workspace |
POST | /sites | Create a site |
GET | /sites/:id | A site's settings |
PATCH | /sites/:id | Change a site's settings |
GET | /sites/:id/install | Install code. ?framework=next|react|vue|other |
GET | /sites/:id/realtime | Visitors right now |
GET | /sites/:id/installation | Whether events arrive. ?check_page=true also loads the home page |
POST | /movers | What changed: the biggest risers and fallers |
POST | /query | Run a stats query |
Query
POST /query takes the same query as the dashboard:
curl https://app.pageflock.com/api/v1/query \
-H "Authorization: Bearer $PAGEFLOCK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"site_id": "SITE_ID",
"date_range": "30d",
"metrics": ["visitors", "pageviews", "bounce_rate"],
"dimensions": ["source"],
"filters": ["is", "country", ["DK", "SE"]],
"order_by": [["visitors", "desc"]],
"limit": 10
}'| Field | |
|---|---|
site_id | A site ID, a list of them, or "*" for every site the key can read |
date_range | today, yesterday, 7d, 30d, 90d, month, last_month, year, 12mo, all, or ["2026-01-01", "2026-01-31"] |
metrics | visitors, visits, pageviews, views_per_visit, bounce_rate, visit_duration, events, conversion_rate, time_on_page, scroll_depth |
dimensions | Up to three of path, entry_path, exit_path, hostname, source, channel, referrer, the utm_* fields, country, region, city, browser, os, device, event, prop:<key>, time:hour, time:day, time:week, time:month, and site |
filters | A condition [operator, dimension, values], with is, is_not, contains, contains_not or matches, combined with ["and", [...]], ["or", [...]] and ["not", ...] |
order_by | Up to three [metric or dimension, "asc" or "desc"] |
compare | previous_period or year_over_year |
limit | Rows to return, 1 to 10,000. Defaults to 100 |
Errors
Errors have a status code and a body like this:
{ "error": { "code": "forbidden", "message": "This key can't create sites." } }