OpenAPI Specification
openapi: 3.1.0
info:
title: Swetrix Admin Annotations Views API
description: The Swetrix Admin API manages analytics projects, funnels, annotations, project views (segments), and organisations. Supports full CRUD operations for all Swetrix account resources. All requests require authentication via the X-Api-Key header. Rate limit is 600 requests/hour.
version: '1.0'
contact:
name: Swetrix Support
url: https://swetrix.com/contact
termsOfService: https://swetrix.com/privacy
license:
name: AGPL-3.0
url: https://github.com/Swetrix/swetrix-api/blob/main/LICENSE
servers:
- url: https://api.swetrix.com
description: Swetrix Production API
security:
- ApiKeyAuth: []
tags:
- name: Views
description: Manage saved dashboard views (segments)
paths:
/v1/project/{pid}/views:
get:
operationId: listViews
summary: List Project Views
description: Returns all saved dashboard views (segments) for a project. Optional X-Password header for password-protected projects.
tags:
- Views
parameters:
- name: pid
in: path
required: true
schema:
type: string
description: Project ID
responses:
'200':
description: Array of saved views
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ProjectView'
'401':
$ref: '#/components/responses/Unauthorized'
post:
operationId: createView
summary: Create Project View
description: Creates a new saved dashboard view (segment) for a project.
tags:
- Views
parameters:
- name: pid
in: path
required: true
schema:
type: string
description: Project ID
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateViewRequest'
responses:
'201':
description: View created
content:
application/json:
schema:
$ref: '#/components/schemas/ProjectView'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
/v1/project/{pid}/views/{viewId}:
get:
operationId: getView
summary: Get Project View
description: Retrieves a single saved dashboard view configuration.
tags:
- Views
parameters:
- name: pid
in: path
required: true
schema:
type: string
- name: viewId
in: path
required: true
schema:
type: string
responses:
'200':
description: View configuration
content:
application/json:
schema:
$ref: '#/components/schemas/ProjectView'
'401':
$ref: '#/components/responses/Unauthorized'
patch:
operationId: updateView
summary: Update Project View
description: Updates an existing saved view's name, filters, or custom events.
tags:
- Views
parameters:
- name: pid
in: path
required: true
schema:
type: string
- name: viewId
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateViewRequest'
responses:
'200':
description: Updated view
content:
application/json:
schema:
$ref: '#/components/schemas/ProjectView'
'401':
$ref: '#/components/responses/Unauthorized'
delete:
operationId: deleteView
summary: Delete Project View
description: Removes a saved dashboard view.
tags:
- Views
parameters:
- name: pid
in: path
required: true
schema:
type: string
- name: viewId
in: path
required: true
schema:
type: string
responses:
'204':
description: View deleted
'401':
$ref: '#/components/responses/Unauthorized'
components:
responses:
Unauthorized:
description: Unauthorized - missing or invalid API key
content:
application/json:
schema:
type: object
properties:
message:
type: string
BadRequest:
description: Bad request - malformed body or missing required fields
content:
application/json:
schema:
type: object
properties:
message:
type: string
schemas:
ProjectView:
type: object
properties:
id:
type: string
name:
type: string
type:
type: string
enum:
- traffic
- performance
filters:
type: array
items:
type: object
customEvents:
type: array
items:
type: string
CreateViewRequest:
type: object
required:
- name
- type
properties:
name:
type: string
minLength: 1
maxLength: 20
type:
type: string
enum:
- traffic
- performance
filters:
type: array
items:
type: object
customEvents:
type: array
items:
type: string
maxItems: 3
UpdateViewRequest:
type: object
properties:
name:
type: string
maxLength: 20
filters:
type: array
items:
type: object
customEvents:
type: array
items:
type: string
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-Api-Key
description: API key from Swetrix account settings (https://swetrix.com/user-settings)
externalDocs:
description: Swetrix Admin API Documentation
url: https://swetrix.com/docs/admin-api