Skip to Content
Swetrix
On this page

Admin API reference

Use the Swetrix Admin API to manage projects and automate analytics administration with authenticated requests and documented parameters.

Swetrix provides the ability to control your projects (and soon your account) via an API as well.

Each request must be authenticated with an API key using X-Api-Key HTTP header. You can obtain an API key in your Swetrix account settings.

Rate limit for the API depends on your plan. You can find more information on the billing page. The current rate limits are:

  • Standard plan: 300 requests per hour;
  • Plus plan: 6000 requests per hour;
  • Enterprise plan: custom, and may be unlimited on demand.

If you have special needs for more requests, please contact us to request more capacity.

Concepts

Retrying a create request

POST /v1/project, POST /v1/project/funnel, and POST /v1/project/annotation accept an optional Idempotency-Key header. Generate a key once for each intended creation, before sending the request. A UUID works well. Keys accept 1–128 ASCII letters, digits, periods, underscores, colons, or hyphens.

For example, send this request again with the same key and body if the connection drops. A completed retry returns the original 201 response and annotation ID, provided the caller still has access.

curl 'https://api.swetrix.com/v1/project/annotation' \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H 'Idempotency-Key: 1cd79c24-7e63-4f65-ab31-b2b9e052c390' \
  -H 'Content-Type: application/json' \
  -d '{"pid":"WvZCYTrOPzSK","date":"2026-11-04","text":"Released the new checkout"}'

Keys are scoped to the authenticated account and create endpoint for 24 hours. Reusing a key with different request data returns 409 Conflict. For an operation still in progress, retry later with its original key. After the 24-hour window the same key can create a new resource. Requests without the header follow the existing create behavior.

Community Edition coordinates creates on its ClickHouse server. Point all API replicas at the same ClickHouse node for keyed writes. If an API process stops after reserving a key, a retry can recover the original response once the resource is present. If the write cannot be confirmed, the key can return 409 for the remainder of the window. Check for the resource before starting another creation.

Projects manipulation

'Create project' payload

NameTypeRequiredDescription
namestringtrueA display name for your project, max length is 50 chars.
isCaptchabooleanfalse(Only supported when creating a new project). Set to true if your project is a CAPTCHA project. false by default.
isPasswordProtectedbooleanfalseSet to true if your project's dashboard should be password protected. false by default.
passwordstringfalseRequired only if isPasswordProtected is set to true. That is the password unauthorised people will have to enter to access your project's dashboard.
organisationIdstringfalseOrganisation you want to add this project to. You must be an owner or admin of the organisation to add a project to it.

'Update project' payload

NameTypeDescription
namestringA display name for your project, max length is 50 chars.
isCaptchaboolean(Only supported when creating a new project). Set to true if your project is a CAPTCHA project. false by default.
activebooleanSet to true to collect analytics data. Set to false to stop collecting new events while keeping existing data and settings available.
publicbooleanSet to true if your project should have a publicly available dashboard.
isPasswordProtectedbooleanSet to true if your project's dashboard should be password protected. false by default.
passwordstringRequired only if isPasswordProtected is set to true. That is the password unauthorised people will have to enter to access your project's dashboard.
originsArray<string>Domains allowed to send analytics using this Project ID. Traffic from all other domains is blocked. Supports wildcards, for example: ['cornell.edu', 'app.example.com', '*.gov.uk']. An empty array allows all domains.
ipBlacklistArray<string>IP addresses or CIDR ranges whose traffic should be ignored for this project. Useful for excluding your own visits. For example: ['172.126.10.16', '192.168.0.1/32', '::1'].
ipWhitelistArray<string>IP addresses or CIDR ranges that are never flagged by bot protection. Useful for server-side event tracking. For example: ['172.126.10.16', '192.168.0.1/32', '::1'].
botsProtectionLeveloff, basic, or strictChoose how aggressively bot and automated traffic should be filtered. off tracks all traffic, basic filters common bots, and strict adds stronger automated-traffic checks. basic by default.
organisationIdstringOrganisation you want to add this project to. You must be an owner or admin of the organisation to add a project to it.

Organisations manipulation

'Create organisation' payload

NameTypeRequiredDescription
namestringtrueA display name for your organisation, max length is 50 chars.

'Invite member' payload

NameTypeRequiredDescription
emailstringtrueThe email address of the user you want to invite.
roleowner or admin or viewertrueThe role to assign to the invited user.

'Update member role' payload

NameTypeRequiredDescription
roleowner or admin or viewertrueThe new role to assign to the member.

Funnels manipulation

'Create funnel' payload

NameTypeRequiredDescription
namestringtrueA display name for your funnel, max length is 50 chars.
pidstringtrueThe Project ID the funnel belongs to.
stepsArray<string>trueAn array of paths for the funnel steps (e.g., ['/', '/signup', '/dash']).

'Update funnel' payload

NameTypeRequiredDescription
idstringtrueThe ID of the funnel to update.
pidstringtrueThe Project ID the funnel belongs to.
namestringtrueA display name for your funnel, max length is 50 chars.
stepsArray<string>trueAn array of paths for the funnel steps (e.g., ['/', '/signup', '/dash']).

Annotations manipulation

'Create annotation' payload

NameTypeRequiredDescription
pidstringtrueThe Project ID the annotation belongs to.
datestringtrueDate of the annotation (YYYY-MM-DD).
textstringtrueAnnotation text (max 120 characters).

'Update annotation' payload

NameTypeRequiredDescription
idstringtrueThe ID of the annotation to update.
pidstringtrueThe Project ID the annotation belongs to.
datestringfalseDate of the annotation (YYYY-MM-DD).
textstringfalseAnnotation text (max 120 characters).

Project views (Segments) manipulation

Project views are the API representation of Segments — saved combinations of dashboard filters and custom event metrics that users can switch between from the dashboard.

Filter object

The filters field on a view is an array of filter objects with the following shape:

NameTypeRequiredDescription
columnstringtrueThe traffic column to filter on. One of: cc, rg, ct, host, pg, lc, br, brv, os, osv, dv, ref, so, me, ca, te, co. Unsupported columns are stripped out.
filterstringtrueThe value to match against.
isExclusivebooleantrueIf true, rows matching filter are excluded; otherwise only matching rows are kept.
isContainsbooleanfalseIf true, filter is treated as a substring match instead of an exact match.

Custom event object

Each entry in customEvents describes a custom-event metric to render on the dashboard alongside the view. Up to 3 custom events can be attached to a view.

NameTypeRequiredDescription
customEventNamestringtrueName of the custom event to aggregate (1–100 chars).
metricKeystringtrueDisplay key for the metric on the dashboard (1–100 chars).
metaKeystringfalseOptional event metadata key to group on (max 100 chars).
metaValuestringfalseOptional event metadata value to filter on (max 100 chars).
metaValueTypestring or integer or floattrueHow to interpret metaValue when aggregating.

'Create project view' payload

NameTypeRequiredDescription
namestringtrueA display name for the view (1–20 chars).
typetraffic or performancetrueWhich dashboard the view applies to. Cannot be changed after creation.
filtersArray<Filter>falseFilters to pre-apply when the view is selected. See Filter object.
customEventsArray<CustomEvent>falseCustom-event metrics to display with the view. See Custom event object. Max 3.

'Update project view' payload

All fields are optional; only those present are updated. The view type cannot be changed.

NameTypeDescription
namestringA display name for the view (1–20 chars).
filtersArray<Filter>Replaces the stored filters. See Filter object.
customEventsArray<CustomEvent>Replaces the stored custom-event metrics. See Custom event object. Max 3.

Endpoints

GET /v1/project/directory

Find projects by name or ID with the projects:read permission. Each result contains the project ID, name, website URL (or null), collection status (active), and dashboard visibility (public). A scoped key sees only projects its owner currently owns and the key is allowed to read.

Query parameterDescription
searchCase-insensitive substring of a name or ID, up to 100 characters.
idExact 12-character project ID. An unknown or inaccessible ID returns an empty page.
takeNumber of results to return, from 1 to 100. Defaults to 25.
skipNumber of results to skip, from 0 to 50,000. Defaults to 0.

Results are ordered by name and then ID. page_total is the number of results on this page. total counts all matches visible to the caller.

Find a project
curl 'https://api.swetrix.com/v1/project/directory?search=bakery&take=5' \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"
Response (200 OK)
{
  "results": [
    {
      "id": "WvZCYTrOPzSK",
      "name": "Bakery",
      "websiteUrl": "https://bakery.example",
      "active": true,
      "public": false
    }
  ],
  "page_total": 1,
  "total": 1
}

GET /v1/project

List projects with dashboard data, including saved funnels. Scoped keys need both projects:read and funnels:read.

Request
curl -i -X GET https://api.swetrix.com/v1/project \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

GET /v1/project/:id

Read the full dashboard details for a project. Scoped keys need both projects:read and funnels:read. Use GET /v1/project/directory?id=PROJECT_ID for basic project information.

Request
curl -i -X GET https://api.swetrix.com/v1/project/WvZCYTrOPzSK \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

POST /v1/project

This endpoint allows you to create a new project.

Request
curl -i -X POST https://api.swetrix.com/v1/project \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"name": "PASSWORD PROTECTED","isPasswordProtected": true,"password": "12345678"}'
Response (201 Created)
{
  "id": "WvZCYTrOPzSK",
  "name": "PASSWORD PROTECTED",
  "origins": [],
  "isPasswordProtected": true,
  "ipBlacklist": null,
  "ipWhitelist": null,
  "captchaSecretKey": null,
  "active": true,
  "public": false,
  "isTransferring": false,
  "isAnalyticsProject": true,
  "isCaptchaProject": false,
  "isCaptchaEnabled": false,
  "botsProtectionLevel": "basic",
  "created": "2023-10-07T10:23:09.000Z",
  "organisation": {
    "id": "ORG_ID"
  }
}

PUT /v1/project/:id

This endpoint allows you to edit an existing project.

Request
curl -i -X PUT https://api.swetrix.com/v1/project/WvZCYTrOPzSK \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"origins": ["example.com", "example.co.uk"],"public": true}'
Response (200 OK)
{
  "id": "WvZCYTrOPzSK",
  "name": "PASSWORD PROTECTED",
  "origins": ["example.com", "example.co.uk"],
  "ipBlacklist": null,
  "ipWhitelist": null,
  "active": true,
  "public": true,
  "isTransferring": false,
  "isAnalyticsProject": true,
  "isCaptchaProject": false,
  "isCaptchaEnabled": false,
  "captchaSecretKey": null,
  "botsProtectionLevel": "basic",
  "created": "2023-10-07T10:23:09.000Z",
  "isPasswordProtected": true,
  "organisation": {
    "id": "ORG_ID"
  }
}

DELETE /v1/project/:id

This endpoint allows you to delete a project.

Request
curl -i -X DELETE https://api.swetrix.com/v1/project/WvZCYTrOPzSK \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json"
Response (204 No Content)

POST /v1/project/:id/pin

Pin a project to the top of the dashboard.

Request
curl -i -X POST https://api.swetrix.com/v1/project/WvZCYTrOPzSK/pin \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

DELETE /v1/project/:id/pin

Unpin a project from the top of the dashboard.

Request
curl -i -X DELETE https://api.swetrix.com/v1/project/WvZCYTrOPzSK/pin \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

PATCH /v1/project/:id/organisation

This endpoint allows you to assign a project to an organisation, or unassign it from an organisation. To unassign a project from an organisation, don't pass the request body.

Request
curl -i -X PATCH https://api.swetrix.com/v1/project/WvZCYTrOPzSK/organisation \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"organisationId": "ORG_ID"}'
Response (204 No Content)

GET /v1/project/funnels/:pid

Get all funnels for a specific project.

Request
curl -i -X GET https://api.swetrix.com/v1/project/funnels/WvZCYTrOPzSK \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

POST /v1/project/funnel

Create a new funnel.

Request
curl -i -X POST https://api.swetrix.com/v1/project/funnel \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"name": "Sign up","pid": "WvZCYTrOPzSK", "steps": ["/", "/signup"]}'

PATCH /v1/project/funnel

Update an existing funnel.

Request
curl -i -X PATCH https://api.swetrix.com/v1/project/funnel \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"id": "FUNNEL_ID", "name": "Sign up 2", "pid": "WvZCYTrOPzSK", "steps": ["/", "/signup"]}'

DELETE /v1/project/funnel/:id/:pid

Delete a funnel.

Request
curl -i -X DELETE https://api.swetrix.com/v1/project/funnel/FUNNEL_ID/WvZCYTrOPzSK \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

GET /v1/project/annotations/:pid

Get all annotations for a specific project.

Request
curl -i -X GET https://api.swetrix.com/v1/project/annotations/WvZCYTrOPzSK \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

POST /v1/project/annotation

Create a new annotation.

Request
curl -i -X POST https://api.swetrix.com/v1/project/annotation \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"text": "Marketing campaign", "pid": "WvZCYTrOPzSK", "date": "2023-10-01"}'

PATCH /v1/project/annotation

Update an existing annotation.

Request
curl -i -X PATCH https://api.swetrix.com/v1/project/annotation \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"id": "ANNOTATION_ID", "pid": "WvZCYTrOPzSK", "text": "Updated text"}'

DELETE /v1/project/annotation/:id/:pid

Delete an annotation.

Request
curl -i -X DELETE https://api.swetrix.com/v1/project/annotation/ANNOTATION_ID/WvZCYTrOPzSK \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

GET /v1/project/:pid/views

List all Segments (project views) for a project. For password-protected projects, pass the dashboard password via the X-Password header.

Request
curl -i -X GET https://api.swetrix.com/v1/project/WvZCYTrOPzSK/views \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"
Response (200 OK)
[
  {
    "id": "9d8b8b2f-7c7d-4e9c-b7c5-1f3b6f0a1d2e",
    "projectId": "WvZCYTrOPzSK",
    "name": "US Mobile Traffic",
    "type": "traffic",
    "filters": [
      { "column": "cc", "filter": "US", "isExclusive": false },
      { "column": "dv", "filter": "mobile", "isExclusive": false }
    ],
    "customEvents": [],
    "createdAt": "2026-04-01T10:23:09.000Z",
    "updatedAt": "2026-04-01T10:23:09.000Z"
  }
]

GET /v1/project/:pid/views/:viewId

Get a single project view. For password-protected projects, pass the dashboard password via the X-Password header.

Request
curl -i -X GET https://api.swetrix.com/v1/project/WvZCYTrOPzSK/views/VIEW_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

POST /v1/project/:pid/views

Create a new project view. Requires admin or owner access on the project.

Request
curl -i -X POST https://api.swetrix.com/v1/project/WvZCYTrOPzSK/views \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "US Mobile Traffic",
    "type": "traffic",
    "filters": [
      { "column": "cc", "filter": "US", "isExclusive": false },
      { "column": "dv", "filter": "mobile", "isExclusive": false }
    ]
  }'
Response (201 Created)
{
  "id": "9d8b8b2f-7c7d-4e9c-b7c5-1f3b6f0a1d2e",
  "projectId": "WvZCYTrOPzSK",
  "name": "US Mobile Traffic",
  "type": "traffic",
  "filters": "[{\"column\":\"cc\",\"filter\":\"US\",\"isExclusive\":false},{\"column\":\"dv\",\"filter\":\"mobile\",\"isExclusive\":false}]",
  "createdAt": "2026-04-01T10:23:09.000Z",
  "updatedAt": "2026-04-01T10:23:09.000Z"
}

PATCH /v1/project/:pid/views/:viewId

Update an existing project view. Requires admin or owner access on the project. The view type cannot be changed.

Request
curl -i -X PATCH https://api.swetrix.com/v1/project/WvZCYTrOPzSK/views/VIEW_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "US Mobile (paid)",
    "filters": [
      { "column": "cc", "filter": "US", "isExclusive": false },
      { "column": "dv", "filter": "mobile", "isExclusive": false },
      { "column": "so", "filter": "google", "isExclusive": false }
    ]
  }'

DELETE /v1/project/:pid/views/:viewId

Delete a project view. Requires admin or owner access on the project.

Request
curl -i -X DELETE https://api.swetrix.com/v1/project/WvZCYTrOPzSK/views/VIEW_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"
Response (204 No Content)

GET /v1/organisation

List all organisations you are a member of.

Request
curl -i -X GET https://api.swetrix.com/v1/organisation \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

GET /v1/organisation/:orgId

Get details of a specific organisation.

Request
curl -i -X GET https://api.swetrix.com/v1/organisation/ORG_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

POST /v1/organisation

Create a new organisation.

Request
curl -i -X POST https://api.swetrix.com/v1/organisation \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"name": "My Organisation"}'

PATCH /v1/organisation/:orgId

Update an organisation.

Request
curl -i -X PATCH https://api.swetrix.com/v1/organisation/ORG_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"name": "My Updated Organisation"}'

DELETE /v1/organisation/:orgId

Delete an organisation. You must be the owner to do this.

Request
curl -i -X DELETE https://api.swetrix.com/v1/organisation/ORG_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

POST /v1/organisation/:orgId/invite

Invite a new member to the organisation.

Request
curl -i -X POST https://api.swetrix.com/v1/organisation/ORG_ID/invite \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"email": "friend@example.com", "role": "viewer"}'

PATCH /v1/organisation/member/:memberId

Update a member's role.

Request
curl -i -X PATCH https://api.swetrix.com/v1/organisation/member/MEMBER_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"role": "admin"}'

DELETE /v1/organisation/member/:memberId

Remove a member from the organisation.

Request
curl -i -X DELETE https://api.swetrix.com/v1/organisation/member/MEMBER_ID \
  -H "X-Api-Key: ${SWETRIX_API_KEY}"

Status and error codes

200 OK

Typical successful response when updating a project or account settings.

201 Created

The request was successful and the project was created.

204 No Content

The request was successful and there is no data to return. Usually this code is sent when deleting an entity.

400 Bad Request

This error is usually returned when the request body is malformed (for example, the pid parameter is missing or invalid).

500 Internal Server Error

This error is usually returned when the server is unable to process the request due to a temporary problem (for example, the database is unavailable). If you receive this error, please try again later. If the problem persists, please contact us.

On this page