: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'
export const AlertsCreateBody = /* @__PURE__ */ zod
.record(zod.string(), zod.unknown())
.describe('Deep\/recursive schema (opaque in Zod — use TypeScript types for full shape)')
export const AlertsUpdateBody = /* @__PURE__ */ zod
.record(zod.string(), zod.unknown())
.describe('Deep\/recursive schema (opaque in Zod — use TypeScript types for full shape)')
export const AlertsPartialUpdateBody = /* @__PURE__ */ zod
.record(zod.string(), zod.unknown())
.describe('Deep\/recursive schema (opaque in Zod — use TypeScript types for full shape)')
/**
* Send this alert to a Slack channel as well as by email. The workspace must already be connected to the project. The returned IDs identify the destination.
*/
export const alertsDestinationsCreateBodyTypeDefault = `slack`
export const AlertsDestinationsCreateBody = /* @__PURE__ */ zod.object({
type: zod
.enum(['slack'])
.describe('\* `slack` - slack')
.default(alertsDestinationsCreateBodyTypeDefault)
.describe('Destination type. Slack is the only type this endpoint creates.\n\n\* `slack` - slack'),
slack_workspace_id: zod
.number()
.describe('Integration ID of the Slack workspace to post in. List them with the integrations endpoint.'),
slack_channel_id: zod.string().describe('Slack channel ID to post in, for example C0123456789.'),
slack_channel_name: zod
.string()
.optional()
.describe('Channel name shown on the destination, for example product-alerts.'),
})
/**
* Stop sending this alert to a destination. The alert keeps its email recipients.
*/
export const alertsDestinationsDeleteCreateBodyHogFunctionIdsMax = 100
export const AlertsDestinationsDeleteCreateBody = /* @__PURE__ */ zod.object({
hog_function_ids: zod
.array(zod.uuid())
.min(1)
.max(alertsDestinationsDeleteCreateBodyHogFunctionIdsMax)
.describe('Destination IDs to delete, as returned when the destination was created.'),
})
/**
* Simulate a detector on an insight's historical data. No AlertCheck records are created. The AI detector makes a real model call, so that mode needs the 'alert:write' scope.
*/
export const alertsSimulateCreateBodyEvaluationDelayIntervalsDefault = 0
export const alertsSimulateCreateBodyEvaluationDelayIntervalsMin = 0
export const alertsSimulateCreateBodyEvaluationDelayIntervalsMax = 100
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOneTypeDefault = `zscore`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemTwoTypeDefault = `mad`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemThreeTypeDefault = `iqr`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemFourTypeDefault = `threshold`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemFiveTypeDefault = `ecod`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemSixTypeDefault = `copod`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemSevenTypeDefault = `isolation_forest`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemEightTypeDefault = `knn`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemNineTypeDefault = `hbos`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOnezeroTypeDefault = `lof`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOneoneTypeDefault = `ocsvm`
export const alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOnetwoTypeDefault = `pca`
export const alertsSimulateCreateBodyDetectorConfigOneOneTypeDefault = `ensemble`
export const alertsSimulateCreateBodyDetectorConfigOneTwoTypeDefault = `zscore`
export const alertsSimulateCreateBodyDetectorConfigOneThreeTypeDefault = `mad`
export const alertsSimulateCreateBodyDetectorConfigOneFourTypeDefault = `iqr`
export const alertsSimulateCreateBodyDetectorConfigOneFiveTypeDefault = `threshold`
export const alertsSimulateCreateBodyDetectorConfigOneSixTypeDefault = `ecod`
export const alertsSimulateCreateBodyDetectorConfigOneSevenTypeDefault = `copod`
export const alertsSimulateCreateBodyDetectorConfigOneEightTypeDefault = `isolation_forest`
export const alertsSimulateCreateBodyDetectorConfigOneNineTypeDefault = `knn`
export const alertsSimulateCreateBodyDetectorConfigOneOnezeroTypeDefault = `hbos`
export const alertsSimulateCreateBodyDetectorConfigOneOneoneTypeDefault = `lof`
export const alertsSimulateCreateBodyDetectorConfigOneOnetwoTypeDefault = `ocsvm`
export const alertsSimulateCreateBodyDetectorConfigOneOnethreeTypeDefault = `pca`
export const alertsSimulateCreateBodyDetectorConfigOneOnefourInstructionsOneMax = 2000
export const alertsSimulateCreateBodyDetectorConfigOneOnefourTypeDefault = `llm`
export const alertsSimulateCreateBodySeriesIndexDefault = 0
export const alertsSimulateCreateBodyConfigOneOneTypeDefault = `TrendsAlertConfig`
export const alertsSimulateCreateBodyConfigOneTwoTypeDefault = `HogQLAlertConfig`
export const alertsSimulateCreateBodyConfigOneThreeTypeDefault = `FunnelsAlertConfig`
export const alertsSimulateCreateBodyConfigOneFourTypeDefault = `MetricsAlertConfig`
export const AlertsSimulateCreateBody = /* @__PURE__ */ zod.object({
evaluation_delay_intervals: zod
.number()
.min(alertsSimulateCreateBodyEvaluationDelayIntervalsMin)
.max(alertsSimulateCreateBodyEvaluationDelayIntervalsMax)
.default(alertsSimulateCreateBodyEvaluationDelayIntervalsDefault)
.describe(
'Skip this many completed insight intervals before simulation, matching live evaluation. Time-series Trends only; a positive delay requires check_ongoing_interval=false.'
),
insight: zod
.union([zod.number(), zod.string()])
.describe('Numeric insight ID or saved insight short ID to simulate the detector on.'),
detector_config: zod
.union([
zod.object({
detectors: zod
.array(
zod.union([
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Anomaly probability threshold [0-1]. Points above this probability are flagged (default: 0.9)'
),
type: zod
.enum(['zscore'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOneTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Rolling window size for calculating mean\/std (default: 30)'),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Anomaly probability threshold [0-1]. Points above this probability are flagged (default: 0.9)'
),
type: zod
.enum(['mad'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemTwoTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Rolling window size for calculating median\/MAD (default: 30)'),
}),
zod.object({
multiplier: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'IQR multiplier for fence calculation (default: 1.5, use 3.0 for far outliers)'
),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
type: zod
.enum(['iqr'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemThreeTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Rolling window size for calculating quartiles (default: 30)'),
}),
zod.object({
lower_bound: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Lower bound - values below this are anomalies'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
type: zod
.enum(['threshold'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemFourTypeDefault),
upper_bound: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Upper bound - values above this are anomalies'),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['ecod'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemFiveTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['copod'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemSixTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
n_estimators: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of trees in the forest (default: 100)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['isolation_forest'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemSevenTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
method: zod
.union([zod.enum(['largest', 'mean', 'median']), zod.null()])
.optional()
.describe("Distance method: 'largest', 'mean', 'median' (default: 'largest')"),
n_neighbors: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of neighbors to consider (default: 5)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['knn'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemEightTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
n_bins: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of histogram bins (default: 10)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['hbos'])
.default(alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemNineTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
n_neighbors: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of neighbors for LOF (default: 20)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['lof'])
.default(
alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOnezeroTypeDefault
),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
kernel: zod
.union([zod.string(), zod.null()])
.optional()
.describe('SVM kernel type (default: \"rbf\")'),
nu: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Upper bound on training errors fraction (default: 0.1)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['ocsvm'])
.default(
alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOneoneTypeDefault
),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'
),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod
.enum(['pca'])
.default(
alertsSimulateCreateBodyDetectorConfigOneOneDetectorsItemOnetwoTypeDefault
),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
])
)
.describe('Sub-detector configurations (minimum 2)'),
operator: zod.enum(['and', 'or']).describe('How to combine sub-detector results'),
type: zod.enum(['ensemble']).default(alertsSimulateCreateBodyDetectorConfigOneOneTypeDefault),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Anomaly probability threshold [0-1]. Points above this probability are flagged (default: 0.9)'
),
type: zod.enum(['zscore']).default(alertsSimulateCreateBodyDetectorConfigOneTwoTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Rolling window size for calculating mean\/std (default: 30)'),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Anomaly probability threshold [0-1]. Points above this probability are flagged (default: 0.9)'
),
type: zod.enum(['mad']).default(alertsSimulateCreateBodyDetectorConfigOneThreeTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Rolling window size for calculating median\/MAD (default: 30)'),
}),
zod.object({
multiplier: zod
.union([zod.number(), zod.null()])
.optional()
.describe('IQR multiplier for fence calculation (default: 1.5, use 3.0 for far outliers)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
type: zod.enum(['iqr']).default(alertsSimulateCreateBodyDetectorConfigOneFourTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Rolling window size for calculating quartiles (default: 30)'),
}),
zod.object({
lower_bound: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Lower bound - values below this are anomalies'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
type: zod.enum(['threshold']).default(alertsSimulateCreateBodyDetectorConfigOneFiveTypeDefault),
upper_bound: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Upper bound - values above this are anomalies'),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['ecod']).default(alertsSimulateCreateBodyDetectorConfigOneSixTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['copod']).default(alertsSimulateCreateBodyDetectorConfigOneSevenTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
n_estimators: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of trees in the forest (default: 100)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['isolation_forest']).default(alertsSimulateCreateBodyDetectorConfigOneEightTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
method: zod
.union([zod.enum(['largest', 'mean', 'median']), zod.null()])
.optional()
.describe("Distance method: 'largest', 'mean', 'median' (default: 'largest')"),
n_neighbors: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of neighbors to consider (default: 5)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['knn']).default(alertsSimulateCreateBodyDetectorConfigOneNineTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
n_bins: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of histogram bins (default: 10)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['hbos']).default(alertsSimulateCreateBodyDetectorConfigOneOnezeroTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
n_neighbors: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Number of neighbors for LOF (default: 20)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['lof']).default(alertsSimulateCreateBodyDetectorConfigOneOneoneTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
kernel: zod.union([zod.string(), zod.null()]).optional().describe('SVM kernel type (default: \"rbf\")'),
nu: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Upper bound on training errors fraction (default: 0.1)'),
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['ocsvm']).default(alertsSimulateCreateBodyDetectorConfigOneOnetwoTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
preprocessing: zod
.union([
zod.object({
diffs_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Order of differencing. 0 = raw values, 1 = first-order diffs (default: 0)'),
lags_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Number of lag features. 0 = none, >0 = include n lagged values (default: 0)'
),
smooth_n: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Moving average window size. 0 = no smoothing, >1 = smooth over n points (default: 0)'
),
}),
zod.null(),
])
.optional()
.describe('Preprocessing transforms applied before detection'),
threshold: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Anomaly probability threshold (default: 0.9)'),
type: zod.enum(['pca']).default(alertsSimulateCreateBodyDetectorConfigOneOnethreeTypeDefault),
window: zod
.union([zod.number(), zod.null()])
.optional()
.describe(
'Rolling window size — how many historical data points to train on (default: based on calculation interval)'
),
}),
zod.object({
instructions: zod
.union([
zod.string().max(alertsSimulateCreateBodyDetectorConfigOneOnefourInstructionsOneMax),
zod.null(),
])
.optional()
.describe('What counts as unusual or interesting for this metric, in your own words. Optional.'),
type: zod.enum(['llm']).default(alertsSimulateCreateBodyDetectorConfigOneOnefourTypeDefault),
}),
])
.describe('Detector configuration types')
.optional()
.describe(
'Detector configuration to simulate. Omit it to use the default daily z-score detector (threshold 0.95, window 90, first-difference preprocessing).'
),
series_index: zod
.number()
.default(alertsSimulateCreateBodySeriesIndexDefault)
.describe('Zero-based index of the series to analyze (trends insights only).'),
date_from: zod
.string()
.nullish()
.describe(
"Relative date string for how far back to simulate (e.g. '-24h', '-30d', '-4w'). If not provided, uses the detector's minimum required samples. Trends insights only — a SQL query's own rows are the series."
),
config: zod
.union([
zod
.union([
zod.object({
check_ongoing_interval: zod
.union([zod.boolean(), zod.null()])
.optional()
.describe(
'When true, evaluate the current (still incomplete) time interval in addition to completed ones.'
),
series_index: zod
.number()
.describe("Zero-based index of the series in the insight's query to monitor."),
type: zod.enum(['TrendsAlertConfig']).default(alertsSimulateCreateBodyConfigOneOneTypeDefault),
}),
zod.object({
column: zod
.union([zod.string(), zod.null()])
.optional()
.describe(
'Name of the result column to evaluate. When unset, the single numeric column is used (an error if the result has more than one numeric column).'
),
evaluation: zod
.enum(['last_row', 'first_row', 'any_row'])
.describe('How to read the result rows — an explicit choice, no implicit default.'),
label_column: zod
.union([zod.string(), zod.null()])
.optional()
.describe(
'Column whose value labels the evaluated row(s) in breach messages: every row in `any_row` mode, or the single evaluated row in `last_row`\/`first_row`. When unset, the first non-evaluated column is used, falling back to the row number (any_row) or the value column name (last_row\/first_row).'
),
type: zod.enum(['HogQLAlertConfig']).default(alertsSimulateCreateBodyConfigOneTwoTypeDefault),
}),
zod.object({
check_ongoing_interval: zod
.union([zod.boolean(), zod.null()])
.optional()
.describe(
'When true, evaluate the current (still in-progress) period; by default only completed periods are used.'
),
funnel_step: zod
.union([zod.number(), zod.null()])
.optional()
.describe('Zero-based step index to evaluate. Null = the last step (overall conversion).'),
metric: zod.enum(['conversion_from_start', 'conversion_from_previous']),
type: zod
.enum(['FunnelsAlertConfig'])
.default(alertsSimulateCreateBodyConfigOneThreeTypeDefault),
}),
zod.object({
check_ongoing_interval: zod
.union([zod.boolean(), zod.null()])
.optional()
.describe(
'When true, anchor on the trailing (possibly still accumulating) bucket instead of the last complete one.'
),
type: zod
.enum(['MetricsAlertConfig'])
.default(alertsSimulateCreateBodyConfigOneFourTypeDefault),
variables: zod
.union([
zod.record(
zod.string(),
zod.object({
all: zod.union([zod.boolean(), zod.null()]).optional(),
values: zod
.array(zod.string())
.describe(
'The selected values. Empty when `all` is true: All stands for every option of the variable.'
),
})
),
zod.null(),
])
.optional()
.describe("Values for the `$name` variables in the insight's query."),
}),
])
.describe(
'Per-insight-kind alert config, discriminated by ``type`` — keeps the OpenAPI (and the\ngenerated frontend types and MCP tool schemas) in sync with every kind alerts support.'
),
zod.null(),
])
.optional()
.describe(
'Per-insight-kind alert config. For SQL insights, selects the evaluated column and read direction (last_row\/first_row) so the preview matches the alert; ignored for trends.'
),
alert: zod
.uuid()
.nullish()
.describe(
"ID of the saved alert this preview is for. The AI detector reads the points that the alert's earlier AI checks fired on, the same way a live check does. Omit it for a new alert."
),
})