Skip to content

: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.

91.5 KB
Raw Blame
/**
 * 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'

/**
 * Staff-only, unscoped status/entry/rebuild/clear for the HyperCache-backed flag caches.
 *
 * Rebuild/clear act on two logical targets: 'evaluation' (the /flags cache) and 'definitions'
 * (the /flags/definitions local-eval cache), independently readable and mutable.
 *
 * Reuses the existing cache functions and Celery tasks (the same mechanism signal handlers use
 * when a flag changes) rather than re-implementing cache-write logic. Registered on the root
 * router so it is not team-nested; staff act on teams they do not belong to.
 */
export const featureFlagsStaffCacheClearCreateBodyTeamIdsMax = 50

export const FeatureFlagsStaffCacheClearCreateBody = /* @__PURE__ */ zod.object({
    team_ids: zod
        .array(zod.number())
        .max(featureFlagsStaffCacheClearCreateBodyTeamIdsMax)
        .describe('Team ids to act on (max 50 per request).'),
    caches: zod
        .array(
            zod
                .enum(['evaluation', 'definitions'])
                .describe('\* `evaluation` - evaluation\n\* `definitions` - definitions')
        )
        .default([`evaluation`, `definitions`])
        .describe(
            "Which logical caches to act on: 'evaluation' (the \/flags cache) and\/or 'definitions' (the \/flags\/definitions local-eval cache). Defaults to both."
        ),
})

/**
 * Staff-only, unscoped status/entry/rebuild/clear for the HyperCache-backed flag caches.
 *
 * Rebuild/clear act on two logical targets: 'evaluation' (the /flags cache) and 'definitions'
 * (the /flags/definitions local-eval cache), independently readable and mutable.
 *
 * Reuses the existing cache functions and Celery tasks (the same mechanism signal handlers use
 * when a flag changes) rather than re-implementing cache-write logic. Registered on the root
 * router so it is not team-nested; staff act on teams they do not belong to.
 */
export const featureFlagsStaffCacheRebuildCreateBodyTeamIdsMax = 50

export const FeatureFlagsStaffCacheRebuildCreateBody = /* @__PURE__ */ zod.object({
    team_ids: zod
        .array(zod.number())
        .max(featureFlagsStaffCacheRebuildCreateBodyTeamIdsMax)
        .describe('Team ids to act on (max 50 per request).'),
    caches: zod
        .array(
            zod
                .enum(['evaluation', 'definitions'])
                .describe('\* `evaluation` - evaluation\n\* `definitions` - definitions')
        )
        .default([`evaluation`, `definitions`])
        .describe(
            "Which logical caches to act on: 'evaluation' (the \/flags cache) and\/or 'definitions' (the \/flags\/definitions local-eval cache). Defaults to both."
        ),
})

/**
 * Staff-only, unscoped read/write for TeamFeatureFlagsConfig: behavior rollout gates and the
 * per-team feature-flag count override.
 *
 * set() writes one team only, by design. Rollout settings are changed after staff verify SDK
 * compatibility, and max_feature_flags_override is a per-customer capacity grant. Neither is a
 * bulk operation, unlike the cache tools' rebuild and clear. flag_evaluations_mode belongs to the
 * organization, and only set_flag_evaluations_mode() writes it, for the organizations of the given
 * teams. It uses the same helpers as the set_flag_evaluations_mode command, including the guard
 * against lowering an organization, and it writes every organization of a request in one
 * transaction.
 *
 * set() takes partial updates: omit a setting to leave it unchanged, and send
 * max_feature_flags_override as null to clear the override.
 *
 * Registered on the root router so it is not team-nested; staff act on teams they do not
 * belong to, same as staff_cache.py / staff_teams.py.
 */
export const featureFlagsStaffTeamConfigSetCreateBodyMaxFeatureFlagsOverrideMax = 20000

export const FeatureFlagsStaffTeamConfigSetCreateBody = /* @__PURE__ */ zod.object({
    team_id: zod.number().describe('Team id to update. Exactly one team per request.'),
    minimal_flag_called_events: zod
        .boolean()
        .optional()
        .describe(
            "New value for the team's minimal_flag_called_events setting. Omit to leave it unchanged. Only set true after confirming that team's SDK versions support the slim $feature_flag_called event shape."
        ),
    property_matching_version: zod
        .union([zod.literal(1), zod.literal(2)])
        .describe('\* `1` - Legacy\n\* `2` - Explicit')
        .optional()
        .describe(
            "New property matching version for the team. Version 1 preserves legacy behavior. Version 2 uses explicit scalar and array equality. Only set version 2 after confirming that the team's local-evaluation SDK versions support it. Omit to leave it unchanged.\n\n\* `1` - Legacy\n\* `2` - Explicit"
        ),
    max_feature_flags_override: zod
        .number()
        .min(1)
        .max(featureFlagsStaffTeamConfigSetCreateBodyMaxFeatureFlagsOverrideMax)
        .nullish()
        .describe(
            'New per-team flag-count limit (1-20,000). Send null to clear the override so the team falls back to the global default. Omit to leave it unchanged.'
        ),
})

/**
 * Staff-only, unscoped read/write for TeamFeatureFlagsConfig: behavior rollout gates and the
 * per-team feature-flag count override.
 *
 * set() writes one team only, by design. Rollout settings are changed after staff verify SDK
 * compatibility, and max_feature_flags_override is a per-customer capacity grant. Neither is a
 * bulk operation, unlike the cache tools' rebuild and clear. flag_evaluations_mode belongs to the
 * organization, and only set_flag_evaluations_mode() writes it, for the organizations of the given
 * teams. It uses the same helpers as the set_flag_evaluations_mode command, including the guard
 * against lowering an organization, and it writes every organization of a request in one
 * transaction.
 *
 * set() takes partial updates: omit a setting to leave it unchanged, and send
 * max_feature_flags_override as null to clear the override.
 *
 * Registered on the root router so it is not team-nested; staff act on teams they do not
 * belong to, same as staff_cache.py / staff_teams.py.
 */
export const featureFlagsStaffTeamConfigSetFlagEvaluationsModeCreateBodyTeamIdsMax = 50

export const featureFlagsStaffTeamConfigSetFlagEvaluationsModeCreateBodyAllowDowngradeDefault = false
export const featureFlagsStaffTeamConfigSetFlagEvaluationsModeCreateBodyDryRunDefault = false

export const FeatureFlagsStaffTeamConfigSetFlagEvaluationsModeCreateBody = /* @__PURE__ */ zod.object({
    flag_evaluations_mode: zod
        .union([zod.literal(0), zod.literal(1), zod.literal(2)])
        .describe(
            "Target flag_evaluations mode. 0 reads events. 1 reads flag_evaluations for the flag Usage tab, the per-project counts on a flag's Projects tab, and events lists filtered to only $feature_flag_called, such as the Activity page. 2 reads the same way as 1, and ingestion stops writing $feature_flag_called to events for teams in the ingestion allowlist. On PostHog Cloud the table is available in SQL on every mode. Self-hosted, it is available on 1 and 2.\n\n\* `0` - Events\n\* `1` - Read flag evaluations\n\* `2` - Flag evaluations only"
        ),
    team_ids: zod
        .array(zod.number())
        .min(1)
        .max(featureFlagsStaffTeamConfigSetFlagEvaluationsModeCreateBodyTeamIdsMax)
        .describe(
            'Teams whose organizations to move (max 50). The mode belongs to the organization, so the write moves every team of each organization that owns one of these teams.'
        ),
    allow_downgrade: zod
        .boolean()
        .default(featureFlagsStaffTeamConfigSetFlagEvaluationsModeCreateBodyAllowDowngradeDefault)
        .describe(
            'Also lower organizations that are above the target mode. Lowering an organization from 2 restarts the events writes that ingestion stopped for its teams in the ingestion allowlist. The events table keeps a gap for those teams for the time the organization spent on 2.'
        ),
    dry_run: zod
        .boolean()
        .default(featureFlagsStaffTeamConfigSetFlagEvaluationsModeCreateBodyDryRunDefault)
        .describe('Report what the write would change, and write nothing.'),
})

export const featureFlagsCopyFlagsCreateBodyTargetProjectIdsMax = 50

export const featureFlagsCopyFlagsCreateBodyCopyScheduleDefault = false
export const featureFlagsCopyFlagsCreateBodyDisableCopiedFlagDefault = false
export const featureFlagsCopyFlagsCreateBodyCopyDependenciesDefault = false

export const FeatureFlagsCopyFlagsCreateBody = /* @__PURE__ */ zod.object({
    feature_flag_key: zod.string().describe('Key of the feature flag to copy'),
    from_project: zod.number().describe('Source project ID to copy the flag from'),
    target_project_ids: zod
        .array(zod.number())
        .min(1)
        .max(featureFlagsCopyFlagsCreateBodyTargetProjectIdsMax)
        .describe('List of target project IDs to copy the flag to'),
    copy_schedule: zod
        .boolean()
        .default(featureFlagsCopyFlagsCreateBodyCopyScheduleDefault)
        .describe('Whether to also copy scheduled changes for this flag'),
    disable_copied_flag: zod
        .boolean()
        .default(featureFlagsCopyFlagsCreateBodyDisableCopiedFlagDefault)
        .describe(
            "Whether to force the copied flag to be disabled in target projects, ignoring the source flag's enabled status"
        ),
    copy_dependencies: zod
        .boolean()
        .default(featureFlagsCopyFlagsCreateBodyCopyDependenciesDefault)
        .describe('Whether to also copy missing feature flags that this flag depends on'),
})

export const featureFlagsCopyFlagsDependencyRequirementsCreateBodyTargetProjectIdsMax = 50

export const FeatureFlagsCopyFlagsDependencyRequirementsCreateBody = /* @__PURE__ */ zod.object({
    feature_flag_key: zod.string().describe('Key of the feature flag to check'),
    from_project: zod.number().describe('Source project ID to copy the flag from'),
    target_project_ids: zod
        .array(zod.number())
        .min(1)
        .max(featureFlagsCopyFlagsDependencyRequirementsCreateBodyTargetProjectIdsMax)
        .describe('List of target project IDs to check dependency copy eligibility for'),
})

/**
 * Hide an evaluation context name from the flag editor's suggestion list, or restore it.
 *
 * POST hides the name; DELETE restores it. The underlying context row and any flags already
 * using it are never modified — this only controls what gets suggested.
 */
export const organizationsProjectsEvaluationContextSuggestionsCreateBodyContextNameMax = 255

export const OrganizationsProjectsEvaluationContextSuggestionsCreateBody = /* @__PURE__ */ zod.object({
    context_name: zod
        .string()
        .max(organizationsProjectsEvaluationContextSuggestionsCreateBodyContextNameMax)
        .describe(
            "Name of the evaluation context to hide from (POST) or restore to (DELETE) the flag editor's suggestion list. Case-insensitive and whitespace-trimmed."
        ),
})

/**
 * Create, read, update and delete feature flags. [See docs](https://posthog.com/docs/feature-flags) for more information on feature flags.
 *
 * If you're looking to use feature flags on your application, you can either use our JavaScript Library or our dedicated endpoint to check if feature flags are enabled for a given user.
 */
export const featureFlagsCreateBodyFiltersOneEarlyExitDefault = false

export const FeatureFlagsCreateBody = /* @__PURE__ */ zod.object({
    key: zod.string().optional().describe('Feature flag key.'),
    name: zod
        .string()
        .optional()
        .describe('Feature flag description (stored in the `name` field for backwards compatibility).'),
    filters: zod
        .object({
            groups: zod
                .array(
                    zod.object({
                        properties: zod
                            .array(
                                zod.union([
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        value: zod
                                            .unknown()
                                            .describe(
                                                'Comparison value for the property filter. Supports strings, numbers, booleans, and arrays.'
                                            ),
                                        operator: zod
                                            .enum([
                                                'exact',
                                                'is_not',
                                                'icontains',
                                                'not_icontains',
                                                'starts_with',
                                                'not_starts_with',
                                                'ends_with',
                                                'not_ends_with',
                                                'regex',
                                                'not_regex',
                                                'gt',
                                                'gte',
                                                'lt',
                                                'lte',
                                            ])
                                            .describe(
                                                '\* `exact` - exact\n\* `is_not` - is_not\n\* `icontains` - icontains\n\* `not_icontains` - not_icontains\n\* `starts_with` - starts_with\n\* `not_starts_with` - not_starts_with\n\* `ends_with` - ends_with\n\* `not_ends_with` - not_ends_with\n\* `regex` - regex\n\* `not_regex` - not_regex\n\* `gt` - gt\n\* `gte` - gte\n\* `lt` - lt\n\* `lte` - lte'
                                            )
                                            .describe(
                                                'Operator used to compare the property value.\n\n\* `exact` - exact\n\* `is_not` - is_not\n\* `icontains` - icontains\n\* `not_icontains` - not_icontains\n\* `starts_with` - starts_with\n\* `not_starts_with` - not_starts_with\n\* `ends_with` - ends_with\n\* `not_ends_with` - not_ends_with\n\* `regex` - regex\n\* `not_regex` - not_regex\n\* `gt` - gt\n\* `gte` - gte\n\* `lt` - lt\n\* `lte` - lte'
                                            ),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['is_set', 'is_not_set'])
                                            .describe('\* `is_set` - is_set\n\* `is_not_set` - is_not_set')
                                            .describe(
                                                'Existence operator.\n\n\* `is_set` - is_set\n\* `is_not_set` - is_not_set'
                                            ),
                                        value: zod
                                            .unknown()
                                            .optional()
                                            .describe(
                                                'Optional value. Runtime behavior determines whether this is ignored.'
                                            ),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['is_date_exact', 'is_date_before', 'is_date_after'])
                                            .describe(
                                                '\* `is_date_exact` - is_date_exact\n\* `is_date_before` - is_date_before\n\* `is_date_after` - is_date_after'
                                            )
                                            .describe(
                                                'Date comparison operator.\n\n\* `is_date_exact` - is_date_exact\n\* `is_date_after` - is_date_after\n\* `is_date_before` - is_date_before'
                                            ),
                                        value: zod
                                            .string()
                                            .describe('Date value in ISO format or relative date expression.'),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum([
                                                'semver_eq',
                                                'semver_neq',
                                                'semver_gt',
                                                'semver_gte',
                                                'semver_lt',
                                                'semver_lte',
                                                'semver_tilde',
                                                'semver_caret',
                                                'semver_wildcard',
                                            ])
                                            .describe(
                                                '\* `semver_eq` - semver_eq\n\* `semver_neq` - semver_neq\n\* `semver_gt` - semver_gt\n\* `semver_gte` - semver_gte\n\* `semver_lt` - semver_lt\n\* `semver_lte` - semver_lte\n\* `semver_tilde` - semver_tilde\n\* `semver_caret` - semver_caret\n\* `semver_wildcard` - semver_wildcard'
                                            )
                                            .describe(
                                                'Semantic version comparison operator.\n\n\* `semver_eq` - semver_eq\n\* `semver_neq` - semver_neq\n\* `semver_gt` - semver_gt\n\* `semver_gte` - semver_gte\n\* `semver_lt` - semver_lt\n\* `semver_lte` - semver_lte\n\* `semver_tilde` - semver_tilde\n\* `semver_caret` - semver_caret\n\* `semver_wildcard` - semver_wildcard'
                                            ),
                                        value: zod.string().describe('Semantic version string.'),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['icontains_multi', 'not_icontains_multi'])
                                            .describe(
                                                '\* `icontains_multi` - icontains_multi\n\* `not_icontains_multi` - not_icontains_multi'
                                            )
                                            .describe(
                                                'Multi-contains operator.\n\n\* `icontains_multi` - icontains_multi\n\* `not_icontains_multi` - not_icontains_multi'
                                            ),
                                        value: zod.array(zod.string()).describe('List of strings to evaluate against.'),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort'])
                                            .describe('\* `cohort` - cohort')
                                            .describe(
                                                'Cohort property type required for in\/not_in operators.\n\n\* `cohort` - cohort'
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['in', 'not_in'])
                                            .describe('\* `in` - in\n\* `not_in` - not_in')
                                            .describe(
                                                'Membership operator for cohort properties.\n\n\* `in` - in\n\* `not_in` - not_in'
                                            ),
                                        value: zod
                                            .unknown()
                                            .describe('Cohort comparison value (single or list, depending on usage).'),
                                        cohort_deleted: zod
                                            .boolean()
                                            .optional()
                                            .describe(
                                                'Set to true in responses when the cohort is deleted or does not exist. The flag cannot evaluate this condition. Ignored on write.'
                                            ),
                                        cohort_missing: zod
                                            .boolean()
                                            .optional()
                                            .describe(
                                                'Set to true in responses when no cohort with this id exists in the project, so it cannot be restored. `cohort_deleted` is also true. Absent for a soft-deleted cohort. Ignored on write.'
                                            ),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['flag'])
                                            .describe('\* `flag` - flag')
                                            .describe(
                                                'Flag property type required for flag dependency checks.\n\n\* `flag` - flag'
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['flag_evaluates_to'])
                                            .describe('\* `flag_evaluates_to` - flag_evaluates_to')
                                            .describe(
                                                'Operator for feature flag dependency evaluation.\n\n\* `flag_evaluates_to` - flag_evaluates_to'
                                            ),
                                        value: zod.unknown().describe('Value to compare flag evaluation against.'),
                                    }),
                                ])
                            )
                            .optional()
                            .describe('Property conditions for this release condition group.'),
                        rollout_percentage: zod
                            .number()
                            .optional()
                            .describe('Rollout percentage for this release condition group.'),
                        variant: zod.string().nullish().describe('Variant key override for multivariate flags.'),
                        aggregation_group_type_index: zod
                            .number()
                            .nullish()
                            .describe('Group type index for this condition set. None means person-level aggregation.'),
                    })
                )
                .optional()
                .describe('Release condition groups for the feature flag.'),
            multivariate: zod
                .union([
                    zod.object({
                        variants: zod
                            .array(
                                zod.object({
                                    key: zod.string().describe('Unique key for this variant.'),
                                    name: zod.string().optional().describe('Human-readable name for this variant.'),
                                    rollout_percentage: zod.number().describe('Variant rollout percentage.'),
                                })
                            )
                            .describe('Variant definitions for multivariate feature flags.'),
                    }),
                    zod.null(),
                ])
                .optional()
                .describe('Multivariate configuration for variant-based rollouts.'),
            aggregation_group_type_index: zod
                .number()
                .nullish()
                .describe('Group type index for group-based feature flags.'),
            payloads: zod
                .record(zod.string(), zod.string())
                .optional()
                .describe('Optional payload values keyed by variant key.'),
            feature_enrollment: zod
                .boolean()
                .nullish()
                .describe(
                    'Whether this flag has early access feature enrollment enabled. When true, the flag is evaluated against the person property $feature_enrollment\/{flag_key}.'
                ),
            early_exit: zod
                .boolean()
                .default(featureFlagsCreateBodyFiltersOneEarlyExitDefault)
                .describe(
                    'When true, condition evaluation stops at the first matching condition set rather than continuing to evaluate subsequent groups.'
                ),
        })
        .optional()
        .describe('Feature flag targeting configuration.'),
    active: zod.boolean().optional().describe('Whether the feature flag is active.'),
    archived: zod
        .boolean()
        .optional()
        .describe(
            'Whether the flag is archived. Archived flags are hidden from the flag list by default and must be disabled (`active: false`).'
        ),
    tags: zod.array(zod.string()).optional().describe('Organizational tags for this feature flag.'),
    evaluation_contexts: zod
        .array(zod.string())
        .optional()
        .describe('Evaluation contexts that control where this flag evaluates at runtime.'),
    is_remote_configuration: zod
        .boolean()
        .nullish()
        .describe(
            'Whether this flag is a remote configuration flag that delivers a payload rather than gating a feature.'
        ),
    ensure_experience_continuity: zod
        .boolean()
        .nullish()
        .describe(
            "Whether to persist a user's flag value across the anonymous-to-identified transition (the 'persist across authentication steps' option). Incompatible with device_id bucketing."
        ),
    evaluation_runtime: zod
        .union([
            zod
                .enum(['server', 'client', 'all'])
                .describe('\* `server` - Server\n\* `client` - Client\n\* `all` - All'),
            zod.null(),
        ])
        .optional()
        .describe(
            "Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.\n\n\* `server` - Server\n\* `client` - Client\n\* `all` - All"
        ),
    bucketing_identifier: zod
        .union([
            zod
                .enum(['distinct_id', 'device_id'])
                .describe('\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID'),
            zod.null(),
        ])
        .optional()
        .describe(
            "Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.\n\n\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID"
        ),
})

/**
 * Create, read, update and delete feature flags. [See docs](https://posthog.com/docs/feature-flags) for more information on feature flags.
 *
 * If you're looking to use feature flags on your application, you can either use our JavaScript Library or our dedicated endpoint to check if feature flags are enabled for a given user.
 */
export const featureFlagsUpdateBodyKeyMax = 400

export const featureFlagsUpdateBodyVersionDefault = 0

export const FeatureFlagsUpdateBody = /* @__PURE__ */ zod
    .object({
        name: zod
            .string()
            .optional()
            .describe('contains the description for the flag (field name `name` is kept for backwards-compatibility)'),
        key: zod.string().max(featureFlagsUpdateBodyKeyMax),
        filters: zod.record(zod.string(), zod.unknown()).optional(),
        deleted: zod.boolean().optional(),
        active: zod.boolean().optional(),
        archived: zod
            .boolean()
            .optional()
            .describe(
                'Whether the flag is archived. Archived flags are hidden from the flag list by default and must be disabled (`active: false`).'
            ),
        version: zod.number().default(featureFlagsUpdateBodyVersionDefault),
        ensure_experience_continuity: zod.boolean().nullish(),
        tags: zod.array(zod.unknown()).optional(),
        evaluation_contexts: zod.array(zod.unknown()).optional(),
        analytics_dashboards: zod.array(zod.number()).optional(),
        has_enriched_analytics: zod.boolean().nullish(),
        creation_context: zod
            .enum([
                'feature_flags',
                'experiments',
                'surveys',
                'early_access_features',
                'web_experiments',
                'product_tours',
            ])
            .describe(
                '\* `feature_flags` - feature_flags\n\* `experiments` - experiments\n\* `surveys` - surveys\n\* `early_access_features` - early_access_features\n\* `web_experiments` - web_experiments\n\* `product_tours` - product_tours'
            )
            .optional()
            .describe(
                "Indicates the origin product of the feature flag. Choices: 'feature_flags', 'experiments', 'surveys', 'early_access_features', 'web_experiments', 'product_tours'.\n\n\* `feature_flags` - feature_flags\n\* `experiments` - experiments\n\* `surveys` - surveys\n\* `early_access_features` - early_access_features\n\* `web_experiments` - web_experiments\n\* `product_tours` - product_tours"
            ),
        is_remote_configuration: zod.boolean().nullish(),
        has_encrypted_payloads: zod.boolean().nullish(),
        evaluation_runtime: zod
            .union([
                zod
                    .enum(['server', 'client', 'all'])
                    .describe('\* `server` - Server\n\* `client` - Client\n\* `all` - All'),
                zod.enum(['']),
                zod.null(),
            ])
            .optional()
            .describe(
                'Specifies where this feature flag should be evaluated\n\n\* `server` - Server\n\* `client` - Client\n\* `all` - All'
            ),
        bucketing_identifier: zod
            .union([
                zod
                    .enum(['distinct_id', 'device_id'])
                    .describe('\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID'),
                zod.enum(['']),
                zod.null(),
            ])
            .optional()
            .describe(
                'Identifier used for bucketing users into rollout and variants\n\n\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID'
            ),
        _create_in_folder: zod.string().optional(),
    })
    .describe('Serializer mixin that handles tags for objects.')

/**
 * Create, read, update and delete feature flags. [See docs](https://posthog.com/docs/feature-flags) for more information on feature flags.
 *
 * If you're looking to use feature flags on your application, you can either use our JavaScript Library or our dedicated endpoint to check if feature flags are enabled for a given user.
 */
export const featureFlagsPartialUpdateBodyAskRollbackReasonDefault = false
export const featureFlagsPartialUpdateBodyRollbackReasonNoteMax = 1000

export const featureFlagsPartialUpdateBodyFiltersOneEarlyExitDefault = false
export const featureFlagsPartialUpdateBodyVersionMin = 0

export const FeatureFlagsPartialUpdateBody = /* @__PURE__ */ zod.object({
    ask_rollback_reason: zod
        .boolean()
        .default(featureFlagsPartialUpdateBodyAskRollbackReasonDefault)
        .describe(
            "When true, the edit lowers the flag's exposure, and the request sends no `rollback_reason`, the flag is not saved and the response is a 409 with the code `rollback_reason_required`. Send the edit again without this field to save it, with or without a `rollback_reason`. Ignored for an edit that needs approval and for a config version 2 flag."
        ),
    rollback_reason: zod
        .union([
            zod
                .enum(['errors', 'metrics', 'planned', 'wrong_configuration', 'other'])
                .describe(
                    '\* `errors` - Errors or bugs\n\* `metrics` - Metrics got worse\n\* `planned` - It was planned\n\* `wrong_configuration` - Wrong configuration\n\* `other` - Other'
                ),
            zod.null(),
        ])
        .optional()
        .describe(
            "Why this edit lowers the flag's exposure, for example a rollback after errors. Stored on the activity log entry of the edit. Not stored for an edit that needs approval or for a config version 2 flag.\n\n\* `errors` - Errors or bugs\n\* `metrics` - Metrics got worse\n\* `planned` - It was planned\n\* `wrong_configuration` - Wrong configuration\n\* `other` - Other"
        ),
    rollback_reason_note: zod
        .string()
        .max(featureFlagsPartialUpdateBodyRollbackReasonNoteMax)
        .nullish()
        .describe('A free-text note for `rollback_reason`. Requires `rollback_reason`.'),
    key: zod.string().optional().describe('Feature flag key.'),
    name: zod
        .string()
        .optional()
        .describe('Feature flag description (stored in the `name` field for backwards compatibility).'),
    filters: zod
        .object({
            groups: zod
                .array(
                    zod.object({
                        properties: zod
                            .array(
                                zod.union([
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        value: zod
                                            .unknown()
                                            .describe(
                                                'Comparison value for the property filter. Supports strings, numbers, booleans, and arrays.'
                                            ),
                                        operator: zod
                                            .enum([
                                                'exact',
                                                'is_not',
                                                'icontains',
                                                'not_icontains',
                                                'starts_with',
                                                'not_starts_with',
                                                'ends_with',
                                                'not_ends_with',
                                                'regex',
                                                'not_regex',
                                                'gt',
                                                'gte',
                                                'lt',
                                                'lte',
                                            ])
                                            .describe(
                                                '\* `exact` - exact\n\* `is_not` - is_not\n\* `icontains` - icontains\n\* `not_icontains` - not_icontains\n\* `starts_with` - starts_with\n\* `not_starts_with` - not_starts_with\n\* `ends_with` - ends_with\n\* `not_ends_with` - not_ends_with\n\* `regex` - regex\n\* `not_regex` - not_regex\n\* `gt` - gt\n\* `gte` - gte\n\* `lt` - lt\n\* `lte` - lte'
                                            )
                                            .describe(
                                                'Operator used to compare the property value.\n\n\* `exact` - exact\n\* `is_not` - is_not\n\* `icontains` - icontains\n\* `not_icontains` - not_icontains\n\* `starts_with` - starts_with\n\* `not_starts_with` - not_starts_with\n\* `ends_with` - ends_with\n\* `not_ends_with` - not_ends_with\n\* `regex` - regex\n\* `not_regex` - not_regex\n\* `gt` - gt\n\* `gte` - gte\n\* `lt` - lt\n\* `lte` - lte'
                                            ),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['is_set', 'is_not_set'])
                                            .describe('\* `is_set` - is_set\n\* `is_not_set` - is_not_set')
                                            .describe(
                                                'Existence operator.\n\n\* `is_set` - is_set\n\* `is_not_set` - is_not_set'
                                            ),
                                        value: zod
                                            .unknown()
                                            .optional()
                                            .describe(
                                                'Optional value. Runtime behavior determines whether this is ignored.'
                                            ),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['is_date_exact', 'is_date_before', 'is_date_after'])
                                            .describe(
                                                '\* `is_date_exact` - is_date_exact\n\* `is_date_before` - is_date_before\n\* `is_date_after` - is_date_after'
                                            )
                                            .describe(
                                                'Date comparison operator.\n\n\* `is_date_exact` - is_date_exact\n\* `is_date_after` - is_date_after\n\* `is_date_before` - is_date_before'
                                            ),
                                        value: zod
                                            .string()
                                            .describe('Date value in ISO format or relative date expression.'),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum([
                                                'semver_eq',
                                                'semver_neq',
                                                'semver_gt',
                                                'semver_gte',
                                                'semver_lt',
                                                'semver_lte',
                                                'semver_tilde',
                                                'semver_caret',
                                                'semver_wildcard',
                                            ])
                                            .describe(
                                                '\* `semver_eq` - semver_eq\n\* `semver_neq` - semver_neq\n\* `semver_gt` - semver_gt\n\* `semver_gte` - semver_gte\n\* `semver_lt` - semver_lt\n\* `semver_lte` - semver_lte\n\* `semver_tilde` - semver_tilde\n\* `semver_caret` - semver_caret\n\* `semver_wildcard` - semver_wildcard'
                                            )
                                            .describe(
                                                'Semantic version comparison operator.\n\n\* `semver_eq` - semver_eq\n\* `semver_neq` - semver_neq\n\* `semver_gt` - semver_gt\n\* `semver_gte` - semver_gte\n\* `semver_lt` - semver_lt\n\* `semver_lte` - semver_lte\n\* `semver_tilde` - semver_tilde\n\* `semver_caret` - semver_caret\n\* `semver_wildcard` - semver_wildcard'
                                            ),
                                        value: zod.string().describe('Semantic version string.'),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort', 'person', 'group'])
                                            .describe('\* `cohort` - cohort\n\* `person` - person\n\* `group` - group')
                                            .optional()
                                            .describe(
                                                "Property filter type. Set it on every property. Use `group` with `group_type_index` to filter on a group's properties.\n\n\* `cohort` - cohort\n\* `person` - person\n\* `group` - group"
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['icontains_multi', 'not_icontains_multi'])
                                            .describe(
                                                '\* `icontains_multi` - icontains_multi\n\* `not_icontains_multi` - not_icontains_multi'
                                            )
                                            .describe(
                                                'Multi-contains operator.\n\n\* `icontains_multi` - icontains_multi\n\* `not_icontains_multi` - not_icontains_multi'
                                            ),
                                        value: zod.array(zod.string()).describe('List of strings to evaluate against.'),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['cohort'])
                                            .describe('\* `cohort` - cohort')
                                            .describe(
                                                'Cohort property type required for in\/not_in operators.\n\n\* `cohort` - cohort'
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['in', 'not_in'])
                                            .describe('\* `in` - in\n\* `not_in` - not_in')
                                            .describe(
                                                'Membership operator for cohort properties.\n\n\* `in` - in\n\* `not_in` - not_in'
                                            ),
                                        value: zod
                                            .unknown()
                                            .describe('Cohort comparison value (single or list, depending on usage).'),
                                        cohort_deleted: zod
                                            .boolean()
                                            .optional()
                                            .describe(
                                                'Set to true in responses when the cohort is deleted or does not exist. The flag cannot evaluate this condition. Ignored on write.'
                                            ),
                                        cohort_missing: zod
                                            .boolean()
                                            .optional()
                                            .describe(
                                                'Set to true in responses when no cohort with this id exists in the project, so it cannot be restored. `cohort_deleted` is also true. Absent for a soft-deleted cohort. Ignored on write.'
                                            ),
                                    }),
                                    zod.object({
                                        key: zod.string().describe('Property key used in this feature flag condition.'),
                                        type: zod
                                            .enum(['flag'])
                                            .describe('\* `flag` - flag')
                                            .describe(
                                                'Flag property type required for flag dependency checks.\n\n\* `flag` - flag'
                                            ),
                                        cohort_name: zod
                                            .string()
                                            .nullish()
                                            .describe('Resolved cohort name for cohort-type filters.'),
                                        group_type_index: zod
                                            .number()
                                            .nullish()
                                            .describe(
                                                "Group type index a `group` filter reads properties from. Defaults to the condition set's `aggregation_group_type_index`."
                                            ),
                                        operator: zod
                                            .enum(['flag_evaluates_to'])
                                            .describe('\* `flag_evaluates_to` - flag_evaluates_to')
                                            .describe(
                                                'Operator for feature flag dependency evaluation.\n\n\* `flag_evaluates_to` - flag_evaluates_to'
                                            ),
                                        value: zod.unknown().describe('Value to compare flag evaluation against.'),
                                    }),
                                ])
                            )
                            .optional()
                            .describe('Property conditions for this release condition group.'),
                        rollout_percentage: zod
                            .number()
                            .optional()
                            .describe('Rollout percentage for this release condition group.'),
                        variant: zod.string().nullish().describe('Variant key override for multivariate flags.'),
                        aggregation_group_type_index: zod
                            .number()
                            .nullish()
                            .describe('Group type index for this condition set. None means person-level aggregation.'),
                    })
                )
                .optional()
                .describe('Release condition groups for the feature flag.'),
            multivariate: zod
                .union([
                    zod.object({
                        variants: zod
                            .array(
                                zod.object({
                                    key: zod.string().describe('Unique key for this variant.'),
                                    name: zod.string().optional().describe('Human-readable name for this variant.'),
                                    rollout_percentage: zod.number().describe('Variant rollout percentage.'),
                                })
                            )
                            .describe('Variant definitions for multivariate feature flags.'),
                    }),
                    zod.null(),
                ])
                .optional()
                .describe('Multivariate configuration for variant-based rollouts.'),
            aggregation_group_type_index: zod
                .number()
                .nullish()
                .describe('Group type index for group-based feature flags.'),
            payloads: zod
                .record(zod.string(), zod.string())
                .optional()
                .describe('Optional payload values keyed by variant key.'),
            feature_enrollment: zod
                .boolean()
                .nullish()
                .describe(
                    'Whether this flag has early access feature enrollment enabled. When true, the flag is evaluated against the person property $feature_enrollment\/{flag_key}.'
                ),
            early_exit: zod
                .boolean()
                .default(featureFlagsPartialUpdateBodyFiltersOneEarlyExitDefault)
                .describe(
                    'When true, condition evaluation stops at the first matching condition set rather than continuing to evaluate subsequent groups.'
                ),
        })
        .optional()
        .describe('Feature flag targeting configuration.'),
    active: zod.boolean().optional().describe('Whether the feature flag is active.'),
    archived: zod
        .boolean()
        .optional()
        .describe(
            'Whether the flag is archived. Archived flags are hidden from the flag list by default and must be disabled (`active: false`).'
        ),
    tags: zod.array(zod.string()).optional().describe('Organizational tags for this feature flag.'),
    evaluation_contexts: zod
        .array(zod.string())
        .optional()
        .describe('Evaluation contexts that control where this flag evaluates at runtime.'),
    is_remote_configuration: zod
        .boolean()
        .nullish()
        .describe(
            'Whether this flag is a remote configuration flag that delivers a payload rather than gating a feature.'
        ),
    ensure_experience_continuity: zod
        .boolean()
        .nullish()
        .describe(
            "Whether to persist a user's flag value across the anonymous-to-identified transition (the 'persist across authentication steps' option). Incompatible with device_id bucketing."
        ),
    evaluation_runtime: zod
        .union([
            zod
                .enum(['server', 'client', 'all'])
                .describe('\* `server` - Server\n\* `client` - Client\n\* `all` - All'),
            zod.null(),
        ])
        .optional()
        .describe(
            "Where this flag is allowed to evaluate: 'server' (server-side SDKs only), 'client' (client-side SDKs only), or 'all' (both). Defaults to 'all'.\n\n\* `server` - Server\n\* `client` - Client\n\* `all` - All"
        ),
    bucketing_identifier: zod
        .union([
            zod
                .enum(['distinct_id', 'device_id'])
                .describe('\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID'),
            zod.null(),
        ])
        .optional()
        .describe(
            "Identifier used to bucket users into rollout percentages and variants: 'distinct_id' (user ID, the default) or 'device_id'. Using 'device_id' is incompatible with ensure_experience_continuity=True.\n\n\* `distinct_id` - User ID (default)\n\* `device_id` - Device ID"
        ),
    version: zod
        .number()
        .min(featureFlagsPartialUpdateBodyVersionMin)
        .optional()
        .describe(
            "The `version` from your most recent read of this flag. Required when the flag's `filters.version` is 2: the update is then refused with 409 if anyone else changed the flag after that version. Other flags do not check it."
        ),
})

/**
 * Start a read-only analysis of where the project's GitHub repository checks this flag.
 *
 * An agent clones the repository, finds every check of the flag, and reports the code each outcome runs.
 * It does not change code or the flag. Returns 400 when no repository can be chosen (see
 * `code_analysis_target`), 403 when AI data processing is not approved or the request comes from a task
 * sandbox, and 409 when an analysis is already running.
 */
export const featureFlagsAnalyzeCodeCreateBodyRepositoryMax = 255

export const FeatureFlagsAnalyzeCodeCreateBody = /* @__PURE__ */ zod.object({
    repository: zod
        .string()
        .max(featureFlagsAnalyzeCodeCreateBodyRepositoryMax)
        .nullish()
        .describe(
            "GitHub repository to analyze, as `organization\/repository`. It must be connected to the project's GitHub integration. Omit it to use the repository the last analysis used, the environment's default flag cleanup repository, or the only connected repository."
        ),
})

/**
 * Disable a feature flag.
 *
 * Sets `active` to false and changes nothing else. Targeting, variants, payloads, tags and
 * archived state are left as they are. Refused when other active flags depend on this one.
 * An already-disabled flag is returned unchanged.
 *
 * A disabled flag stops evaluating for every consumer, including a linked experiment or a
 * session replay setting. Read the full definition first to report that impact.
 *
 * Send the `version` your last read returned. A flag whose `filters.version` is 2 requires
 * it, and for any flag a change after that version is refused with 409.
 */
export const featureFlagsDisableCreateBodyVersionMin = 0

export const FeatureFlagsDisableCreateBody = /* @__PURE__ */ zod.object({
    version: zod
        .number()
        .min(featureFlagsDisableCreateBodyVersionMin)
        .nullish()
        .describe(
            "The `version` from your most recent read of this flag. Required when the flag's `filters.version` is 2, optional otherwise. When sent, the change is refused with 409 if anyone else changed the flag after that version. Null is the same as leaving it out."
        ),
})

/**
 * Enable a feature flag.
 *
 * Sets `active` to true and changes nothing else. Targeting, variants, payloads, tags and
 * archived state are left as they are. An archived flag is refused: unarchive it first. A
 * flag whose own flag dependencies are disabled or use an unsupported configuration
 * format is also refused, as is a flag whose release conditions target a deleted cohort.
 * An already-enabled flag is returned unchanged.
 *
 * Send the `version` your last read returned. A flag whose `filters.version` is 2 requires
 * it, and for any flag a change after that version is refused with 409.
 */
export const featureFlagsEnableCreateBodyVersionMin = 0

export const FeatureFlagsEnableCreateBody = /* @__PURE__ */ zod.object({
    version: zod
        .number()
        .min(featureFlagsEnableCreateBodyVersionMin)
        .nullish()
        .describe(
            "The `version` from your most recent read of this flag. Required when the flag's `filters.version` is 2, optional otherwise. When sent, the change is refused with 409 if anyone else changed the flag after that version. Null is the same as leaving it out."
        ),
})

/**
 * Open a draft pull request that removes this stale flag's checks from the code.
 *
 * An agent starts from the checks the latest code analysis found, keeps the code for one outcome, and
 * opens the pull request in the repository the analysis read. It does not change the flag. Returns 400
 * when the flag isn't stale, the analysis found no checks, or an outcome must be chosen (see
 * `cleanup` on `code_analysis`), 403 when AI data processing is not approved or the request comes from a
 * task sandbox, and 409 when a cleanup pull request is still being opened.
 */
export const featureFlagsOpenCleanupPrCreateBodyKeepOutcomeMax = 400

export const FeatureFlagsOpenCleanupPrCreateBody = /* @__PURE__ */ zod.object({
    keep_outcome: zod
        .string()
        .max(featureFlagsOpenCleanupPrCreateBodyKeepOutcomeMax)
        .nullish()
        .describe(
            'Outcome whose code to keep: `enabled`, `disabled`, or a variant key from `cleanup.outcome_options`. Omit it to keep `cleanup.suggested_outcome`.'
        ),
})

/**
 * Serve a feature flag to every user.
 *
 * Adds a release condition with no property filters at 100% and keeps the existing
 * conditions below it. Payloads, holdout and every other field are left as they are. On a
 * boolean flag, removing the new condition restores the previous targeting. On a
 * multivariate flag the variant distribution is rewritten as well, so removing the
 * condition restores the audience but not the old split. A flag that already leads with
 * such a condition gains no second one.
 *
 * This changes targeting only. A disabled flag still serves nobody, and a holdout is
 * evaluated before release conditions, so users in one keep getting the holdout variant
 * instead of the rollout. A flag gated on early access enrollment is refused, because that
 * gate is evaluated before release conditions too and no targeting change gets past it.
 *
 * A multivariate flag needs `variant_key`, and every other flag rejects it. A release
 * condition decides who the flag serves, not which variant they get, so rolling a
 * multivariate flag out to everyone also gives the named variant 100% of the variant
 * distribution and every other variant 0%. To serve everyone and keep the current split
 * between variants, update the flag instead.
 *
 * Send the `version` your last read returned. A change to the flag after that version is
 * refused with 409. Read the flag again and decide the rollout against its current
 * definition.
 */
export const featureFlagsRollOutToEveryoneCreateBodyVersionMin = 0

export const FeatureFlagsRollOutToEveryoneCreateBody = /* @__PURE__ */ zod.object({
    version: zod
        .number()
        .min(featureFlagsRollOutToEveryoneCreateBodyVersionMin)
        .nullable()
        .describe(
            'The `version` from your most recent read of this flag. The change is refused with 409 if anyone else changed the flag after that version. A flag written before versioning reads as `null`; send that back unchanged and it is read as 0, so the value a read returns is always one this accepts.'
        ),
    variant_key: zod
        .string()
        .nullish()
        .describe(
            'The variant every user gets. Required for a multivariate flag and rejected for any other flag, because a release condition decides who the flag serves and not which variant they get.'
        ),
})

/**
 * Set what percentage of one release condition's audience a feature flag is served to.
 *
 * Changes `rollout_percentage` on the release condition at `condition_index` and nothing
 * else. The condition's property filters, every other condition, the variants, payloads,
 * holdout and every remaining field are left as they are.
 *
 * Send the `version` your last read returned. A change to the flag after that version is
 * refused with 409, because a condition index only names the condition you read. Read the
 * flag again and decide the percentage against its current definition.
 *
 * On a multivariate flag this sets how many of the matching users get a variant at all. It
 * does not change how the variants are split between them.
 */
export const featureFlagsSetReleaseConditionRolloutCreateBodyConditionIndexMin = 0

export const featureFlagsSetReleaseConditionRolloutCreateBodyRolloutPercentageMin = 0
export const featureFlagsSetReleaseConditionRolloutCreateBodyRolloutPercentageMax = 100

export const featureFlagsSetReleaseConditionRolloutCreateBodyVersionMin = 0

export const FeatureFlagsSetReleaseConditionRolloutCreateBody = /* @__PURE__ */ zod.object({
    condition_index: zod
        .number()
        .min(featureFlagsSetReleaseConditionRolloutCreateBodyConditionIndexMin)
        .describe(
            'Zero-based position of the release condition in `filters.groups`, counted from the read that produced `version`.'
        ),
    rollout_percentage: zod
        .number()
        .min(featureFlagsSetReleaseConditionRolloutCreateBodyRolloutPercentageMin)
        .max(featureFlagsSetReleaseConditionRolloutCreateBodyRolloutPercentageMax)
        .describe(
            'Percentage of the users matching that condition who are served the flag, 0 through 100. On a multivariate flag this is how many matching users get a variant at all, not how the variants are split between them. Fractional percentages such as 0.5 are accepted, the same as a write that sends `filters`.'
        ),
    version: zod
        .number()
        .min(featureFlagsSetReleaseConditionRolloutCreateBodyVersionMin)
        .nullable()
        .describe(
            'The `version` from your most recent read of this flag. The change is refused with 409 if anyone else changed the flag after that version. A flag written before versioning reads as `null`; send that back unchanged and it is read as 0, so the value a read returns is always one this accepts.'
        ),
})

/**
 * Test feature flag evaluation against a specific user at an optional point in time.
 *
 * This endpoint allows testing how a feature flag would evaluate for a specific user,
 * optionally at a historical timestamp. When a timestamp is provided, both the flag
 * conditions and person properties are evaluated as they existed at that time.
 */
export const FeatureFlagsTestEvaluationCreateBody = /* @__PURE__ */ zod.object({
    distinct_id: zod
        .string()
        .optional()
        .describe('User distinct ID to test against (mutually exclusive with person_id)'),
    person_id: zod.string().optional().describe('Person ID to test against (mutually exclusive with distinct_id)'),
    timestamp: zod.iso
        .datetime({ offset: true })
        .nullish()
        .describe(
            'Optional point-in-time to evaluate the flag against — both flag conditions and person properties are reconstructed as they existed at that timestamp. ISO 8601 with timezone, e.g. ``2026-04-29T15:30:00Z`` or ``2026-04-29T15:30:00+00:00``. Naive timestamps (no timezone) are interpreted as UTC.'
        ),
    groups: zod
        .unknown()
        .optional()
        .describe('Groups for feature flag evaluation (JSON object, defaults to empty dict)'),
})

/**
 * Bulk delete feature flags by filter criteria or explicit IDs.
 *
 * Accepts either:
 * - {"filters": {...}} - Same filter params as list endpoint (search, active, type, etc.)
 * - {"ids": [...]} - Explicit list of flag IDs (no limit)
 *
 * Returns same format as bulk_delete for UI compatibility.
 *
 * Config version 1 flags are deleted with batched updates, and cache invalidation
 * runs once at the end. Config version 2 flags are deleted one at a time through
 * ``update_flag``. Each one bumps its ``version`` and commits on its own.
 */

export const FeatureFlagsBulkDeleteCreateBody = /* @__PURE__ */ zod.object({
    filters: zod
        .object({
            active: zod
                .enum(['true', 'false', 'STALE'])
                .describe('\* `true` - true\n\* `false` - false\n\* `STALE` - STALE')
                .optional()
                .describe(
                    "'true' and 'false' filter on serving state, the flag's `active` column. 'STALE' returns enabled flags only, so a disabled flag is never STALE. An enabled flag matches when its last recorded `$feature_flag_called` event is more than 30 days old. With no recorded event, it matches when it is at least 30 days old and either stores `filters` as `{}` or serves one result to everyone through a release condition at 100% with no property filters. A flag with no recorded event and an empty `groups` list does not match, even when its `status` reads STALE. The reverse also happens: a multivariate flag matches when a variant is at 100% under a release condition at 100% with no property filters, or when that condition names a variant. Its `status` can still read ACTIVE, because an earlier variant in the list or an earlier targeted condition can serve a different result. In a flag of either type that mixes person and group aggregation, the filter also counts a group-aggregated condition at 100% with no property filters, which `status` does not. An SDK that sends no `$feature_flag_called` event leaves no record, so a STALE flag can still be in use.\n\n\* `true` - true\n\* `false` - false\n\* `STALE` - STALE"
                ),
            created_by_id: zod.number().optional().describe('Filter to flags created by a specific user ID.'),
            search: zod
                .string()
                .optional()
                .describe(
                    'Search by feature flag key or name (case-insensitive). Spaces, underscores, and hyphens count as the same separator.'
                ),
            type: zod
                .enum(['boolean', 'multivariant', 'experiment', 'remote_config'])
                .describe(
                    '\* `boolean` - boolean\n\* `multivariant` - multivariant\n\* `experiment` - experiment\n\* `remote_config` - remote_config'
                )
                .optional()
                .describe(
                    'Filter by flag type.\n\n\* `boolean` - boolean\n\* `multivariant` - multivariant\n\* `experiment` - experiment\n\* `remote_config` - remote_config'
                ),
            evaluation_runtime: zod
                .enum(['server', 'client', 'all'])
                .describe('\* `server` - Server\n\* `client` - Client\n\* `all` - All')
                .optional()
                .describe(
                    'Filter by evaluation runtime.\n\n\* `server` - Server\n\* `client` - Client\n\* `all` - All'
                ),
            excluded_properties: zod
                .string()
                .optional()
                .describe('JSON-encoded property filter to exclude. Same shape as the list endpoint.'),
            tags: zod
                .array(zod.string())
                .optional()
                .describe('Tag names to filter by. Flags carrying at least one of these tags match.'),
            excluded_tags: zod
                .array(zod.string())
                .optional()
                .describe('Tag names to exclude. Flags carrying any of these tags are filtered out.'),
            has_evaluation_contexts: zod
                .boolean()
                .optional()
                .describe('When true, only matches flags with at least one evaluation context.'),
            archived: zod
                .boolean()
                .optional()
                .describe('Filter by archived state. When omitted, archived flags are excluded.'),
        })
        .describe("Allowed filter keys for bulk_delete — same shape as the list endpoint's query params.")
        .optional()
        .describe(
            "Filter criteria — same shape as the list endpoint's query params. Mutually exclusive with `ids`. Use this to bulk-delete by search\/active\/tags\/etc. instead of supplying explicit IDs."
        ),
    ids: zod
        .array(zod.number().min(1))
        .optional()
        .describe('Explicit feature flag IDs to soft-delete. Mutually exclusive with `filters`.'),
})

/**
 * Get feature flag keys by IDs.
 * Accepts a list of feature flag IDs and returns a mapping of ID to key.
 */
export const FeatureFlagsBulkKeysRetrieveBody = /* @__PURE__ */ zod.object({
    ids: zod
        .array(zod.unknown())
        .optional()
        .describe(
            'Feature flag IDs to look up keys for. Strings of digits are also accepted; any other value is reported in the response `warning` field and otherwise ignored.'
        ),
})

/**
 * Bulk update tags on multiple objects.
 *
 * PAT access: this action has no ``required_scopes=`` on the decorator —
 * inheriting viewsets must add ``"bulk_update_tags"`` to their
 * ``scope_object_write_actions`` list to accept personal API keys.
 * Without that opt-in, ``APIScopePermission`` rejects PAT requests with
 * "This action does not support personal API key access". Done per-viewset
 * so granting ``<scope>:write`` for one resource doesn't leak access to
 * sibling resources that share this mixin.
 *
 * Accepts:
 * - {"ids": [...], "action": "add"|"remove"|"set", "tags": ["tag1", "tag2"]}
 *
 * Actions:
 * - "add": Add tags to existing tags on each object
 * - "remove": Remove specific tags from each object
 * - "set": Replace all tags on each object with the provided list
 */
export const featureFlagsBulkUpdateTagsCreateBodyIdsMax = 500

export const featureFlagsBulkUpdateTagsCreateBodyTagsItemMax = 255

export const featureFlagsBulkUpdateTagsCreateBodyTagsMax = 100

export const FeatureFlagsBulkUpdateTagsCreateBody = /* @__PURE__ */ zod.object({
    ids: zod
        .array(zod.number())
        .max(featureFlagsBulkUpdateTagsCreateBodyIdsMax)
        .describe('List of object IDs to update tags on.'),
    action: zod
        .enum(['add', 'remove', 'set'])
        .describe('\* `add` - add\n\* `remove` - remove\n\* `set` - set')
        .describe(
            "'add' merges with existing tags, 'remove' deletes specific tags, 'set' replaces all tags.\n\n\* `add` - add\n\* `remove` - remove\n\* `set` - set"
        ),
    tags: zod
        .array(zod.string().max(featureFlagsBulkUpdateTagsCreateBodyTagsItemMax))
        .max(featureFlagsBulkUpdateTagsCreateBodyTagsMax)
        .describe('Tag names to add, remove, or set (up to 100 per request, 255 characters each).'),
})

/**
 * Create, read, update and delete feature flags. [See docs](https://posthog.com/docs/feature-flags) for more information on feature flags.
 *
 * If you're looking to use feature flags on your application, you can either use our JavaScript Library or our dedicated endpoint to check if feature flags are enabled for a given user.
 */
export const FeatureFlagsUserBlastRadiusCreateBody = /* @__PURE__ */ zod.object({
    condition: zod.record(zod.string(), zod.unknown()).describe('The release condition to evaluate'),
    group_type_index: zod
        .number()
        .nullish()
        .describe('Group type index for group-based flags (null for person-based flags)'),
})

/**
 * Create, read, update and delete scheduled changes.
 */
export const scheduledChangesCreateBodyRecordIdMax = 200

export const scheduledChangesCreateBodyIsRecurringDefault = false
export const scheduledChangesCreateBodyCronExpressionMax = 100

export const ScheduledChangesCreateBody = /* @__PURE__ */ zod.object({
    record_id: zod
        .string()
        .max(scheduledChangesCreateBodyRecordIdMax)
        .describe('The ID of the record to modify (e.g. the feature flag ID).'),
    model_name: zod
        .enum(['FeatureFlag'])
        .describe('\* `FeatureFlag` - feature flag')
        .describe(
            'The type of record to modify. Currently only \"FeatureFlag\" is supported.\n\n\* `FeatureFlag` - feature flag'
        ),
    payload: zod
        .unknown()
        .describe(
            "The change to apply. Must include an 'operation' key and a 'value' key. Supported operations: 'update_status' (value: true\/false to enable\/disable the flag), 'add_release_condition' (value: object with 'groups', 'payloads', and 'multivariate' keys), 'update_variants' (value: object with 'variants' and 'payloads' keys)."
        ),
    scheduled_at: zod.iso
        .datetime({ offset: true })
        .describe("ISO 8601 datetime when the change should be applied (e.g. '2025-06-01T14:00:00Z')."),
    is_recurring: zod
        .boolean()
        .default(scheduledChangesCreateBodyIsRecurringDefault)
        .describe("Whether this schedule repeats. Only the 'update_status' operation supports recurring schedules."),
    recurrence_interval: zod
        .union([
            zod
                .enum(['daily', 'weekly', 'monthly', 'yearly'])
                .describe('\* `daily` - daily\n\* `weekly` - weekly\n\* `monthly` - monthly\n\* `yearly` - yearly'),
            zod.null(),
        ])
        .optional()
        .describe(
            'How often the schedule repeats. Required when is_recurring is true. One of: daily, weekly, monthly, yearly.\n\n\* `daily` - daily\n\* `weekly` - weekly\n\* `monthly` - monthly\n\* `yearly` - yearly'
        ),
    cron_expression: zod.string().max(scheduledChangesCreateBodyCronExpressionMax).nullish(),
    end_date: zod.iso
        .datetime({ offset: true })
        .nullish()
        .describe('Optional ISO 8601 datetime after which a recurring schedule stops executing.'),
})

/**
 * Create, read, update and delete scheduled changes.
 */
export const scheduledChangesUpdateBodyRecordIdMax = 200

export const scheduledChangesUpdateBodyIsRecurringDefault = false
export const scheduledChangesUpdateBodyCronExpressionMax = 100

export const ScheduledChangesUpdateBody = /* @__PURE__ */ zod.object({
    record_id: zod
        .string()
        .max(scheduledChangesUpdateBodyRecordIdMax)
        .describe('The ID of the record to modify (e.g. the feature flag ID).'),
    model_name: zod
        .enum(['FeatureFlag'])
        .describe('\* `FeatureFlag` - feature flag')
        .describe(
            'The type of record to modify. Currently only \"FeatureFlag\" is supported.\n\n\* `FeatureFlag` - feature flag'
        ),
    payload: zod
        .unknown()
        .describe(
            "The change to apply. Must include an 'operation' key and a 'value' key. Supported operations: 'update_status' (value: true\/false to enable\/disable the flag), 'add_release_condition' (value: object with 'groups', 'payloads', and 'multivariate' keys), 'update_variants' (value: object with 'variants' and 'payloads' keys)."
        ),
    scheduled_at: zod.iso
        .datetime({ offset: true })
        .describe("ISO 8601 datetime when the change should be applied (e.g. '2025-06-01T14:00:00Z')."),
    is_recurring: zod
        .boolean()
        .default(scheduledChangesUpdateBodyIsRecurringDefault)
        .describe("Whether this schedule repeats. Only the 'update_status' operation supports recurring schedules."),
    recurrence_interval: zod
        .union([
            zod
                .enum(['daily', 'weekly', 'monthly', 'yearly'])
                .describe('\* `daily` - daily\n\* `weekly` - weekly\n\* `monthly` - monthly\n\* `yearly` - yearly'),
            zod.null(),
        ])
        .optional()
        .describe(
            'How often the schedule repeats. Required when is_recurring is true. One of: daily, weekly, monthly, yearly.\n\n\* `daily` - daily\n\* `weekly` - weekly\n\* `monthly` - monthly\n\* `yearly` - yearly'
        ),
    cron_expression: zod.string().max(scheduledChangesUpdateBodyCronExpressionMax).nullish(),
    end_date: zod.iso
        .datetime({ offset: true })
        .nullish()
        .describe('Optional ISO 8601 datetime after which a recurring schedule stops executing.'),
})

/**
 * Create, read, update and delete scheduled changes.
 */
export const scheduledChangesPartialUpdateBodyRecordIdMax = 200

export const scheduledChangesPartialUpdateBodyIsRecurringDefault = false
export const scheduledChangesPartialUpdateBodyCronExpressionMax = 100

export const ScheduledChangesPartialUpdateBody = /* @__PURE__ */ zod.object({
    record_id: zod
        .string()
        .max(scheduledChangesPartialUpdateBodyRecordIdMax)
        .optional()
        .describe('The ID of the record to modify (e.g. the feature flag ID).'),
    model_name: zod
        .enum(['FeatureFlag'])
        .describe('\* `FeatureFlag` - feature flag')
        .optional()
        .describe(
            'The type of record to modify. Currently only \"FeatureFlag\" is supported.\n\n\* `FeatureFlag` - feature flag'
        ),
    payload: zod
        .unknown()
        .optional()
        .describe(
            "The change to apply. Must include an 'operation' key and a 'value' key. Supported operations: 'update_status' (value: true\/false to enable\/disable the flag), 'add_release_condition' (value: object with 'groups', 'payloads', and 'multivariate' keys), 'update_variants' (value: object with 'variants' and 'payloads' keys)."
        ),
    scheduled_at: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe("ISO 8601 datetime when the change should be applied (e.g. '2025-06-01T14:00:00Z')."),
    is_recurring: zod
        .boolean()
        .default(scheduledChangesPartialUpdateBodyIsRecurringDefault)
        .describe("Whether this schedule repeats. Only the 'update_status' operation supports recurring schedules."),
    recurrence_interval: zod
        .union([
            zod
                .enum(['daily', 'weekly', 'monthly', 'yearly'])
                .describe('\* `daily` - daily\n\* `weekly` - weekly\n\* `monthly` - monthly\n\* `yearly` - yearly'),
            zod.null(),
        ])
        .optional()
        .describe(
            'How often the schedule repeats. Required when is_recurring is true. One of: daily, weekly, monthly, yearly.\n\n\* `daily` - daily\n\* `weekly` - weekly\n\* `monthly` - monthly\n\* `yearly` - yearly'
        ),
    cron_expression: zod.string().max(scheduledChangesPartialUpdateBodyCronExpressionMax).nullish(),
    end_date: zod.iso
        .datetime({ offset: true })
        .nullish()
        .describe('Optional ISO 8601 datetime after which a recurring schedule stops executing.'),
})