Documentation

Analytics API

Everything the SDK and the dashboard do is available over HTTP, so you can send events from any language and read your numbers from your own tools.

Base address and authentication

The service is at https://api.analytics.vantrex.cloud and every path starts with /v1. Responses are JSON.

ForAuthenticate with
Sending eventsA project key in Authorization: Bearer vtxa_sk_…. A publishable key may also go in the request body as key, which is how browsers send beacons. A secret key is refused in a body.
Managing projects and reading dataA Vantrex access token with the analytics scope, as Authorization: Bearer vtx_…. Create one under Account, Tokens.

Sending events

POST /v1/collect

Sends one event, or up to 100 in events, with a body of at most 64 KB.

curl https://api.analytics.vantrex.cloud/v1/collect \
  -H "Authorization: Bearer $VANTREX_ANALYTICS_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "login",
    "status": "ok",
    "user_id": "u_123",
    "email": "ann@example.com",
    "ip": "203.0.113.9",
    "user_agent": "Mozilla/5.0 …",
    "duration_ms": 240
  }'
FieldMeaning
typelogin, signup, click, identify or heartbeat.
statusok (default) or error.
error_codeWhy it failed, up to 64 characters.
user_id, name, emailThe person. Only the fields the project collects are stored.
visitor_idLinks the person to the browser tab they have open (the vtxa_vid cookie).
ip, user_agentThe end user's address and browser, when you send from a server. Used for country, browser and device; the address is not stored.
duration_msHow long the attempt took.
tsWhen it happened, RFC 3339, up to 7 days in the past. Secret key only.
deployment_idWhich deployment was running, for linked projects.
propsExtra values: at most 20 keys and 2 KB.

The answer is 202 with {"accepted": n}. A publishable key can send only click and heartbeat; login, signup and identify need the secret key.

POST /v1/heartbeat

Says a visitor is on a page: {"visitor_id": "…", "path": "/pricing"}, or with "end": true when they leave. Answers 204. A visitor counts as online for two minutes after their last heartbeat.

POST /v1/identify

Secret key only. Sends user_id, optional name and email, and the visitor_id to attach them to. Answers 204.

Reading data

These need an access token with the analytics scope (read for reads, write for changes). Another account's projects answer 404.

RequestReturns
GET /v1/projectsYour analytics projects, with how many people are online now.
POST /v1/projectsCreates one from name, url, optional collect_fields, allowed_origins and deploy_project_id. The reply includes the secret_key, once.
GET /v1/projects/{id}One project.
PATCH /v1/projects/{id}Changes its name, address, collected fields, allowed origins or deploy link.
DELETE /v1/projects/{id}Deletes it and its events.
POST /v1/projects/{id}/keys/rotateCreates a new secret key; the old one works for 10 more minutes.
GET /v1/stats/logins, /signups, /clicksTotals, a time series, countries, browsers, systems, devices and error codes. Query: project (omit for all), range (24h, 7d, 30d, 90d), status (ok or error), deployment (one linked project only).
GET /v1/activePeople online now, with country, browser, page and, if collected, name or email. Query: project.
GET /v1/overviewThe numbers behind the dashboard home.
GET /v1/projects/{id}/exportEvery stored event, as JSON lines or with ?format=csv.
curl "https://api.analytics.vantrex.cloud/v1/stats/logins?range=7d&status=error" \
  -H "Authorization: Bearer $VTX_TOKEN"

Rate limits and errors

WhatLimit
Browser events, per visitor address240 a minute
Heartbeats, per visitor60 a minute
Browser events, per project3 000 a minute
Server events, per project6 000 a minute
Events per request100, in at most 64 KB
Analytics projects per account20

Past a limit the answer is 429 with a Retry-After header in seconds. Other errors use the usual codes with a JSON body such as {"error": "invalid key"}: 400 for a bad request, 401 for a missing or wrong key, 403 for an event type the key may not send or an origin that is not allowed, 404 for something that is not yours.