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.

19.3 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'

/**
 * ViewSet for organization-level integrations.
 *
 * Provides access to integrations that are scoped to the entire organization
 * (vs. project-level integrations). Examples include Vercel, AWS Marketplace, etc.
 *
 * Creation is handled by the integration installation flows
 * (e.g., Vercel marketplace installation). Users can disconnect integrations
 * via the DELETE endpoint.
 */
export const IntegrationsEnvironmentMappingPartialUpdateBody = /* @__PURE__ */ zod
    .looseObject({})
    .describe('Serializer for organization-level integrations.')

export const roleExternalReferencesCreateBodyProviderMax = 32

export const roleExternalReferencesCreateBodyProviderOrganizationIdMax = 255

export const roleExternalReferencesCreateBodyProviderRoleIdMax = 255

export const roleExternalReferencesCreateBodyProviderRoleSlugMax = 255

export const roleExternalReferencesCreateBodyProviderRoleNameMax = 255

export const RoleExternalReferencesCreateBody = /* @__PURE__ */ zod.object({
    provider: zod
        .string()
        .max(roleExternalReferencesCreateBodyProviderMax)
        .describe('Integration kind (e.g., github, linear, jira, slack).'),
    provider_organization_id: zod
        .string()
        .max(roleExternalReferencesCreateBodyProviderOrganizationIdMax)
        .describe('Provider organization\/workspace\/site identifier.'),
    provider_role_id: zod
        .string()
        .max(roleExternalReferencesCreateBodyProviderRoleIdMax)
        .describe('Stable provider role identifier.'),
    provider_role_slug: zod
        .string()
        .max(roleExternalReferencesCreateBodyProviderRoleSlugMax)
        .nullish()
        .describe('Human-friendly provider role identifier.'),
    provider_role_name: zod
        .string()
        .max(roleExternalReferencesCreateBodyProviderRoleNameMax)
        .describe('Display name of the provider role.'),
    role: zod.uuid().describe('PostHog role UUID this external role maps to.'),
})

export const IntegrationsCreateBody = /* @__PURE__ */ zod
    .object({
        kind: zod
            .enum([
                'anthropic',
                'apple-ads',
                'apns',
                'aws-redshift',
                'aws-s3',
                'azure-blob',
                'bing-ads',
                'clickup',
                'customerio-app',
                'customerio-track',
                'customerio-webhook',
                'databricks',
                'email',
                'firebase',
                'github',
                'gitlab',
                'google-ads',
                'google-analytics',
                'google-calendar',
                'google-cloud-service-account',
                'google-cloud-storage',
                'google-pubsub',
                'google-search-console',
                'google-sheets',
                'helpscout',
                'hubspot',
                'instagram',
                'intercom',
                'jira',
                'linear',
                'linkedin-ads',
                'meta-ads',
                'pardot',
                'pinterest-ads',
                'postgresql',
                'posthog',
                'reddit-ads',
                'twitter-ads',
                'resend',
                's3-compatible',
                'salesforce',
                'slack',
                'slack-posthog-code',
                'snapchat',
                'snowflake',
                'stripe',
                'tiktok-ads',
                'twilio',
                'vercel',
                'youtube-analytics',
            ])
            .describe(
                '\* `anthropic` - Anthropic\n\* `apple-ads` - Apple Ads\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `twitter-ads` - Twitter Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
            )
            .describe(
                "The provider of the integration, for example 'slack' or 'github'.\n\n\* `anthropic` - Anthropic\n\* `apple-ads` - Apple Ads\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `twitter-ads` - Twitter Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics"
            ),
        config: zod.unknown().optional(),
    })
    .describe('The request schema of a create. A create accepts only the public kinds, so the schema lists them.')

export const integrationsEmailPartialUpdateBodyKindMax = 32

export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
    .object({
        kind: zod
            .string()
            .max(integrationsEmailPartialUpdateBodyKindMax)
            .optional()
            .describe(
                "The provider of the integration, for example 'slack' or 'github'. A create accepts only the kinds that PostHog connects here. Data warehouse sources also store their typed-in credentials as integrations, under a kind per source type."
            ),
        config: zod.unknown().optional(),
    })
    .describe('Standard Integration serializer.')

/**
 * Register existing device tokens, for example exported from another provider, on this push channel. Each token is stored encrypted on its person, as the mobile SDK stores it. A row fails when no person has its distinct ID, unless create_missing_persons is set, or when the token is the wrong kind for the channel. Send dry_run first to see every failure without storing anything.
 * @summary Import push device tokens
 */
export const integrationsPushTokensCreateBodySubscriptionsItemDistinctIdMax = 200

export const integrationsPushTokensCreateBodySubscriptionsItemDeviceTokenMax = 4096

export const integrationsPushTokensCreateBodyDryRunDefault = false
export const integrationsPushTokensCreateBodyCreateMissingPersonsDefault = false

export const IntegrationsPushTokensCreateBody = /* @__PURE__ */ zod.object({
    subscriptions: zod
        .array(
            zod.object({
                distinct_id: zod
                    .string()
                    .max(integrationsPushTokensCreateBodySubscriptionsItemDistinctIdMax)
                    .describe("The person's distinct ID in this project: the ID your app passes to `identify`."),
                device_token: zod
                    .string()
                    .max(integrationsPushTokensCreateBodySubscriptionsItemDeviceTokenMax)
                    .describe(
                        'The token of one device. An APNs channel takes the hex APNs device token. A Firebase channel takes the FCM registration token. Expo push tokens are not accepted.'
                    ),
            })
        )
        .describe('Up to 1000 devices to register on this push channel. List a person once per device.'),
    dry_run: zod
        .boolean()
        .default(integrationsPushTokensCreateBodyDryRunDefault)
        .describe(
            'Check every row and report what would fail, without storing anything. Run this first and fix the failed rows before importing.'
        ),
    import_id: zod
        .uuid()
        .nullish()
        .describe(
            'A new UUID for each batch. Send the same value when you retry that batch, so a retried batch can be recognized as a repeat.'
        ),
    create_missing_persons: zod
        .boolean()
        .default(integrationsPushTokensCreateBodyCreateMissingPersonsDefault)
        .describe(
            "Create a person for a distinct ID that has none. Off by default, because a distinct ID that does not match your app's identify call creates a person that never gets a push."
        ),
})

/**
 * Unified endpoint for generating Domain Connect apply URLs.
 *
 * Accepts a context ("email" or "proxy") and the relevant resource ID.
 * The backend resolves the domain, template variables, and service ID
 * based on context, then builds the signed apply URL.
 */
export const integrationsDomainConnectApplyUrlCreateBodyKindMax = 32

export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
    .object({
        kind: zod
            .string()
            .max(integrationsDomainConnectApplyUrlCreateBodyKindMax)
            .describe(
                "The provider of the integration, for example 'slack' or 'github'. A create accepts only the kinds that PostHog connects here. Data warehouse sources also store their typed-in credentials as integrations, under a kind per source type."
            ),
        config: zod.unknown().optional(),
    })
    .describe('Standard Integration serializer.')

/**
 * Reuse a GitHub installation already linked to a sibling team in the same organization.
 */
export const IntegrationsGithubLinkExistingCreateBody = /* @__PURE__ */ zod.object({
    discovery_id: zod.uuid().nullish().describe('Discovery response ID for diagnostics only; grants no authority.'),
    source_team_id: zod
        .number()
        .nullish()
        .describe('Sibling team in the same organization whose GitHub installation should be reused.'),
    installation_id: zod
        .string()
        .nullish()
        .describe('GitHub installation ID to link; resolved within the organization when source_team_id is omitted.'),
})

/**
 * Mint a User OAuth URL to bootstrap a fresh `code` when the install flow returns without one.
 */
export const IntegrationsGithubOauthAuthorizeCreateBody = /* @__PURE__ */ zod.object({
    installation_id: zod.string().optional().describe('GitHub installation ID to carry through the User OAuth flow.'),
    next: zod.string().optional().describe('Relative URL to redirect to after the OAuth flow completes.'),
    connect_from: zod
        .enum(['posthog_code'])
        .describe('\* `posthog_code` - posthog_code')
        .optional()
        .describe(
            "Originating surface for the connect flow; only 'posthog_code' is recognized.\n\n\* `posthog_code` - posthog_code"
        ),
})

/**
 * Seed GitHub setup callback state without redirecting to GitHub.
 *
 * Used when the user opens an existing installation's settings on github.com (e.g. PostHog
 * Code "Update in GitHub") so the subsequent Setup URL redirect can be validated.
 */
export const IntegrationsGithubPrepareCallbackCreateBody = /* @__PURE__ */ zod.object({
    next: zod
        .string()
        .optional()
        .describe(
            'Relative URL to redirect to after GitHub setup completes (e.g. account-connected for PostHog Desktop).'
        ),
    installation_id: zod
        .string()
        .optional()
        .describe(
            "GitHub installation ID being managed; binds the seeded update state so a callback can't swap in a different installation."
        ),
})

/**
 * Notify project admins that a member is requesting an integration be connected.
 */
export const integrationsRequestAccessCreateBodyReasonMax = 2000

export const IntegrationsRequestAccessCreateBody = /* @__PURE__ */ zod.object({
    kind: zod
        .enum([
            'anthropic',
            'apple-ads',
            'apns',
            'aws-redshift',
            'aws-s3',
            'azure-blob',
            'bing-ads',
            'clickup',
            'customerio-app',
            'customerio-track',
            'customerio-webhook',
            'databricks',
            'email',
            'firebase',
            'github',
            'gitlab',
            'google-ads',
            'google-analytics',
            'google-calendar',
            'google-cloud-service-account',
            'google-cloud-storage',
            'google-pubsub',
            'google-search-console',
            'google-sheets',
            'helpscout',
            'hubspot',
            'instagram',
            'intercom',
            'jira',
            'linear',
            'linkedin-ads',
            'meta-ads',
            'pardot',
            'pinterest-ads',
            'postgresql',
            'posthog',
            'reddit-ads',
            'twitter-ads',
            'resend',
            's3-compatible',
            'salesforce',
            'slack',
            'slack-posthog-code',
            'snapchat',
            'snowflake',
            'stripe',
            'tiktok-ads',
            'twilio',
            'vercel',
            'youtube-analytics',
        ])
        .describe(
            '\* `anthropic` - Anthropic\n\* `apple-ads` - Apple Ads\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `twitter-ads` - Twitter Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
        )
        .describe(
            "The kind of integration the member is requesting be connected (e.g. 'slack', 'github').\n\n\* `anthropic` - Anthropic\n\* `apple-ads` - Apple Ads\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `twitter-ads` - Twitter Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics"
        ),
    reason: zod
        .string()
        .max(integrationsRequestAccessCreateBodyReasonMax)
        .describe(
            'Explanation from the requester of why this integration is needed. Shown to admins in the notification email.'
        ),
})

/**
 * Replay an API request against the connected PostHog project. The server injects the connection's token; the response is passed through.
 * @summary Forward a request through a PostHog connection
 */
export const PosthogConnectionsForwardCreateBody = /* @__PURE__ */ zod.object({
    method: zod
        .enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
        .describe('\* `GET` - GET\n\* `POST` - POST\n\* `PUT` - PUT\n\* `PATCH` - PATCH\n\* `DELETE` - DELETE')
        .describe(
            "HTTP method to use against the target project's API.\n\n\* `GET` - GET\n\* `POST` - POST\n\* `PUT` - PUT\n\* `PATCH` - PATCH\n\* `DELETE` - DELETE"
        ),
    path: zod
        .string()
        .describe('Relative target API path with no host or scheme, e.g. `api\/projects\/2\/insights\/`.'),
    query: zod.record(zod.string(), zod.string()).optional().describe('Query parameters to send to the target.'),
    data: zod.unknown().optional().describe('JSON request body for write methods.'),
})