Result Types¶
Explore on DeepWiki
Ask questions about result structures, DataFrame conversion, or type usage patterns.
All result types are immutable frozen dataclasses with:
- Lazy DataFrame conversion via the
.dfproperty - JSON serialization via the
.to_dict()method - Full type hints for IDE/mypy support
App API Types¶
Types for the Mixpanel App API infrastructure.
mixpanel_headless.PublicWorkspace
¶
Bases: BaseModel
A workspace within a Mixpanel project.
Represents a workspace as returned by the Mixpanel App API
GET /api/app/projects/{pid}/workspaces/public endpoint.
Extra fields from the API response are preserved via extra="allow".
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Workspace identifier.
TYPE:
|
name |
Human-readable workspace name.
TYPE:
|
project_id |
Parent project identifier.
TYPE:
|
is_default |
Whether this is the default workspace.
TYPE:
|
description |
Workspace description, if set.
TYPE:
|
is_global |
Whether workspace is global.
TYPE:
|
is_restricted |
Whether workspace has restrictions.
TYPE:
|
is_visible |
Whether workspace is visible.
TYPE:
|
created_iso |
ISO 8601 creation timestamp.
TYPE:
|
creator_name |
Name of workspace creator.
TYPE:
|
Example
description
class-attribute
instance-attribute
¶
Workspace description, if set.
is_global
class-attribute
instance-attribute
¶
Whether workspace is global.
is_restricted
class-attribute
instance-attribute
¶
Whether workspace has restrictions.
is_visible
class-attribute
instance-attribute
¶
Whether workspace is visible.
created_iso
class-attribute
instance-attribute
¶
ISO 8601 creation timestamp.
creator_name
class-attribute
instance-attribute
¶
Name of workspace creator.
mixpanel_headless.CursorPagination
¶
Bases: BaseModel
Cursor-based pagination metadata from App API responses.
| ATTRIBUTE | DESCRIPTION |
|---|---|
page_size |
Number of items per page.
TYPE:
|
next_cursor |
Cursor for next page, or None if last page.
TYPE:
|
previous_cursor |
Cursor for previous page.
TYPE:
|
Example
mixpanel_headless.PaginatedResponse
¶
Bases: BaseModel, Generic[T]
Paginated App API response wrapper.
Generic wrapper for paginated responses from the Mixpanel App API. Contains the results list, status, and optional pagination metadata.
| ATTRIBUTE | DESCRIPTION |
|---|---|
status |
Response status (typically "ok").
TYPE:
|
results |
Page of results.
TYPE:
|
pagination |
Pagination metadata, or None for single-page responses.
TYPE:
|
Example
Insights Query Types¶
Types for Workspace.query() — typed Insights engine queries with composable metrics, filters, and breakdowns.
mixpanel_headless.Metric
dataclass
¶
Metric(
event: str,
math: MathType = "total",
property: str | CustomPropertyRef | InlineCustomProperty | None = None,
per_user: PerUserAggregation | None = None,
percentile_value: int | float | None = None,
filters: list[Filter] | None = None,
filters_combinator: FiltersCombinator = "all",
segment_method: SegmentMethod | None = None,
)
Encapsulates a single event to query with its aggregation settings.
Used with Workspace.query() to specify per-event math, property,
per-user aggregation, and filters. Plain event name strings inherit
top-level query defaults; Metric objects override them.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Mixpanel event name.
TYPE:
|
math |
Aggregation function. Default:
TYPE:
|
property |
Property for property-based math types (name, ref, or inline).
TYPE:
|
per_user |
Per-user pre-aggregation (average, total, min, max).
TYPE:
|
filters |
Per-metric filters (applied in addition to global
TYPE:
|
filters_combinator |
How per-metric filters combine.
TYPE:
|
Example
property
class-attribute
instance-attribute
¶
Property for property-based math types (name, ref, or inline).
per_user
class-attribute
instance-attribute
¶
Per-user pre-aggregation type.
percentile_value
class-attribute
instance-attribute
¶
Custom percentile value (e.g. 95 for p95).
Required when math="percentile". Ignored for other math types.
Maps to percentile in bookmark JSON.
filters
class-attribute
instance-attribute
¶
Per-metric filters (list of Filter objects).
filters_combinator
class-attribute
instance-attribute
¶
How per-metric filters combine ("all" = AND, "any" = OR).
segment_method
class-attribute
instance-attribute
¶
Segment method for counting qualifying events.
Controls how events are counted per user: "all" counts every
qualifying event (default server behavior), "first" counts
only the first qualifying event per user.
Maps to segmentMethod in the bookmark measurement block.
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event is empty or contains control characters (M1), math requires a property but none is set (M2), or math="percentile" but percentile_value is missing (M3). |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.Formula
dataclass
¶
A formula expression referencing events by position letter (A, B, C...).
Letters map to event positions in the list passed to
Workspace.query(). A is the first event, B the second, etc.
Can be passed as an element of the events list alongside strings
and Metric objects, or use the top-level formula parameter
for single-formula convenience.
| ATTRIBUTE | DESCRIPTION |
|---|---|
expression |
Formula expression, e.g.
TYPE:
|
label |
Optional display label for the formula result.
TYPE:
|
Example
from mixpanel_headless import Formula, Metric
# Formula in the events list
result = ws.query(
[Metric("Signup", math="unique"),
Metric("Purchase", math="unique"),
Formula("(B / A) * 100", label="Conversion %")],
)
# Equivalent using top-level parameter
result = ws.query(
[Metric("Signup", math="unique"),
Metric("Purchase", math="unique")],
formula="(B / A) * 100",
formula_label="Conversion %",
)
mixpanel_headless.Filter
dataclass
¶
Filter(
_property: str | CustomPropertyRef | InlineCustomProperty,
_operator: FilterOperator,
_value: str
| int
| float
| list[str]
| list[int | float]
| list[dict[str, Any]]
| None,
_property_type: FilterPropertyType = "string",
_resource_type: Literal["events", "people"] = "events",
_date_unit: FilterDateUnit | None = None,
_list_item_filters: tuple[Filter, ...] | None = None,
_list_item_quantifier: Literal["any", "all"] | None = None,
)
Represents a typed filter condition on a property.
Constructed exclusively via class methods — never instantiated directly. Each class method maps to specific filterType, filterOperator, and filterValue format in the bookmark JSON.
Example
__post_init__
¶
Validate Filter mode invariants.
Only validates the list_contains mode today. Other operator
modes rely on classmethod-only validation; expanding this
coverage is a separate concern from this PR's list_contains
feature.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/mixpanel_headless/types.py
equals
classmethod
¶
equals(
property: str | CustomPropertyRef | InlineCustomProperty,
value: str | list[str],
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create an equality filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Value or list of values.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for string equality. |
Source code in src/mixpanel_headless/types.py
not_equals
classmethod
¶
not_equals(
property: str | CustomPropertyRef | InlineCustomProperty,
value: str | list[str],
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a not-equals filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Value or list of values.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for string inequality. |
Source code in src/mixpanel_headless/types.py
contains
classmethod
¶
contains(
property: str | CustomPropertyRef | InlineCustomProperty,
value: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a contains (substring) filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Substring to match.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for substring containment. |
Source code in src/mixpanel_headless/types.py
not_contains
classmethod
¶
not_contains(
property: str | CustomPropertyRef | InlineCustomProperty,
value: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a not-contains filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Substring that must not match.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for substring non-containment. |
Source code in src/mixpanel_headless/types.py
greater_than
classmethod
¶
greater_than(
property: str | CustomPropertyRef | InlineCustomProperty,
value: int | float,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a greater-than filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Numeric threshold.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for numeric greater-than. |
Source code in src/mixpanel_headless/types.py
less_than
classmethod
¶
less_than(
property: str | CustomPropertyRef | InlineCustomProperty,
value: int | float,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a less-than filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Numeric threshold.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for numeric less-than. |
Source code in src/mixpanel_headless/types.py
between
classmethod
¶
between(
property: str | CustomPropertyRef | InlineCustomProperty,
min_val: int | float,
max_val: int | float,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a between (inclusive range) filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
min_val
|
Minimum value (inclusive).
TYPE:
|
max_val
|
Maximum value (inclusive).
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for numeric range. |
Source code in src/mixpanel_headless/types.py
not_between
classmethod
¶
not_between(
property: str | CustomPropertyRef | InlineCustomProperty,
min_val: int | float,
max_val: int | float,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a not-between (exclusive range) filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
min_val
|
Minimum value (exclusive).
TYPE:
|
max_val
|
Maximum value (exclusive).
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for numeric values outside the range. |
Source code in src/mixpanel_headless/types.py
at_least
classmethod
¶
at_least(
property: str | CustomPropertyRef | InlineCustomProperty,
value: int | float,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a greater-than-or-equal filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Numeric threshold (inclusive).
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for numeric greater-than-or-equal. |
Source code in src/mixpanel_headless/types.py
at_most
classmethod
¶
at_most(
property: str | CustomPropertyRef | InlineCustomProperty,
value: int | float,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a less-than-or-equal filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
value
|
Numeric threshold (inclusive).
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for numeric less-than-or-equal. |
Source code in src/mixpanel_headless/types.py
is_set
classmethod
¶
is_set(
property: str | CustomPropertyRef | InlineCustomProperty,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a property-existence filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for property existence. |
Source code in src/mixpanel_headless/types.py
is_not_set
classmethod
¶
is_not_set(
property: str | CustomPropertyRef | InlineCustomProperty,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a property-nonexistence filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for property non-existence. |
Source code in src/mixpanel_headless/types.py
starts_with
classmethod
¶
starts_with(
property: str | CustomPropertyRef | InlineCustomProperty,
prefix: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a starts-with (prefix match) filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
prefix
|
String prefix to match.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for string prefix matching. |
Source code in src/mixpanel_headless/types.py
ends_with
classmethod
¶
ends_with(
property: str | CustomPropertyRef | InlineCustomProperty,
suffix: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create an ends-with (suffix match) filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
suffix
|
String suffix to match.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for string suffix matching. |
Source code in src/mixpanel_headless/types.py
is_true
classmethod
¶
is_true(
property: str | CustomPropertyRef | InlineCustomProperty,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a boolean true filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for boolean true. |
Source code in src/mixpanel_headless/types.py
is_false
classmethod
¶
is_false(
property: str | CustomPropertyRef | InlineCustomProperty,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a boolean false filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for boolean false. |
Source code in src/mixpanel_headless/types.py
in_cohort
classmethod
¶
Create a filter restricting to users in a cohort.
Accepts either a saved cohort ID (int) or an inline
CohortDefinition. The filter can be passed to where=
on any query method (query, query_funnel,
query_retention, query_flow).
| PARAMETER | DESCRIPTION |
|---|---|
cohort
|
Saved cohort ID (positive integer) or inline
TYPE:
|
name
|
Display name for the cohort. Optional for saved cohorts; recommended for inline definitions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for cohort membership (contains). |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If cohort ID is not positive (CF1) or name is empty when provided (CF2). |
Example
Source code in src/mixpanel_headless/types.py
not_in_cohort
classmethod
¶
Create a filter excluding users in a cohort.
Accepts either a saved cohort ID (int) or an inline
CohortDefinition. The filter can be passed to where=
on any query method.
| PARAMETER | DESCRIPTION |
|---|---|
cohort
|
Saved cohort ID (positive integer) or inline
TYPE:
|
name
|
Display name for the cohort. Optional for saved cohorts; recommended for inline definitions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for cohort exclusion (does not contain). |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If cohort ID is not positive (CF1) or name is empty when provided (CF2). |
Source code in src/mixpanel_headless/types.py
on
classmethod
¶
on(
property: str | CustomPropertyRef | InlineCustomProperty,
date: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a date equality filter (exact date match).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty (e.g.
TYPE:
|
date
|
Date in YYYY-MM-DD format.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for exact date match. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If date is not valid YYYY-MM-DD. |
Source code in src/mixpanel_headless/types.py
not_on
classmethod
¶
not_on(
property: str | CustomPropertyRef | InlineCustomProperty,
date: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a date inequality filter (not on date).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
date
|
Date in YYYY-MM-DD format.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for date inequality. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If date is not valid YYYY-MM-DD. |
Source code in src/mixpanel_headless/types.py
before
classmethod
¶
before(
property: str | CustomPropertyRef | InlineCustomProperty,
date: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a date before filter.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
date
|
Date in YYYY-MM-DD format.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for dates before the specified date. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If date is not valid YYYY-MM-DD. |
Source code in src/mixpanel_headless/types.py
since
classmethod
¶
since(
property: str | CustomPropertyRef | InlineCustomProperty,
date: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a date since filter (from date onward).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
date
|
Date in YYYY-MM-DD format.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for dates on or after the specified date. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If date is not valid YYYY-MM-DD. |
Source code in src/mixpanel_headless/types.py
in_the_last
classmethod
¶
in_the_last(
property: str | CustomPropertyRef | InlineCustomProperty,
quantity: int,
date_unit: FilterDateUnit,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a relative date filter (in the last N units).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
quantity
|
Number of time units (must be positive).
TYPE:
|
date_unit
|
Time unit (
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for events within the last N units. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If quantity is not positive. |
Source code in src/mixpanel_headless/types.py
not_in_the_last
classmethod
¶
not_in_the_last(
property: str | CustomPropertyRef | InlineCustomProperty,
quantity: int,
date_unit: FilterDateUnit,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a relative date exclusion filter (not in the last N units).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
quantity
|
Number of time units (must be positive).
TYPE:
|
date_unit
|
Time unit (
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for events NOT within the last N units. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If quantity is not positive. |
Source code in src/mixpanel_headless/types.py
date_between
classmethod
¶
date_between(
property: str | CustomPropertyRef | InlineCustomProperty,
from_date: str,
to_date: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a date range filter (between two dates, inclusive).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
from_date
|
Start date in YYYY-MM-DD format.
TYPE:
|
to_date
|
End date in YYYY-MM-DD format.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for dates within the range. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If dates are not valid YYYY-MM-DD or from_date is after to_date. |
Source code in src/mixpanel_headless/types.py
date_not_between
classmethod
¶
date_not_between(
property: str | CustomPropertyRef | InlineCustomProperty,
from_date: str,
to_date: str,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a date exclusion range filter (not between two dates).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
from_date
|
Start date in YYYY-MM-DD format.
TYPE:
|
to_date
|
End date in YYYY-MM-DD format.
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for dates outside the range. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If dates are not valid YYYY-MM-DD or from_date is after to_date. |
Source code in src/mixpanel_headless/types.py
in_the_next
classmethod
¶
in_the_next(
property: str | CustomPropertyRef | InlineCustomProperty,
quantity: int,
date_unit: FilterDateUnit,
*,
resource_type: Literal["events", "people"] = "events",
) -> Filter
Create a relative date filter (in the next N units).
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name, CustomPropertyRef, or InlineCustomProperty.
TYPE:
|
quantity
|
Number of time units (must be positive).
TYPE:
|
date_unit
|
Time unit (
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter for events within the next N units. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If quantity is not positive. |
Source code in src/mixpanel_headless/types.py
list_contains
classmethod
¶
list_contains(
property: str,
*item_filters: Filter,
quantifier: Literal["any", "all"] = "any",
resource_type: Literal["events", "people"] = "events",
**equals: str | list[str],
) -> Filter
Match events whose list-of-object property contains items satisfying inner conditions.
Used to filter on subproperties of objects nested inside a list
property (e.g. cart is a list of {"Brand": str, "Category":
str, "Price": int}). Each inner condition is evaluated
per-item; the quantifier controls whether at least one item
("any", the default) or every item ("all") must satisfy
all inner conditions.
Two ways to specify inner conditions:
- Keyword shorthand for the common equality case:
Filter.list_contains("cart", Brand="nike", Category="hats"). Inner equality filters inherit the outerresource_type. - Explicit Filter instances for any wire-format operator:
Filter.list_contains("cart", Filter.equals("Brand", "nike"), Filter.greater_than("Price", 50)). Each inner Filter carries its ownresource_typefrom its own factory call — passresource_type=explicitly on each inner factory if you want them to match the outer.
Mixing the two shapes in one call raises ValueError.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Name of the list-of-object property to filter on.
TYPE:
|
*item_filters
|
Inner
TYPE:
|
quantifier
|
TYPE:
|
resource_type
|
Resource type. Default:
TYPE:
|
**equals
|
Keyword shorthand — each
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Filter
|
Filter that emits the |
Filter
|
on serialization. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If both |
TypeError
|
If a |
Example
Source code in src/mixpanel_headless/types.py
8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 | |
mixpanel_headless.GroupBy
dataclass
¶
GroupBy(
property: str | CustomPropertyRef | InlineCustomProperty,
property_type: CustomPropertyType = "string",
bucket_size: int | float | None = None,
bucket_min: int | float | None = None,
bucket_max: int | float | None = None,
_list_item_mode: ListItemGroupMode | None = None,
)
Specifies a property breakdown with optional numeric bucketing.
Used with Workspace.query() to break down results by property values.
String properties are broken down by distinct values; numeric properties
can be bucketed into ranges.
| ATTRIBUTE | DESCRIPTION |
|---|---|
property |
Property to break down by (name, ref, or inline).
TYPE:
|
property_type |
Data type of the property. Default:
TYPE:
|
bucket_size |
Bucket width for numeric properties.
TYPE:
|
bucket_min |
Minimum value for numeric buckets.
TYPE:
|
bucket_max |
Maximum value for numeric buckets.
TYPE:
|
Example
property
instance-attribute
¶
Property to break down by (name, ref, or inline).
property_type
class-attribute
instance-attribute
¶
Data type of the property. One of the four scalar types.
Note: list-item breakdowns set _list_item_mode instead — the
wire builder hardcodes propertyType: "object" for that branch
independently of this field.
bucket_size
class-attribute
instance-attribute
¶
Bucket width for numeric properties.
bucket_min
class-attribute
instance-attribute
¶
Minimum value for numeric buckets.
bucket_max
class-attribute
instance-attribute
¶
Maximum value for numeric buckets.
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If property is an empty string (GB1),
bucket_size is not positive (GB2),
bucket_min >= bucket_max (GB3),
|
Source code in src/mixpanel_headless/types.py
list_item
classmethod
¶
Break down by a subproperty of objects inside a list property.
Mirrors the Mixpanel UI's cart.Brand / cart.Category
breakdown for list-of-object properties (e.g. cart is a
list of {"Brand": str, "Category": str, "Price": int}
items). Each list item contributes one count per distinct
subproperty value it carries.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Name of the list-of-object property.
TYPE:
|
sub
|
Subproperty name to break down by.
TYPE:
|
sub_type
|
Data type of the subproperty. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GroupBy
|
|
GroupBy
|
structure in the bookmark JSON. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Example
Source code in src/mixpanel_headless/types.py
mixpanel_headless.ListItemGroupMode
dataclass
¶
Discriminator for GroupBy.list_item — sub-property name + scalar type.
Pairs the subproperty name with its inferred scalar type so they
cannot be set independently. Used as the optional _list_item_mode
field on GroupBy; presence of this field marks a GroupBy as a
list-item breakdown.
| ATTRIBUTE | DESCRIPTION |
|---|---|
sub |
Subproperty name (must be non-empty after stripping).
TYPE:
|
sub_type |
Subproperty data type. One of the four
TYPE:
|
Example
sub_type
instance-attribute
¶
Subproperty data type, matching :data:CustomPropertyType.
__post_init__
¶
Validate sub is non-empty and sub_type is a known scalar type.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.QueryResult
dataclass
¶
QueryResult(
computed_at: str,
from_date: str,
to_date: str,
headers: list[str] = list(),
series: dict[str, Any] = dict(),
params: dict[str, Any] = dict(),
meta: dict[str, Any] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Structured output from a Workspace.query() execution.
Contains the query response data with lazy DataFrame conversion. The series structure varies by query mode:
- Timeseries:
{metric_name: {date_string: value}} - Total:
{metric_name: {"all": value}}
| ATTRIBUTE | DESCRIPTION |
|---|---|
computed_at |
When the query was computed (ISO format).
TYPE:
|
from_date |
Effective start date from response.
TYPE:
|
to_date |
Effective end date from response.
TYPE:
|
headers |
Column headers from the insights response.
TYPE:
|
series |
Query result data (structure varies by mode).
TYPE:
|
params |
Generated bookmark params sent to API (for debugging/persistence).
TYPE:
|
meta |
Response metadata (sampling factor, limits hit).
TYPE:
|
Example
headers
class-attribute
instance-attribute
¶
Column headers from the insights response.
series
class-attribute
instance-attribute
¶
Query result data.
For timeseries: {metric_name: {date_string: value}}
For total: {metric_name: {"all": value}}
params
class-attribute
instance-attribute
¶
Generated bookmark params sent to API (for debugging/persistence).
meta
class-attribute
instance-attribute
¶
Response metadata. Conforms to :class:QueryMeta
(sampling_factor, is_cached, computation_time, query_id).
df
property
¶
Convert to DataFrame.
For timeseries mode: columns are date, event, count.
For total mode: columns are event, count.
For segmented timeseries (with group_by): columns are
date, event, segment, count.
For segmented total (with group_by): columns are
event, segment, count.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
Normalized DataFrame with one row per (date, metric, segment) |
DataFrame
|
combination. Segmented responses are detected automatically |
DataFrame
|
by checking whether inner values are dicts (segment nesting) |
DataFrame
|
or scalars (flat response). |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all QueryResult fields. |
Source code in src/mixpanel_headless/types.py
Cohort Query Types¶
Types for cohort-scoped queries — filter by cohort, break down by cohort membership, or track cohort size as a metric across all query engines.
mixpanel_headless.CohortBreakdown
dataclass
¶
CohortBreakdown(
cohort: int | CohortDefinition,
name: str | None = None,
include_negated: bool = True,
)
Break down query results by cohort membership.
Represents a cohort-based breakdown dimension for use in the
group_by= parameter of query(), query_funnel(),
and query_retention().
Accepts either a saved cohort ID (int) or an inline
CohortDefinition. When include_negated=True (default),
both "In Cohort" and "Not In Cohort" segments are shown.
| ATTRIBUTE | DESCRIPTION |
|---|---|
cohort |
Saved cohort ID (positive integer) or inline
TYPE:
|
name |
Display name. Optional for saved cohorts; recommended for inline definitions.
TYPE:
|
include_negated |
Whether to include a "Not In" segment.
Default:
TYPE:
|
Example
mixpanel_headless.CohortMetric
dataclass
¶
Track cohort size over time as an event metric.
Represents a cohort size metric for use in the events=
parameter of query() (insights only). Produces a show clause
with behavior.type: "cohort" in the bookmark JSON.
Cannot be used with query_funnel(), query_retention(),
or query_flow() (CM4 — insights only).
Inline CohortDefinition is not supported (CM5 — server returns
500). Use a saved cohort ID instead. This is enforced at construction.
| ATTRIBUTE | DESCRIPTION |
|---|---|
cohort |
Saved cohort ID (positive integer) or inline
TYPE:
|
name |
Display name / series label. Optional for saved cohorts; recommended for inline definitions.
TYPE:
|
Example
from mixpanel_headless import CohortMetric, Metric, Formula
# Track cohort growth
result = ws.query(CohortMetric(123, "Power Users"), last=90, unit="week")
# Mix with event metrics and formulas
result = ws.query(
[Metric("Login", math="unique"), CohortMetric(123, "Power Users")],
formula="(B / A) * 100",
formula_label="Power User %",
)
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If cohort ID is not positive (CM1), name
is empty when provided (CM2), or cohort is an inline
|
Source code in src/mixpanel_headless/types.py
Custom Property Query Types¶
Types for using saved or inline custom properties as property references in query breakdowns, filters, and metric measurement. See Custom Properties in Queries for usage guide.
mixpanel_headless.CustomPropertyRef
dataclass
¶
A reference to a persisted custom property by its integer ID.
Used in GroupBy.property, Filter class methods, and
Metric.property to reference a custom property that was
previously created and saved in Mixpanel.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The custom property's server-assigned ID (must be positive).
TYPE:
|
Example
mixpanel_headless.InlineCustomProperty
dataclass
¶
InlineCustomProperty(
formula: str,
inputs: dict[str, PropertyInput],
property_type: Literal["string", "number", "boolean", "datetime"]
| None = None,
resource_type: Literal["events", "people"] = "events",
)
An ephemeral computed property defined by a formula and input references.
Defines a custom property inline at query time without persisting it
to Mixpanel. The formula uses variables (A-Z) that map to concrete
properties via the inputs dict.
Can be used in GroupBy.property, Filter class methods, and
Metric.property to compute derived values on the fly.
| ATTRIBUTE | DESCRIPTION |
|---|---|
formula |
Expression in Mixpanel's formula language (max 20,000 chars).
TYPE:
|
inputs |
Mapping from single uppercase letters (A-Z) to property references.
TYPE:
|
property_type |
Result type of the formula.
TYPE:
|
resource_type |
Data domain —
TYPE:
|
Example
from mixpanel_headless import InlineCustomProperty, PropertyInput
# Explicit construction
icp = InlineCustomProperty(
formula="A * B",
inputs={
"A": PropertyInput("price", type="number"),
"B": PropertyInput("quantity", type="number"),
},
property_type="number",
)
# Convenience constructor for all-numeric inputs
icp = InlineCustomProperty.numeric("A * B", A="price", B="quantity")
inputs
instance-attribute
¶
Mapping from single uppercase letters (A-Z) to property references.
property_type
class-attribute
instance-attribute
¶
Result type of the formula; None defers to containing type.
resource_type
class-attribute
instance-attribute
¶
Data domain (plural form for top-level customProperty schema).
numeric
classmethod
¶
Create an all-numeric-input inline custom property.
Convenience constructor that creates PropertyInput entries
with type="number" and resource_type="event" for each
keyword argument, and sets property_type="number".
| PARAMETER | DESCRIPTION |
|---|---|
formula
|
Expression in Mixpanel's formula language.
TYPE:
|
**properties
|
Mapping of variable letters to property names. Each key becomes an input key, each value becomes the property name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
InlineCustomProperty
|
InlineCustomProperty with all-numeric inputs and |
InlineCustomProperty
|
|
Example
Source code in src/mixpanel_headless/types.py
mixpanel_headless.PropertyInput
dataclass
¶
PropertyInput(
name: str,
type: Literal["string", "number", "boolean", "datetime", "list"] = "string",
resource_type: Literal["event", "user"] = "event",
)
A raw property reference mapping a formula variable to a named property.
Used as an entry in :attr:InlineCustomProperty.inputs to bind a
formula variable (A-Z) to a concrete Mixpanel event or user property.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The raw property name (e.g.,
TYPE:
|
type |
Property data type. Default:
TYPE:
|
resource_type |
Property domain —
TYPE:
|
Example
Advanced Query Types¶
Types for advanced query features — period-over-period comparison, frequency analysis, and frequency filtering across query engines.
mixpanel_headless.TimeComparison
dataclass
¶
TimeComparison(
type: TimeComparisonType,
unit: TimeComparisonUnit | None = None,
date: str | None = None,
)
Overlay a comparison time period on insights, funnel, or retention queries.
Enables period-over-period analysis by specifying how the comparison window is determined. Three modes are supported:
- relative: Compare against a prior period offset by
unit(e.g. previous month, previous week). - absolute-start: Compare against a window starting on a fixed
date (
date), running the same duration as the primary range. - absolute-end: Compare against a window ending on a fixed date.
Use the factory class methods rather than constructing directly:
TimeComparison.relative(unit)TimeComparison.absolute_start(date)TimeComparison.absolute_end(date)
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
Discriminant —
TYPE:
|
unit |
Time unit for relative comparison. Required when
TYPE:
|
date |
ISO date (YYYY-MM-DD) for absolute comparison. Required
when
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If validation rules TC1-TC3 are violated during construction. |
Example
from mixpanel_headless.types import TimeComparison
# Compare against previous month
tc = TimeComparison.relative("month")
# Compare against window starting on a fixed date
tc = TimeComparison.absolute_start("2026-01-01")
# Compare against window ending on a fixed date
tc = TimeComparison.absolute_end("2026-12-31")
type
instance-attribute
¶
Discriminant — "relative", "absolute-start", or "absolute-end".
unit
class-attribute
instance-attribute
¶
Time unit for relative comparison (day, week, month, quarter, year).
date
class-attribute
instance-attribute
¶
ISO date (YYYY-MM-DD) for absolute comparison.
__post_init__
¶
Validate construction arguments (rules TC1-TC3).
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If type="relative" and unit is None (TC1), or type="relative" and date is set (TC1), or type is absolute and date is None (TC2), or type is absolute and unit is set (TC2), or date does not match YYYY-MM-DD format (TC3). |
Source code in src/mixpanel_headless/types.py
6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 | |
relative
classmethod
¶
Create a relative time comparison.
Compares against a prior period offset by the given unit (e.g. previous month, previous week).
| PARAMETER | DESCRIPTION |
|---|---|
unit
|
Time unit for the comparison offset. One of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TimeComparison
|
A |
TimeComparison
|
specified |
Source code in src/mixpanel_headless/types.py
absolute_start
classmethod
¶
Create an absolute-start time comparison.
Compares against a window that starts on the given date, running the same duration as the primary query range.
| PARAMETER | DESCRIPTION |
|---|---|
date
|
Start date in YYYY-MM-DD format.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TimeComparison
|
A |
TimeComparison
|
the specified |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If date is not in YYYY-MM-DD format (TC3). |
Example
Source code in src/mixpanel_headless/types.py
absolute_end
classmethod
¶
Create an absolute-end time comparison.
Compares against a window that ends on the given date, running the same duration as the primary query range.
| PARAMETER | DESCRIPTION |
|---|---|
date
|
End date in YYYY-MM-DD format.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TimeComparison
|
A |
TimeComparison
|
the specified |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If date is not in YYYY-MM-DD format (TC3). |
Example
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FrequencyBreakdown
dataclass
¶
FrequencyBreakdown(
event: str,
bucket_size: int = 1,
bucket_min: int = 0,
bucket_max: int = 10,
label: str | None = None,
)
Break down query results by how often users performed an event.
Used with Workspace.query() / build_params() in the
group_by= parameter to segment users by event frequency.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Event name to count frequency for.
TYPE:
|
bucket_size |
Width of each frequency bucket. Default:
TYPE:
|
bucket_min |
Minimum frequency value. Default:
TYPE:
|
bucket_max |
Maximum frequency value. Default:
TYPE:
|
label |
Display label for the breakdown.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If validation rules FB1-FB4 are violated. |
Example
from mixpanel_headless import FrequencyBreakdown
# How often users purchased (0-10 in increments of 1)
result = ws.query("Login", group_by=FrequencyBreakdown("Purchase"))
# Custom buckets: 0-50 in increments of 5
result = ws.query(
"Login",
group_by=FrequencyBreakdown(
"Purchase", bucket_size=5, bucket_min=0, bucket_max=50
),
)
bucket_size
class-attribute
instance-attribute
¶
Width of each frequency bucket.
label
class-attribute
instance-attribute
¶
Display label for the breakdown.
__post_init__
¶
Validate construction arguments (rules FB1-FB4).
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event is empty (FB1), bucket_size is not positive (FB2), bucket_min >= bucket_max (FB3), or bucket_min is negative (FB4). |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FrequencyFilter
dataclass
¶
FrequencyFilter(
event: str,
value: int | float,
operator: FrequencyFilterOperator = "is at least",
date_range_value: int | None = None,
date_range_unit: Literal["day", "week", "month"] | None = None,
event_filters: list[Filter] | None = None,
label: str | None = None,
)
Filter query results by how often users performed an event.
Used with Workspace.query() / build_params() in the
where= parameter to restrict results to users meeting a
frequency threshold.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Event name to count frequency for.
TYPE:
|
operator |
Comparison operator. Default:
TYPE:
|
value |
Threshold value for the comparison.
TYPE:
|
date_range_value |
Lookback window size. Must be paired with
TYPE:
|
date_range_unit |
Lookback window unit (
TYPE:
|
event_filters |
Property filters applied to the frequency event before counting.
TYPE:
|
label |
Display label for the filter.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If validation rules FF1-FF5 are violated. |
Example
from mixpanel_headless import FrequencyFilter
# Users who logged in at least 5 times
result = ws.query("Purchase", where=FrequencyFilter("Login", value=5))
# Users who purchased 3+ times in the last 30 days
result = ws.query(
"Login",
where=FrequencyFilter(
"Purchase",
value=3,
date_range_value=30,
date_range_unit="day",
),
)
operator
class-attribute
instance-attribute
¶
Comparison operator.
date_range_value
class-attribute
instance-attribute
¶
Lookback window size.
date_range_unit
class-attribute
instance-attribute
¶
Lookback window unit.
event_filters
class-attribute
instance-attribute
¶
Property filters applied to the frequency event.
__post_init__
¶
Validate construction arguments (rules FF1-FF5).
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event is empty (FF1), operator is invalid (FF2), value is negative (FF3), date_range_value and date_range_unit are not both set or both None (FF4), or date_range_value is not positive when set (FF5). |
Source code in src/mixpanel_headless/types.py
Cohort Definition Types¶
Types for building inline cohort definitions programmatically — used with Filter.in_cohort(), CohortBreakdown, and CohortMetric.
mixpanel_headless.CohortDefinition
dataclass
¶
A composed set of criteria combined with AND/OR logic.
Produces valid Mixpanel cohort definition JSON (legacy selector +
behaviors format) via to_dict(). Behavior keys are globally
re-indexed to ensure uniqueness across arbitrary nesting.
Example
Create a definition combining criteria with AND logic.
Equivalent to CohortDefinition.all_of(*criteria).
| PARAMETER | DESCRIPTION |
|---|---|
*criteria
|
One or more criteria or nested definitions.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no criteria are provided (CD9). |
Source code in src/mixpanel_headless/types.py
all_of
classmethod
¶
Combine criteria and/or definitions with AND logic.
| PARAMETER | DESCRIPTION |
|---|---|
*criteria
|
One or more criteria or nested definitions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortDefinition
|
CohortDefinition with AND combinator. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no criteria are provided (CD9). |
Source code in src/mixpanel_headless/types.py
any_of
classmethod
¶
Combine criteria and/or definitions with OR logic.
| PARAMETER | DESCRIPTION |
|---|---|
*criteria
|
One or more criteria or nested definitions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortDefinition
|
CohortDefinition with OR combinator. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no criteria are provided (CD9). |
Source code in src/mixpanel_headless/types.py
to_dict
¶
Serialize to Mixpanel cohort definition format.
Produces {"selector": {...}, "behaviors": {...}} with globally
re-indexed behavior keys (bhvr_0, bhvr_1, ...) ensuring
uniqueness across arbitrary nesting depth.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with |
Example
cohort = CohortDefinition.all_of(
CohortCriteria.has_property("plan", "premium"),
CohortCriteria.did_event("Purchase", at_least=3, within_days=30),
)
data = cohort.to_dict()
# {"selector": {"operator": "and", "children": [...]},
# "behaviors": {"bhvr_0": {...}}}
# Pass directly to cohort CRUD:
ws.create_cohort(CreateCohortParams(
name="Premium Purchasers",
definition=data,
))
Source code in src/mixpanel_headless/types.py
9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 | |
mixpanel_headless.CohortCriteria
dataclass
¶
CohortCriteria(
_selector_node: dict[str, Any],
_behavior_key: str | None,
_behavior: dict[str, Any] | None,
)
A single atomic condition for cohort membership.
Constructed exclusively via class methods — never instantiate directly.
Produces selector nodes and behavior entries for the Mixpanel cohort
definition format (legacy selector + behaviors JSON).
Example
did_event
classmethod
¶
did_event(
event: str,
*,
at_least: int | None = None,
at_most: int | None = None,
exactly: int | None = None,
within_days: int | None = None,
within_weeks: int | None = None,
within_months: int | None = None,
from_date: str | None = None,
to_date: str | None = None,
where: Filter | list[Filter] | None = None,
aggregation: CohortAggregationType | None = None,
aggregation_property: str | None = None,
) -> CohortCriteria
Create a behavioral criterion based on event frequency.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name (must be non-empty).
TYPE:
|
at_least
|
Minimum event count (
TYPE:
|
at_most
|
Maximum event count (
TYPE:
|
exactly
|
Exact event count (
TYPE:
|
within_days
|
Rolling window in days.
TYPE:
|
within_weeks
|
Rolling window in weeks.
TYPE:
|
within_months
|
Rolling window in months.
TYPE:
|
from_date
|
Absolute start date (YYYY-MM-DD).
TYPE:
|
to_date
|
Absolute end date (YYYY-MM-DD).
TYPE:
|
where
|
Event property filter(s). |
aggregation
|
Aggregation operator for property-based thresholds
(total, unique, average, min, max, median). Must be paired
with
TYPE:
|
aggregation_property
|
Event property to aggregate (e.g.,
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortCriteria
|
CohortCriteria with behavioral selector node and behavior entry. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no frequency param or multiple are set, frequency is negative, event name is empty/whitespace, time constraints are missing or conflicting, dates are malformed/misordered, or aggregation and aggregation_property are not both set or both None (CA1/CA2). |
Source code in src/mixpanel_headless/types.py
8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 | |
did_not_do_event
classmethod
¶
did_not_do_event(
event: str,
*,
within_days: int | None = None,
within_weeks: int | None = None,
within_months: int | None = None,
from_date: str | None = None,
to_date: str | None = None,
) -> CohortCriteria
Create a criterion for users who did NOT perform an event.
Shorthand for did_event(event, exactly=0, ...).
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name.
TYPE:
|
within_days
|
Rolling window in days.
TYPE:
|
within_weeks
|
Rolling window in weeks.
TYPE:
|
within_months
|
Rolling window in months.
TYPE:
|
from_date
|
Absolute start date (YYYY-MM-DD).
TYPE:
|
to_date
|
Absolute end date (YYYY-MM-DD).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortCriteria
|
CohortCriteria equivalent to |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
On constraint violations. |
Source code in src/mixpanel_headless/types.py
has_property
classmethod
¶
has_property(
property: str,
value: str | int | float | bool | list[str],
*,
operator: Literal[
"equals",
"not_equals",
"contains",
"not_contains",
"greater_than",
"less_than",
"is_set",
"is_not_set",
] = "equals",
property_type: Literal[
"string", "number", "boolean", "datetime", "list"
] = "string",
) -> CohortCriteria
Create a property-based criterion.
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name (must be non-empty).
TYPE:
|
value
|
Value to compare against.
TYPE:
|
operator
|
Comparison operator. Default:
TYPE:
|
property_type
|
Data type of the property. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortCriteria
|
CohortCriteria with property selector node. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If property name is empty (CD7). |
Source code in src/mixpanel_headless/types.py
property_is_set
classmethod
¶
Check if a user property exists.
Shorthand for has_property(property, "", operator="is_set").
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortCriteria
|
CohortCriteria checking property existence. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If property name is empty (CD7). |
Source code in src/mixpanel_headless/types.py
property_is_not_set
classmethod
¶
Check if a user property does not exist.
Shorthand for has_property(property, "", operator="is_not_set").
| PARAMETER | DESCRIPTION |
|---|---|
property
|
Property name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortCriteria
|
CohortCriteria checking property non-existence. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If property name is empty (CD7). |
Source code in src/mixpanel_headless/types.py
in_cohort
classmethod
¶
Create a criterion for membership in a saved cohort.
| PARAMETER | DESCRIPTION |
|---|---|
cohort_id
|
Cohort ID (must be positive integer).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortCriteria
|
CohortCriteria with cohort reference selector node. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If cohort_id is not a positive integer (CD8). |
Source code in src/mixpanel_headless/types.py
not_in_cohort
classmethod
¶
Create a criterion for non-membership in a saved cohort.
| PARAMETER | DESCRIPTION |
|---|---|
cohort_id
|
Cohort ID (must be positive integer).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CohortCriteria
|
CohortCriteria with cohort exclusion selector node. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If cohort_id is not a positive integer (CD8). |
Source code in src/mixpanel_headless/types.py
Funnel Query Types¶
Types for Workspace.query_funnel() — typed funnel conversion analysis with step definitions, exclusions, and conversion windows.
mixpanel_headless.FunnelStep
dataclass
¶
FunnelStep(
event: str,
label: str | None = None,
filters: list[Filter] | None = None,
filters_combinator: FiltersCombinator = "all",
order: FunnelOrder | None = None,
)
A single step in a funnel query.
Use plain event-name strings for simple funnels. Use FunnelStep
objects when you need per-step filters, labels, or ordering overrides.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Mixpanel event name for this funnel step.
TYPE:
|
label |
Display label for this step. Defaults to the event name
when
TYPE:
|
filters |
Per-step filter conditions. Each
TYPE:
|
filters_combinator |
How per-step filters combine.
TYPE:
|
order |
Per-step ordering override. Only meaningful when the
top-level funnel
TYPE:
|
Example
from mixpanel_headless import FunnelStep, Filter
# Simple step (equivalent to just using "Signup" string)
step1 = FunnelStep("Signup")
# Step with per-step filter and label
step2 = FunnelStep(
"Purchase",
label="High-Value Purchase",
filters=[Filter.greater_than("amount", 50)],
)
ws.query_funnel([step1, step2])
label
class-attribute
instance-attribute
¶
Display label for this step (defaults to event name).
filters
class-attribute
instance-attribute
¶
Per-step filter conditions.
filters_combinator
class-attribute
instance-attribute
¶
How per-step filters combine (AND/OR).
order
class-attribute
instance-attribute
¶
Per-step ordering override (only meaningful with top-level order='any').
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event is empty or contains control characters (FS1). |
mixpanel_headless.Exclusion
dataclass
¶
An event to exclude between funnel steps.
Users who perform the excluded event within the specified step range
are removed from the funnel. Use plain strings for full-range
exclusions; use Exclusion objects when you need to target
specific step ranges.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Event name to exclude between steps.
TYPE:
|
from_step |
Start of exclusion range (0-indexed, inclusive). Defaults to 0 (first step).
TYPE:
|
to_step |
End of exclusion range (0-indexed, inclusive).
TYPE:
|
Example
from_step
class-attribute
instance-attribute
¶
Start of exclusion range (0-indexed, inclusive).
to_step
class-attribute
instance-attribute
¶
End of exclusion range (0-indexed, inclusive). None = last step.
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event is empty (EX1), from_step is negative (EX2), or to_step < from_step (EX3). |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.HoldingConstant
dataclass
¶
A property to hold constant across all funnel steps.
When a property is held constant, only users whose property value
is the same at every funnel step are counted as converting. For
example, holding "platform" constant means a user who signed up
on iOS but purchased on web is not counted as converting.
| ATTRIBUTE | DESCRIPTION |
|---|---|
property |
Property name to hold constant across steps.
TYPE:
|
resource_type |
Whether this is an event property or a
user-profile property. Defaults to
TYPE:
|
Example
mixpanel_headless.FunnelQueryResult
dataclass
¶
FunnelQueryResult(
computed_at: str,
from_date: str,
to_date: str,
steps_data: list[dict[str, Any]] = list(),
series: dict[str, Any] = dict(),
params: dict[str, Any] = dict(),
meta: dict[str, Any] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a funnel query via the insights API.
Contains step-level conversion data, timing information, the generated bookmark params (for debugging or persisting as a saved report), and a lazy DataFrame conversion.
Unlike FunnelResult (which wraps the legacy funnel API), this
type wraps the richer bookmark-based insights API response and
provides additional fields like avg_time, avg_time_from_start,
and the params dict.
| ATTRIBUTE | DESCRIPTION |
|---|---|
computed_at |
When the query was computed (ISO format).
TYPE:
|
from_date |
Effective start date from the response.
TYPE:
|
to_date |
Effective end date from the response.
TYPE:
|
steps_data |
Step-level results. Each dict contains keys:
TYPE:
|
series |
Raw series data from the API (for advanced use).
TYPE:
|
params |
Generated bookmark params sent to the API
(for debugging or persistence via
TYPE:
|
meta |
Response metadata (e.g.
TYPE:
|
Example
result = ws.query_funnel(["Signup", "Purchase"])
# Overall conversion
print(result.overall_conversion_rate) # e.g. 0.12
# DataFrame view
print(result.df)
# step event count step_conv_ratio overall_conv_ratio ...
# Save as a report
ws.create_bookmark(CreateBookmarkParams(
name="Signup → Purchase Funnel",
bookmark_type="funnels",
params=result.params,
))
steps_data
class-attribute
instance-attribute
¶
Step-level results. Each dict conforms to :class:FunnelStepData
(event, count, step_conv_ratio, overall_conv_ratio, avg_time,
avg_time_from_start).
series
class-attribute
instance-attribute
¶
Raw series data from the API.
params
class-attribute
instance-attribute
¶
Generated bookmark params sent to API.
meta
class-attribute
instance-attribute
¶
Response metadata. Conforms to :class:QueryMeta
(sampling_factor, is_cached, computation_time, query_id).
overall_conversion_rate
property
¶
End-to-end conversion rate from first to last step.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Float between 0.0 and 1.0 representing the fraction of |
float
|
users who completed all funnel steps. Returns 0.0 if |
float
|
|
df
property
¶
Convert to DataFrame with one row per funnel step.
Columns: step, event, count, step_conv_ratio,
overall_conv_ratio, avg_time, avg_time_from_start.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
Normalized DataFrame with one row per step. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all FunnelQueryResult fields. |
Source code in src/mixpanel_headless/types.py
Retention Query Types¶
Types for Workspace.query_retention() — typed retention analysis with event pairs, custom buckets, alignment modes, and segmentation.
mixpanel_headless.RetentionEvent
dataclass
¶
RetentionEvent(
event: str,
filters: list[Filter] | None = None,
filters_combinator: FiltersCombinator = "all",
)
An event specification for retention queries.
Wraps an event name with optional per-event filters. Use plain
event-name strings for simple retention queries. Use RetentionEvent
objects when you need per-event filter conditions.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Mixpanel event name.
TYPE:
|
filters |
Per-event filter conditions. Each
TYPE:
|
filters_combinator |
How per-event filters combine.
TYPE:
|
Example
filters
class-attribute
instance-attribute
¶
Per-event filter conditions.
filters_combinator
class-attribute
instance-attribute
¶
How per-event filters combine (AND/OR).
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event is empty or contains control characters (RE1). |
mixpanel_headless.RetentionAlignment
module-attribute
¶
Retention alignment mode.
+------------------+----------------------------------------------+ | Value | Meaning | +==================+==============================================+ | birth | Align to each cohort's born date (default) | +------------------+----------------------------------------------+ | interval_start | Align all cohorts to the same start date | +------------------+----------------------------------------------+
mixpanel_headless.RetentionMode
module-attribute
¶
Display mode for retention query results.
+--------+----------------------------------------------+ | Value | Meaning | +========+==============================================+ | curve | Retention curve (default) | +--------+----------------------------------------------+ | trends | Trend lines over time | +--------+----------------------------------------------+ | table | Tabular cohort x bucket grid | +--------+----------------------------------------------+
mixpanel_headless.RetentionMathType
module-attribute
¶
Aggregation function for retention query metrics.
+----------------+----------------------------------------------+ | Value | Meaning | +================+==============================================+ | retention_rate | Percentage of users retained (default) | +----------------+----------------------------------------------+ | unique | Raw count of retained users | +----------------+----------------------------------------------+ | total | Total event count per retention bucket | +----------------+----------------------------------------------+ | average | Average of a numeric property per bucket | +----------------+----------------------------------------------+
Maps directly to the measurement.math field in bookmark JSON.
mixpanel_headless.RetentionQueryResult
dataclass
¶
RetentionQueryResult(
computed_at: str,
from_date: str,
to_date: str,
cohorts: dict[str, dict[str, Any]] = dict(),
average: dict[str, Any] = dict(),
params: dict[str, Any] = dict(),
meta: dict[str, Any] = dict(),
segments: dict[str, dict[str, dict[str, Any]]] = dict(),
segment_averages: dict[str, dict[str, Any]] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a retention query via the insights API.
Contains cohort-level retention data, the generated bookmark params
(for debugging or persisting as a saved report), and a lazy
DataFrame conversion. Supports both unsegmented and segmented
(group_by) queries.
| ATTRIBUTE | DESCRIPTION |
|---|---|
computed_at |
When the query was computed (ISO format).
TYPE:
|
from_date |
Effective start date from the response.
TYPE:
|
to_date |
Effective end date from the response.
TYPE:
|
cohorts |
Aggregate cohort-level retention data. Keys are cohort
date strings (
TYPE:
|
average |
Synthetic
TYPE:
|
params |
Generated bookmark params sent to the API
(for debugging or persistence via
TYPE:
|
meta |
Response metadata (e.g.
TYPE:
|
segments |
Per-segment cohort data. Maps segment name to a dict of cohort_date → {first, counts, rates}. Empty for unsegmented queries.
TYPE:
|
segment_averages |
Per-segment
TYPE:
|
Example
# Unsegmented retention
result = ws.query_retention("Signup", "Login")
print(result.df)
# cohort_date bucket count rate
# Segmented retention
result = ws.query_retention(
"Signup", "Login", group_by="platform"
)
print(result.df)
# segment cohort_date bucket count rate
for name, cohorts in result.segments.items():
print(f"{name}: {len(cohorts)} cohorts")
cohorts
class-attribute
instance-attribute
¶
Cohort-level retention data. Each value conforms to
:class:RetentionCohortData (first, counts, rates).
For segmented queries, this contains the $overall aggregate.
average
class-attribute
instance-attribute
¶
Synthetic $average cohort data. Conforms to :class:RetentionCohortData.
params
class-attribute
instance-attribute
¶
Generated bookmark params sent to API.
meta
class-attribute
instance-attribute
¶
Response metadata. Conforms to :class:QueryMeta.
segments
class-attribute
instance-attribute
¶
Per-segment cohort data. Each inner value conforms to
:class:RetentionCohortData (first, counts, rates).
Empty for unsegmented queries. Populated when group_by is used
and the API returns breakdown segments alongside $overall.
segment_averages
class-attribute
instance-attribute
¶
Per-segment $average cohort data. Each value conforms to
:class:RetentionCohortData.
Empty for unsegmented queries.
df
property
¶
Convert to DataFrame with one row per (cohort_date, bucket) pair.
For unsegmented queries, columns are:
cohort_date, bucket, count, rate.
For segmented queries (when segments is non-empty), columns are:
segment, cohort_date, bucket, count, rate.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
Normalized DataFrame. Empty DataFrame with correct columns |
DataFrame
|
if data is empty. |
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all RetentionQueryResult fields. |
dict[str, Any]
|
Includes |
dict[str, Any]
|
when non-empty. |
Source code in src/mixpanel_headless/types.py
Flow Query Types¶
Types for Workspace.query_flow() — typed flow path analysis with step definitions, direction controls, and visualization modes.
mixpanel_headless.FlowStep
dataclass
¶
FlowStep(
event: str,
forward: int | None = None,
reverse: int | None = None,
label: str | None = None,
filters: list[Filter] | None = None,
filters_combinator: FiltersCombinator = "all",
session_event: FlowSessionEvent | None = None,
)
An anchor event in a flow query with per-step configuration.
Each flow step identifies a specific event and optional constraints (forward/reverse step counts, filters) that define a node in the flow analysis.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
The event name to anchor this step on.
TYPE:
|
forward |
Maximum number of forward steps to trace from this event.
TYPE:
|
reverse |
Maximum number of reverse steps to trace from this event.
TYPE:
|
label |
Optional display label for this step. If
TYPE:
|
filters |
Optional list of
TYPE:
|
filters_combinator |
How to combine multiple filters —
TYPE:
|
session_event |
Optional session anchor type —
TYPE:
|
Example
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event is empty or contains control characters (FL1), forward/reverse is outside 0-5 range (FL2), or session_event conflicts with event name (FS1). |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FlowTreeNode
dataclass
¶
FlowTreeNode(
event: str,
type: FlowNodeType,
step_number: int,
total_count: int,
drop_off_count: int = 0,
converted_count: int = 0,
anchor_type: FlowAnchorType = "NORMAL",
is_computed: bool = False,
children: tuple[FlowTreeNode, ...] = (),
time_percentiles_from_start: dict[str, Any] = dict(),
time_percentiles_from_prev: dict[str, Any] = dict(),
)
A node in a recursive flow prefix tree.
Represents a single event in a flow path tree returned by the Mixpanel
Flows API when using mode="tree". Each node tracks aggregate counts
(total, drop-off, converted) and optionally timing percentiles. Children
represent subsequent events in the flow.
The tree preserves full path context — unlike the sankey graph which merges nodes at the same step position, each tree node is unique to its specific path from root.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
The event name at this position in the flow.
TYPE:
|
type |
Node type —
TYPE:
|
step_number |
Zero-based step index in the flow.
TYPE:
|
total_count |
Total number of users reaching this node.
TYPE:
|
drop_off_count |
Number of users who dropped off at this node.
TYPE:
|
converted_count |
Number of users who continued past this node.
TYPE:
|
anchor_type |
Anchor classification —
TYPE:
|
is_computed |
Whether this is a computed/custom event.
TYPE:
|
children |
Child nodes representing subsequent events. Defaults to an empty tuple.
TYPE:
|
time_percentiles_from_start |
Timing percentile data from flow start to this node. Empty dict if timing data is not enabled.
TYPE:
|
time_percentiles_from_prev |
Timing percentile data from the previous node to this node. Empty dict if timing data is not enabled.
TYPE:
|
Example
root = FlowTreeNode(
event="Login", type="ANCHOR", step_number=0,
total_count=1000, drop_off_count=50, converted_count=950,
children=(
FlowTreeNode(
event="Search", type="NORMAL", step_number=1,
total_count=600,
),
),
)
root.depth # 1
root.conversion_rate # 0.95
root.all_paths() # [[root, search_node]]
depth
property
¶
Maximum depth of the subtree rooted at this node.
A leaf node has depth 0. A node with one level of children has depth 1, and so on.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Non-negative integer representing the longest path from |
int
|
this node to any leaf descendant. |
node_count
property
¶
leaf_count
property
¶
conversion_rate
property
¶
drop_off_rate
property
¶
all_paths
¶
Return all root-to-leaf paths through this subtree.
Each path is a list of FlowTreeNode objects from this node
down to a leaf, preserving the full node chain so callers can
inspect counts, rates, and timing along each path.
| RETURNS | DESCRIPTION |
|---|---|
list[list[FlowTreeNode]]
|
List of paths, where each path is a list of nodes. The |
list[list[FlowTreeNode]]
|
number of paths equals |
Example
Source code in src/mixpanel_headless/types.py
find
¶
Find all nodes matching an event name via depth-first search.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
The event name to search for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[FlowTreeNode]
|
List of matching |
list[FlowTreeNode]
|
no nodes match. |
Source code in src/mixpanel_headless/types.py
flatten
¶
Return all nodes in pre-order (depth-first) traversal.
The root node appears first, followed by its children's subtrees in order.
| RETURNS | DESCRIPTION |
|---|---|
list[FlowTreeNode]
|
List of all nodes in the subtree. Length equals |
list[FlowTreeNode]
|
|
Source code in src/mixpanel_headless/types.py
to_dict
¶
Serialize the tree node recursively to a dictionary.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all node attributes and recursively |
dict[str, Any]
|
serialized children. Suitable for JSON serialization. |
Source code in src/mixpanel_headless/types.py
render
¶
Render the tree as an ASCII string for debugging.
Uses box-drawing characters (├──, └──, │) to display
the tree hierarchy with event names and counts.
| PARAMETER | DESCRIPTION |
|---|---|
_prefix
|
Internal prefix for recursive indentation. Do not pass this argument directly.
TYPE:
|
_is_last
|
Internal flag for connector selection. Do not pass this argument directly.
TYPE:
|
_is_root
|
Internal flag distinguishing the root call from recursive children. Do not pass directly.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Multi-line string representation of the tree. |
Example
Source code in src/mixpanel_headless/types.py
to_anytree
¶
Convert to an anytree.AnyNode tree with parent references.
Creates a parallel anytree representation of this subtree. Each anytree node carries the same attributes (event, type, counts, etc.) and gains parent references, path resolution, and rendering capabilities from the anytree library.
| RETURNS | DESCRIPTION |
|---|---|
Any
|
An |
Any
|
Use |
Any
|
and |
Example
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FlowQueryResult
dataclass
¶
FlowQueryResult(
computed_at: str,
steps: list[dict[str, Any]] = list(),
flows: list[dict[str, Any]] = list(),
breakdowns: list[dict[str, Any]] = list(),
overall_conversion_rate: float = 0.0,
params: dict[str, Any] = dict(),
meta: dict[str, Any] = dict(),
mode: Literal["sankey", "paths", "tree"] = "sankey",
trees: list[FlowTreeNode] = list(),
*,
_df_cache: DataFrame | None = None,
_nodes_df_cache: DataFrame | None = None,
_edges_df_cache: DataFrame | None = None,
_graph_cache: DiGraph[str] | None = None,
_trees_df_cache: DataFrame | None = None,
_anytree_cache: list[object] | None = None,
)
Bases: ResultWithDataFrame
Result of an ad-hoc flow query.
Holds the raw flow analysis data returned by the Mixpanel API, including step nodes, flow edges, breakdowns, and overall conversion.
| ATTRIBUTE | DESCRIPTION |
|---|---|
computed_at |
ISO-8601 timestamp when the query was computed.
TYPE:
|
steps |
List of step-node dicts from the API response.
TYPE:
|
flows |
List of flow-edge dicts describing transitions between steps.
TYPE:
|
breakdowns |
List of breakdown dicts when a breakdown property is used.
TYPE:
|
overall_conversion_rate |
Overall conversion rate across the flow (0.0 to 1.0).
TYPE:
|
params |
The query parameters that produced this result.
TYPE:
|
meta |
API metadata (sampling factor, request timing, etc.).
TYPE:
|
mode |
The flow visualization mode —
TYPE:
|
Example
steps
class-attribute
instance-attribute
¶
Step-node dicts. Each conforms to :class:FlowStepNode.
flows
class-attribute
instance-attribute
¶
Flow-edge dicts. Each conforms to :class:FlowEdge.
meta
class-attribute
instance-attribute
¶
Response metadata. Conforms to :class:QueryMeta.
nodes_df
property
¶
Extract a flat DataFrame of nodes from sankey step data.
Each row represents a single node in the flow graph, with columns for step index, event name, node type, count, anchor type, custom event flag, and conversion rate change.
The totalCount field in the API response is a string and is
parsed to int here.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
the correct columns when |
edges_df
property
¶
Extract a flat DataFrame of edges from sankey step data.
Each row represents a directed edge between two nodes in the flow graph, with columns for source step/event, target step/event, edge count, and target node type.
The totalCount field in the API response is a string and is
parsed to int here.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns: |
DataFrame
|
|
DataFrame
|
Returns an empty DataFrame with the correct columns when |
DataFrame
|
|
graph
property
¶
Build a networkx directed graph from sankey step data.
Nodes are keyed as "{event}@{step}" to distinguish the same
event appearing at different steps (e.g. "Login@0" vs
"Login@2"). Each node carries step, event, type,
count, and anchor_type attributes. Each edge carries
count and type attributes.
The graph is lazily constructed on first access and cached for subsequent calls.
| RETURNS | DESCRIPTION |
|---|---|
DiGraph
|
A |
DiGraph
|
empty graph when |
df
property
¶
Mode-aware DataFrame from flow data.
For sankey mode, returns the same DataFrame as nodes_df
(one row per node with step, event, type, count, etc.).
For paths mode, returns a tabular DataFrame with one row per
step in each flow path, including path_index, step,
event, type, and count columns.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame built from nodes (sankey) or flow paths (paths). |
DataFrame
|
Returns an empty DataFrame if no data is available. |
anytree
property
¶
Lazily-cached list of anytree.AnyNode roots from tree data.
Each FlowTreeNode in trees is converted to an anytree
node tree via to_anytree(), enabling parent references,
path resolution, and RenderTree display.
| RETURNS | DESCRIPTION |
|---|---|
list[Any]
|
List of |
list[Any]
|
|
top_transitions
¶
Return the N highest-traffic transitions between events.
Uses the edges DataFrame to find the most common transitions, sorted by count descending.
| PARAMETER | DESCRIPTION |
|---|---|
n
|
Maximum number of transitions to return. Default: 10.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[tuple[str, str, int]]
|
List of (source_node, target_node, count) tuples sorted |
list[tuple[str, str, int]]
|
by count descending, where each node is formatted as |
list[tuple[str, str, int]]
|
|
list[tuple[str, str, int]]
|
list if no edges exist. |
Example
Source code in src/mixpanel_headless/types.py
drop_off_summary
¶
Per-step drop-off counts and rates.
Analyzes each step to identify drop-off nodes (type == "DROPOFF") and calculates the drop-off rate relative to total traffic at that step.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict mapping step keys (e.g., "step_0") to dicts with: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
Returns empty dict if no steps exist. |
Example
Source code in src/mixpanel_headless/types.py
to_dict
¶
Serialize the flow query result for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all FlowQueryResult fields suitable for |
dict[str, Any]
|
JSON serialization. |
Source code in src/mixpanel_headless/types.py
Session Replay Types¶
Types for the session-replay surface — Workspace.replays_for_user(), fetch_replay(), fetch_replays(), and the mp replays CLI. See the Session Replay guide. Replay is conceptually a ReplayBundle of size one; both expose the same DataFrame projections.
mixpanel_headless.ReplaySummary
dataclass
¶
ReplaySummary(
replay_id: str,
distinct_id: str | None,
project_id: int,
start_time: int,
retention_days: int,
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Discovery handle for a single replay (data-model §2.1).
Returned by :meth:Workspace.list_replays. Holds the minimum info
needed to decide whether to materialize the full recording: replay
ID, distinct ID, project, start time, retention window. Use
:meth:Workspace.fetch_replay to upgrade a summary into a full
:class:Replay with the rrweb bytes pulled and parsed.
| ATTRIBUTE | DESCRIPTION |
|---|---|
replay_id |
Mixpanel replay identifier; non-empty.
TYPE:
|
distinct_id |
Mixpanel user identifier;
TYPE:
|
project_id |
Owning project; positive int.
TYPE:
|
start_time |
Unix ms timestamp from the
TYPE:
|
retention_days |
Days of CDN retention; one of
TYPE:
|
Example
df
property
¶
Single-row DataFrame projection of this summary.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
|
DataFrame
|
Cached on first access. |
__post_init__
¶
Validate per data-model §2.1.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
Source code in src/mixpanel_headless/types.py
to_dict
¶
JSON-serializable representation.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with the five summary fields. |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.SignedReplay
dataclass
¶
SignedReplay(
replay_id: str,
url: str,
query_string: str,
env: Literal["prod", "dev"],
signed_at: float,
)
Signed CDN access handle (data-model §2.2).
SECURITY: query_string is a bearer credential valid for ~5 minutes.
:meth:__repr__ and :meth:__str__ mask it so default Python logging
cannot leak the signature. :meth:to_dict IS the documented escape
hatch — callers that need the raw credential opt in explicitly and
receive an extra _warning key as a reminder.
| ATTRIBUTE | DESCRIPTION |
|---|---|
replay_id |
Mixpanel replay identifier.
TYPE:
|
url |
CDN URL prefix with trailing slash; CDN files live at
TYPE:
|
query_string |
The signed bearer credential (NOT logged by default).
TYPE:
|
env |
Replay environment,
TYPE:
|
signed_at |
Unix seconds when the URL was signed;
TYPE:
|
Example
expires_at
property
¶
Approximate expiration timestamp (signed_at + 300 seconds).
| RETURNS | DESCRIPTION |
|---|---|
float
|
Unix seconds at which the signed URL is considered expired. |
is_expired
property
¶
Whether the URL has crossed the 5-minute TTL boundary.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when |
__post_init__
¶
Validate per data-model §2.2.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
Source code in src/mixpanel_headless/types.py
to_dict
¶
Full serialization including the bearer credential.
WARNING: includes the full query_string. The returned dict
carries a top-level _warning key noting the bearer nature so
downstream serializers can surface the risk.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with |
Source code in src/mixpanel_headless/types.py
__repr__
¶
Masked representation — never leaks query_string.
| RETURNS | DESCRIPTION |
|---|---|
str
|
String of the form |
str
|
|
Source code in src/mixpanel_headless/types.py
mixpanel_headless.ReplayEvent
dataclass
¶
ReplayEvent(
replay_id: str,
event_name: str,
event_time: int,
properties: dict[str, Any] | None = None,
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Mixpanel event that occurred during a replay's time window (data-model §2.4).
Optional enrichment on :class:Replay (via
fetch_replay(include_mixpanel_events=True)) and the primary return
type of :meth:Workspace.events_for_replay.
| ATTRIBUTE | DESCRIPTION |
|---|---|
replay_id |
Owning replay ID; non-empty.
TYPE:
|
event_name |
Mixpanel event name; non-empty.
TYPE:
|
event_time |
Unix SECONDS timestamp (Mixpanel native), not ms.
TYPE:
|
properties |
Selected event properties;
TYPE:
|
df
property
¶
Single-row DataFrame projection of this event.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
|
__post_init__
¶
Validate per data-model §2.4.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
Source code in src/mixpanel_headless/types.py
to_dict
¶
JSON-serializable representation.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with the four visible fields. |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.UserAction
dataclass
¶
UserAction(
timestamp: int,
action: _REPLAY_ACTION_LITERAL,
target_node_id: int | None,
target_desc: str,
url: str | None,
metadata: dict[str, Any] = dict(),
description: str = "",
)
Normalized user action extracted from rrweb events (data-model §2.3).
Produced by the rrweb analyzer and exposed via :attr:Replay.actions —
the atomic unit the :class:ReplayBundle aggregations operate over.
| ATTRIBUTE | DESCRIPTION |
|---|---|
timestamp |
Unix ms timestamp of the action.
TYPE:
|
action |
One of the closed-set action labels (
TYPE:
|
target_node_id |
rrweb DOM node ID of the action target, if any.
TYPE:
|
target_desc |
Human-readable target description (e.g.
TYPE:
|
url |
Active page URL when the action happened, if known.
TYPE:
|
metadata |
Action-specific extras (text_length, is_checked, …).
TYPE:
|
description |
Full human-readable phrase for the markdown timeline
(e.g.
TYPE:
|
__post_init__
¶
Validate per data-model §2.3.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
Source code in src/mixpanel_headless/types.py
to_dict
¶
JSON-serializable representation.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with the seven visible fields. |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.Replay
dataclass
¶
Replay(
replay_id: str,
distinct_id: str | None,
project_id: int,
start_time: int,
end_time: int,
retention_days: int,
rrweb_events: list[dict[str, Any]] = list(),
actions: list[UserAction] = list(),
mixpanel_events: list[ReplayEvent] = list(),
*,
_df_cache: DataFrame | None = None,
_events_df_cache: DataFrame | None = None,
_actions_df_cache: DataFrame | None = None,
_mixpanel_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Single fully-materialized session replay (data-model §2.5).
Returned by :meth:Workspace.fetch_replay. Conceptually a
:class:ReplayBundle of size 1; the same DataFrame projections are
available on both. fetch_replay runs the rrweb analyzer, so
actions is populated (empty only when the stream yields none).
| ATTRIBUTE | DESCRIPTION |
|---|---|
replay_id |
Mixpanel replay identifier.
TYPE:
|
distinct_id |
Mixpanel user identifier; may be
TYPE:
|
project_id |
Owning project.
TYPE:
|
start_time |
Unix ms timestamp of the first event.
TYPE:
|
end_time |
Unix ms timestamp of the last event.
TYPE:
|
retention_days |
One of
TYPE:
|
rrweb_events |
Raw rrweb event dicts, timestamp-sorted.
TYPE:
|
actions |
Normalized :class:
TYPE:
|
mixpanel_events |
Mixpanel events that occurred in the replay
window. Populated only when the caller passed
TYPE:
|
duration_seconds
property
¶
Replay duration in seconds.
| RETURNS | DESCRIPTION |
|---|---|
float
|
|
events_df
property
¶
Long-format projection of raw rrweb events (data-model §2.5).
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
|
DataFrame
|
row per rrweb event in input order. Cached after first access. |
actions_df
property
¶
Long-format projection of normalized actions (data-model §2.5).
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
|
DataFrame
|
per action. |
DataFrame
|
|
mixpanel_df
property
¶
Long-format projection of associated Mixpanel events (data-model §2.5).
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
— empty when the caller did not pass |
DataFrame
|
|
DataFrame
|
Cached after first access. |
df
property
¶
Default projection per FR-018: returns actions_df.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
The same DataFrame as |
summary_markdown
property
¶
Analyzer-produced markdown timeline rendered from actions.
:meth:Workspace.fetch_replay runs the rrweb analyzer; when
actions is non-empty this returns the markdown timeline. When
actions is empty (test fixture, no-events fetch) it returns a
one-line placeholder.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Multi-line markdown string suitable for stdout / LLM consumption. |
errors
property
¶
Console errors captured during the replay.
Filters the action stream for action == "console_error" and
projects the actions_df columns so callers can slice it like
any other action subset.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with the |
DataFrame
|
replay had no console errors. |
__post_init__
¶
Validate per data-model §2.5.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
Source code in src/mixpanel_headless/types.py
__repr__
¶
Concise repr that never serializes the rrweb event payload.
The default dataclass repr would dump every dict in
rrweb_events (tens of MB for a real recording, e.g. full DOM
snapshots). This emits counts only so logging, REPL echo, and
tracebacks stay bounded.
| RETURNS | DESCRIPTION |
|---|---|
str
|
A one-line summary: id, user, stream sizes, and duration. |
Source code in src/mixpanel_headless/types.py
__str__
¶
page_path
¶
URL sequence visited during the replay.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
URLs from the replay's |
Source code in src/mixpanel_headless/types.py
to_rrweb_player_json
¶
Timestamp-sorted rrweb events ready for the rrweb JS player.
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]]
|
A new list of the raw rrweb dicts sorted ascending by |
list[dict[str, Any]]
|
|
Source code in src/mixpanel_headless/types.py
clicks_on
¶
Filter click actions by an arbitrary predicate.
| PARAMETER | DESCRIPTION |
|---|---|
predicate
|
Callable taking a :class:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame projection ( |
DataFrame
|
actions for which |
Source code in src/mixpanel_headless/types.py
to_dict
¶
JSON-serializable representation.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with the eight visible fields. |
dict[str, Any]
|
included so the dict can re-hydrate a full :class: |
via
|
meth:
TYPE:
|
Source code in src/mixpanel_headless/types.py
mixpanel_headless.ReplayBundle
dataclass
¶
ReplayBundle(
replays: list[Replay] = list(),
computed_at: str = "",
project_id: int = 0,
*,
_df_cache: DataFrame | None = None,
_sessions_df_cache: DataFrame | None = None,
_actions_df_cache: DataFrame | None = None,
_events_df_cache: DataFrame | None = None,
_mixpanel_df_cache: DataFrame | None = None,
_elements_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Collection of replays with cross-session projections (data-model §2.6).
Materialized by
:meth:Workspace.fetch_replays and :meth:Workspace.replays_for_user.
Inherits :class:ResultWithDataFrame; df returns sessions_df
(the most useful default — one row per replay with derived counts).
All DataFrame projections are lazy: computed on first access, cached via
object.__setattr__ since the dataclass is frozen.
Filters (filter, where, find_pattern, error_sessions,
head, sample) return a NEW bundle that is a proper subset of
the original; caches do NOT propagate, so the new bundle re-computes
its projections from its filtered replays slice. This keeps
chained filters memory-efficient at the cost of one re-compute per
chained step.
| ATTRIBUTE | DESCRIPTION |
|---|---|
replays |
The replays contained in this bundle.
TYPE:
|
computed_at |
ISO-8601 UTC timestamp when this bundle was built.
TYPE:
|
project_id |
Owning Mixpanel project (constant across replays).
TYPE:
|
sessions_df
property
¶
One row per replay with derived per-session counts.
Columns: replay_id, distinct_id, start_time,
end_time, duration_s, retention_days, n_events,
n_actions, n_clicks, n_inputs, n_pages,
n_errors, n_mp_events, entry_url, exit_url.
actions_df
property
¶
Long-format actions across all replays.
Columns: replay_id, t, action, target_node_id,
target_desc, description, url, metadata.
events_df
property
¶
Long-format raw rrweb events across all replays.
Columns: replay_id, t, type, source, mouse_type,
target_node_id, url, raw.
mixpanel_df
property
¶
Long-format Mixpanel events across all replays.
Columns: replay_id, t, event_name, properties.
Empty when no replay was fetched with include_mixpanel_events=True
and :meth:join_mixpanel_events was not called.
elements_df
property
¶
One row per (target_desc, normalized_url) with click counts.
Counts exclude focus-only interactions (a real click fires both a
focused and a clicked action; counting both double-counts every
click). URLs are normalized via :func:url_normalizer so the same
element on parameterized pages (/boards#id=1 vs #id=2)
aggregates into one row instead of fragmenting per URL variant.
Columns: target_desc, url (normalized), n_clicks,
n_unique_replays.
df
property
¶
Default DataFrame projection for the bundle (data-model §2.6).
| RETURNS | DESCRIPTION |
|---|---|
The
|
attr:
TYPE:
|
DataFrame
|
derived per-session counts. Lazily computed and cached. |
summary_markdown
property
¶
Markdown rollup of the bundle: header totals plus per-session timelines.
Builds a # Bundle summary header with replay / event / action /
error totals, then appends each replay's own
:attr:Replay.summary_markdown separated by horizontal rules. A
replay whose per-replay summary is unavailable degrades to a bare
## Replay <id> heading rather than failing the whole rollup.
| RETURNS | DESCRIPTION |
|---|---|
str
|
A markdown string. When the bundle is empty, returns |
str
|
|
__post_init__
¶
Validate that every replay in the bundle shares project_id.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
A replay's |
Source code in src/mixpanel_headless/types.py
__repr__
¶
Concise repr that never serializes the contained replays.
Each :class:Replay carries its full rrweb event stream, so the
default dataclass repr would dump tens of MB per replay. This emits
the replay count only, keeping logging and tracebacks bounded.
| RETURNS | DESCRIPTION |
|---|---|
str
|
A one-line summary: replay count, project, and computed_at. |
Source code in src/mixpanel_headless/types.py
__str__
¶
top_clicks
¶
Rank the most-clicked targets across every replay in the bundle.
Thin wrapper over the bundle-level top_clicks aggregator, which
counts genuine clicks only — focus-only interactions are excluded so
each user click is counted once.
| PARAMETER | DESCRIPTION |
|---|---|
n
|
Maximum number of click targets to return. Default 10.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
A DataFrame with columns |
DataFrame
|
descending by |
DataFrame
|
bundle has no clicks. |
Source code in src/mixpanel_headless/types.py
rage_clicks
¶
Find rage-click bursts: repeated clicks on one target in a tight window.
Thin wrapper over the bundle-level rage_clicks aggregator. A burst
is threshold or more clicks on the same target_desc whose
timestamps span no more than window_ms. Focus-only interactions
are excluded so burst sizes reflect real clicks.
| PARAMETER | DESCRIPTION |
|---|---|
threshold
|
Minimum clicks for a burst to count. Default 3.
TYPE:
|
window_ms
|
Maximum span of the burst, in milliseconds. Default 1000.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
A DataFrame with columns |
DataFrame
|
|
DataFrame
|
Empty (with those columns) when no burst meets the threshold. |
Source code in src/mixpanel_headless/types.py
long_pauses
¶
Find idle stretches between consecutive actions longer than a threshold.
Thin wrapper over the bundle-level long_pauses aggregator. Each
gap between two consecutive actions in a replay that is at least
threshold_s seconds becomes one row.
| PARAMETER | DESCRIPTION |
|---|---|
threshold_s
|
Minimum pause length, in seconds. Default 10.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
A DataFrame with columns |
DataFrame
|
of the action preceding the pause), and |
DataFrame
|
(with those columns) when no pause meets the threshold. |
Source code in src/mixpanel_headless/types.py
filter
¶
Return a new bundle containing only the replays matching predicate.
The base filter primitive behind :meth:where, :meth:find_pattern,
and :meth:error_sessions. The result is a proper subset; DataFrame
caches are NOT propagated, so the new bundle recomputes its
projections from the filtered slice (immutable semantics — self
is left unchanged).
| PARAMETER | DESCRIPTION |
|---|---|
predicate
|
A callable invoked once per replay; replays for which
it returns
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReplayBundle
|
A new :class: |
ReplayBundle
|
|
Source code in src/mixpanel_headless/types.py
where
¶
where(
*,
distinct_id: str | None = None,
contains_url: str | None = None,
has_event: str | None = None,
min_duration_s: float | None = None,
max_duration_s: float | None = None,
) -> ReplayBundle
Convenience predicate filter; equivalent to a chained filter call.
| PARAMETER | DESCRIPTION |
|---|---|
distinct_id
|
Keep replays whose
TYPE:
|
contains_url
|
Keep replays where any navigation URL includes the substring.
TYPE:
|
has_event
|
Keep replays whose
TYPE:
|
min_duration_s
|
Keep replays with
TYPE:
|
max_duration_s
|
Keep replays with
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReplayBundle
|
A new :class: |
Source code in src/mixpanel_headless/types.py
find_pattern
¶
find_pattern(
action_sequence: list[str],
*,
label_fn: Callable[[UserAction], str] | None = None,
) -> ReplayBundle
Return a new bundle containing replays whose action labels
include action_sequence as a contiguous subsequence.
| PARAMETER | DESCRIPTION |
|---|---|
action_sequence
|
Labels to look for, in order. An empty list matches every replay (returns a full clone of the bundle).
TYPE:
|
label_fn
|
Optional label-fn override (defaults to
:func:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReplayBundle
|
A new :class: |
Source code in src/mixpanel_headless/types.py
error_sessions
¶
Return a new bundle of only the replays that emitted a console error.
Delegates to the error_sessions aggregator to collect the IDs of
replays with at least one console_error action, then filters down
to them. The result is a proper subset (immutable semantics — self
is left unchanged).
| RETURNS | DESCRIPTION |
|---|---|
ReplayBundle
|
A new :class: |
ReplayBundle
|
empty when the bundle has no console errors. |
Source code in src/mixpanel_headless/types.py
head
¶
Return a new bundle containing the first n replays, in order.
Order-preserving counterpart to :meth:sample. The result is a proper
subset (immutable semantics — self is left unchanged).
| PARAMETER | DESCRIPTION |
|---|---|
n
|
How many leading replays to keep. Values larger than the bundle size keep every replay. Default 5.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReplayBundle
|
A new :class: |
ReplayBundle
|
|
Source code in src/mixpanel_headless/types.py
sample
¶
Return a new bundle with up to n replays, deterministic per seed.
| PARAMETER | DESCRIPTION |
|---|---|
n
|
How many replays to sample.
TYPE:
|
seed
|
Optional seed for reproducible sampling.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReplayBundle
|
A new :class: |
ReplayBundle
|
|
Source code in src/mixpanel_headless/types.py
join_mixpanel_events
¶
Return a new bundle whose mixpanel_df is populated.
In this implementation the join requires callers to have fetched
replays with include_mixpanel_events=True; the bundle simply
re-exposes the already-attached events.
| PARAMETER | DESCRIPTION |
|---|---|
properties
|
Reserved for the future on-demand-join variant.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReplayBundle
|
A new :class: |
ReplayBundle
|
distinct object so callers can rely on the immutable-semantics |
ReplayBundle
|
contract. |
Source code in src/mixpanel_headless/types.py
compare
¶
Compare action frequencies between this bundle and other.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
The bundle to diff against.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
|
Source code in src/mixpanel_headless/types.py
to_dict
¶
Serialize the bundle to a JSON-friendly dict (lossy on DataFrames).
The DataFrame projections (sessions_df, actions_df, …) are
derived views and are NOT included; only the source replays plus
bundle metadata are serialized. Consumers rebuild the projections on
demand rather than persisting them.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
A dict with keys |
dict[str, Any]
|
(each replay serialized via :meth: |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.default_label_fn
¶
Canonical activity label: "{action}:{tag}@{normalized_url}".
tag comes from action.target_desc (the analyzer's best
description of the element — e.g. 'button "Sign in"'). The URL
is normalized through :func:url_normalizer so analogous actions on
parameterized pages aggregate cleanly.
| PARAMETER | DESCRIPTION |
|---|---|
action
|
A :class:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The activity label string. |
Example
Source code in src/mixpanel_headless/replay_labels.py
mixpanel_headless.selector_label_fn
¶
Build a label-fn that prefers a stable selector attribute when present.
For instrumented apps, data-testid (or your project's equivalent)
is the most stable activity identifier — it survives DOM refactors,
locale changes, and CSS tweaks. The returned label-fn looks for the
requested attribute in action.metadata and uses it as the label
body when present; otherwise it falls back to :func:default_label_fn.
| PARAMETER | DESCRIPTION |
|---|---|
attr
|
The metadata key to consult. Default
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[UserAction], str]
|
A callable |
for
|
meth:
TYPE:
|
Example
Source code in src/mixpanel_headless/replay_labels.py
mixpanel_headless.url_normalizer
¶
Normalize a URL into a path template suitable for label aggregation.
Strips the query string and replaces numeric / hex path segments with
:id. The host portion is preserved when present (otherwise the
function treats the input as a bare path).
| PARAMETER | DESCRIPTION |
|---|---|
url
|
A URL, absolute or relative.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The normalized path template. Example: |
str
|
|
Example
Source code in src/mixpanel_headless/replay_labels.py
Legacy Query Results¶
mixpanel_headless.SegmentationResult
dataclass
¶
SegmentationResult(
event: str,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
segment_property: str | None,
total: int,
series: dict[str, dict[str, int]] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a segmentation query.
Contains time-series data for an event, optionally segmented by a property.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
segment_property
instance-attribute
¶
Property used for segmentation (None if total only).
series
class-attribute
instance-attribute
¶
Time series data by segment.
Structure: {segment_name: {date_string: count}} Example: {"US": {"2024-01-01": 150, "2024-01-02": 200}, "EU": {...}} For unsegmented queries, segment_name is "total".
df
property
¶
Convert to DataFrame with columns: date, segment, count.
For unsegmented queries, segment column is 'total'.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FunnelResult
dataclass
¶
FunnelResult(
funnel_id: int,
funnel_name: str,
from_date: str,
to_date: str,
conversion_rate: float,
steps: list[FunnelResultStep] = list(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a funnel query.
Contains step-by-step conversion data for a funnel.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_headless.FunnelResultStep
dataclass
¶
mixpanel_headless.RetentionResult
dataclass
¶
RetentionResult(
born_event: str,
return_event: str,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
cohorts: list[CohortInfo] = list(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Result of a retention query.
Contains cohort-based retention data.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_headless.CohortInfo
dataclass
¶
Retention data for a single cohort.
retention
class-attribute
instance-attribute
¶
Retention percentages by period (0.0 to 1.0).
Discovery Types¶
mixpanel_headless.FunnelInfo
dataclass
¶
A saved funnel definition.
Represents a funnel saved in Mixpanel that can be queried using the funnel() method.
mixpanel_headless.SavedCohort
dataclass
¶
A saved cohort definition.
Represents a user cohort saved in Mixpanel for profile filtering.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_headless/types.py
mixpanel_headless.TopEvent
dataclass
¶
Today's event activity data.
Represents an event's current activity including count and trend.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Event name.
TYPE:
|
count |
Today's event count.
TYPE:
|
percent_change |
Change vs yesterday (-1.0 to +infinity).
TYPE:
|
Example
mixpanel_headless.SchemaGraphResult
dataclass
¶
SchemaGraphResult(
computed_at: str,
events: list[dict[str, Any]] = list(),
properties: list[dict[str, Any]] = list(),
user_properties: list[dict[str, Any]] = list(),
include_density: bool = False,
params: dict[str, Any] = dict(),
*,
_df_cache: DataFrame | None = None,
_events_df_cache: DataFrame | None = None,
_properties_df_cache: DataFrame | None = None,
_relationships_df_cache: DataFrame | None = None,
_graph_cache: DiGraph[str] | None = None,
)
Bases: ResultWithDataFrame
Full Lexicon schema plus the event<->property relationship graph.
Adapts the power-tools getSchema view to headless: it gathers event
definitions, event properties, and user properties from the Lexicon, and
records which properties appear on which events (and the inverse) from a
single bulk data-definitions/properties?includeEvents=true call, so for
any event you can list the properties that travel with it.
Group properties are out of scope for now (headless has no data-groups listing to enumerate them); only event and user properties are gathered.
| ATTRIBUTE | DESCRIPTION |
|---|---|
computed_at |
ISO-8601 timestamp when the schema was gathered.
TYPE:
|
events |
Event definition dicts (Lexicon shape, camelCase keys).
TYPE:
|
properties |
Event property dicts; each carries an
TYPE:
|
user_properties |
User property dicts.
TYPE:
|
event_to_properties |
Map of event name to the property names on it
(derived from
TYPE:
|
property_to_events |
Map of property name to the events it appears on
(derived from
TYPE:
|
include_density |
Whether per-property density was requested.
TYPE:
|
meta |
Derived gather metadata — entity counts plus per-row drop counts
(
TYPE:
|
params |
The parameters that produced this result.
TYPE:
|
Example
events_df
property
¶
Flat DataFrame of event definitions.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
|
DataFrame
|
columns) when there are no events. |
properties_df
property
¶
Flat DataFrame of event and user properties.
Each row carries a resource_type discriminator (event or
user).
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
no properties. |
relationships_df
property
¶
Edge-list DataFrame of event<->property relationships.
One row per (event, property) pair. density_local is the property's
top-level densityLocal (returned at the property level by the bulk
call) repeated on each of its edges; it is None unless
include_density was requested.
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame with columns |
DataFrame
|
Empty (with those columns) when no relationships exist. |
df
property
¶
Headline DataFrame — the event<->property relationship edge list.
| RETURNS | DESCRIPTION |
|---|---|
The
|
attr:
TYPE:
|
__post_init__
¶
Derive the adjacency maps and meta from properties.
properties (each entry carrying an inner events list) is the single
source of truth: event_to_properties / property_to_events are built
here — events seeded from events so an event with no properties still
appears — rather than being passed in, so the maps can never disagree with
properties. The same pass records meta counts, including the rows
dropped for a missing/empty name or a malformed events entry; a
nonzero drop count signals the Lexicon response shape may have changed.
Source code in src/mixpanel_headless/types.py
11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 | |
properties_for_event
¶
Return the property names that appear on an event.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Property names on the event (empty when unknown or none). |
Source code in src/mixpanel_headless/types.py
events_for_property
¶
Return the events a property appears on.
| PARAMETER | DESCRIPTION |
|---|---|
prop
|
Property name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Event names carrying the property (empty when unknown or none). |
Source code in src/mixpanel_headless/types.py
orphan_properties
¶
Return event properties that appear on no events.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Property names with no event relationships. Properties without a |
list[str]
|
name are skipped (matching |
Source code in src/mixpanel_headless/types.py
to_graph
¶
Build a directed event->property relationship graph.
Event names become nodes with kind="event" and property names nodes
with kind="property"; a directed edge runs from each event to every
property that appears on it, carrying the property's density_local
(None unless include_density was requested).
The graph is bipartite (no event->event or property->property edges)
provided event and property names are disjoint; nodes are keyed by bare
name, so an event and a property that share a name collapse to one node.
Built lazily and cached.
| RETURNS | DESCRIPTION |
|---|---|
DiGraph
|
A |
DiGraph
|
properties. |
Example
Source code in src/mixpanel_headless/types.py
11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 | |
to_dict
¶
Serialize the schema graph for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all fields suitable for JSON serialization. |
Source code in src/mixpanel_headless/types.py
Subproperty Discovery Types¶
Types for Workspace.subproperties() — schema discovery for list-of-object event properties. See Subproperties for usage.
mixpanel_headless.SubPropertyInfo
dataclass
¶
SubPropertyInfo(
name: str,
type: CustomPropertyType,
sample_values: tuple[str | int | float | bool, ...],
)
Discovered subproperty of a list-of-object event property.
Returned by :meth:Workspace.subproperties to describe the inner
structure of properties whose values are lists of objects (e.g.
cart is a list of {"Brand": str, "Category": str, "Price":
int} items). Use the name and type to construct
:meth:GroupBy.list_item and :meth:Filter.list_contains calls.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Subproperty name as it appears inside each object.
TYPE:
|
type |
Inferred data type. Mixed sub-value types collapse to
TYPE:
|
sample_values |
Up to 5 distinct sample values observed across the sampled rows.
TYPE:
|
Example
type
instance-attribute
¶
Inferred data type, suitable for GroupBy.list_item(sub_type=...).
sample_values
instance-attribute
¶
Up to 5 distinct sample values observed across the sampled rows.
to_dict
¶
Serialize the subproperty info as a plain dict for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with |
dict[str, Any]
|
|
dict[str, Any]
|
JSON serialization. |
Source code in src/mixpanel_headless/types.py
Lexicon Types¶
mixpanel_headless.LexiconSchema
dataclass
¶
Complete schema definition from Mixpanel Lexicon.
Represents a documented event or profile property definition from the Mixpanel data dictionary.
mixpanel_headless.LexiconDefinition
dataclass
¶
LexiconDefinition(
description: str | None,
properties: dict[str, LexiconProperty],
metadata: LexiconMetadata | None,
)
Full schema definition for an event or profile property in Lexicon.
Contains the structural definition including description, properties, and platform-specific metadata.
properties
instance-attribute
¶
Property definitions keyed by property name.
metadata
instance-attribute
¶
Optional Mixpanel-specific metadata for the entity.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with properties, and optionally description and metadata. |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.LexiconProperty
dataclass
¶
Schema definition for a single property in a Lexicon schema.
Describes the type and metadata for an event or profile property.
type
instance-attribute
¶
JSON Schema type (string, number, boolean, array, object, integer, null).
description
instance-attribute
¶
Human-readable description of the property.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with type, and optionally description and metadata. |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.LexiconMetadata
dataclass
¶
LexiconMetadata(
source: str | None,
display_name: str | None,
tags: list[str],
hidden: bool,
dropped: bool,
contacts: list[str],
team_contacts: list[str],
)
Mixpanel-specific metadata for Lexicon schemas and properties.
Contains platform-specific information about how schemas and properties are displayed and organized in the Mixpanel UI.
source
instance-attribute
¶
Origin of the schema definition (e.g., 'api', 'csv', 'ui').
display_name
instance-attribute
¶
Human-readable display name in Mixpanel UI.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all metadata fields. |
Source code in src/mixpanel_headless/types.py
Event Analytics Results¶
mixpanel_headless.EventCountsResult
dataclass
¶
EventCountsResult(
events: list[str],
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
type: Literal["general", "unique", "average"],
series: dict[str, dict[str, int]],
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Time-series event count data.
Contains aggregate counts for multiple events over time with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_headless.PropertyCountsResult
dataclass
¶
PropertyCountsResult(
event: str,
property_name: str,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
type: Literal["general", "unique", "average"],
series: dict[str, dict[str, int]],
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Time-series property value distribution data.
Contains aggregate counts by property values over time with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
series
instance-attribute
¶
Time series data by property value.
Structure: {property_value: {date: count}} Example: {"US": {"2024-01-01": 150, "2024-01-02": 200}, "EU": {...}}
df
property
¶
Convert to DataFrame with columns: date, value, count.
Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_headless/types.py
Advanced Query Results¶
mixpanel_headless.UserEvent
dataclass
¶
mixpanel_headless.ActivityFeedResult
dataclass
¶
ActivityFeedResult(
distinct_ids: list[str],
from_date: str | None,
to_date: str | None,
events: list[UserEvent] = list(),
sentinel_event: dict[str, Any] | None = None,
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Collection of user events from activity feed query.
Contains chronological event history for one or more users with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
from_date
instance-attribute
¶
Start date filter (YYYY-MM-DD), None if not specified.
to_date
instance-attribute
¶
End date filter (YYYY-MM-DD), None if not specified.
events
class-attribute
instance-attribute
¶
Event history (chronological order).
sentinel_event
class-attribute
instance-attribute
¶
Opaque pagination cursor from results.sentinel_event.
Returned verbatim by the stream/bookmark endpoint; None when there are no
further pages. Pass it back unchanged as activity_feed(..., sentinel_event=)
to fetch the next page. Kept as a raw dict (server-defined token) because it
carries the exact time/$insert_id the server needs, which a converted
:class:UserEvent would lose.
df
property
¶
Convert to DataFrame with columns: event, time, distinct_id, + properties.
Flattens event properties into individual columns. Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FrequencyResult
dataclass
¶
FrequencyResult(
event: str | None,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"],
addiction_unit: Literal["hour", "day"],
data: dict[str, list[int]] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Event frequency distribution (addiction analysis).
Contains frequency arrays showing how many users performed events in N time periods, with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
data
class-attribute
instance-attribute
¶
Frequency arrays by date.
Structure: {date: [count_1, count_2, ...]} Example: {"2024-01-01": [100, 50, 25, 10]}
Each array shows user counts by frequency: - Index 0: users active exactly 1 time - Index 1: users active exactly 2 times - Index N: users active exactly N+1 times
df
property
¶
Convert to DataFrame with columns: date, period_1, period_2, ...
Each period_N column shows users active in at least N time periods. Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_headless/types.py
mixpanel_headless.NumericBucketResult
dataclass
¶
NumericBucketResult(
event: str,
from_date: str,
to_date: str,
property_expr: str,
unit: Literal["hour", "day"],
series: dict[str, dict[str, int]] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Events segmented into numeric property ranges.
Contains time-series data bucketed by automatically determined numeric ranges, with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
mixpanel_headless.NumericSumResult
dataclass
¶
NumericSumResult(
event: str,
from_date: str,
to_date: str,
property_expr: str,
unit: Literal["hour", "day"],
results: dict[str, float] = dict(),
computed_at: str | None = None,
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Sum of numeric property values per time unit.
Contains daily or hourly sum totals for a numeric property with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
results
class-attribute
instance-attribute
¶
Sum values: {date: sum}.
computed_at
class-attribute
instance-attribute
¶
Computation timestamp (if provided by API).
df
property
¶
Convert to DataFrame with columns: date, sum.
Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
Source code in src/mixpanel_headless/types.py
mixpanel_headless.NumericAverageResult
dataclass
¶
NumericAverageResult(
event: str,
from_date: str,
to_date: str,
property_expr: str,
unit: Literal["hour", "day"],
results: dict[str, float] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Average of numeric property values per time unit.
Contains daily or hourly average values for a numeric property with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
Bookmark Types¶
mixpanel_headless.BookmarkInfo
dataclass
¶
BookmarkInfo(
id: int,
name: str,
type: BookmarkType,
project_id: int,
created: str,
modified: str,
workspace_id: int | None = None,
dashboard_id: int | None = None,
description: str | None = None,
creator_id: int | None = None,
creator_name: str | None = None,
)
Metadata for a saved report (bookmark) from the Mixpanel Bookmarks API.
Represents a saved Insights, Funnel, Retention, or Flows report that can be queried using query_saved_report() or query_saved_flows().
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Unique bookmark identifier.
TYPE:
|
name |
User-defined report name.
TYPE:
|
type |
Report type (insights, funnels, retention, flows, launch-analysis).
TYPE:
|
project_id |
Parent Mixpanel project ID.
TYPE:
|
created |
Creation timestamp (ISO format).
TYPE:
|
modified |
Last modification timestamp (ISO format).
TYPE:
|
workspace_id |
Optional workspace ID if scoped to a workspace.
TYPE:
|
dashboard_id |
Optional parent dashboard ID if linked to a dashboard.
TYPE:
|
description |
Optional user-provided description.
TYPE:
|
creator_id |
Optional creator's user ID.
TYPE:
|
creator_name |
Optional creator's display name.
TYPE:
|
workspace_id
class-attribute
instance-attribute
¶
Workspace ID if scoped to a workspace.
dashboard_id
class-attribute
instance-attribute
¶
Parent dashboard ID if linked to a dashboard.
description
class-attribute
instance-attribute
¶
User-provided description.
creator_name
class-attribute
instance-attribute
¶
Creator's display name.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all bookmark metadata fields. |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.SavedReportResult
dataclass
¶
SavedReportResult(
bookmark_id: int,
computed_at: str,
from_date: str,
to_date: str,
headers: list[str] = list(),
series: dict[str, Any] = dict(),
_df_cache: DataFrame | None = None,
)
Data from a saved report (Insights, Retention, or Funnel).
Contains data from a pre-configured saved report with automatic report type detection and lazy DataFrame conversion support.
The report_type property automatically detects the report type based on headers: "$retention" indicates retention, "$funnel" indicates funnel, otherwise it's an insights report.
| ATTRIBUTE | DESCRIPTION |
|---|---|
bookmark_id |
Saved report identifier.
TYPE:
|
computed_at |
When report was computed (ISO format).
TYPE:
|
from_date |
Report start date.
TYPE:
|
to_date |
Report end date.
TYPE:
|
headers |
Report column headers (used for type detection).
TYPE:
|
series |
Report data (structure varies by report type).
TYPE:
|
headers
class-attribute
instance-attribute
¶
Report column headers (used for type detection).
series
class-attribute
instance-attribute
¶
Report data (structure varies by report type).
For Insights reports: {event_name: {date: count}} For Retention reports: {series_name: {date: {segment: {first, counts, rates}}}} For Funnel reports: {count: {...}, overall_conv_ratio: {...}, ...}
report_type
property
¶
Detect the report type from headers.
| RETURNS | DESCRIPTION |
|---|---|
SavedReportType
|
'retention' if headers contain '$retention', |
SavedReportType
|
'funnel' if headers contain '$funnel', |
SavedReportType
|
'flows' if headers contain '$flows', |
SavedReportType
|
'insights' otherwise. |
df
property
¶
Convert to DataFrame.
For Insights reports: columns are date, event, count. For Retention/Funnel reports: flattens the nested structure.
Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all report fields including detected report_type. |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FlowsResult
dataclass
¶
FlowsResult(
bookmark_id: int,
computed_at: str,
steps: list[dict[str, Any]] = list(),
breakdowns: list[dict[str, Any]] = list(),
overall_conversion_rate: float = 0.0,
metadata: dict[str, Any] = dict(),
*,
_df_cache: DataFrame | None = None,
)
Bases: ResultWithDataFrame
Data from a saved Flows report.
Contains user path/navigation data from a pre-configured Flows report with lazy DataFrame conversion support.
Inherits from ResultWithDataFrame to provide: - Lazy DataFrame caching via _df_cache field - Normalized table output via to_table_dict() method
| ATTRIBUTE | DESCRIPTION |
|---|---|
bookmark_id |
Saved report identifier.
TYPE:
|
computed_at |
When report was computed (ISO format).
TYPE:
|
steps |
Flow step data with event sequences and counts.
TYPE:
|
breakdowns |
Path breakdown data showing user flow distribution.
TYPE:
|
overall_conversion_rate |
End-to-end conversion rate (0.0 to 1.0).
TYPE:
|
metadata |
Additional API metadata from the response.
TYPE:
|
steps
class-attribute
instance-attribute
¶
Flow step data with event sequences and counts.
breakdowns
class-attribute
instance-attribute
¶
Path breakdown data showing user flow distribution.
overall_conversion_rate
class-attribute
instance-attribute
¶
End-to-end conversion rate (0.0 to 1.0).
metadata
class-attribute
instance-attribute
¶
Additional API metadata from the response.
df
property
¶
Convert steps to DataFrame.
Returns DataFrame with columns derived from step data structure. Conversion is lazy - computed on first access and cached.
to_dict
¶
Serialize for JSON output.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all flows report fields. |
Source code in src/mixpanel_headless/types.py
Dashboard CRUD Types¶
mixpanel_headless.Dashboard
¶
Bases: BaseModel
A Mixpanel dashboard as returned by the App API.
Represents the full dashboard entity including metadata, permissions,
and optional layout/content fields. Extra fields from API evolution
are preserved via extra="allow".
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Unique dashboard identifier.
TYPE:
|
title |
Dashboard title.
TYPE:
|
description |
Dashboard description.
TYPE:
|
is_private |
Whether the dashboard is private.
TYPE:
|
is_restricted |
Whether the dashboard has restricted access.
TYPE:
|
creator_id |
ID of the dashboard creator.
TYPE:
|
creator_name |
Name of the dashboard creator.
TYPE:
|
creator_email |
Email of the dashboard creator.
TYPE:
|
created |
Creation timestamp (lenient parsing).
TYPE:
|
modified |
Last modification timestamp.
TYPE:
|
is_favorited |
Whether the current user has favorited this dashboard.
TYPE:
|
pinned_date |
Date the dashboard was pinned, if any.
TYPE:
|
layout_version |
Layout version metadata.
TYPE:
|
unique_view_count |
Number of unique viewers.
TYPE:
|
total_view_count |
Total view count.
TYPE:
|
last_modified_by_id |
ID of the last modifier.
TYPE:
|
last_modified_by_name |
Name of the last modifier.
TYPE:
|
last_modified_by_email |
Email of the last modifier.
TYPE:
|
filters |
Dashboard-level filters.
TYPE:
|
breakdowns |
Dashboard-level breakdowns.
TYPE:
|
time_filter |
Dashboard-level time filter.
TYPE:
|
generation_type |
How the dashboard was generated.
TYPE:
|
parent_dashboard_id |
Parent dashboard ID for nested dashboards.
TYPE:
|
child_dashboards |
Child dashboard references.
TYPE:
|
can_update_basic |
Permission flag.
TYPE:
|
can_share |
Permission flag.
TYPE:
|
can_view |
Permission flag.
TYPE:
|
can_update_restricted |
Permission flag.
TYPE:
|
can_update_visibility |
Permission flag.
TYPE:
|
is_superadmin |
Whether current user is superadmin.
TYPE:
|
allow_staff_override |
Whether staff override is allowed.
TYPE:
|
can_pin |
Whether current user can pin.
TYPE:
|
is_shared_with_project |
Whether shared with the project.
TYPE:
|
creator |
Creator identifier string.
TYPE:
|
ancestors |
Ancestor dashboard references.
TYPE:
|
layout |
Dashboard layout data.
TYPE:
|
contents |
Dashboard contents data.
TYPE:
|
num_active_public_links |
Number of active public links.
TYPE:
|
new_content |
New content data.
TYPE:
|
template_type |
Template type if created from a template.
TYPE:
|
Example
dashboard = Dashboard(
id=1, title="Q1 Metrics", is_private=False,
is_restricted=False, is_favorited=False,
can_update_basic=True, can_share=True, can_view=True,
can_update_restricted=False, can_update_visibility=False,
is_superadmin=False, allow_staff_override=False,
can_pin=True, is_shared_with_project=True, ancestors=[],
)
assert dashboard.title == "Q1 Metrics"
description
class-attribute
instance-attribute
¶
Dashboard description.
is_private
class-attribute
instance-attribute
¶
Whether the dashboard is private.
is_restricted
class-attribute
instance-attribute
¶
Whether the dashboard has restricted access.
creator_id
class-attribute
instance-attribute
¶
ID of the dashboard creator.
creator_name
class-attribute
instance-attribute
¶
Name of the dashboard creator.
creator_email
class-attribute
instance-attribute
¶
Email of the dashboard creator.
modified
class-attribute
instance-attribute
¶
Last modification timestamp.
is_favorited
class-attribute
instance-attribute
¶
Whether the current user has favorited this dashboard.
pinned_date
class-attribute
instance-attribute
¶
Date the dashboard was pinned, if any.
layout_version
class-attribute
instance-attribute
¶
Layout version metadata.
unique_view_count
class-attribute
instance-attribute
¶
Number of unique viewers.
total_view_count
class-attribute
instance-attribute
¶
Total view count.
last_modified_by_id
class-attribute
instance-attribute
¶
ID of the last modifier.
last_modified_by_name
class-attribute
instance-attribute
¶
Name of the last modifier.
last_modified_by_email
class-attribute
instance-attribute
¶
Email of the last modifier.
filters
class-attribute
instance-attribute
¶
Dashboard-level filters.
breakdowns
class-attribute
instance-attribute
¶
Dashboard-level breakdowns.
time_filter
class-attribute
instance-attribute
¶
Dashboard-level time filter.
generation_type
class-attribute
instance-attribute
¶
How the dashboard was generated.
parent_dashboard_id
class-attribute
instance-attribute
¶
Parent dashboard ID for nested dashboards.
child_dashboards
class-attribute
instance-attribute
¶
Child dashboard references.
can_update_basic
class-attribute
instance-attribute
¶
Permission: can update basic fields.
can_update_restricted
class-attribute
instance-attribute
¶
Permission: can update restricted fields.
can_update_visibility
class-attribute
instance-attribute
¶
Permission: can update visibility.
is_superadmin
class-attribute
instance-attribute
¶
Whether current user is superadmin.
allow_staff_override
class-attribute
instance-attribute
¶
Whether staff override is allowed.
is_shared_with_project
class-attribute
instance-attribute
¶
Whether shared with the project.
ancestors
class-attribute
instance-attribute
¶
Ancestor dashboard references.
num_active_public_links
class-attribute
instance-attribute
¶
Number of active public links.
template_type
class-attribute
instance-attribute
¶
Template type if created from a template.
mixpanel_headless.CreateDashboardParams
¶
Bases: BaseModel
Parameters for creating a new dashboard.
| ATTRIBUTE | DESCRIPTION |
|---|---|
title |
Dashboard title (required).
TYPE:
|
description |
Dashboard description.
TYPE:
|
is_private |
Whether the dashboard should be private.
TYPE:
|
is_restricted |
Whether the dashboard should have restricted access.
TYPE:
|
filters |
Dashboard-level filters.
TYPE:
|
breakdowns |
Dashboard-level breakdowns.
TYPE:
|
time_filter |
Dashboard-level time filter.
TYPE:
|
duplicate |
ID of dashboard to duplicate.
TYPE:
|
rows |
Initial dashboard content with layout. Each row contains 1-4
content items (text cards or reports). Items in the same row are
placed side-by-side with auto-distributed widths. This is the
recommended way to create dashboards with proper layout — adding
content after creation via
TYPE:
|
Example
import json
params = CreateDashboardParams(
title="Product Health",
rows=[
DashboardRow(contents=[
DashboardRowContent(
content_type="text",
content_params={"markdown": "<h2>Overview</h2>"},
),
]),
DashboardRow(contents=[
DashboardRowContent(
content_type="report",
content_params={"bookmark": {
"name": "DAU", "type": "insights",
"params": json.dumps(dau_result.params),
}},
),
DashboardRowContent(
content_type="report",
content_params={"bookmark": {
"name": "Signups", "type": "insights",
"params": json.dumps(signup_result.params),
}},
),
]),
],
)
description
class-attribute
instance-attribute
¶
Dashboard description.
is_private
class-attribute
instance-attribute
¶
Whether the dashboard should be private.
is_restricted
class-attribute
instance-attribute
¶
Whether the dashboard should have restricted access.
filters
class-attribute
instance-attribute
¶
Dashboard-level filters.
breakdowns
class-attribute
instance-attribute
¶
Dashboard-level breakdowns.
time_filter
class-attribute
instance-attribute
¶
Dashboard-level time filter.
duplicate
class-attribute
instance-attribute
¶
ID of dashboard to duplicate.
rows
class-attribute
instance-attribute
¶
Initial content rows with layout. Each row has 1-4 content items.
mixpanel_headless.UpdateDashboardParams
¶
Bases: BaseModel
Parameters for updating an existing dashboard.
All fields are optional — only provided fields are sent to the API.
| ATTRIBUTE | DESCRIPTION |
|---|---|
title |
New dashboard title.
TYPE:
|
description |
New dashboard description.
TYPE:
|
is_private |
New privacy setting.
TYPE:
|
is_restricted |
New restriction setting.
TYPE:
|
filters |
New dashboard-level filters.
TYPE:
|
breakdowns |
New dashboard-level breakdowns.
TYPE:
|
time_filter |
New dashboard-level time filter.
TYPE:
|
layout |
New dashboard layout data.
TYPE:
|
content |
New dashboard content data.
TYPE:
|
Example
description
class-attribute
instance-attribute
¶
New dashboard description.
is_restricted
class-attribute
instance-attribute
¶
New restriction setting.
filters
class-attribute
instance-attribute
¶
New dashboard-level filters.
breakdowns
class-attribute
instance-attribute
¶
New dashboard-level breakdowns.
time_filter
class-attribute
instance-attribute
¶
New dashboard-level time filter.
mixpanel_headless.BlueprintTemplate
¶
Bases: BaseModel
A dashboard blueprint template.
| ATTRIBUTE | DESCRIPTION |
|---|---|
title_key |
Template title key.
TYPE:
|
description_key |
Template description key.
TYPE:
|
alternative_description_key |
Alternative description key.
TYPE:
|
number_of_reports |
Number of reports in the template.
TYPE:
|
mixpanel_headless.BlueprintConfig
¶
mixpanel_headless.BlueprintCard
¶
Bases: BaseModel
A card in a blueprint dashboard.
| ATTRIBUTE | DESCRIPTION |
|---|---|
card_type |
Card type (serialized as
TYPE:
|
text_card_id |
Text card ID, if applicable.
TYPE:
|
bookmark_id |
Bookmark ID, if applicable.
TYPE:
|
markdown |
Markdown content for text cards.
TYPE:
|
name |
Card name.
TYPE:
|
params |
Card parameters.
TYPE:
|
Example
card_type
class-attribute
instance-attribute
¶
Card type (serialized as "type").
text_card_id
class-attribute
instance-attribute
¶
Text card ID, if applicable.
bookmark_id
class-attribute
instance-attribute
¶
Bookmark ID, if applicable.
markdown
class-attribute
instance-attribute
¶
Markdown content for text cards.
mixpanel_headless.BlueprintFinishParams
¶
Bases: BaseModel
Parameters for finalizing a blueprint dashboard.
| ATTRIBUTE | DESCRIPTION |
|---|---|
dashboard_id |
ID of the blueprint dashboard to finalize.
TYPE:
|
cards |
List of cards to include.
TYPE:
|
Example
mixpanel_headless.CreateRcaDashboardParams
¶
Bases: BaseModel
Parameters for creating an RCA dashboard.
| ATTRIBUTE | DESCRIPTION |
|---|---|
rca_source_id |
Source ID for RCA analysis.
TYPE:
|
rca_source_data |
Source data configuration.
TYPE:
|
Example
mixpanel_headless.RcaSourceData
¶
Bases: BaseModel
Source data for RCA dashboard creation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
source_type |
Source type (serialized as
TYPE:
|
date |
Date string.
TYPE:
|
metric_source |
Whether this is a metric source.
TYPE:
|
Example
mixpanel_headless.UpdateReportLinkParams
¶
mixpanel_headless.UpdateTextCardParams
¶
Report CRUD Types¶
mixpanel_headless.Bookmark
¶
Bases: BaseModel
A Mixpanel bookmark (saved report) as returned by the App API.
Represents the full bookmark entity including query parameters,
metadata, and permissions. The bookmark_type field is aliased
from "type" in the API response.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Unique bookmark identifier.
TYPE:
|
project_id |
Parent project identifier.
TYPE:
|
name |
Bookmark name.
TYPE:
|
bookmark_type |
Report type (aliased from
TYPE:
|
description |
Bookmark description.
TYPE:
|
icon |
Bookmark icon.
TYPE:
|
params |
Query parameters (JSON value defining the report).
TYPE:
|
dashboard_id |
Associated dashboard ID.
TYPE:
|
include_in_dashboard |
Whether included in dashboard.
TYPE:
|
is_default |
Whether this is a default bookmark.
TYPE:
|
creator_id |
ID of the creator.
TYPE:
|
creator_name |
Name of the creator.
TYPE:
|
creator_email |
Email of the creator.
TYPE:
|
created |
Creation timestamp.
TYPE:
|
modified |
Last modification timestamp.
TYPE:
|
last_modified_by_id |
ID of the last modifier.
TYPE:
|
last_modified_by_name |
Name of the last modifier.
TYPE:
|
last_modified_by_email |
Email of the last modifier.
TYPE:
|
metadata |
Report-specific metadata.
TYPE:
|
is_visibility_restricted |
Visibility restriction flag.
TYPE:
|
is_modification_restricted |
Modification restriction flag.
TYPE:
|
can_update_basic |
Permission flag.
TYPE:
|
can_view |
Permission flag.
TYPE:
|
can_share |
Permission flag.
TYPE:
|
generation_type |
How the bookmark was generated.
TYPE:
|
original_type |
Original report type before conversion.
TYPE:
|
unique_view_count |
Number of unique viewers.
TYPE:
|
total_view_count |
Total view count.
TYPE:
|
Example
project_id
class-attribute
instance-attribute
¶
Parent project identifier.
bookmark_type
class-attribute
instance-attribute
¶
Report type (aliased from "type").
description
class-attribute
instance-attribute
¶
Bookmark description.
params
class-attribute
instance-attribute
¶
Query parameters (JSON value defining the report).
dashboard_id
class-attribute
instance-attribute
¶
Associated dashboard ID.
include_in_dashboard
class-attribute
instance-attribute
¶
Whether included in dashboard.
is_default
class-attribute
instance-attribute
¶
Whether this is a default bookmark.
creator_name
class-attribute
instance-attribute
¶
Name of the creator.
creator_email
class-attribute
instance-attribute
¶
Email of the creator.
modified
class-attribute
instance-attribute
¶
Last modification timestamp.
last_modified_by_id
class-attribute
instance-attribute
¶
ID of the last modifier.
last_modified_by_name
class-attribute
instance-attribute
¶
Name of the last modifier.
last_modified_by_email
class-attribute
instance-attribute
¶
Email of the last modifier.
metadata
class-attribute
instance-attribute
¶
Report-specific metadata.
is_visibility_restricted
class-attribute
instance-attribute
¶
Visibility restriction flag.
is_modification_restricted
class-attribute
instance-attribute
¶
Modification restriction flag.
can_update_basic
class-attribute
instance-attribute
¶
Permission: can update basic fields.
generation_type
class-attribute
instance-attribute
¶
How the bookmark was generated.
original_type
class-attribute
instance-attribute
¶
Original report type before conversion.
unique_view_count
class-attribute
instance-attribute
¶
Number of unique viewers.
total_view_count
class-attribute
instance-attribute
¶
Total view count.
mixpanel_headless.BookmarkMetadata
¶
Bases: BaseModel
Metadata associated with a bookmark/report.
Contains optional display and calculation settings that vary by bookmark type (insights, funnels, retention, etc.).
| ATTRIBUTE | DESCRIPTION |
|---|---|
table_display_mode |
Table display mode setting.
TYPE:
|
compare_enabled |
Whether comparison is enabled.
TYPE:
|
compare_filters |
Comparison filter settings.
TYPE:
|
retention_calculation_type |
Retention calculation method.
TYPE:
|
event_name |
Associated event name.
TYPE:
|
funnel_conversion_window |
Funnel conversion window in days.
TYPE:
|
funnel_breakdown_limit |
Maximum funnel breakdown count.
TYPE:
|
table_display_mode
class-attribute
instance-attribute
¶
Table display mode setting.
compare_enabled
class-attribute
instance-attribute
¶
Whether comparison is enabled.
compare_filters
class-attribute
instance-attribute
¶
Comparison filter settings.
retention_calculation_type
class-attribute
instance-attribute
¶
Retention calculation method.
event_name
class-attribute
instance-attribute
¶
Associated event name.
funnel_conversion_window
class-attribute
instance-attribute
¶
Funnel conversion window in days.
funnel_breakdown_limit
class-attribute
instance-attribute
¶
Maximum funnel breakdown count.
mixpanel_headless.CreateBookmarkParams
¶
Bases: BaseModel
Parameters for creating a new bookmark/report.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Bookmark name (required).
TYPE:
|
bookmark_type |
Report type (required, serialized as
TYPE:
|
params |
Query parameters (required).
TYPE:
|
description |
Bookmark description.
TYPE:
|
icon |
Bookmark icon.
TYPE:
|
dashboard_id |
Dashboard to associate with. Required by
TYPE:
|
is_visibility_restricted |
Visibility restriction flag.
TYPE:
|
is_modification_restricted |
Modification restriction flag.
TYPE:
|
Example
bookmark_type
class-attribute
instance-attribute
¶
Report type (required, serialized as "type").
Pydantic-validated against the canonical set on construction —
typos like "insightz" are rejected before any API call.
description
class-attribute
instance-attribute
¶
Bookmark description.
dashboard_id
class-attribute
instance-attribute
¶
Dashboard to associate with.
is_visibility_restricted
class-attribute
instance-attribute
¶
Visibility restriction flag.
is_modification_restricted
class-attribute
instance-attribute
¶
Modification restriction flag.
mixpanel_headless.UpdateBookmarkParams
¶
Bases: BaseModel
Parameters for updating an existing bookmark/report.
All fields are optional — only provided fields are sent to the API.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
New bookmark name.
TYPE:
|
params |
New query parameters.
TYPE:
|
description |
New bookmark description.
TYPE:
|
icon |
New bookmark icon.
TYPE:
|
dashboard_id |
New associated dashboard ID.
TYPE:
|
is_visibility_restricted |
New visibility restriction.
TYPE:
|
is_modification_restricted |
New modification restriction.
TYPE:
|
deleted |
Soft-delete flag.
TYPE:
|
Example
params
class-attribute
instance-attribute
¶
New query parameters.
description
class-attribute
instance-attribute
¶
New bookmark description.
dashboard_id
class-attribute
instance-attribute
¶
New associated dashboard ID.
is_visibility_restricted
class-attribute
instance-attribute
¶
New visibility restriction.
is_modification_restricted
class-attribute
instance-attribute
¶
New modification restriction.
mixpanel_headless.BulkUpdateBookmarkEntry
¶
Bases: BaseModel
Entry for bulk-updating bookmarks.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Bookmark ID to update (required).
TYPE:
|
name |
New bookmark name.
TYPE:
|
params |
New query parameters.
TYPE:
|
description |
New bookmark description.
TYPE:
|
icon |
New bookmark icon.
TYPE:
|
is_visibility_restricted |
New visibility restriction.
TYPE:
|
is_modification_restricted |
New modification restriction.
TYPE:
|
params
class-attribute
instance-attribute
¶
New query parameters.
description
class-attribute
instance-attribute
¶
New bookmark description.
is_visibility_restricted
class-attribute
instance-attribute
¶
New visibility restriction.
is_modification_restricted
class-attribute
instance-attribute
¶
New modification restriction.
mixpanel_headless.BookmarkHistoryResponse
¶
Bases: BaseModel
Response from the bookmark history endpoint.
| ATTRIBUTE | DESCRIPTION |
|---|---|
results |
List of history entries.
TYPE:
|
pagination |
Pagination metadata.
TYPE:
|
mixpanel_headless.BookmarkHistoryPagination
¶
Bases: BaseModel
Pagination metadata for bookmark history responses.
| ATTRIBUTE | DESCRIPTION |
|---|---|
next_cursor |
Cursor for next page.
TYPE:
|
previous_cursor |
Cursor for previous page.
TYPE:
|
page_size |
Number of items per page.
TYPE:
|
Cohort CRUD Types¶
mixpanel_headless.Cohort
¶
Bases: BaseModel
A Mixpanel cohort as returned by the App API.
Represents the full cohort entity with definition, metadata, and
cross-references. Extra fields from API evolution are preserved
via extra="allow".
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Unique cohort identifier.
TYPE:
|
name |
Cohort name.
TYPE:
|
description |
Cohort description.
TYPE:
|
count |
Number of users in the cohort.
TYPE:
|
is_visible |
Whether the cohort is visible.
TYPE:
|
is_locked |
Whether the cohort is locked.
TYPE:
|
data_group_id |
Data group identifier.
TYPE:
|
last_edited |
Last edited timestamp string.
TYPE:
|
created_by |
Creator information.
TYPE:
|
referenced_by |
IDs of entities referencing this cohort.
TYPE:
|
verified |
Whether the cohort is verified.
TYPE:
|
last_queried |
Last queried timestamp string.
TYPE:
|
referenced_directly_by |
IDs of entities directly referencing this cohort.
TYPE:
|
active_integrations |
Active integration IDs.
TYPE:
|
is_visible
class-attribute
instance-attribute
¶
Whether the cohort is visible.
is_locked
class-attribute
instance-attribute
¶
Whether the cohort is locked.
data_group_id
class-attribute
instance-attribute
¶
Data group identifier.
last_edited
class-attribute
instance-attribute
¶
Last edited timestamp string.
created_by
class-attribute
instance-attribute
¶
Creator information.
referenced_by
class-attribute
instance-attribute
¶
IDs of entities referencing this cohort.
verified
class-attribute
instance-attribute
¶
Whether the cohort is verified.
last_queried
class-attribute
instance-attribute
¶
Last queried timestamp string.
referenced_directly_by
class-attribute
instance-attribute
¶
IDs of entities directly referencing this cohort.
active_integrations
class-attribute
instance-attribute
¶
Active integration IDs.
mixpanel_headless.CohortCreator
¶
mixpanel_headless.CreateCohortParams
¶
Bases: _DefinitionFlatteningModel
Parameters for creating a new cohort.
The definition dict is flattened into the top-level JSON payload
at serialization time — its keys become top-level fields in the request body.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Cohort name (required).
TYPE:
|
description |
Cohort description.
TYPE:
|
data_group_id |
Data group identifier.
TYPE:
|
is_locked |
Whether the cohort should be locked.
TYPE:
|
is_visible |
Whether the cohort should be visible.
TYPE:
|
deleted |
Soft-delete flag.
TYPE:
|
Example
mixpanel_headless.UpdateCohortParams
¶
Bases: _DefinitionFlatteningModel
Parameters for updating an existing cohort.
All fields are optional — only provided fields are sent to the API.
The definition dict is flattened into the payload.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
New cohort name.
TYPE:
|
description |
New cohort description.
TYPE:
|
data_group_id |
New data group identifier.
TYPE:
|
is_locked |
New lock setting.
TYPE:
|
is_visible |
New visibility setting.
TYPE:
|
deleted |
Soft-delete flag.
TYPE:
|
Example
mixpanel_headless.BulkUpdateCohortEntry
¶
Bases: _DefinitionFlatteningModel
Entry for bulk-updating cohorts.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Cohort ID to update (required).
TYPE:
|
name |
New cohort name.
TYPE:
|
description |
New cohort description.
TYPE:
|
Feature Flag Enums¶
mixpanel_headless.FeatureFlagStatus
¶
Bases: str, Enum
Lifecycle state of a feature flag.
| ATTRIBUTE | DESCRIPTION |
|---|---|
ENABLED |
Flag is active and serving variants.
|
DISABLED |
Flag is inactive (default state).
|
ARCHIVED |
Flag is soft-deleted, excluded from default listings.
|
mixpanel_headless.ServingMethod
¶
Bases: str, Enum
Controls how flag values are delivered to clients.
| ATTRIBUTE | DESCRIPTION |
|---|---|
CLIENT |
Client-side evaluation (default).
|
SERVER |
Server-side evaluation only.
|
REMOTE_OR_LOCAL |
Remote preferred, local fallback.
|
REMOTE_ONLY |
Remote evaluation only.
|
mixpanel_headless.FlagContractStatus
¶
Feature Flag Types¶
mixpanel_headless.FeatureFlag
¶
Bases: BaseModel
A Mixpanel feature flag as returned by the App API.
Represents the full feature flag entity including configuration,
metadata, and permissions. Extra fields from API evolution are
preserved via extra="allow".
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Unique identifier (UUID).
TYPE:
|
project_id |
Project this flag belongs to.
TYPE:
|
name |
Human-readable name.
TYPE:
|
key |
Machine-readable key (unique per project).
TYPE:
|
description |
Optional description.
TYPE:
|
status |
Current lifecycle status.
TYPE:
|
tags |
Tags for organization.
TYPE:
|
experiment_id |
Linked experiment ID if flag backs an experiment.
TYPE:
|
context |
Flag context identifier.
TYPE:
|
data_group_id |
Data group identifier.
TYPE:
|
serving_method |
How flag values are delivered.
TYPE:
|
ruleset |
Variants, rollout rules, and test overrides.
TYPE:
|
hash_salt |
Salt for deterministic variant assignment.
TYPE:
|
workspace_id |
Workspace this flag belongs to.
TYPE:
|
content_type |
Content type identifier.
TYPE:
|
created |
ISO 8601 creation timestamp.
TYPE:
|
modified |
ISO 8601 last-modified timestamp.
TYPE:
|
enabled_at |
Timestamp when flag was last enabled.
TYPE:
|
deleted |
Timestamp when flag was deleted.
TYPE:
|
creator_id |
Creator's user ID.
TYPE:
|
creator_name |
Creator's display name.
TYPE:
|
creator_email |
Creator's email.
TYPE:
|
last_modified_by_id |
Last modifier's user ID.
TYPE:
|
last_modified_by_name |
Last modifier's display name.
TYPE:
|
last_modified_by_email |
Last modifier's email.
TYPE:
|
is_favorited |
Whether current user has favorited.
TYPE:
|
pinned_date |
Date flag was pinned.
TYPE:
|
can_edit |
Permission: can current user edit.
TYPE:
|
Example
flag = FeatureFlag(
id="abc-123",
project_id=12345,
name="Dark Mode",
key="dark_mode",
status=FeatureFlagStatus.DISABLED,
context="default",
serving_method=ServingMethod.CLIENT,
ruleset={"variants": []},
created="2026-01-01T00:00:00Z",
modified="2026-01-01T00:00:00Z",
)
assert flag.key == "dark_mode"
description
class-attribute
instance-attribute
¶
Optional description.
status
class-attribute
instance-attribute
¶
Current lifecycle status.
tags
class-attribute
instance-attribute
¶
Tags for organization.
experiment_id
class-attribute
instance-attribute
¶
Linked experiment ID if flag backs an experiment.
data_group_id
class-attribute
instance-attribute
¶
Data group identifier.
serving_method
class-attribute
instance-attribute
¶
How flag values are delivered.
ruleset
class-attribute
instance-attribute
¶
Variants, rollout rules, and test overrides.
hash_salt
class-attribute
instance-attribute
¶
Salt for deterministic variant assignment.
workspace_id
class-attribute
instance-attribute
¶
Workspace this flag belongs to.
content_type
class-attribute
instance-attribute
¶
Content type identifier.
enabled_at
class-attribute
instance-attribute
¶
Timestamp when flag was last enabled.
deleted
class-attribute
instance-attribute
¶
Timestamp when flag was deleted.
creator_name
class-attribute
instance-attribute
¶
Creator's display name.
creator_email
class-attribute
instance-attribute
¶
Creator's email.
last_modified_by_id
class-attribute
instance-attribute
¶
Last modifier's user ID.
last_modified_by_name
class-attribute
instance-attribute
¶
Last modifier's display name.
last_modified_by_email
class-attribute
instance-attribute
¶
Last modifier's email.
is_favorited
class-attribute
instance-attribute
¶
Whether current user has favorited.
pinned_date
class-attribute
instance-attribute
¶
Date flag was pinned.
can_edit
class-attribute
instance-attribute
¶
Permission: can current user edit.
mixpanel_headless.CreateFeatureFlagParams
¶
Bases: BaseModel
Parameters for creating a new feature flag.
The Mixpanel API requires name, key, context,
serving_method, tags, and ruleset (with variants
and rollout sub-fields). Sensible defaults are provided for
the non-obvious required fields so that minimal usage works::
CreateFeatureFlagParams(name="Dark Mode", key="dark_mode")
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Flag name (required).
TYPE:
|
key |
Unique machine-readable key (required).
TYPE:
|
description |
Optional description.
TYPE:
|
status |
Initial status (defaults to disabled).
TYPE:
|
tags |
Tags for organization (required by API, defaults to empty list).
TYPE:
|
context |
Flag context identifier (required by API, defaults
to
TYPE:
|
serving_method |
How flag values are delivered (required by API,
defaults to
TYPE:
|
ruleset |
Ruleset with
TYPE:
|
Example
description
class-attribute
instance-attribute
¶
Optional description.
status
class-attribute
instance-attribute
¶
Initial status (defaults to disabled).
tags
class-attribute
instance-attribute
¶
Tags for organization (required by API, defaults to empty list).
context
class-attribute
instance-attribute
¶
Flag context identifier (required by API).
serving_method
class-attribute
instance-attribute
¶
How flag values are delivered (required by API).
ruleset
class-attribute
instance-attribute
¶
ruleset: dict[str, Any] = Field(
default_factory=lambda: {
"variants": [
{
"key": "On",
"value": True,
"is_control": False,
"split": 1.0,
"is_sticky": False,
},
{
"key": "Off",
"value": False,
"is_control": True,
"split": 0.0,
"is_sticky": False,
},
],
"rollout": [],
}
)
Ruleset with variants and rollout (required by API).
mixpanel_headless.UpdateFeatureFlagParams
¶
Bases: BaseModel
Parameters for updating an existing feature flag (PUT semantics).
All required fields must always be provided since this performs a
full replacement, not a partial update. The API requires tags,
context, and serving_method in addition to name, key,
status, and ruleset.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Flag name (required).
TYPE:
|
key |
Unique key (required).
TYPE:
|
status |
Target status (required).
TYPE:
|
ruleset |
Complete ruleset — replaces existing (required).
TYPE:
|
description |
Optional description.
TYPE:
|
tags |
Tags for organization (required by API, defaults to empty list).
TYPE:
|
context |
Flag context identifier (required by API, defaults
to
TYPE:
|
serving_method |
How flag values are delivered (required by API,
defaults to
TYPE:
|
Example
ruleset
instance-attribute
¶
Complete ruleset — replaces existing (required).
description
class-attribute
instance-attribute
¶
Optional description.
tags
class-attribute
instance-attribute
¶
Tags for organization (required by API, defaults to empty list).
context
class-attribute
instance-attribute
¶
Flag context identifier (required by API).
serving_method
class-attribute
instance-attribute
¶
How flag values are delivered (required by API).
mixpanel_headless.SetTestUsersParams
¶
Bases: BaseModel
Parameters for setting test user variant overrides on a flag.
| ATTRIBUTE | DESCRIPTION |
|---|---|
users |
Mapping of variant keys to user distinct IDs.
TYPE:
|
mixpanel_headless.FlagHistoryParams
¶
mixpanel_headless.FlagHistoryResponse
¶
mixpanel_headless.FlagLimitsResponse
¶
Bases: BaseModel
Account-level feature flag usage and limits.
| ATTRIBUTE | DESCRIPTION |
|---|---|
limit |
Maximum allowed flags.
TYPE:
|
is_trial |
Whether account is on trial.
TYPE:
|
current_usage |
Current number of flags.
TYPE:
|
contract_status |
Contract status.
TYPE:
|
Example
Experiment Enums¶
mixpanel_headless.ExperimentStatus
¶
Bases: str, Enum
Lifecycle state of an experiment.
State transitions: draft → active (launch) → concluded
(conclude) → success | fail (decide).
| ATTRIBUTE | DESCRIPTION |
|---|---|
DRAFT |
Experiment created but not started.
|
ACTIVE |
Experiment running, collecting data.
|
CONCLUDED |
Experiment stopped, awaiting decision.
|
SUCCESS |
Experiment decided as successful.
|
FAIL |
Experiment decided as failed.
|
Experiment Types¶
mixpanel_headless.ExperimentCreator
¶
Bases: BaseModel
Creator metadata for an experiment.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Creator's user ID.
TYPE:
|
first_name |
Creator's first name.
TYPE:
|
last_name |
Creator's last name.
TYPE:
|
mixpanel_headless.Experiment
¶
Bases: BaseModel
A Mixpanel A/B experiment as returned by the App API.
Represents the full experiment entity including lifecycle state,
variants, metrics, and metadata. Extra fields from API evolution
are preserved via extra="allow".
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Unique identifier (UUID).
TYPE:
|
name |
Human-readable name.
TYPE:
|
description |
Optional description.
TYPE:
|
hypothesis |
Experiment hypothesis.
TYPE:
|
status |
Current lifecycle status.
TYPE:
|
variants |
Variant configuration.
TYPE:
|
metrics |
Success metrics.
TYPE:
|
settings |
Experiment settings.
TYPE:
|
exposures_cache |
Cached exposure data.
TYPE:
|
results_cache |
Cached result data.
TYPE:
|
start_date |
ISO 8601 start date.
TYPE:
|
end_date |
ISO 8601 end date.
TYPE:
|
created |
ISO 8601 creation timestamp.
TYPE:
|
updated |
ISO 8601 last-updated timestamp.
TYPE:
|
creator |
Creator metadata.
TYPE:
|
feature_flag |
Linked feature flag data.
TYPE:
|
is_favorited |
Whether current user has favorited.
TYPE:
|
pinned_date |
Date experiment was pinned.
TYPE:
|
tags |
Tags for organization.
TYPE:
|
can_edit |
Permission: can current user edit.
TYPE:
|
last_modified_by_id |
Last modifier's user ID.
TYPE:
|
last_modified_by_name |
Last modifier's display name.
TYPE:
|
last_modified_by_email |
Last modifier's email.
TYPE:
|
Example
description
class-attribute
instance-attribute
¶
Optional description.
hypothesis
class-attribute
instance-attribute
¶
Experiment hypothesis.
status
class-attribute
instance-attribute
¶
Current lifecycle status.
variants
class-attribute
instance-attribute
¶
Variant configuration (list from API, may also be dict).
metrics
class-attribute
instance-attribute
¶
Success metrics (list from API, may also be dict).
settings
class-attribute
instance-attribute
¶
Experiment settings.
exposures_cache
class-attribute
instance-attribute
¶
Cached exposure data.
results_cache
class-attribute
instance-attribute
¶
Cached result data.
created
class-attribute
instance-attribute
¶
ISO 8601 creation timestamp.
updated
class-attribute
instance-attribute
¶
ISO 8601 last-updated timestamp.
creator
class-attribute
instance-attribute
¶
Creator metadata.
feature_flag
class-attribute
instance-attribute
¶
Linked feature flag data.
is_favorited
class-attribute
instance-attribute
¶
Whether current user has favorited.
pinned_date
class-attribute
instance-attribute
¶
Date experiment was pinned.
can_edit
class-attribute
instance-attribute
¶
Permission: can current user edit.
last_modified_by_id
class-attribute
instance-attribute
¶
Last modifier's user ID.
last_modified_by_name
class-attribute
instance-attribute
¶
Last modifier's display name.
last_modified_by_email
class-attribute
instance-attribute
¶
Last modifier's email.
mixpanel_headless.CreateExperimentParams
¶
Bases: BaseModel
Parameters for creating a new experiment.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Experiment name (required).
TYPE:
|
description |
Optional description.
TYPE:
|
hypothesis |
Experiment hypothesis.
TYPE:
|
settings |
Experiment settings.
TYPE:
|
access_type |
Access control type.
TYPE:
|
can_edit |
Edit permission.
TYPE:
|
Example
mixpanel_headless.UpdateExperimentParams
¶
Bases: BaseModel
Parameters for updating an existing experiment (PATCH semantics).
All fields optional — only provided fields are updated.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Updated name.
TYPE:
|
description |
Updated description.
TYPE:
|
hypothesis |
Updated hypothesis.
TYPE:
|
variants |
Updated variant config.
TYPE:
|
metrics |
Updated metrics.
TYPE:
|
settings |
Updated settings.
TYPE:
|
start_date |
Updated start date.
TYPE:
|
end_date |
Updated end date.
TYPE:
|
tags |
Updated tags.
TYPE:
|
exposures_cache |
Updated exposures cache.
TYPE:
|
results_cache |
Updated results cache.
TYPE:
|
status |
Updated status.
TYPE:
|
global_access_type |
Updated access type.
TYPE:
|
Example
description
class-attribute
instance-attribute
¶
Updated description.
variants
class-attribute
instance-attribute
¶
Updated variant config (list or dict).
metrics
class-attribute
instance-attribute
¶
Updated metrics (list or dict).
settings
class-attribute
instance-attribute
¶
Updated settings.
exposures_cache
class-attribute
instance-attribute
¶
Updated exposures cache.
results_cache
class-attribute
instance-attribute
¶
Updated results cache.
global_access_type
class-attribute
instance-attribute
¶
Updated access type.
mixpanel_headless.ExperimentConcludeParams
¶
mixpanel_headless.ExperimentDecideParams
¶
mixpanel_headless.DuplicateExperimentParams
¶
Annotation Types¶
mixpanel_headless.Annotation
¶
Bases: BaseModel
Response model for a timeline annotation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Annotation ID.
TYPE:
|
project_id |
Project ID.
TYPE:
|
date |
Annotation date (ISO format).
TYPE:
|
description |
Annotation text.
TYPE:
|
user |
Creator user info.
TYPE:
|
tags |
Associated tags.
TYPE:
|
tags
class-attribute
instance-attribute
¶
Associated tags.
mixpanel_headless.AnnotationUser
¶
Bases: BaseModel
Nested user info for annotation creator.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
User ID.
TYPE:
|
first_name |
First name.
TYPE:
|
last_name |
Last name.
TYPE:
|
mixpanel_headless.AnnotationTag
¶
Bases: BaseModel
Annotation tag for categorization.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Tag ID.
TYPE:
|
name |
Tag name.
TYPE:
|
project_id |
Project ID.
TYPE:
|
has_annotations |
Whether tag has annotations.
TYPE:
|
mixpanel_headless.CreateAnnotationParams
¶
Bases: BaseModel
Parameters for creating a new annotation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
date |
Date string in
TYPE:
|
description |
Annotation text (max 512 characters, required).
TYPE:
|
tags |
Tag IDs to associate.
TYPE:
|
user_id |
Creator user ID.
TYPE:
|
description
class-attribute
instance-attribute
¶
Annotation text (max 512 characters).
mixpanel_headless.UpdateAnnotationParams
¶
Bases: BaseModel
Parameters for updating an annotation (PATCH semantics).
Only description and tags can be changed after creation;
the annotation date is immutable.
| ATTRIBUTE | DESCRIPTION |
|---|---|
description |
New description (max 512 characters).
TYPE:
|
tags |
New tag IDs.
TYPE:
|
mixpanel_headless.CreateAnnotationTagParams
¶
Webhook Enums¶
mixpanel_headless.WebhookAuthType
¶
Bases: str, Enum
Authentication type for webhooks.
Values
BASIC: HTTP Basic authentication.
Webhook Types¶
mixpanel_headless.ProjectWebhook
¶
Bases: BaseModel
Response model for a project webhook.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Webhook ID (UUID string).
TYPE:
|
name |
Webhook name.
TYPE:
|
url |
Webhook URL.
TYPE:
|
is_enabled |
Whether enabled.
TYPE:
|
auth_type |
Authentication type.
TYPE:
|
created |
Creation timestamp.
TYPE:
|
modified |
Last modified timestamp.
TYPE:
|
creator_id |
Creator user ID.
TYPE:
|
creator_name |
Creator name.
TYPE:
|
auth_type
class-attribute
instance-attribute
¶
Authentication type.
mixpanel_headless.CreateWebhookParams
¶
Bases: BaseModel
Parameters for creating a webhook.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Webhook name (required).
TYPE:
|
url |
Webhook URL (required).
TYPE:
|
auth_type |
Auth type ("basic" or None).
TYPE:
|
username |
Basic auth username.
TYPE:
|
password |
Basic auth password.
TYPE:
|
auth_type
class-attribute
instance-attribute
¶
Auth type (e.g. WebhookAuthType.BASIC).
mixpanel_headless.UpdateWebhookParams
¶
Bases: BaseModel
Parameters for updating a webhook (PATCH semantics).
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
New name.
TYPE:
|
url |
New URL.
TYPE:
|
auth_type |
New auth type.
TYPE:
|
username |
New username.
TYPE:
|
password |
New password.
TYPE:
|
is_enabled |
New enabled state.
TYPE:
|
auth_type
class-attribute
instance-attribute
¶
New auth type.
mixpanel_headless.WebhookTestParams
¶
mixpanel_headless.WebhookTestResult
¶
Bases: BaseModel
Response model for webhook connectivity test.
| ATTRIBUTE | DESCRIPTION |
|---|---|
success |
Whether test succeeded.
TYPE:
|
status_code |
HTTP status code.
TYPE:
|
message |
Descriptive message.
TYPE:
|
Example
mixpanel_headless.WebhookMutationResult
¶
Alert Enums¶
mixpanel_headless.AlertFrequencyPreset
¶
Bases: int, Enum
Preset frequency values for alert check intervals.
Values
HOURLY: Check every hour (3600 seconds). DAILY: Check every day (86400 seconds). WEEKLY: Check every week (604800 seconds).
Alert Types¶
mixpanel_headless.CustomAlert
¶
Bases: BaseModel
Response model for a custom alert.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Alert ID.
TYPE:
|
name |
Alert name.
TYPE:
|
bookmark |
Linked saved report.
TYPE:
|
condition |
Trigger condition (opaque JSON).
TYPE:
|
frequency |
Check frequency in seconds.
TYPE:
|
paused |
Whether alert is paused.
TYPE:
|
subscriptions |
Notification targets.
TYPE:
|
notification_windows |
Notification window config.
TYPE:
|
creator |
Creator user info.
TYPE:
|
workspace |
Workspace metadata.
TYPE:
|
project |
Project metadata.
TYPE:
|
created |
Creation timestamp.
TYPE:
|
modified |
Last modified timestamp.
TYPE:
|
last_checked |
Last check timestamp.
TYPE:
|
last_fired |
Last trigger timestamp.
TYPE:
|
valid |
Whether alert is valid.
TYPE:
|
results |
Latest evaluation results.
TYPE:
|
bookmark
class-attribute
instance-attribute
¶
Linked saved report.
condition
class-attribute
instance-attribute
¶
Trigger condition (opaque JSON).
subscriptions
class-attribute
instance-attribute
¶
Notification targets.
notification_windows
class-attribute
instance-attribute
¶
Notification window config.
workspace
class-attribute
instance-attribute
¶
Workspace metadata.
last_checked
class-attribute
instance-attribute
¶
Last check timestamp.
last_fired
class-attribute
instance-attribute
¶
Last trigger timestamp.
results
class-attribute
instance-attribute
¶
Latest evaluation results.
mixpanel_headless.AlertBookmark
¶
mixpanel_headless.AlertCreator
¶
Bases: BaseModel
Nested creator info for an alert.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
User ID.
TYPE:
|
first_name |
First name.
TYPE:
|
last_name |
Last name.
TYPE:
|
email |
Email.
TYPE:
|
mixpanel_headless.AlertWorkspace
¶
mixpanel_headless.AlertProject
¶
mixpanel_headless.CreateAlertParams
¶
Bases: BaseModel
Parameters for creating a new alert.
| ATTRIBUTE | DESCRIPTION |
|---|---|
bookmark_id |
ID of linked bookmark (required).
TYPE:
|
name |
Alert name (required).
TYPE:
|
condition |
Trigger condition JSON (required).
TYPE:
|
frequency |
Check frequency in seconds (required).
TYPE:
|
paused |
Start paused or active (required).
TYPE:
|
subscriptions |
Notification targets (required).
TYPE:
|
notification_windows |
Notification window config.
TYPE:
|
Example
params = CreateAlertParams(
bookmark_id=12345,
name="Daily signups drop",
condition={
"keys": [{"header": "Signup", "value": "Signup"}],
"type": "absolute",
"op": "<",
"value": 100,
},
frequency=AlertFrequencyPreset.DAILY,
paused=False,
subscriptions=[{"type": "email", "value": "team@example.com"}],
)
mixpanel_headless.UpdateAlertParams
¶
Bases: BaseModel
Parameters for updating an alert (PATCH semantics).
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
New name.
TYPE:
|
bookmark_id |
New bookmark ID.
TYPE:
|
condition |
New condition.
TYPE:
|
frequency |
New frequency.
TYPE:
|
paused |
New pause state.
TYPE:
|
subscriptions |
New subscriptions.
TYPE:
|
notification_windows |
New notification windows.
TYPE:
|
mixpanel_headless.AlertCount
¶
Bases: BaseModel
Response model for alert count and limits.
| ATTRIBUTE | DESCRIPTION |
|---|---|
anomaly_alerts_count |
Current alert count.
TYPE:
|
alert_limit |
Account limit.
TYPE:
|
is_below_limit |
Whether below limit.
TYPE:
|
Example
mixpanel_headless.AlertHistoryPagination
¶
Bases: BaseModel
Pagination metadata for alert history.
| ATTRIBUTE | DESCRIPTION |
|---|---|
next_cursor |
Next page cursor.
TYPE:
|
previous_cursor |
Previous page cursor.
TYPE:
|
page_size |
Page size.
TYPE:
|
mixpanel_headless.AlertHistoryResponse
¶
Bases: BaseModel
Response model for alert history (paginated).
| ATTRIBUTE | DESCRIPTION |
|---|---|
results |
History entries.
TYPE:
|
pagination |
Pagination metadata.
TYPE:
|
Example
mixpanel_headless.AlertScreenshotResponse
¶
Bases: BaseModel
Response model for alert screenshot URL.
| ATTRIBUTE | DESCRIPTION |
|---|---|
signed_url |
Signed GCS URL for screenshot.
TYPE:
|
mixpanel_headless.AlertValidation
¶
Bases: BaseModel
Per-alert validation result.
| ATTRIBUTE | DESCRIPTION |
|---|---|
alert_id |
Alert ID.
TYPE:
|
alert_name |
Alert name.
TYPE:
|
valid |
Whether valid.
TYPE:
|
reason |
Reason if invalid.
TYPE:
|
mixpanel_headless.ValidateAlertsForBookmarkParams
¶
Bases: BaseModel
Parameters for validating alerts against a bookmark.
| ATTRIBUTE | DESCRIPTION |
|---|---|
alert_ids |
Alert IDs to validate (required).
TYPE:
|
bookmark_type |
Bookmark type to validate against (required).
TYPE:
|
bookmark_params |
Bookmark params JSON (required).
TYPE:
|
Example
mixpanel_headless.ValidateAlertsForBookmarkResponse
¶
Bases: BaseModel
Response model for alert-bookmark validation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
alert_validations |
Per-alert validation results.
TYPE:
|
invalid_count |
Count of invalid alerts.
TYPE:
|
Example
Data Governance Enums¶
mixpanel_headless.PropertyResourceType
¶
Bases: str, Enum
Resource type for property definitions.
Values
EVENT: Event property.
USER: User profile property.
GROUPPROFILE: Group profile property (wire format: groupprofile).
mixpanel_headless.CustomPropertyResourceType
¶
Bases: str, Enum
Resource type for custom properties.
Values
EVENTS: Event-level custom property. PEOPLE: User profile custom property. GROUP_PROFILES: Group profile custom property.
Event Definition Types¶
mixpanel_headless.EventDefinition
¶
Bases: BaseModel
A Mixpanel event definition from the Lexicon.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Server-assigned event ID.
TYPE:
|
name |
Event name (unique identifier).
TYPE:
|
display_name |
Human-readable name.
TYPE:
|
description |
Event description.
TYPE:
|
hidden |
Whether hidden from UI.
TYPE:
|
dropped |
Whether data is dropped at ingestion.
TYPE:
|
merged |
Whether merged into another event.
TYPE:
|
verified |
Whether verified by governance team.
TYPE:
|
tags |
Assigned tag names.
TYPE:
|
custom_event_id |
Links to custom event.
TYPE:
|
last_modified |
ISO 8601 timestamp.
TYPE:
|
status |
Event status.
TYPE:
|
platforms |
Tracking platforms.
TYPE:
|
created_utc |
ISO 8601 creation timestamp.
TYPE:
|
modified_utc |
ISO 8601 modification timestamp.
TYPE:
|
display_name
class-attribute
instance-attribute
¶
Human-readable name.
dropped
class-attribute
instance-attribute
¶
Whether data is dropped at ingestion.
merged
class-attribute
instance-attribute
¶
Whether merged into another event.
verified
class-attribute
instance-attribute
¶
Whether verified by governance team.
custom_event_id
class-attribute
instance-attribute
¶
Links to custom event.
last_modified
class-attribute
instance-attribute
¶
ISO 8601 timestamp.
platforms
class-attribute
instance-attribute
¶
Tracking platforms.
created_utc
class-attribute
instance-attribute
¶
ISO 8601 creation timestamp.
modified_utc
class-attribute
instance-attribute
¶
ISO 8601 modification timestamp.
mixpanel_headless.UpdateEventDefinitionParams
¶
Bases: BaseModel
Parameters for updating an event definition (PATCH semantics).
All fields are optional; only set fields are sent.
| ATTRIBUTE | DESCRIPTION |
|---|---|
hidden |
Whether hidden from UI.
TYPE:
|
dropped |
Whether data is dropped.
TYPE:
|
merged |
Whether merged.
TYPE:
|
verified |
Whether verified.
TYPE:
|
tags |
Tag names to assign.
TYPE:
|
display_name |
Human-readable name (sent as
TYPE:
|
description |
Event description.
TYPE:
|
Example
display_name
class-attribute
instance-attribute
¶
Human-readable name (sent as displayName).
mixpanel_headless.BulkEventUpdate
¶
Bases: BaseModel
A single event update entry for bulk operations.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Event name (identifier).
TYPE:
|
id |
Alternative identifier.
TYPE:
|
hidden |
Whether hidden from UI.
TYPE:
|
dropped |
Whether data is dropped.
TYPE:
|
merged |
Whether merged.
TYPE:
|
verified |
Whether verified.
TYPE:
|
tags |
Tag names.
TYPE:
|
display_name |
Human-readable name (sent as
TYPE:
|
contacts |
Contact emails.
TYPE:
|
team_contacts |
Team contact emails.
TYPE:
|
display_name
class-attribute
instance-attribute
¶
display_name: str | None = Field(
default=None,
serialization_alias="displayName",
validation_alias=AliasChoices("display_name", "displayName"),
)
Human-readable name. Always emitted as displayName via an explicit
serialization alias (rather than a model-wide alias_generator) so the
established team_contacts wire shape stays snake_case. Accepts either
display_name or displayName on input, so a camelCase payload echoed
by lexicon events get round-trips instead of silently dropping the
field. (contacts / team_contacts remain snake_case on input and the
wire by design.)
team_contacts
class-attribute
instance-attribute
¶
Team contact emails.
mixpanel_headless.BulkUpdateEventsParams
¶
Bases: BaseModel
Parameters for bulk-updating event definitions.
| ATTRIBUTE | DESCRIPTION |
|---|---|
events |
List of event update entries (required).
TYPE:
|
Property Definition Types¶
mixpanel_headless.PropertyDefinition
¶
Bases: BaseModel
A Mixpanel property definition from the Lexicon.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Server-assigned property ID.
TYPE:
|
name |
Property name.
TYPE:
|
resource_type |
Property resource type as the API returns it, e.g.
TYPE:
|
display_name |
Human-readable name.
TYPE:
|
description |
Property description.
TYPE:
|
example_value |
Example value shown in the Lexicon.
TYPE:
|
hidden |
Whether hidden from UI.
TYPE:
|
dropped |
Whether data is dropped.
TYPE:
|
merged |
Whether merged into another property.
TYPE:
|
sensitive |
PII flag.
TYPE:
|
data_group_id |
Data group identifier.
TYPE:
|
id
class-attribute
instance-attribute
¶
Server-assigned property ID (may be absent for custom properties).
resource_type
class-attribute
instance-attribute
¶
Property resource type as the API returns it, e.g. Event / User
(capitalized, matching the write contract).
display_name
class-attribute
instance-attribute
¶
Human-readable name (Lexicon displayName).
description
class-attribute
instance-attribute
¶
Property description.
example_value
class-attribute
instance-attribute
¶
Example value shown in the Lexicon (exampleValue).
merged
class-attribute
instance-attribute
¶
Whether merged into another property.
data_group_id
class-attribute
instance-attribute
¶
Data group identifier.
mixpanel_headless.UpdatePropertyDefinitionParams
¶
Bases: BaseModel
Parameters for updating a property definition (PATCH semantics).
All fields are optional; only set fields are sent.
| ATTRIBUTE | DESCRIPTION |
|---|---|
hidden |
Whether hidden from UI.
TYPE:
|
dropped |
Whether data is dropped.
TYPE:
|
merged |
Whether merged.
TYPE:
|
sensitive |
PII flag.
TYPE:
|
display_name |
Human-readable name (sent as
TYPE:
|
description |
Property description.
TYPE:
|
example_value |
Example value (sent as
TYPE:
|
resource_type |
Resource type (
TYPE:
|
Example
display_name
class-attribute
instance-attribute
¶
Human-readable name (sent as displayName).
description
class-attribute
instance-attribute
¶
Property description.
example_value
class-attribute
instance-attribute
¶
Example value (sent as exampleValue).
resource_type
class-attribute
instance-attribute
¶
Resource type, constrained to the capitalized forms the data-definitions
API accepts. Sent verbatim as resourceType to disambiguate a user
property from an event property of the same name.
mixpanel_headless.BulkPropertyUpdate
¶
Bases: BaseModel
A single property update entry for bulk operations.
Uses camelCase serialization to match the Django API contract.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Property name (required).
TYPE:
|
resource_type |
Resource type (required).
TYPE:
|
id |
Property ID.
TYPE:
|
hidden |
Whether hidden from UI.
TYPE:
|
dropped |
Whether data is dropped.
TYPE:
|
sensitive |
PII flag.
TYPE:
|
display_name |
Human-readable name (sent as
TYPE:
|
example_value |
Example value (sent as
TYPE:
|
data_group_id |
Data group identifier.
TYPE:
|
Example
resource_type
instance-attribute
¶
Resource type (Event / User); sent verbatim as resourceType
to disambiguate a user property from an event property of the same name.
Constrained to the capitalized forms the data-definitions API accepts.
display_name
class-attribute
instance-attribute
¶
Human-readable name (sent as displayName).
example_value
class-attribute
instance-attribute
¶
Example value (sent as exampleValue).
data_group_id
class-attribute
instance-attribute
¶
Data group identifier.
mixpanel_headless.BulkUpdatePropertiesParams
¶
Bases: BaseModel
Parameters for bulk-updating property definitions.
| ATTRIBUTE | DESCRIPTION |
|---|---|
properties |
List of property update entries (required).
TYPE:
|
Example
properties
instance-attribute
¶
List of property update entries.
Lexicon Tag Types¶
mixpanel_headless.LexiconTag
¶
mixpanel_headless.CreateTagParams
¶
mixpanel_headless.UpdateTagParams
¶
Drop Filter Types¶
mixpanel_headless.DropFilter
¶
Bases: BaseModel
A drop filter for discarding events at ingestion.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Server-assigned filter ID.
TYPE:
|
event_name |
Event name to filter.
TYPE:
|
filters |
Filter condition JSON.
TYPE:
|
active |
Whether the filter is active.
TYPE:
|
display_name |
Human-readable name.
TYPE:
|
created |
ISO 8601 creation timestamp.
TYPE:
|
mixpanel_headless.CreateDropFilterParams
¶
Bases: BaseModel
Parameters for creating a drop filter.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event_name |
Event name to filter (required).
TYPE:
|
filters |
Filter condition JSON (required).
TYPE:
|
Example
mixpanel_headless.UpdateDropFilterParams
¶
Bases: BaseModel
Parameters for updating a drop filter.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Drop filter ID (required).
TYPE:
|
event_name |
New event name.
TYPE:
|
filters |
New filter condition JSON.
TYPE:
|
active |
Whether the filter is active.
TYPE:
|
active
class-attribute
instance-attribute
¶
Whether the filter is active.
mixpanel_headless.DropFilterLimitsResponse
¶
Bases: BaseModel
Response model for drop filter limits.
| ATTRIBUTE | DESCRIPTION |
|---|---|
filter_limit |
Maximum allowed filters.
TYPE:
|
Custom Property Types¶
mixpanel_headless.ComposedPropertyValue
¶
Bases: BaseModel
A composed property reference within a custom property formula.
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
Property type.
TYPE:
|
type_cast |
Type cast instruction.
TYPE:
|
resource_type |
Resource type (required).
TYPE:
|
behavior |
Behavior specification.
TYPE:
|
join_property_type |
Join property type.
TYPE:
|
resource_type
instance-attribute
¶
Resource type. Uses singular form (event, user, groupprofile) from the
Mixpanel API composed property schema — distinct from
CustomPropertyResourceType which uses plural form.
value
class-attribute
instance-attribute
¶
Property name in the project (e.g. "deal_name").
label
class-attribute
instance-attribute
¶
Human-readable label for the property (e.g. "Deal Name").
property_default_type
class-attribute
instance-attribute
¶
Default property type hint (e.g. "string", "number").
join_property_type
class-attribute
instance-attribute
¶
Join property type.
mixpanel_headless.CustomProperty
¶
Bases: BaseModel
A Mixpanel custom property (computed/formula property).
| ATTRIBUTE | DESCRIPTION |
|---|---|
custom_property_id |
Server-assigned property ID.
TYPE:
|
name |
Property name.
TYPE:
|
description |
Property description.
TYPE:
|
resource_type |
Resource type (events, people, group_profiles). |
property_type |
Property type.
TYPE:
|
display_formula |
Formula expression.
TYPE:
|
composed_properties |
Referenced properties in formula.
TYPE:
|
is_locked |
Whether the property is locked.
TYPE:
|
is_visible |
Whether the property is visible.
TYPE:
|
data_group_id |
Data group identifier.
TYPE:
|
created |
ISO 8601 creation timestamp.
TYPE:
|
modified |
ISO 8601 modification timestamp.
TYPE:
|
example_value |
Example value.
TYPE:
|
description
class-attribute
instance-attribute
¶
Property description.
resource_type
instance-attribute
¶
Resource type (events, people, group_profiles).
display_formula
class-attribute
instance-attribute
¶
Formula expression.
composed_properties
class-attribute
instance-attribute
¶
Referenced properties in formula.
is_locked
class-attribute
instance-attribute
¶
Whether the property is locked.
is_visible
class-attribute
instance-attribute
¶
Whether the property is visible.
data_group_id
class-attribute
instance-attribute
¶
Data group identifier.
created
class-attribute
instance-attribute
¶
ISO 8601 creation timestamp.
modified
class-attribute
instance-attribute
¶
ISO 8601 modification timestamp.
mixpanel_headless.CreateCustomPropertyParams
¶
Bases: BaseModel
Parameters for creating a custom property.
Validation rules:
- display_formula and behavior are mutually exclusive.
- behavior and composed_properties are mutually exclusive.
- display_formula requires composed_properties.
- One of display_formula or behavior must be set.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Property name (required).
TYPE:
|
resource_type |
Resource type (required). |
description |
Property description.
TYPE:
|
display_formula |
Formula expression (mutually exclusive with behavior).
TYPE:
|
composed_properties |
Referenced properties (required if display_formula set).
TYPE:
|
is_locked |
Whether the property is locked.
TYPE:
|
is_visible |
Whether the property is visible.
TYPE:
|
data_group_id |
Data group identifier.
TYPE:
|
behavior |
Behavior specification (mutually exclusive with display_formula).
TYPE:
|
Example
resource_type
instance-attribute
¶
Resource type (events, people, group_profiles).
description
class-attribute
instance-attribute
¶
Property description.
display_formula
class-attribute
instance-attribute
¶
Formula expression (mutually exclusive with behavior).
composed_properties
class-attribute
instance-attribute
¶
Referenced properties (required if display_formula set).
is_locked
class-attribute
instance-attribute
¶
Whether the property is locked.
is_visible
class-attribute
instance-attribute
¶
Whether the property is visible.
property_type
class-attribute
instance-attribute
¶
Output type of the custom property (string, number, boolean, datetime). Auto-inferred by the API from the formula if not set.
example_value
class-attribute
instance-attribute
¶
Example output value for documentation purposes.
data_group_id
class-attribute
instance-attribute
¶
Data group identifier.
behavior
class-attribute
instance-attribute
¶
Behavior specification (mutually exclusive with display_formula).
mixpanel_headless.UpdateCustomPropertyParams
¶
Bases: BaseModel
Parameters for updating a custom property (PUT — full replacement).
Note: resource_type and data_group_id are immutable.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Property name.
TYPE:
|
description |
Property description.
TYPE:
|
display_formula |
Formula expression.
TYPE:
|
composed_properties |
Referenced properties.
TYPE:
|
is_locked |
Whether the property is locked.
TYPE:
|
is_visible |
Whether the property is visible.
TYPE:
|
description
class-attribute
instance-attribute
¶
Property description.
display_formula
class-attribute
instance-attribute
¶
Formula expression.
composed_properties
class-attribute
instance-attribute
¶
Referenced properties.
is_locked
class-attribute
instance-attribute
¶
Whether the property is locked.
is_visible
class-attribute
instance-attribute
¶
Whether the property is visible.
Lookup Table Types¶
mixpanel_headless.LookupTable
¶
Bases: BaseModel
A Mixpanel lookup table.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Server-assigned table ID.
TYPE:
|
name |
Table name.
TYPE:
|
token |
Table token.
TYPE:
|
created_at |
ISO 8601 creation timestamp.
TYPE:
|
last_modified_at |
ISO 8601 modification timestamp.
TYPE:
|
has_mapped_properties |
Whether the table has mapped properties.
TYPE:
|
mixpanel_headless.UploadLookupTableParams
¶
Bases: BaseModel
Parameters for uploading a lookup table CSV.
The upload is a 3-step process handled by the workspace method: 1. Get a signed upload URL 2. Upload CSV to signed URL 3. Register the table
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Table name (1-255 characters, required).
TYPE:
|
file_path |
Path to local CSV file (required).
TYPE:
|
data_group_id |
For replacing an existing table.
TYPE:
|
Example
mixpanel_headless.MarkLookupTableReadyParams
¶
Bases: BaseModel
Parameters for marking a lookup table as ready.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Table name (required).
TYPE:
|
key |
Primary key column name (required).
TYPE:
|
data_group_id |
For replacing an existing table.
TYPE:
|
mixpanel_headless.LookupTableUploadUrl
¶
mixpanel_headless.UpdateLookupTableParams
¶
Schema Registry Types¶
Types for managing JSON Schema Draft 7 definitions in the schema registry.
mixpanel_headless.SchemaEntry
¶
Bases: BaseModel
A schema registry entry for an event, custom event, or profile.
Represents a JSON Schema Draft 7 definition registered in the Mixpanel schema registry. Used for both API responses and as entries in bulk create/update operations.
| ATTRIBUTE | DESCRIPTION |
|---|---|
entity_type |
Entity type ("event", "custom_event", "profile").
TYPE:
|
name |
Entity name (event name or "$user" for profile).
TYPE:
|
version |
Schema version in YYYY-MM-DD format.
TYPE:
|
schema_definition |
JSON Schema Draft 7 definition (API field: schemaJson).
TYPE:
|
Example
mixpanel_headless.BulkCreateSchemasParams
¶
Bases: BaseModel
Parameters for bulk-creating schemas in the registry.
| ATTRIBUTE | DESCRIPTION |
|---|---|
entries |
Schema entries to create.
TYPE:
|
truncate |
If true, delete all existing schemas of entity_type before inserting.
TYPE:
|
entity_type |
Entity type for all entries (only "event" supported for batch operations).
TYPE:
|
Example
mixpanel_headless.BulkCreateSchemasResponse
¶
mixpanel_headless.BulkPatchResult
¶
Bases: BaseModel
Per-entry result from a bulk schema update operation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
entity_type |
Entity type processed.
TYPE:
|
name |
Entity name processed.
TYPE:
|
status |
Result status ("ok" or "error").
TYPE:
|
error |
Error message if status is "error".
TYPE:
|
error
class-attribute
instance-attribute
¶
Error message if status is "error".
mixpanel_headless.DeleteSchemasResponse
¶
Bases: BaseModel
Response from a schema deletion operation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
delete_count |
Number of schemas deleted.
TYPE:
|
Schema Enforcement Types¶
Types for configuring schema enforcement policies.
mixpanel_headless.SchemaEnforcementConfig
¶
Bases: BaseModel
Schema enforcement configuration for a project.
Controls how Mixpanel handles events that don't match defined schemas.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Config ID.
TYPE:
|
last_modified |
Last modification timestamp.
TYPE:
|
last_modified_by |
User who last modified.
TYPE:
|
rule_event |
Enforcement action ("Warn and Accept", "Warn and Hide", "Warn and Drop").
TYPE:
|
notification_emails |
Notification recipients.
TYPE:
|
events |
Event enforcement rules.
TYPE:
|
common_properties |
Common property rules.
TYPE:
|
user_properties |
User property rules.
TYPE:
|
initialized_by |
User who initialized.
TYPE:
|
initialized_from |
Initialization start date.
TYPE:
|
initialized_to |
Initialization end date.
TYPE:
|
state |
Enforcement state ("planned" or "ingested").
TYPE:
|
last_modified
class-attribute
instance-attribute
¶
Last modification timestamp.
last_modified_by
class-attribute
instance-attribute
¶
User who last modified.
rule_event
class-attribute
instance-attribute
¶
Enforcement action: "Warn and Accept", "Warn and Hide", "Warn and Drop".
notification_emails
class-attribute
instance-attribute
¶
Notification recipients.
events
class-attribute
instance-attribute
¶
Event enforcement rules.
common_properties
class-attribute
instance-attribute
¶
Common property rules.
user_properties
class-attribute
instance-attribute
¶
User property rules.
initialized_by
class-attribute
instance-attribute
¶
User who initialized.
initialized_from
class-attribute
instance-attribute
¶
Initialization start date.
initialized_to
class-attribute
instance-attribute
¶
Initialization end date.
state
class-attribute
instance-attribute
¶
Enforcement state ("planned" or "ingested").
mixpanel_headless.InitSchemaEnforcementParams
¶
Bases: BaseModel
Parameters for initializing schema enforcement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
rule_event |
Enforcement action ("Warn and Accept", "Warn and Hide", "Warn and Drop").
TYPE:
|
mixpanel_headless.UpdateSchemaEnforcementParams
¶
Bases: BaseModel
Parameters for partially updating schema enforcement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
notification_emails |
Updated notification recipients.
TYPE:
|
rule_event |
Updated enforcement action.
TYPE:
|
events |
Updated event list.
TYPE:
|
properties |
Updated property map.
TYPE:
|
Example
mixpanel_headless.ReplaceSchemaEnforcementParams
¶
Bases: BaseModel
Parameters for fully replacing schema enforcement configuration.
All fields are required since this is a full replacement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
common_properties |
Full common property rules.
TYPE:
|
user_properties |
Full user property rules.
TYPE:
|
events |
Full event rules.
TYPE:
|
rule_event |
Enforcement action.
TYPE:
|
notification_emails |
Notification recipients.
TYPE:
|
schema_id |
Schema definition ID.
TYPE:
|
Example
Data Audit Types¶
Types for schema audit operations and violation reporting.
mixpanel_headless.AuditViolation
¶
Bases: BaseModel
A single violation found during a data audit.
| ATTRIBUTE | DESCRIPTION |
|---|---|
violation |
Violation type (e.g., "Unexpected Event", "Missing Property", "Unexpected Type for Property").
TYPE:
|
name |
Property or event name.
TYPE:
|
platform |
Platform ("iOS", "Android", "Web").
TYPE:
|
version |
Version string.
TYPE:
|
count |
Number of occurrences.
TYPE:
|
event |
Event name (for property violations).
TYPE:
|
sensitive |
Whether property is marked sensitive.
TYPE:
|
property_type_error |
Type mismatch description.
TYPE:
|
platform
class-attribute
instance-attribute
¶
Platform: "iOS", "Android", "Web".
event
class-attribute
instance-attribute
¶
Event name (for property violations).
sensitive
class-attribute
instance-attribute
¶
Whether property is marked sensitive.
property_type_error
class-attribute
instance-attribute
¶
Type mismatch description.
mixpanel_headless.AuditResponse
¶
Bases: BaseModel
Response from a data audit operation.
Contains a list of schema violations and the timestamp when the audit was computed.
| ATTRIBUTE | DESCRIPTION |
|---|---|
violations |
List of audit violations.
TYPE:
|
computed_at |
Timestamp of audit computation.
TYPE:
|
Example
Data Volume Anomaly Types¶
Types for monitoring and managing data volume anomalies.
mixpanel_headless.DataVolumeAnomaly
¶
Bases: BaseModel
A detected data volume anomaly.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Anomaly ID.
TYPE:
|
timestamp |
Detection timestamp.
TYPE:
|
actual_count |
Actual observed count.
TYPE:
|
predicted_upper |
Upper bound of prediction.
TYPE:
|
predicted_lower |
Lower bound of prediction.
TYPE:
|
percent_variance |
Variance percentage.
TYPE:
|
status |
Anomaly status ("open" or "dismissed").
TYPE:
|
project |
Project ID.
TYPE:
|
event |
Event ID.
TYPE:
|
event_name |
Event name.
TYPE:
|
property |
Property ID.
TYPE:
|
property_name |
Property name.
TYPE:
|
metric |
Metric ID.
TYPE:
|
metric_name |
Metric name.
TYPE:
|
metric_type |
Metric type.
TYPE:
|
primary_type |
Primary anomaly type.
TYPE:
|
drift_types |
Drift type details.
TYPE:
|
anomaly_class |
Anomaly class ("Event", "Property", "PropertyTypeDrift", "Metric").
TYPE:
|
Example
mixpanel_headless.UpdateAnomalyParams
¶
Bases: BaseModel
Parameters for updating a single anomaly status.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Anomaly ID.
TYPE:
|
status |
New status ("open" or "dismissed").
TYPE:
|
anomaly_class |
Anomaly class.
TYPE:
|
mixpanel_headless.BulkAnomalyEntry
¶
Bases: BaseModel
A single entry in a bulk anomaly update.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Anomaly ID.
TYPE:
|
anomaly_class |
Anomaly class.
TYPE:
|
mixpanel_headless.BulkUpdateAnomalyParams
¶
Bases: BaseModel
Parameters for bulk-updating anomaly statuses.
| ATTRIBUTE | DESCRIPTION |
|---|---|
anomalies |
Anomalies to update.
TYPE:
|
status |
New status for all ("open" or "dismissed").
TYPE:
|
Example
Event Deletion Request Types¶
Types for managing event deletion requests.
mixpanel_headless.EventDeletionRequest
¶
Bases: BaseModel
An event deletion request with lifecycle status.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Request ID.
TYPE:
|
display_name |
Display name.
TYPE:
|
event_name |
Event to delete.
TYPE:
|
from_date |
Start date.
TYPE:
|
to_date |
End date.
TYPE:
|
filters |
Deletion filters.
TYPE:
|
status |
Request status ("Submitted", "Processing", "Completed", "Failed").
TYPE:
|
deleted_events_count |
Count of deleted events.
TYPE:
|
created |
Creation timestamp.
TYPE:
|
requesting_user |
User who requested.
TYPE:
|
Example
mixpanel_headless.CreateDeletionRequestParams
¶
Bases: BaseModel
Parameters for creating an event deletion request.
| ATTRIBUTE | DESCRIPTION |
|---|---|
from_date |
Start date (YYYY-MM-DD or datetime).
TYPE:
|
to_date |
End date.
TYPE:
|
event_name |
Event name to delete.
TYPE:
|
filters |
Optional deletion filters.
TYPE:
|
Example
filters
class-attribute
instance-attribute
¶
Optional deletion filters.
mixpanel_headless.PreviewDeletionFiltersParams
¶
Bases: BaseModel
Parameters for previewing event deletion filters.
This is a read-only operation that shows what events would match.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event_name |
Event name.
TYPE:
|
from_date |
Start date.
TYPE:
|
to_date |
End date.
TYPE:
|
filters |
Optional filters.
TYPE:
|
Example
Business Context Types¶
Types for the markdown documentation that grounds AI assistants — see the Business Context guide. Both org and project scopes return the same BusinessContext model; BusinessContextChain bundles both for the convenience get_business_context_chain() round-trip.
The 50,000-character cap is exposed as the constant mixpanel_headless.BUSINESS_CONTEXT_MAX_CHARS and enforced both client-side (before any HTTP call) and server-side.
mixpanel_headless.BusinessContext
¶
Bases: BaseModel
Business context content at a single scope.
Returned by Workspace.get_business_context() and
Workspace.set_business_context(). The organization_id field
is populated for level="organization" and project_id for
level="project" so callers can identify which scope a value
came from when handling both in the same code path.
| ATTRIBUTE | DESCRIPTION |
|---|---|
level |
TYPE:
|
content |
The markdown content. Empty string when no context is set at this scope.
TYPE:
|
organization_id |
Owning organization ID — populated when
TYPE:
|
project_id |
Owning project ID — populated when
TYPE:
|
is_empty |
Computed —
TYPE:
|
character_count |
Computed —
TYPE:
|
Example
level
instance-attribute
¶
Which scope this context belongs to.
organization_id
class-attribute
instance-attribute
¶
Owning organization ID (set when level="organization").
project_id
class-attribute
instance-attribute
¶
Owning project ID (set when level="project").
is_empty
property
¶
True when no content has been set at this scope.
Computed field — appears in model_dump() so JSON / CLI
consumers can --jq '.is_empty' directly.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
character_count
property
¶
Length of content in characters.
Computed field — appears in model_dump() so JSON / CLI
consumers can --jq '.character_count' directly.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Number of Unicode characters in |
int
|
|
mixpanel_headless.BusinessContextChain
¶
Bases: BaseModel
Both organization and project business context returned together.
Returned by Workspace.get_business_context_chain(), which calls
the project-scoped /business-context/chain endpoint and resolves
both scopes in a single round-trip.
| ATTRIBUTE | DESCRIPTION |
|---|---|
organization |
Organization-level context (shared across projects).
TYPE:
|
project |
Project-level context (specific to the active project).
TYPE:
|