:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
/**
* Auto-generated Zod validation schemas from the Django backend OpenAPI schema.
* To modify these schemas, update the Django serializers or views, then run:
* hogli build:openapi
* Questions or issues? #team-devex on Slack
*
* PostHog API - generated
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
/**
* Create a new endpoint.
*/
export const EndpointsCreateBody = /* @__PURE__ */ zod
.object({
name: zod
.string()
.nullish()
.describe(
'Unique URL-safe name. Must start with a letter, only letters\/numbers\/hyphens\/underscores, max 128 chars.'
),
query: zod
.unknown()
.optional()
.describe('HogQL or insight query this endpoint executes. Changing this auto-creates a new version.'),
description: zod.string().nullish().describe('Human-readable description of what this endpoint returns.'),
data_freshness_seconds: zod
.number()
.nullish()
.describe(
'How fresh the data should be, in seconds. Must be one of: 900 (15 min), 1800 (30 min), 3600 (1 h), 21600 (6 h), 43200 (12 h), 86400 (24 h, default), 604800 (7 d). Controls cache TTL and materialization sync frequency.'
),
is_active: zod.boolean().nullish().describe('Whether this endpoint is available for execution via the API.'),
is_materialized: zod.boolean().nullish().describe('Whether query results are materialized to S3.'),
derived_from_insight: zod
.string()
.nullish()
.describe('Short ID of the insight this endpoint was derived from.'),
version: zod
.number()
.nullish()
.describe('Target a specific version for updates (defaults to current version).'),
bucket_overrides: zod
.record(zod.string(), zod.unknown())
.nullish()
.describe(
'Per-column bucket overrides for range variable materialization. Keys are column names, values are bucket keys.'
),
deleted: zod.boolean().nullish().describe('Set to true to soft-delete this endpoint.'),
tags: zod
.array(zod.string())
.nullish()
.describe('List of tag names to associate with this endpoint. Replaces any existing tags.'),
optional_breakdown_properties: zod
.array(zod.string())
.nullish()
.describe(
'Breakdown property names that may be omitted on \/run. Omitted ones return data aggregated across all values of that breakdown. Defaults to [] — every breakdown variable is required.'
),
})
.describe('Schema for creating\/updating endpoints. OpenAPI docs only — validation uses Pydantic.')
/**
* Update an existing endpoint. Parameters are optional. Pass version in body or ?version=N query param to target a specific version.
*/
export const EndpointsUpdateBody = /* @__PURE__ */ zod
.object({
name: zod
.string()
.nullish()
.describe(
'Unique URL-safe name. Must start with a letter, only letters\/numbers\/hyphens\/underscores, max 128 chars.'
),
query: zod
.unknown()
.optional()
.describe('HogQL or insight query this endpoint executes. Changing this auto-creates a new version.'),
description: zod.string().nullish().describe('Human-readable description of what this endpoint returns.'),
data_freshness_seconds: zod
.number()
.nullish()
.describe(
'How fresh the data should be, in seconds. Must be one of: 900 (15 min), 1800 (30 min), 3600 (1 h), 21600 (6 h), 43200 (12 h), 86400 (24 h, default), 604800 (7 d). Controls cache TTL and materialization sync frequency.'
),
is_active: zod.boolean().nullish().describe('Whether this endpoint is available for execution via the API.'),
is_materialized: zod.boolean().nullish().describe('Whether query results are materialized to S3.'),
derived_from_insight: zod
.string()
.nullish()
.describe('Short ID of the insight this endpoint was derived from.'),
version: zod
.number()
.nullish()
.describe('Target a specific version for updates (defaults to current version).'),
bucket_overrides: zod
.record(zod.string(), zod.unknown())
.nullish()
.describe(
'Per-column bucket overrides for range variable materialization. Keys are column names, values are bucket keys.'
),
deleted: zod.boolean().nullish().describe('Set to true to soft-delete this endpoint.'),
tags: zod
.array(zod.string())
.nullish()
.describe('List of tag names to associate with this endpoint. Replaces any existing tags.'),
optional_breakdown_properties: zod
.array(zod.string())
.nullish()
.describe(
'Breakdown property names that may be omitted on \/run. Omitted ones return data aggregated across all values of that breakdown. Defaults to [] — every breakdown variable is required.'
),
})
.describe('Schema for creating\/updating endpoints. OpenAPI docs only — validation uses Pydantic.')
/**
* Update an existing endpoint.
*/
export const EndpointsPartialUpdateBody = /* @__PURE__ */ zod
.object({
name: zod
.string()
.nullish()
.describe(
'Unique URL-safe name. Must start with a letter, only letters\/numbers\/hyphens\/underscores, max 128 chars.'
),
query: zod
.unknown()
.optional()
.describe('HogQL or insight query this endpoint executes. Changing this auto-creates a new version.'),
description: zod.string().nullish().describe('Human-readable description of what this endpoint returns.'),
data_freshness_seconds: zod
.number()
.nullish()
.describe(
'How fresh the data should be, in seconds. Must be one of: 900 (15 min), 1800 (30 min), 3600 (1 h), 21600 (6 h), 43200 (12 h), 86400 (24 h, default), 604800 (7 d). Controls cache TTL and materialization sync frequency.'
),
is_active: zod.boolean().nullish().describe('Whether this endpoint is available for execution via the API.'),
is_materialized: zod.boolean().nullish().describe('Whether query results are materialized to S3.'),
derived_from_insight: zod
.string()
.nullish()
.describe('Short ID of the insight this endpoint was derived from.'),
version: zod
.number()
.nullish()
.describe('Target a specific version for updates (defaults to current version).'),
bucket_overrides: zod
.record(zod.string(), zod.unknown())
.nullish()
.describe(
'Per-column bucket overrides for range variable materialization. Keys are column names, values are bucket keys.'
),
deleted: zod.boolean().nullish().describe('Set to true to soft-delete this endpoint.'),
tags: zod
.array(zod.string())
.nullish()
.describe('List of tag names to associate with this endpoint. Replaces any existing tags.'),
optional_breakdown_properties: zod
.array(zod.string())
.nullish()
.describe(
'Breakdown property names that may be omitted on \/run. Omitted ones return data aggregated across all values of that breakdown. Defaults to [] — every breakdown variable is required.'
),
})
.describe('Schema for creating\/updating endpoints. OpenAPI docs only — validation uses Pydantic.')
/**
* Preview the materialization transform for an endpoint. Shows what the query will look like after materialization, including range pair detection and bucket functions.
*/
export const EndpointsMaterializationPreviewCreateBody = /* @__PURE__ */ zod.object({
version: zod.number().optional().describe('Endpoint version to preview. Defaults to the current version.'),
bucket_overrides: zod
.record(zod.string(), zod.string())
.nullish()
.describe('Per-column bucket function overrides, e.g. {\"timestamp\": \"hour\"}'),
})
/**
* Execute endpoint with optional materialization. Supports version parameter, runs latest version if not set.
*/
export const EndpointsRunCreateBody = /* @__PURE__ */ zod
.record(zod.string(), zod.unknown())
.describe('Deep\/recursive schema (opaque in Zod — use TypeScript types for full shape)')
/**
* Get the most recent execution time per endpoint (endpoint-level). Timestamps are recorded by the run path for personal-API-key calls. For per-version usage, query the query_log table directly.
*/
export const EndpointsLastExecutionTimesCreateBody = /* @__PURE__ */ zod.object({
names: zod.array(zod.string()),
})