Skip to Content
Pageflock

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/v1

It 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.

AccessScopesCan
Read onlystats:read, sites:readRead stats, list sites, check installations
Read and writealso sites:writeAlso 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

MethodPath
GET/workspacesThe key's workspace, as a list
GET/sitesSites in the workspace
POST/sitesCreate a site
GET/sites/:idA site's settings
PATCH/sites/:idChange a site's settings
GET/sites/:id/installInstall code. ?framework=next|react|vue|other
GET/sites/:id/realtimeVisitors right now
GET/sites/:id/installationWhether events arrive. ?check_page=true also loads the home page
POST/moversWhat changed: the biggest risers and fallers
POST/queryRun 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_idA site ID, a list of them, or "*" for every site the key can read
date_rangetoday, yesterday, 7d, 30d, 90d, month, last_month, year, 12mo, all, or ["2026-01-01", "2026-01-31"]
metricsvisitors, visits, pageviews, views_per_visit, bounce_rate, visit_duration, events, conversion_rate, time_on_page, scroll_depth
dimensionsUp 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
filtersA condition [operator, dimension, values], with is, is_not, contains, contains_not or matches, combined with ["and", [...]], ["or", [...]] and ["not", ...]
order_byUp to three [metric or dimension, "asc" or "desc"]
compareprevious_period or year_over_year
limitRows 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." } }

On this page