viakite
Dashboard

API/Basics/Authentication

Authentication

Secret keys, scopes and regions

Your server signs in to the API with a secret key. Each key belongs to one organization, can do only what its scopes allow, and reaches only the projects you pick. Keep secret keys on your servers; public keys are the ones that go in the browser.

Two kinds of key

Create both in Settings → API keys with New key, or with POST/v1/orgs/{org}/keys.

Public keySecret key
Looks likepk_live_us_…sk_live_us_…
Where it goesThe script tag, the SDK, your appYour server, a job, your CI
What it can doSend events to one projectRead and change data, limited by its scopes and projects
Safe in the browserYesNo, never
Shown again laterYes, alwaysNo, only once, when created or rotated

A key reads as <type>_<mode>_<region>_<32 characters>. The mode is live or test, and the region is where the organization's data lives (us, the United States, today). Lists of keys show only the start, such as sk_live_us_ab12, so you can tell keys apart without seeing the secret.

You can create pk_test_… and sk_test_… keys. Events sent with a test key are stored apart from live data and left out of every report; they show only in the event debugger on the Install page, marked test.

Send the key

Put the secret key in the Authorization header as a bearer token, on every request:

terminal
1curl https://api.vk.viabio.me/v1/orgs/org_…/projects \
2 -H "Authorization: Bearer sk_live_us_…"

The same key works on the control plane (api.vk.viabio.me) and on its region's data plane (us.api.vk.viabio.me). A request with no key, a key that doesn't exist, a revoked key, a rotated key past its 24 hours, or a public key gets 401 unauthorized.

A few endpoints are for a signed-in person only, such as creating an organization or reading /v1/me. A key gets 403 session_required there.

Scopes

A secret key needs at least one scope. Scopes are the same permissions that roles give to members, so a key can do exactly what a member with those permissions can. You can only give a key the scopes you have yourself.

ScopeLets the key
analytics.viewRun queries and reports, realtime, funnels, journeys
analytics.manageManage goals, funnels, segments and annotations
analytics.exportExport analytics data
analytics.sharePublish public pages and share tokens
analytics.sendSend server-side events to POST /v1/events
projects.createCreate projects
projects.settingsChange project settings
projects.deleteDelete projects
keys.viewSee API keys
keys.createCreate and change API keys
keys.revokeRevoke API keys
org.settingsChange the organization's settings and manage webhooks
members.viewSee members, groups and roles
members.inviteInvite people and answer join requests
members.removeRemove members
members.rolesGive roles and groups to members
roles.manageCreate and edit custom roles and groups
alerts.view, alerts.manage, alerts.muteSee, change and mute alerts
audit.view, audit.exportSee and export the audit log
billing.view, billing.manageSee or change the plan, usage and invoices

The list also holds org.delete, org.domains, org.sso, and scopes for Monitoring, Logs and Updates, which have no endpoints yet. The scope picker in Settings → API keys shows every one. A key that lacks the scope an endpoint needs gets 403 forbidden. Each endpoint in the reference says which scope it needs.

Give each key the fewest scopes it needs. A job that reads numbers into your own dashboard needs only analytics.view.

Projects a key can reach

A secret key reaches every project in its organization, or only the projects you pick (up to 100). For a project the key can't reach, and for anything in another organization, the API answers 404 not_found, the same as for a project that doesn't exist, so a key never learns what is outside its reach.

Change a key's name, scopes or projects with PATCH/v1/orgs/{org}/keys/{key}. The change applies to the next request.

Regions

Your data stays in its region, and the key says which: sk_live_us_… is the United States. Send data requests to that region's data host, which GET /v1/projects/{project} returns in endpoints.api.

When more regions open, a data request sent to the wrong region will get 421 with the code wrong_region and the right address in details:

response.json
1{
2 "error": {
3 "code": "wrong_region",
4 "message": "This project's data lives in another region",
5 "details": { "region": "eu", "api": "https://eu.api.vk.viabio.me" }
6 }
7}

Not sent today

Only the United States region (us) exists, so the API never answers 421 wrong_region yet. Read the data host from the project's endpoints now, and your code keeps working when a second region opens.

Public keys

A public key only sends events, to the one project it belongs to, through POST /v1/events on the ingest host. It can't read a report, list anything or change a setting; sent as a bearer token to any other endpoint it gets 401 unauthorized. That is why it is safe in your page's HTML.

To stop a public key from being used on other sites, set the project's allowed_hostnames with PATCH /v1/projects/{project}/settings. Events from other hostnames are dropped. There is no dashboard screen for these settings yet.

Keep secret keys safe

  • Keep them in environment variables or your secret manager, never in your repository.
  • Never send a secret key to a browser or ship it in a mobile app. Call the API from your server and pass on only what the page needs.
  • Use one key per service, so you can rotate or revoke one without touching the rest. Last used in Settings → API keys shows which keys are still in use.
  • Every key created, changed, rotated or revoked is in the audit log.

Rotate and revoke

Rotate a key when you replace it on a schedule, or when someone who saw it leaves. POST/v1/orgs/{org}/keys/{key}/rotate returns a new key with the same scopes and projects. The old key keeps working for 24 hours, so you can deploy the new one without downtime; the old key's expires_at says when it stops.

Revoke a key when it may have leaked. DELETE/v1/orgs/{org}/keys/{key} stops it at once, and the next request with it gets 401 unauthorized.

Rate limits

Each secret key may make 10 requests a second, or up to 100 when a paid organization raises it. Every answer carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset; a request over the limit gets 429 rate_limited with Retry-After. See API keys.

Next steps