: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'
/**
* Only for setting properties on the person. "properties" from the request data will be updated via a "$set" event.
* This means that only the properties listed will be updated, but other properties won't be removed nor updated.
* If you would like to remove a property use the `delete_property` endpoint.
*/
export const PersonsUpdateBody = /* @__PURE__ */ zod.object({
properties: zod
.unknown()
.optional()
.describe('Key-value map of person properties set via $set and $set_once operations.'),
})
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://posthog.com/docs/api/capture), the `$set` and `$unset` [properties](https://posthog.com/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const PersonsPartialUpdateBody = /* @__PURE__ */ zod.object({
properties: zod
.unknown()
.optional()
.describe('Key-value map of person properties set via $set and $set_once operations.'),
})
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://posthog.com/docs/api/capture), the `$set` and `$unset` [properties](https://posthog.com/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const personsDeletePropertyCreateBodyUnsetTwoMax = 1000
export const PersonsDeletePropertyCreateBody = /* @__PURE__ */ zod.object({
$unset: zod
.union([
zod.string().min(1),
zod.array(zod.string().min(1)).min(1).max(personsDeletePropertyCreateBodyUnsetTwoMax),
])
.describe('A property key, or a list of property keys, to remove from this person.'),
})
/**
* Shows how the person's key properties changed within the time window of a Trends data point. The key properties are the person properties that the insight's query uses.
* @summary Get a person's properties timeline for an insight data point
*/
export const PersonsPropertiesTimelineCreateBody = /* @__PURE__ */ zod
.record(zod.string(), zod.unknown())
.describe('Deep\/recursive schema (opaque in Zod — use TypeScript types for full shape)')
/**
* Split distinct_ids off a merged person. Two mutually exclusive modes:
*
* - **`distinct_ids_to_split`** (recommended for surgical edits): moves only the listed distinct_ids off this person onto new single-id persons. The original person keeps every other distinct_id and its properties.
* - **`main_distinct_id`**: keeps only the specified distinct_id on this person; moves every *other* distinct_id off onto its own new person. If omitted, the first distinct_id is kept.
*
* The original person always retains its properties. To clear individual properties afterward, use the `delete_property` endpoint.
*
* The split runs asynchronously: a 201 response means the task was enqueued. A split-off person usually gets a UUID derived from `(team_id, distinct_id)`, but gets a random UUID when another person already holds that UUID, so do not compute it client-side. To find or delete a split-off person, look it up by its distinct_id once the task completes. Until then the distinct_id still resolves to the original person.
*/
export const PersonsSplitCreateBody = /* @__PURE__ */ zod.object({
main_distinct_id: zod
.string()
.nullish()
.describe(
'The distinct_id to \*\*keep\*\* on this person; every \*other\* distinct_id is moved to its own new single-id person. If omitted, the first distinct_id on the person is kept. The original person always retains its properties; to clear individual properties afterward, use the delete_property endpoint. To surgically \*remove\* one or more distinct_ids while leaving the merge intact, use `distinct_ids_to_split` instead — these parameters are inverses of each other and cannot be combined.'
),
distinct_ids_to_split: zod
.array(zod.string())
.nullish()
.describe(
'List of distinct_ids to \*\*move off\*\* this person onto new single-id persons. The original person keeps every other distinct_id and its properties. New persons are created with deterministic UUIDs derived from `(team_id, distinct_id)`. Cannot be combined with `main_distinct_id`.'
),
})
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://posthog.com/docs/api/capture), the `$set` and `$unset` [properties](https://posthog.com/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const PersonsUpdatePropertyCreateBody = /* @__PURE__ */ zod.object({
key: zod.string().optional().describe("The property key to set. Pair it with 'value' to set one property."),
value: zod.unknown().optional().describe('The property value. Can be a string, number, boolean, or object.'),
properties: zod
.record(zod.string(), zod.unknown())
.optional()
.describe(
"Property keys and values to set together, instead of 'key' and 'value'. One request sets up to 1000 properties and emits a single $set event."
),
})
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://posthog.com/docs/api/capture), the `$set` and `$unset` [properties](https://posthog.com/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const PersonsBatchByDistinctIdsCreateBody = /* @__PURE__ */ zod.object({
properties: zod
.unknown()
.optional()
.describe('Key-value map of person properties set via $set and $set_once operations.'),
})
/**
* This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the [capture API](https://posthog.com/docs/api/capture), the `$set` and `$unset` [properties](https://posthog.com/docs/product-analytics/user-properties), or one of our SDKs.
*/
export const PersonsBatchByUuidsCreateBody = /* @__PURE__ */ zod.object({
properties: zod
.unknown()
.optional()
.describe('Key-value map of person properties set via $set and $set_once operations.'),
})
/**
* This endpoint allows you to bulk delete persons, either by the PostHog person IDs or by distinct IDs. You can pass in a maximum of 1000 IDs per call. Only events captured before the request will be deleted.
*
* Person records are removed in the background shortly after the request returns, so a successful response reports them in `persons_queued_for_deletion` and `persons_deleted` is 0.
*/
export const personsBulkDeleteCreateBodyDeleteEventsDefault = false
export const personsBulkDeleteCreateBodyDeleteRecordingsDefault = false
export const personsBulkDeleteCreateBodyKeepPersonDefault = false
export const PersonsBulkDeleteCreateBody = /* @__PURE__ */ zod.object({
ids: zod.array(zod.string()).optional().describe('A list of PostHog person UUIDs to delete (max 1000).'),
distinct_ids: zod
.array(zod.string())
.optional()
.describe('A list of distinct IDs whose associated persons will be deleted (max 1000).'),
delete_events: zod
.boolean()
.default(personsBulkDeleteCreateBodyDeleteEventsDefault)
.describe('If true, queue deletion of all events associated with these persons.'),
delete_recordings: zod
.boolean()
.default(personsBulkDeleteCreateBodyDeleteRecordingsDefault)
.describe('If true, queue deletion of all recordings associated with these persons.'),
keep_person: zod
.boolean()
.default(personsBulkDeleteCreateBodyKeepPersonDefault)
.describe('If true, keep the person records but delete their events and recordings.'),
})