Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
// Generated by `pnpm openapi:contracts`. Do not edit directly.
import type { ZodOpenApiOperationObject } from 'zod-openapi';
import { defineOperation } from '@/openapi/operation';
const operation1 = defineOperation({
method: 'delete',
path: '/api/users/{userId}',
audience: 'public',
auth: 'bearer',
operation: {
operationId: 'deleteUser',
summary: 'Delete a user',
description:
'Deletes the specified user account. The current user cannot delete their own account through this operation.',
tags: ['Users'],
parameters: [
{
name: 'userId',
in: 'path',
required: true,
schema: {
type: 'string',
},
description: 'ID of the associated user.',
},
],
responses: {
'200': {
description: 'The operation completed successfully.',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
ok: {
const: true,
description: 'Whether the operation succeeded.',
},
},
required: ['ok'],
},
},
},
},
'400': {
description: 'Bad request.',
content: {
'application/json': {
example: {
error: {
message: 'Bad request.',
code: 'bad-request',
status: 400,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
'401': {
description: 'Unauthorized.',
content: {
'application/json': {
example: {
error: {
message: 'Unauthorized.',
code: 'unauthorized',
status: 401,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
},
} as ZodOpenApiOperationObject,
});
const operation2 = defineOperation({
method: 'get',
path: '/api/users/{userId}',
audience: 'public',
auth: 'bearer-or-share',
operation: {
operationId: 'getUser',
summary: 'Get a user',
description:
'Returns details for the specified user account when the caller has permission to view it.',
tags: ['Users'],
parameters: [
{
name: 'userId',
in: 'path',
required: true,
schema: {
type: 'string',
},
description: 'ID of the associated user.',
},
],
responses: {
'200': {
description: 'The operation completed successfully.',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
twoFactorAuth: {
type: 'object',
properties: {
isEnabled: {
type: 'boolean',
description: 'Whether two-factor authentication is enabled.',
},
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
secret: {
type: 'string',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
},
required: ['isEnabled', 'id', 'userId', 'secret', 'createdAt', 'updatedAt'],
},
twoFactorRateLimit: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
attempts: {
type: 'number',
},
lockedUntil: {
type: 'string',
format: 'date-time',
description: 'Time until which further authentication attempts are blocked.',
},
},
required: ['id', 'userId', 'updatedAt', 'attempts', 'lockedUntil'],
},
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
username: {
type: 'string',
description: 'Username of the account.',
},
password: {
type: 'string',
description: 'Password used to authenticate the account.',
},
role: {
type: 'string',
description: 'Permission role assigned to the user.',
},
twoFactorRequired: {
type: 'boolean',
description: 'Whether two-factor authentication is required.',
},
websites: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
deletedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was deleted, if applicable.',
},
createdBy: {
type: 'string',
description: 'ID of the user who created the resource.',
},
name: {
type: 'string',
description: 'Display name of the resource.',
},
domain: {
type: 'string',
description: 'Domain name associated with the resource.',
},
resetAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the website analytics were last reset.',
},
teamId: {
type: 'string',
description: 'ID of the associated team.',
},
recorderEnabled: {
type: 'boolean',
description: 'Whether recording is enabled for the website.',
},
replayConfig: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{
type: 'object',
properties: {},
additionalProperties: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
},
},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
description: 'Session replay and heatmap recording configuration.',
},
},
required: [
'id',
'userId',
'createdAt',
'updatedAt',
'deletedAt',
'createdBy',
'name',
'domain',
'resetAt',
'teamId',
'recorderEnabled',
'replayConfig',
],
},
},
createdBy: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
deletedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was deleted, if applicable.',
},
createdBy: {
type: 'string',
description: 'ID of the user who created the resource.',
},
name: {
type: 'string',
description: 'Display name of the resource.',
},
domain: {
type: 'string',
description: 'Domain name associated with the resource.',
},
resetAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the website analytics were last reset.',
},
teamId: {
type: 'string',
description: 'ID of the associated team.',
},
recorderEnabled: {
type: 'boolean',
description: 'Whether recording is enabled for the website.',
},
replayConfig: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{
type: 'object',
properties: {},
additionalProperties: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
},
},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
description: 'Session replay and heatmap recording configuration.',
},
},
required: [
'id',
'userId',
'createdAt',
'updatedAt',
'deletedAt',
'createdBy',
'name',
'domain',
'resetAt',
'teamId',
'recorderEnabled',
'replayConfig',
],
},
description: 'ID of the user who created the resource.',
},
links: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
deletedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was deleted, if applicable.',
},
name: {
type: 'string',
description: 'Display name of the resource.',
},
teamId: {
type: 'string',
description: 'ID of the associated team.',
},
url: {
type: 'string',
description: 'URL associated with the resource.',
},
slug: {
type: 'string',
description: 'URL slug used to access the resource.',
},
},
required: [
'id',
'userId',
'createdAt',
'updatedAt',
'deletedAt',
'name',
'teamId',
'url',
'slug',
],
},
description: 'Tracked links associated with the user.',
},
pixels: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
deletedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was deleted, if applicable.',
},
name: {
type: 'string',
description: 'Display name of the resource.',
},
teamId: {
type: 'string',
description: 'ID of the associated team.',
},
slug: {
type: 'string',
description: 'URL slug used to access the resource.',
},
},
required: [
'id',
'userId',
'createdAt',
'updatedAt',
'deletedAt',
'name',
'teamId',
'slug',
],
},
description: 'Tracking pixels associated with the user.',
},
teams: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
role: {
type: 'string',
description: 'Permission role assigned to the user.',
},
teamId: {
type: 'string',
description: 'ID of the associated team.',
},
},
required: ['id', 'userId', 'createdAt', 'updatedAt', 'role', 'teamId'],
},
description: 'Teams associated with the user.',
},
reports: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
name: {
type: 'string',
description: 'Display name of the resource.',
},
type: {
type: 'string',
},
description: {
type: 'string',
description: 'Description of the resource.',
},
parameters: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{
type: 'object',
properties: {},
additionalProperties: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
},
},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
description: 'Configuration parameters for the resource.',
},
websiteId: {
type: 'string',
description: 'ID of the website.',
},
},
required: [
'id',
'userId',
'createdAt',
'updatedAt',
'name',
'type',
'description',
'parameters',
'websiteId',
],
},
description: 'Saved reports associated with the user.',
},
boards: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
updatedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was last updated.',
},
name: {
type: 'string',
description: 'Display name of the resource.',
},
teamId: {
type: 'string',
description: 'ID of the associated team.',
},
type: {
type: 'string',
},
description: {
type: 'string',
description: 'Description of the resource.',
},
parameters: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{
type: 'object',
properties: {},
additionalProperties: {
anyOf: [
{
type: 'string',
},
{
type: 'number',
},
{
const: false,
},
{
const: true,
},
{},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
},
},
{
type: 'object',
properties: {
length: {
type: 'number',
},
},
required: ['length'],
},
],
description: 'Configuration parameters for the resource.',
},
},
required: [
'id',
'userId',
'createdAt',
'updatedAt',
'name',
'teamId',
'type',
'description',
'parameters',
],
},
description: 'Boards associated with the user.',
},
twoFactorBackupCodes: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
codeHash: {
type: 'string',
},
used: {
type: 'boolean',
},
},
required: ['id', 'userId', 'createdAt', 'codeHash', 'used'],
},
},
twoFactorOtpUseds: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
otp: {
type: 'string',
},
expiresAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the credential expires.',
},
},
required: ['id', 'userId', 'otp', 'expiresAt'],
},
},
apiKeys: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
userId: {
type: 'string',
description: 'ID of the associated user.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
name: {
type: 'string',
description: 'Display name of the resource.',
},
keyHash: {
type: 'string',
},
keyPrefix: {
type: 'string',
description: 'Visible prefix used to identify an API key.',
},
lastUsedAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the credential was last used.',
},
},
required: [
'id',
'userId',
'createdAt',
'name',
'keyHash',
'keyPrefix',
'lastUsedAt',
],
},
description: 'API keys associated with the user.',
},
_count: {
type: 'object',
properties: {
websites: {
type: 'number',
},
createdBy: {
type: 'number',
description: 'ID of the user who created the resource.',
},
links: {
type: 'number',
description: 'Tracked links associated with the user.',
},
pixels: {
type: 'number',
description: 'Tracking pixels associated with the user.',
},
teams: {
type: 'number',
description: 'Teams associated with the user.',
},
reports: {
type: 'number',
description: 'Saved reports associated with the user.',
},
boards: {
type: 'number',
description: 'Boards associated with the user.',
},
twoFactorAuth: {
type: 'number',
},
twoFactorBackupCodes: {
type: 'number',
},
twoFactorOtpUseds: {
type: 'number',
},
twoFactorRateLimit: {
type: 'number',
},
apiKeys: {
type: 'number',
description: 'API keys associated with the user.',
},
},
required: [
'websites',
'createdBy',
'links',
'pixels',
'teams',
'reports',
'boards',
'twoFactorAuth',
'twoFactorBackupCodes',
'twoFactorOtpUseds',
'twoFactorRateLimit',
'apiKeys',
],
},
},
required: [
'twoFactorAuth',
'twoFactorRateLimit',
'id',
'createdAt',
'username',
'password',
'role',
'twoFactorRequired',
'websites',
'createdBy',
'links',
'pixels',
'teams',
'reports',
'boards',
'twoFactorBackupCodes',
'twoFactorOtpUseds',
'apiKeys',
'_count',
],
},
},
},
},
'401': {
description: 'Unauthorized.',
content: {
'application/json': {
example: {
error: {
message: 'Unauthorized.',
code: 'unauthorized',
status: 401,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
},
} as ZodOpenApiOperationObject,
});
const operation3 = defineOperation({
method: 'post',
path: '/api/users/{userId}',
audience: 'public',
auth: 'bearer',
operation: {
operationId: 'updateUser',
summary: 'Update a user',
description: "Updates a user's password. Administrators can also change the username and role.",
tags: ['Users'],
parameters: [
{
name: 'userId',
in: 'path',
required: true,
schema: {
type: 'string',
},
description: 'ID of the associated user.',
},
],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
username: {
type: 'string',
maxLength: 255,
description: 'Username of the account.',
},
password: {
type: 'string',
minLength: 8,
maxLength: 255,
description: 'Password used to authenticate the account.',
},
role: {
type: 'string',
enum: ['admin', 'user', 'view-only'],
description: 'Permission role assigned to the user.',
},
},
},
},
},
},
responses: {
'200': {
description: 'The operation completed successfully.',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Unique identifier of the resource.',
},
createdAt: {
type: 'string',
format: 'date-time',
description: 'Date and time the record was created.',
},
username: {
type: 'string',
description: 'Username of the account.',
},
role: {
type: 'string',
description: 'Permission role assigned to the user.',
},
},
required: ['id', 'createdAt', 'username', 'role'],
},
},
},
},
'400': {
description: 'Bad request.',
content: {
'application/json': {
example: {
error: {
message: 'Bad request.',
code: 'bad-request',
status: 400,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
'401': {
description: 'Unauthorized.',
content: {
'application/json': {
example: {
error: {
message: 'Unauthorized.',
code: 'unauthorized',
status: 401,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
'404': {
description: 'Not found.',
content: {
'application/json': {
example: {
error: {
message: 'Not found.',
code: 'not-found',
status: 404,
},
},
schema: {
$ref: '#/components/schemas/ApiError',
},
},
},
},
},
} as ZodOpenApiOperationObject,
});
export const operations = [operation1, operation2, operation3] as const;