Swetrix
Account settings

API keys

Create scoped Swetrix API keys, choose project access, and manage permissions, rotation, and revocation.

API keys connect scripts, dashboards, and integrations to Swetrix. Create a separate key for each integration and grant only the permissions it needs.

Create a key

  1. Open Account Settings → Account → API keys.
  2. Click Create API key to open the editor modal and give it a descriptive name.
  3. Select individual projects, or enable All projects. Selected projects must belong to your account. All projects includes projects you own now and those you create later.
  4. Set each permission group to No access, Read only, or Read & write. Read-only resources have no write option.
  5. Create the key, reveal it with the eye button, and copy it into your integration.

New keys start with swx_. Nothing is granted until you choose permissions. A key cannot access a selected project after you transfer ownership away from your account.

Keep keys in a server-side secret store or environment variable. Never put an account API key in browser tracking code or a public repository.

Permissions

GroupRead onlyRead & write
AnalyticsTraffic, performance, sessions, profiles, SEO, and CAPTCHA statisticsNot available
EventsCustom events and their metadataAlso send tracking events
Project settingsProject lists, settings, and saved viewsAlso create, update, or delete projects and views
FunnelsSaved funnels and funnel analysisAlso manage saved funnels
AnnotationsTimeline annotationsAlso create, edit, or delete annotations
ErrorsError reports and affected sessionsAlso send errors and update error status
Session replaysView and export recordingsAlso record and delete replays
GoalsGoals, conversion statistics, and associated sessionsNot available
Feature flagsConfiguration, statistics, and evaluationsNot available
Revenue (Cloud)Revenue statisticsAlso record transactions
Organisations (Cloud)Organisations and membersAlso manage organisations and members

Project creation requires All projects and Project settings: Read & write. Organisation permissions apply account-wide and also require All projects. Read & write includes read access.

Some responses combine resources and require multiple read permissions:

  • The v1 /log response includes custom events, so it needs Analytics and Events. /log/chart and the v2 traffic summary work with Analytics alone.
  • Session lists and details (including goal sessions) need Analytics, Events, Errors, and Session replays, plus Revenue on Cloud.
  • Profile lists and sessions need Analytics, Events, and Errors. Profile details also need Revenue on Cloud.
  • Project lists and details include saved funnels, so they need Project settings and Funnels.
  • Funnel and journey session lists also need Analytics, Events, and Errors. Error session lists also need Analytics.
  • Queries that filter on custom events or event metadata also require Events.

Permissions apply to API-enabled endpoints. Account credentials, billing, and API-key management still require a signed-in session. Public tracking endpoints continue to accept ordinary tracker requests without a key; when a key is supplied, its permissions and project access are checked. A key does not grant any rights beyond those of its account.

View and edit access

The API keys list shows names, creation dates, project access, and permissions. Secrets are masked. Use the eye button to reveal a key, then copy it. Revealed list entries hide again after a minute or when you leave the browser tab.

Choose Edit permissions to open the editor modal and change a key's name, projects, or permissions without changing its secret. Save your changes, or cancel to discard them.

Project owners can open Project Settings → Access → API keys to see keys with access to that project, including existing unrestricted keys belonging to collaborators. This view shows metadata only; another person's key cannot be revealed, rotated, or revoked there.

Rotate or revoke a key

Rotate key creates a replacement secret with the same permissions and project access. The old secret stops working immediately. Update every integration using it.

For a deployment without interruption, create a second key with the required permissions, switch your integration, then revoke the old key.

Revoke permanently removes the key and immediately stops future authenticated requests. Requests already authorised may finish.

Existing keys

Keys created before scoped API keys retain their original unrestricted access. Their UUID format remains valid. They appear as Unrestricted, and their creation date is shown as predating scoped keys because that date was not recorded.

Rotating an existing key gives it the swx_ prefix while retaining unrestricted access. Editing its permissions replaces unrestricted access with your chosen scopes and projects, without changing its secret.

Use a key

Send the key in the X-Api-Key header. For example, a key with Analytics: Read only and access to the requested project can fetch traffic statistics:

curl 'https://api.swetrix.com/v1/log/chart?pid=YOUR_PROJECT_ID&timeBucket=day&period=7d' \
  -H "X-Api-Key: $SWETRIX_API_KEY"

Invalid or revoked credentials return 401. A valid key without the required permission or project access returns 403. Multi-project requests require access to every requested project. Cloud keys share the account's API rate limit.

See the Statistics API reference for available endpoints.

On this page