Corsair
PluginsPostHog

PostHog API Endpoints

Complete reference for all PostHog API endpoints

The PostHog plugin provides full access to PostHog's API through a typed interface. All endpoints are organized by resource type and automatically handle authentication, rate limiting, and error handling.

New to Corsair? Learn about core concepts like API access, authentication, and error handling before diving into specific endpoints.

Full Implementation: For the complete, up-to-date list of all endpoints and their implementations, see the PostHog plugin source code on GitHub.

Events

Track events, create aliases, and manage user identities.

eventCreate

events.eventCreate

Track a custom event.

await corsair.posthog.api.events.eventCreate({
    distinct_id: "user-123",
    event: "purchase",
    properties: {
        price: 29.99,
        product: "Premium Plan",
    },
});

Parameters:

NameTypeRequiredDescription
distinct_idstringYesUnique identifier for the user
eventstringYesEvent name
propertiesRecord<string, unknown>NoEvent properties
timestampstringNoEvent timestamp (ISO 8601)
uuidstringNoUnique event ID

aliasCreate

events.aliasCreate

Create an alias to link two distinct IDs.

await corsair.posthog.api.events.aliasCreate({
    distinct_id: "user-123",
    alias: "user-456",
});

Parameters:

NameTypeRequiredDescription
distinct_idstringYesOriginal distinct ID
aliasstringYesAlias distinct ID

identityCreate

events.identityCreate

Create or update a user identity.

await corsair.posthog.api.events.identityCreate({
    distinct_id: "user-123",
    properties: {
        email: "user@example.com",
        name: "John Doe",
    },
});

Parameters:

NameTypeRequiredDescription
distinct_idstringYesUnique identifier for the user
propertiesRecord<string, unknown>NoUser properties

trackPage

events.trackPage

Track a page view.

await corsair.posthog.api.events.trackPage({
    distinct_id: "user-123",
    url: "https://example.com/pricing",
    properties: {
        referrer: "https://google.com",
    },
});

Parameters:

NameTypeRequiredDescription
distinct_idstringYesUnique identifier for the user
urlstringYesPage URL
propertiesRecord<string, unknown>NoPage view properties
timestampstringNoEvent timestamp
uuidstringNoUnique event ID

trackScreen

events.trackScreen

Track a screen view (mobile apps).

await corsair.posthog.api.events.trackScreen({
    distinct_id: "user-123",
    screen_name: "HomeScreen",
    properties: {
        app_version: "1.0.0",
    },
});

Parameters:

NameTypeRequiredDescription
distinct_idstringYesUnique identifier for the user
screen_namestringYesScreen name
propertiesRecord<string, unknown>NoScreen view properties
timestampstringNoEvent timestamp
uuidstringNoUnique event ID