PostHog CaptureBatch

PostHog CaptureBatch

Certified

Capture a batch of PostHog events

Sends many analytics events in a single task, using the PostHog SDK's internal batching (POST /batch). Each item of from is an event with a required distinctId and event, and optional properties and timestamp. All items are validated before anything is sent, so an invalid item means that nothing is captured. Uses the project API key (phc_).

yaml
type: io.kestra.plugin.posthog.CaptureBatch

Capture several events at once

yaml
id: posthog_capture_batch
namespace: company.analytics

tasks:
  - id: capture_batch
    type: io.kestra.plugin.posthog.CaptureBatch
    apiKey: "{{ secret('POSTHOG_API_KEY') }}"
    host: "https://us.i.posthog.com"
    from:
      - distinctId: user_1
        event: pipeline_completed
        properties:
          pipeline_name: etl
      - distinctId: user_2
        event: pipeline_completed
        timestamp: "2026-01-01T00:00:00Z"
Properties

PostHog project API key

The project API key (starts with phc_). Use a Kestra secret, e.g. {{ secret('POSTHOG_API_KEY') }}.

Structured data items, either as a map, a list of map, a URI, or a JSON string.

Structured data items can be defined in the following ways:

  • A single item as a map (a document).
  • A list of items as a list of maps (a list of documents).
  • A URI, supported schemes are kestra for internal storage files, file for host local files, and nsfile for namespace files.
  • A JSON String that will then be serialized either as a single item or a list of items.

Each item is an event with the following keys: distinctId (required), event (required), properties (optional map) and timestamp (optional ISO-8601 date-time with an offset, e.g. 2026-01-01T00: 00: 00Z). Any other key is ignored.

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
Default1000

Maximum number of events per request

Maximum number of events the PostHog SDK sends in one POST /batch request. Must be at least 1. Inputs with at most this many events are sent in a single request.

PostHog host

The PostHog ingestion host, e.g. https://us.i.posthog.com (US Cloud), https://eu.i.posthog.com (EU Cloud) or a self-hosted URL. Defaults to US Cloud when empty.

Number of events handed to the PostHog SDK

The number of events handed to the PostHog SDK, which sent them and waited for the requests to finish. This is not a confirmation that PostHog accepted them: the SDK does not report delivery failures.