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
| CustomEventRef
| list[str | CustomEventRef]
| SimpleBehavior
| BehaviorRef,
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 the event(s) to query with their 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.
The event is one event name, a saved custom event
(:class:CustomEventRef), a list of names and custom events, a
:class:SimpleBehavior, or a saved simple behavior
(:class:BehaviorRef of type "simple"). A metric over more than
one event counts the events as one series: unique users are counted
once across all the events, and totals add up. query_funnel and
query_retention do not take more than one event per step; use a
custom event there.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Mixpanel event name, a custom event reference, a list of
them, a simple behavior, or a saved simple behavior reference.
A list takes event names and
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
from mixpanel_headless import (
CustomEventRef,
Filter,
FunnelStep,
Metric,
SimpleBehavior,
)
# Simple event with defaults
m1 = Metric("Login")
# With aggregation
m2 = Metric("Purchase", math="average", property="amount")
# With per-user aggregation
m3 = Metric("Purchase", math="total", per_user="average")
# Users who did any of two events, counted once
m4 = Metric(["Login", "SSO Login"], math="unique")
# A saved custom event by id
m5 = Metric(CustomEventRef(42), math="unique")
# Per-event filters: FunnelStep items in a SimpleBehavior
ios_login = FunnelStep("Login", filters=[Filter.equals("platform", "iOS")])
m6 = Metric(SimpleBehavior([ios_login, "SSO Login"]), math="unique")
event
instance-attribute
¶
Event name, custom event, list of them, simple behavior, or saved behavior.
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 |
|---|---|
ParamValidationError
|
If event is empty or contains control
characters ( |
Source code in src/mixpanel_headless/types.py
7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 | |
mixpanel_headless.Formula
dataclass
¶
Formula(
expression: str,
label: str | None = None,
metrics: Sequence[FormulaOperand] | None = None,
)
A formula expression over metrics named by position letter (A, B, C...).
Without metrics, the letters name the other metrics of the query:
A is the first item in the list passed to Workspace.query(), B the
second, and so on. With metrics, the letters name the formula's own
operands instead, and the formula needs no other metric in the query.
This is also the form of a saved formula.
Letters run A to Z, then BA, BB, and so on (27 operands end at BA).
The expression uses + - * / ^, parentheses, and numbers.
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 (without operands).
| ATTRIBUTE | DESCRIPTION |
|---|---|
expression |
Formula expression, e.g.
TYPE:
|
label |
Optional display label for the formula result.
TYPE:
|
metrics |
The formula's own operands, or
TYPE:
|
Example
from mixpanel_headless import Formula, FunnelBehavior, FunnelMetric, 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 %",
)
# A formula with its own operands
result = ws.query(
Formula(
"A / B",
label="Purchases per checkout conversion",
metrics=[
Metric("Purchase", math="total"),
FunnelMetric(FunnelBehavior(["Checkout", "Purchase"])),
],
)
)
label
class-attribute
instance-attribute
¶
Optional display label for the formula result.
metrics
class-attribute
instance-attribute
¶
The formula's own operands (a tuple), or None for the query's metrics.
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If expression is empty
( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.CustomEventRef
dataclass
¶
A reference to a saved custom event by its integer ID.
A custom event is a saved union of events, with optional filters, under
one name. Use this reference as the event of a :class:Metric or as
an event of a :class:SimpleBehavior, to count the custom event
instead of one raw event. The query counts each user once across the
events of the union.
The ID is CustomEvent.id from :meth:Workspace.create_custom_event,
or custom_event_id of an entry of :meth:Workspace.list_custom_events.
Where a query takes an event name only (a query_funnel step, a
query_retention event), pass the name "$custom_event:<id>"
instead. The display name of a custom event is not an event name: it
matches no events and returns zero rows, with no error.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The custom event's server-assigned ID.
TYPE:
|
Example
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If the id is not a positive integer
( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.SimpleBehavior
dataclass
¶
One or more events that count as one behavior.
A user performs the behavior when the user does any of the events. The
query counts the events as one series: unique users are counted once
across all the events, and totals add up. Each event is an event name,
a :class:CustomEventRef, or a :class:FunnelStep (for per-event
filters; the step order has no effect here).
Filters go on each event (a FunnelStep with filters). The
query server ignores filters on the behavior as a whole, so this type
has none.
| ATTRIBUTE | DESCRIPTION |
|---|---|
events |
The events, at least one.
TYPE:
|
name |
The series label. The query server counts the events as one
series only under a non-empty name, so
TYPE:
|
Example
from mixpanel_headless import (
CustomEventRef,
Filter,
FunnelStep,
Metric,
SimpleBehavior,
)
# Any of three sign-in events, as one series named "Signed in"
signed_in = SimpleBehavior(
["Login", "SSO Login", CustomEventRef(42)], name="Signed in"
)
result = ws.query(Metric(signed_in, math="unique"))
# Per-event filters through FunnelStep
big_purchase = SimpleBehavior(
[FunnelStep("Purchase", filters=[Filter.greater_than("amount", 100)])]
)
events
instance-attribute
¶
The events, at least one.
name
class-attribute
instance-attribute
¶
The series label; None joins the event names with " or ".
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If there are no events
( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FunnelBehavior
dataclass
¶
FunnelBehavior(
steps: list[str | FunnelStep],
conversion_window: int = 14,
conversion_window_unit: ConversionWindowUnit = "day",
order: FunnelOrder = "loose",
exclusions: list[str | Exclusion] | None = None,
holding_constant: str
| HoldingConstant
| list[str | HoldingConstant]
| None = None,
reentry_mode: FunnelReentryMode | None = None,
)
An ordered sequence of two or more steps that users convert through.
The fields use the parameter names and the defaults of
:meth:Workspace.query_funnel, so a funnel behavior and a
query_funnel call over the same steps count the same way. The web
app starts a new funnel behavior with a 7-day window; pass
conversion_window=7 to match it.
| ATTRIBUTE | DESCRIPTION |
|---|---|
steps |
The funnel steps, at least two. Each is an event name or a
:class:
TYPE:
|
conversion_window |
How long users have to complete the funnel.
Default:
TYPE:
|
conversion_window_unit |
The unit of
TYPE:
|
order |
TYPE:
|
exclusions |
Events that remove a user from the funnel between
steps. Each is an event name or an :class:
TYPE:
|
holding_constant |
Properties that must keep the same value at every
step. One name, one :class:
TYPE:
|
reentry_mode |
How users re-enter the funnel after they convert.
TYPE:
|
Example
conversion_window
class-attribute
instance-attribute
¶
How long users have to complete the funnel.
conversion_window_unit
class-attribute
instance-attribute
¶
The unit of conversion_window.
order
class-attribute
instance-attribute
¶
Step ordering mode ("loose" or "any").
exclusions
class-attribute
instance-attribute
¶
Events that remove a user from the funnel between steps.
holding_constant
class-attribute
instance-attribute
¶
Properties that must keep the same value at every step.
reentry_mode
class-attribute
instance-attribute
¶
How users re-enter the funnel after they convert (server default).
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If there are fewer than two steps
( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.FunnelMetric
dataclass
¶
FunnelMetric(
behavior: FunnelBehavior | BehaviorRef,
math: FunnelMathType = "conversion_rate_unique",
property: PropertySpec | None = None,
step_index: int | None = None,
label: str | None = None,
)
A funnel behavior measured as one metric, such as its conversion rate.
Use it in :meth:Workspace.query next to other metrics, or as an
operand of a :class:Formula. The math and property rules are those of
:meth:Workspace.query_funnel and math_property: a funnel metric
and a query_funnel call over the same funnel give the same number.
A property math with no property is refused, because the query server
refuses it too. For a property math, an empty or whitespace-only
property name counts as no property.
| ATTRIBUTE | DESCRIPTION |
|---|---|
behavior |
The funnel to measure: a
TYPE:
|
math |
The funnel aggregation. Default:
TYPE:
|
property |
The property to aggregate. Required for a property math
(
TYPE:
|
step_index |
The zero-based step to measure.
TYPE:
|
label |
The series label.
TYPE:
|
Example
from mixpanel_headless import FunnelBehavior, FunnelMetric, Metric
checkout = FunnelBehavior(["Checkout", "Purchase"])
rate = FunnelMetric(checkout, label="Checkout conversion")
spend = FunnelMetric(checkout, math="average", property="amount")
# Conversion rate next to the number of users who checked out
result = ws.query([Metric("Checkout", math="unique"), rate])
behavior
instance-attribute
¶
The funnel to measure, inline or saved.
math
class-attribute
instance-attribute
¶
The funnel aggregation.
property
class-attribute
instance-attribute
¶
The property to aggregate (name, ref, or inline).
step_index
class-attribute
instance-attribute
¶
The zero-based step to measure, or None for the whole funnel.
__post_init__
¶
Validate construction arguments.
The property rules are the rules of :meth:Workspace.query_funnel
for math_property, with the same codes. One rule is stricter:
a blank property name on a property math counts as no property.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If a saved behavior is not a funnel
( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.RetentionBehavior
dataclass
¶
RetentionBehavior(
born_event: str | RetentionEvent,
return_event: str | RetentionEvent,
retention_unit: TimeUnit = "week",
alignment: RetentionAlignment = "birth",
bucket_sizes: list[int] | None = None,
unbounded_mode: RetentionUnboundedMode | None = None,
)
A born event and a return event: users who come back after they start.
The fields use the parameter names and the defaults of
:meth:Workspace.query_retention, so a retention behavior and a
query_retention call over the same events count the same way. The
web app starts a new retention behavior with daily buckets; pass
retention_unit="day" to match it. A retention behavior always holds
exactly two events.
| ATTRIBUTE | DESCRIPTION |
|---|---|
born_event |
The event that puts a user in a cohort. An event name
or a :class:
TYPE:
|
return_event |
The event that counts as a return. An event name or a
:class:
TYPE:
|
retention_unit |
The bucket unit. Default:
TYPE:
|
alignment |
TYPE:
|
bucket_sizes |
Custom bucket sizes (positive integers in ascending
order).
TYPE:
|
unbounded_mode |
How a return counts in later or earlier buckets.
TYPE:
|
Example
born_event
instance-attribute
¶
The event that puts a user in a cohort.
return_event
instance-attribute
¶
The event that counts as a return.
retention_unit
class-attribute
instance-attribute
¶
The bucket unit.
alignment
class-attribute
instance-attribute
¶
Cohort alignment mode.
bucket_sizes
class-attribute
instance-attribute
¶
Custom bucket sizes, or None for uniform buckets.
unbounded_mode
class-attribute
instance-attribute
¶
How a return counts in other buckets (server default).
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If an event name is blank
( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.RetentionMetric
dataclass
¶
RetentionMetric(
behavior: RetentionBehavior | BehaviorRef,
math: RetentionMathType = "retention_rate",
bucket_index: int | None = None,
retention_cumulative: bool = False,
property: PropertySpec | None = None,
label: str | None = None,
)
A retention behavior measured as one metric, such as its retention rate.
Use it in :meth:Workspace.query next to other metrics, or as an
operand of a :class:Formula.
| ATTRIBUTE | DESCRIPTION |
|---|---|
behavior |
The retention behavior to measure: a
TYPE:
|
math |
The retention aggregation. Default:
TYPE:
|
bucket_index |
The zero-based bucket that a line or bar chart
trends:
TYPE:
|
retention_cumulative |
Whether to count retention cumulatively.
Default:
TYPE:
|
property |
The property to aggregate. Required for
TYPE:
|
label |
The series label.
TYPE:
|
Example
behavior
instance-attribute
¶
The retention behavior to measure, inline or saved.
math
class-attribute
instance-attribute
¶
The retention aggregation.
bucket_index
class-attribute
instance-attribute
¶
The zero-based bucket to trend, or None for the report default.
retention_cumulative
class-attribute
instance-attribute
¶
Whether to count retention cumulatively.
property
class-attribute
instance-attribute
¶
The property to aggregate (name, ref, or inline).
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If a saved behavior is not a retention
behavior ( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.Filter
dataclass
¶
Filter(
_property: str | CustomPropertyRef | InlineCustomProperty,
_operator: FilterOperatorInput,
_value: FilterValue,
_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.
The factory classmethods (Filter.equals, Filter.greater_than,
Filter.is_set, ...) are the recommended way to build a Filter: each
one maps to a specific filterType, filterOperator, and filterValue format
in the bookmark JSON. Direct construction is supported and validated:
_operator must be a :data:FilterOperator member or a factory-method
name ("greater_than", "is_set", ...), which __post_init__
normalizes to the wire spelling so both paths serialize identically.
Anything else raises ValueError at construction instead of surfacing
as an HTTP 400 from the query API.
Example
from mixpanel_headless import Filter
f1 = Filter.equals("country", "US")
f2 = Filter.greater_than("age", 18)
f3 = Filter.between("amount", 10, 100)
f4 = Filter.is_set("email")
# Direct construction accepts the factory-method spelling as an alias
Filter("age", "greater_than", 18, "number") == f2 # True
Filter("won", "equals", True, "boolean") == Filter.is_true("won") # True
__post_init__
¶
Normalize operator aliases and validate Filter invariants.
Runs on every construction, including the factory classmethods (whose output is already canonical and passes through untouched):
_operatormust be a string; a factory-method spelling in :data:_FILTER_OPERATOR_ALIASES("greater_than","is_set", ...) is rewritten to the wire operator that factory emits, and the result must be a :data:FilterOperatormember.- The effective property type is derived the same way
build_filter_entryderivesfilterType: anInlineCustomPropertywith a declaredproperty_typewins over_property_type. - On a
booleanproperty,equals/does not equalwith a bool value collapse totrue/falsewith_value=None, matchingFilter.is_true()/Filter.is_false(); any other operator on a boolean property is rejected. true/false(however spelled) take no value: a non-None_valueis rejected on every property type, because the platform serializes boolean filters withfilterValue: null.- The pre-existing
list_containsshape guards run last.
Already-valid input is never rewritten: a wire operator and its value serialize exactly as given.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
ParamValidationError
|
If |
Example
Source code in src/mixpanel_headless/types.py
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 | |
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 |
|---|---|
ParamValidationError
|
If cohort ID is not positive
( |
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 |
|---|---|
ParamValidationError
|
If cohort ID is not positive
( |
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 |
|---|---|
ParamValidationError
|
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 |
|---|---|
ParamValidationError
|
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 |
|---|---|
ParamValidationError
|
If dates are not valid YYYY-MM-DD
( |
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 |
|---|---|
ParamValidationError
|
If dates are not valid YYYY-MM-DD
( |
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 |
|---|---|
ParamValidationError
|
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 |
|---|---|
ParamValidationError
|
If both |
ParamTypeError
|
If a |
Example
Source code in src/mixpanel_headless/types.py
9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 | |
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 |
|---|---|
ParamValidationError
|
If property is an empty string
( |
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 |
|---|---|
ParamValidationError
|
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
include_negated
class-attribute
instance-attribute
¶
Whether to include a 'Not In' segment.
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If cohort ID is not positive
( |
Source code in src/mixpanel_headless/types.py
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 |
|---|---|
ParamValidationError
|
If cohort ID is not positive
( |
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
Saved Entity References¶
References to saved metrics and saved behaviors by id. The params keep the reference, and the server expands the saved definition at query time. See Saved Metrics by Reference for usage guide.
mixpanel_headless.MetricRef
dataclass
¶
MetricRef(
id: int,
*,
type: Literal["metric", "formula", "warehouse"] = "metric",
label: str | None = None,
math: MathType | FunnelMathType | RetentionMathType | None = None,
property: str | CustomPropertyRef | InlineCustomProperty | None = None,
per_user: PerUserAggregation | None = None,
percentile_value: int | float | None = None,
segment_method: SegmentMethod | None = None,
funnel_order: FunnelOrder | None = None,
step_index: int | None = None,
bucket_index: int | None = None,
hidden: bool | None = None,
overrides: Mapping[str, Any] | None = None,
)
A saved metric, used by id in a query.
Pass it to Workspace.query() or build_params() anywhere a
Metric is accepted. The params keep the reference
({"type", "id", "overrides"}), so the server expands the saved
definition at query time, and a report or report link built from the
params follows later edits to the saved metric.
The typed fields change the saved definition for this query only. The
library writes each one into overrides at its wire path, and the
server deep-merges overrides into the expanded clause. overrides
is an escape hatch for other paths and merges after the typed fields.
Filters are not an override. The server merges lists item by item, so
a filter list in overrides would change the saved filters by
position instead of adding to them. Use report-level where= to
filter every metric, or send the metric inline with its own filters.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Saved metric id.
TYPE:
|
type |
Saved metric kind:
TYPE:
|
label |
Series name for this query. Replaces the saved name.
TYPE:
|
math |
Aggregation override (an insights, funnel, or retention math).
TYPE:
|
property |
Property override for property math. The server merges it into the saved property dict, so the keys of a saved custom property stay; to replace a saved custom property with a plain property, send the metric inline.
TYPE:
|
per_user |
Per-user pre-aggregation override.
TYPE:
|
percentile_value |
Percentile override (for example 95).
TYPE:
|
segment_method |
Counting override:
TYPE:
|
funnel_order |
Step order override for a saved funnel metric.
TYPE:
|
step_index |
Funnel step override for a saved funnel metric.
TYPE:
|
bucket_index |
Bucket override for a saved retention metric.
TYPE:
|
hidden |
Whether the chart hides this series.
TYPE:
|
overrides |
Raw overrides, deep-merged after the typed fields. Stored
as a read-only copy (
TYPE:
|
Example
type
class-attribute
instance-attribute
¶
Saved metric kind.
math
class-attribute
instance-attribute
¶
Aggregation override.
property
class-attribute
instance-attribute
¶
Property override for property math.
per_user
class-attribute
instance-attribute
¶
Per-user pre-aggregation override.
percentile_value
class-attribute
instance-attribute
¶
Percentile override.
segment_method
class-attribute
instance-attribute
¶
Counting override.
funnel_order
class-attribute
instance-attribute
¶
Step order override for a saved funnel metric.
step_index
class-attribute
instance-attribute
¶
Funnel step override for a saved funnel metric.
bucket_index
class-attribute
instance-attribute
¶
Bucket override for a saved retention metric.
hidden
class-attribute
instance-attribute
¶
Whether the chart hides this series.
overrides
class-attribute
instance-attribute
¶
Raw overrides, deep-merged after the typed fields (a read-only copy).
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If the id is not a positive integer
( |
Source code in src/mixpanel_headless/types.py
8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 | |
mixpanel_headless.BehaviorRef
dataclass
¶
A saved behavior, used by id in a funnel or retention query.
Pass it to Workspace.query_funnel() in place of the step list, or to
Workspace.query_retention() in place of the born and return events.
The params keep the reference ({"type", "id"}), and the server
expands the saved behavior at query time. The saved behavior sets the
steps, the conversion window, the order, the exclusions, and the other
behavior settings.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Saved behavior id.
TYPE:
|
type |
Saved behavior type:
TYPE:
|
Example
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If the id is not a positive integer
( |
Source code in src/mixpanel_headless/types.py
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 |
|---|---|
ParamValidationError
|
If validation rules TC0-TC3b are violated
during construction (codes |
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 |
|---|---|
ParamValidationError
|
If type is invalid
( |
Source code in src/mixpanel_headless/types.py
7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 | |
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 |
|---|---|
ParamValidationError
|
If validation rules FB1-FB4 are violated
(codes |
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 |
|---|---|
ParamValidationError
|
If event is empty
( |
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.
The threshold is evaluated per query time bucket (the query's
unit), not over the whole report date range. With the default
unit="day", FrequencyFilter("Login", value=5) keeps only
users who logged in five or more times within a single day; a user
who logged in 30 times in a month but never five times on one day
is excluded from every daily bucket. An empty series (zero-row
DataFrame) is therefore the expected result when no user reaches
the threshold inside one bucket, not a sign that the filter failed.
Choose the unit that matches the period you mean: "day" for
"N times in a day", "month" for "N times in a month".
unit="month" over a multi-month range still yields one threshold
per month; "N times over the whole period" needs a date range that
fits inside a single bucket. last= is always a number of days
regardless of unit, so pin a month with from_date /
to_date.
date_range_value / date_range_unit render as a
behavior.dateRange lookback on the wire. In a 2026-09-11 probe
against the analytics query API they had no observable effect on
inline insights filters: results were identical with and without a
31-day lookback. Their behavior for inline filters has not been
verified against Mixpanel's internal fixtures. Do not rely on them
to widen the counting window; use unit instead.
| ATTRIBUTE | DESCRIPTION |
|---|---|
event |
Event name to count frequency for.
TYPE:
|
operator |
Comparison operator. Default:
TYPE:
|
value |
Threshold value for the comparison, counted per query time bucket (see above).
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 |
|---|---|
ParamValidationError
|
If validation rules FF1-FF5 are violated
(codes |
Example
from mixpanel_headless import Filter, FrequencyFilter
# "Users who logged in at least 5 times": the count is taken per
# bucket, so the query's unit decides what "5 times" means.
# Per DAY (default unit): purchases by users with 5+ logins on
# the same day. Often an empty series even when thousands of
# users logged in 5+ times across the month.
daily = ws.query(
"Purchase",
where=FrequencyFilter("Login", value=5),
from_date="2026-03-01",
to_date="2026-03-31",
)
# Per MONTH: purchases by users with 5+ logins anywhere in March.
monthly = ws.query(
"Purchase",
where=FrequencyFilter("Login", value=5),
from_date="2026-03-01",
to_date="2026-03-31",
unit="month",
)
# Logins by users with 3+ purchases over 50 in the month
result = ws.query(
"Login",
where=FrequencyFilter(
"Purchase",
value=3,
event_filters=[Filter.greater_than("amount", 50)],
),
from_date="2026-03-01",
to_date="2026-03-31",
unit="month",
)
value
instance-attribute
¶
Threshold value for the comparison, counted per query time bucket.
operator
class-attribute
instance-attribute
¶
Comparison operator.
date_range_value
class-attribute
instance-attribute
¶
Lookback window size. No observable effect on inline insights filters in a 2026-09-11 probe; unverified against platform fixtures.
date_range_unit
class-attribute
instance-attribute
¶
Lookback window unit. No observable effect on inline insights filters in a 2026-09-11 probe; unverified against platform fixtures.
event_filters
class-attribute
instance-attribute
¶
Property filters applied to the frequency event.
__post_init__
¶
Validate construction arguments (rules FF1-FF5).
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If event is empty
( |
Source code in src/mixpanel_headless/types.py
11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 | |
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 |
|---|---|
ParamValidationError
|
If no criteria are provided
( |
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 |
|---|---|
ParamValidationError
|
If no criteria are provided
( |
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 |
|---|---|
ParamValidationError
|
If no criteria are provided
( |
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
10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 | |
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 |
|---|---|
ParamValidationError
|
If no frequency param or multiple are
set ( |
Source code in src/mixpanel_headless/types.py
10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 | |
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 |
|---|---|
ParamValidationError
|
On constraint violations (same codes
as |
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 |
|---|---|
ParamValidationError
|
If property name is empty
( |
Source code in src/mixpanel_headless/types.py
10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 | |
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 |
|---|---|
ParamValidationError
|
If property name is empty
( |
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 |
|---|---|
ParamValidationError
|
If property name is empty
( |
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 |
|---|---|
ParamValidationError
|
If cohort_id is not a positive integer
( |
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 |
|---|---|
ParamValidationError
|
If cohort_id is not a positive integer
( |
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 |
|---|---|
ParamValidationError
|
If event is empty ( |
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
resource_type
class-attribute
instance-attribute
¶
Whether this is an event property or user-profile property.
__post_init__
¶
Validate construction arguments.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
If property is empty
( |
Source code in src/mixpanel_headless/types.py
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 |
|---|---|
ParamValidationError
|
If event is empty or contains control
characters ( |
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 |
|---|---|
ParamValidationError
|
|
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 |
|---|---|
ParamValidationError
|
|
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 |
|---|---|
ParamValidationError
|
|
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 |
|---|---|
ParamValidationError
|
|
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 |
capture
property
¶
The recording type, read from the raw rrweb events.
"dom" is a recording of a real page DOM (the Mixpanel JavaScript
SDK). "screenshot" is a recording whose DOM is one screenshot
image per screen: the iOS, Android, React Native, and Flutter SDKs,
including Flutter web and desktop. A stream is a screenshot
recording when it has any mp_wireframe event, or when it has
Meta events and none of them carries a page URL (href). A
replay with no events, or with neither a Meta event nor an
mp_wireframe event, is "dom".
| RETURNS | DESCRIPTION |
|---|---|
Literal['dom', 'screenshot']
|
|
has_wireframes
property
¶
Whether the replay holds wireframe screens ("screen" actions).
Screenshot recordings carry wireframes only when the SDK has them turned on, so a screenshot recording can have none.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when at least one action is a |
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 |
|---|---|
ParamValidationError
|
|
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
screen_path
¶
Screen sequence of the replay: the mobile form of :meth:page_path.
Each entry is the target_desc of a "screen" action: an
approximate heading (the top-most labeled text element), or
"(screen)" when the screen has no labeled text. The SDKs send
no screen name, so the heading is a heuristic. Screens are sampled
around gestures, and consecutive identical screens appear once.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Screen headings in timestamp order; empty for a replay without |
list[str]
|
wireframes. |
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]]
|
|
list[dict[str, Any]]
|
are not mutated. |
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,
_screens_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.
screens_df
property
¶
One row per wireframe screen action across the bundle.
Screens exist only in screenshot recordings with wireframes turned
on (see :attr:Replay.capture and :attr:Replay.has_wireframes).
heading is the action's target_desc: an approximate heading,
not a screen name. Identical screens share a fingerprint, so
grouping by it counts screen visits across sessions.
Columns: replay_id, t, heading, fingerprint,
element_count, description.
Example
bundle.screens_df[["replay_id", "t", "heading", "element_count"]]
# replay_id t heading element_count
# 0 r-1 1000 Home 2
# 1 r-1 2700 Receipt 1
# Most-visited screens: count by fingerprint, label by heading.
bundle.screens_df.groupby("fingerprint").agg(
heading=("heading", "first"), visits=("replay_id", "size")
)
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 |
|---|---|
ParamValidationError
|
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
rage_taps
¶
rage_taps(
threshold: int = 3,
window_ms: int = 2000,
radius_px: float = 24,
grace_ms: int = 1000,
) -> pd.DataFrame
Find rage and dead taps in screenshot recordings.
Thin wrapper over the bundle-level rage_taps aggregator. A burst
is threshold or more finger-downs within window_ms of the
first one and within radius_px of its point. Finger-downs
(touch starts, plus mouse clicks in Flutter web and desktop) are
counted from rrweb_events, not from the emitted tap actions,
because a fast burst with overlapping fingers produces far fewer
classified taps. Only screenshot recordings count; web replays use
:meth:rage_clicks.
Each burst is classified per interval: the gaps between
consecutive finger-downs, plus the grace_ms window after the last
one. An interval has a change when a "screen" action in it
differs from the screen shown when the interval began.
- no interval has a change:
kind="dead", the control did nothing; - every gap between finger-downs has a change: intentional (a quantity stepper or a carousel), so the burst is not reported;
- otherwise:
kind="rage", some taps changed nothing, for example a navigation that arrives only after the burst.
A screen that changes on its own (a live clock, a timer) counts as a
change, so a dead control on such a screen can read as "rage" or
be skipped.
| PARAMETER | DESCRIPTION |
|---|---|
threshold
|
Minimum finger-downs for a burst. Default 3.
TYPE:
|
window_ms
|
Maximum time from the first to the last finger-down of a burst, in milliseconds. Default 2000.
TYPE:
|
radius_px
|
Maximum distance of a finger-down from the burst's first point, in touch-space pixels. Default 24.
TYPE:
|
grace_ms
|
Time after the last finger-down in which a screen change still counts as the burst's result, in milliseconds. Default 1000.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
A DataFrame with columns |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
when no burst qualifies. |
Source code in src/mixpanel_headless/types.py
15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 | |
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 the
query API's per-event properties gather
(data_definitions/events?fetch_per_event_properties=true, inverted
client-side onto each property), 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
13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 | |
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
13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 | |
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
¶
Bases: BaseModel
Creator information for a cohort.
The App API uses the same {id, name, email} user shape on saved
metrics and saved behaviors, so :class:SavedMetric and
:class:SavedBehavior reuse this model for created_by,
owned_by, and last_verified_by.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Creator user ID.
TYPE:
|
name |
Creator name.
TYPE:
|
email |
Creator email.
TYPE:
|
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:
|
Saved Metric and Behavior Types¶
Result types of the saved metric and saved behavior methods. They accept any type, any math, and unknown keys; the typed accessors return None or an empty list for a shape they do not know. created_by, owned_by, and last_verified_by use CohortCreator ({id, name, email}). See the Saved Metrics and Behaviors guide.
mixpanel_headless.SavedMetric
¶
Bases: BaseModel
A saved metric: a behavior metric, a saved formula, or a warehouse metric.
Returned by :meth:Workspace.list_metrics and
:meth:Workspace.get_metric. One model covers all three kinds, because
the server keeps them in one collection. The wire type is
metric (a behavior metric), formula, or warehouse; old rows
can have behavior, and the model accepts any string. Unknown keys
(for example allow_staff_override) are kept via extra="allow".
The definition shape depends on the kind:
metric:{behavior, measurement, display?, goals?}formula:{formula: {definition, referencedMetrics}, measurement?, display?, goals?}warehouse:{query, metricType, aggregation?, syncInterval?, ...}
The typed accessors (:attr:behavior_type, :attr:math,
:attr:formula_expression, :attr:referenced_metric_ids,
:attr:display, :attr:goals) read the definition. Each one returns
None or an empty list for a shape it does not know; none of them raises.
The list endpoint also returns metrics that the caller cannot view, with
full definitions; for those rows can_view is False.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Metric identifier. Treat it as opaque.
TYPE:
|
name |
Metric name (unique among active metrics in the project).
TYPE:
|
type |
Metric kind (
TYPE:
|
description |
Metric description (the server sends
TYPE:
|
definition |
The stored definition; its shape depends on
TYPE:
|
created |
Creation time (naive UTC).
TYPE:
|
modified |
Last modification time (naive UTC).
TYPE:
|
created_by |
The user who created the metric.
TYPE:
|
owned_by |
The owner, when one is set.
TYPE:
|
contacts |
The owner email in a one-item list, or an empty list.
TYPE:
|
verified |
Whether a user marked the metric as verified.
TYPE:
|
last_verified |
When the metric was last verified (naive UTC).
TYPE:
|
last_verified_by |
The user who last verified the metric.
TYPE:
|
warehouse_source_id |
The warehouse source, for warehouse metrics only.
TYPE:
|
is_visible |
Whether the metric is visible to the caller.
TYPE:
|
is_locked |
Whether the metric is locked against edits.
TYPE:
|
can_view |
Whether the caller can view the metric.
TYPE:
|
can_update_basic |
Whether the caller can edit the name and definition.
TYPE:
|
can_share |
Whether the caller can share the metric.
TYPE:
|
Example
description
class-attribute
instance-attribute
¶
Metric description (the server sends "" when empty).
definition
instance-attribute
¶
The stored definition; its shape depends on type.
created
class-attribute
instance-attribute
¶
Creation time (naive UTC).
modified
class-attribute
instance-attribute
¶
Last modification time (naive UTC).
created_by
class-attribute
instance-attribute
¶
The user who created the metric ({id, email, name}).
owned_by
class-attribute
instance-attribute
¶
The owner ({id, email, name}), when one is set.
contacts
class-attribute
instance-attribute
¶
The owner email in a one-item list, or an empty list.
verified
class-attribute
instance-attribute
¶
Whether a user marked the metric as verified.
last_verified
class-attribute
instance-attribute
¶
When the metric was last verified (naive UTC).
last_verified_by
class-attribute
instance-attribute
¶
The user who last verified the metric ({id, email, name}).
warehouse_source_id
class-attribute
instance-attribute
¶
The warehouse source, for warehouse metrics only.
is_visible
class-attribute
instance-attribute
¶
Whether the metric is visible to the caller.
is_locked
class-attribute
instance-attribute
¶
Whether the metric is locked against edits.
can_view
class-attribute
instance-attribute
¶
Whether the caller can view the metric.
can_update_basic
class-attribute
instance-attribute
¶
Whether the caller can edit the name and definition.
can_share
class-attribute
instance-attribute
¶
Whether the caller can share the metric.
behavior_type
property
¶
The behavior type of a behavior metric.
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
|
str | None
|
example |
str | None
|
|
str | None
|
and warehouse metrics. |
math
property
¶
The aggregation of the metric.
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
|
str | None
|
value, known to the library or not); otherwise None. |
formula_expression
property
¶
The expression of a saved formula.
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
|
str | None
|
example |
referenced_metric_ids
property
¶
The ids of the saved metrics that a saved formula uses as operands.
An operand refers to a saved metric through its integer id, or
through the string metric_id that the server adds in responses.
Inline operands have no id and are not listed, and neither are
operands whose metric_id does not convert to an integer.
| RETURNS | DESCRIPTION |
|---|---|
list[int]
|
Each id once, in first-use order. An empty list for a metric that |
list[int]
|
is not a formula or for a shape the accessor does not know. |
display
property
¶
The presentation settings of the metric.
| RETURNS | DESCRIPTION |
|---|---|
MetricDisplay | None
|
|
MetricDisplay | None
|
None when it is absent or has a shape the model cannot read. |
goals
property
¶
The goals of the metric.
| RETURNS | DESCRIPTION |
|---|---|
list[MetricGoal]
|
Each entry of |
list[MetricGoal]
|
class: |
list[MetricGoal]
|
are left out; |
list[MetricGoal]
|
empty list when the metric has no goals. |
to_ref
¶
to_ref(
*,
label: str | None = None,
math: MathType | FunnelMathType | RetentionMathType | None = None,
property: str | CustomPropertyRef | InlineCustomProperty | None = None,
per_user: PerUserAggregation | None = None,
percentile_value: int | float | None = None,
segment_method: SegmentMethod | None = None,
funnel_order: FunnelOrder | None = None,
step_index: int | None = None,
bucket_index: int | None = None,
hidden: bool | None = None,
overrides: Mapping[str, Any] | None = None,
) -> MetricRef
Return a reference to this saved metric, for use in a query.
The reference takes the id and the kind of the saved metric. The
keyword arguments are the typed overrides of :class:MetricRef and
change the saved definition for one query only.
| PARAMETER | DESCRIPTION |
|---|---|
label
|
Series name for this query.
TYPE:
|
math
|
Aggregation override.
TYPE:
|
property
|
Property override for property math.
TYPE:
|
per_user
|
Per-user pre-aggregation override.
TYPE:
|
percentile_value
|
Percentile override.
TYPE:
|
segment_method
|
Counting override:
TYPE:
|
funnel_order
|
Step order override for a saved funnel metric.
TYPE:
|
step_index
|
Funnel step override for a saved funnel metric.
TYPE:
|
bucket_index
|
Bucket override for a saved retention metric.
TYPE:
|
hidden
|
Whether the chart hides this series.
TYPE:
|
overrides
|
Raw overrides, deep-merged after the typed fields.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
A
|
class:
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
|
Example
Source code in src/mixpanel_headless/types.py
6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 | |
to_raw_definition
¶
Return the stored definition as a write value, for a copy.
The value holds a copy of the definition, the kind, and (for a
warehouse metric) the warehouse source, which the server keeps
outside the definition. A legacy behavior kind becomes
metric, as in the kind check of update_metric.
| RETURNS | DESCRIPTION |
|---|---|
A
|
class:
TYPE:
|
RawMetricDefinition
|
class: |
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
The stored kind is not one that a create
accepts ( |
Example
Source code in src/mixpanel_headless/types.py
mixpanel_headless.SavedBehavior
¶
Bases: BaseModel
A saved behavior: a reusable "what users did", stored per project.
Returned by :meth:Workspace.list_behaviors and
:meth:Workspace.get_behavior. The wire type is simple,
funnel, or retention; the model accepts any string. The
definition holds one key, behavior, in the show-clause shape of
the web app. Unknown keys (for example can_update_restricted, which
projects without sharing add) are kept via extra="allow".
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Behavior identifier. Treat it as opaque.
TYPE:
|
name |
Behavior name (unique among active behaviors in the project).
TYPE:
|
type |
Behavior type (
TYPE:
|
description |
Behavior description; the server can send
TYPE:
|
definition |
The stored definition,
TYPE:
|
created |
Creation time (naive UTC).
TYPE:
|
modified |
Last modification time (naive UTC).
TYPE:
|
created_by |
The user who created the behavior.
TYPE:
|
verified |
Whether a user marked the behavior as verified.
TYPE:
|
last_verified |
When the behavior was last verified (naive UTC).
TYPE:
|
last_verified_by |
The user who last verified the behavior.
TYPE:
|
is_visible |
Whether the behavior is visible to the caller.
TYPE:
|
is_locked |
Whether the behavior is locked against edits.
TYPE:
|
can_view |
Whether the caller can view the behavior.
TYPE:
|
can_update_basic |
Whether the caller can edit the name and definition.
TYPE:
|
can_share |
Whether the caller can share the behavior.
TYPE:
|
Example
description
class-attribute
instance-attribute
¶
Behavior description; the server can send None.
definition
instance-attribute
¶
The stored definition, {"behavior": {...}}.
created
class-attribute
instance-attribute
¶
Creation time (naive UTC).
modified
class-attribute
instance-attribute
¶
Last modification time (naive UTC).
created_by
class-attribute
instance-attribute
¶
The user who created the behavior ({id, email, name}).
verified
class-attribute
instance-attribute
¶
Whether a user marked the behavior as verified.
last_verified
class-attribute
instance-attribute
¶
When the behavior was last verified (naive UTC).
last_verified_by
class-attribute
instance-attribute
¶
The user who last verified the behavior ({id, email, name}).
is_visible
class-attribute
instance-attribute
¶
Whether the behavior is visible to the caller.
is_locked
class-attribute
instance-attribute
¶
Whether the behavior is locked against edits.
can_view
class-attribute
instance-attribute
¶
Whether the caller can view the behavior.
can_update_basic
class-attribute
instance-attribute
¶
Whether the caller can edit the name and definition.
can_share
class-attribute
instance-attribute
¶
Whether the caller can share the behavior.
behavior_type
property
¶
The type inside the stored behavior definition.
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
|
str | None
|
example |
to_ref
¶
Return a reference to this saved behavior, for use in a query.
| RETURNS | DESCRIPTION |
|---|---|
A
|
class:
TYPE:
|
BehaviorRef
|
behavior. Pass it to |
BehaviorRef
|
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
|
Source code in src/mixpanel_headless/types.py
mixpanel_headless.MetricDisplay
¶
Bases: BaseModel
Presentation settings stored with a saved metric.
Mirrors the display object of a saved metric definition: number
format, the good direction of a change, the chart axis, and the
experiment sizing inputs. The wire keys are camelCase
(hideTrendline, minimumDetectableEffect, oneSided); the
fields are snake_case, and both names work at construction. The model is
open: it keeps keys that it does not name, such as the chartType key
that some stored rows carry.
| ATTRIBUTE | DESCRIPTION |
|---|---|
prefix |
Text before the value (for example
TYPE:
|
suffix |
Text after the value (for example
TYPE:
|
precision |
Number of decimal places (the server allows 0 to 8).
TYPE:
|
abbrev |
Whether large numbers are abbreviated (
TYPE:
|
direction |
The good direction of a change (
TYPE:
|
axis |
Chart axis (
TYPE:
|
trendline |
Whether the chart shows a trend line.
TYPE:
|
hide_trendline |
Whether the chart hides the trend line.
TYPE:
|
minimum_detectable_effect |
Experiment sizing input for this metric.
TYPE:
|
one_sided |
Whether an experiment tests this metric one-sided.
TYPE:
|
power |
Experiment statistical power for this metric.
TYPE:
|
Example
precision
class-attribute
instance-attribute
¶
Number of decimal places (0 to 8 on the server).
abbrev
class-attribute
instance-attribute
¶
Whether large numbers are abbreviated.
direction
class-attribute
instance-attribute
¶
The good direction of a change ("up" or "down").
axis
class-attribute
instance-attribute
¶
Chart axis ("primary" or "secondary").
trendline
class-attribute
instance-attribute
¶
Whether the chart shows a trend line.
hide_trendline
class-attribute
instance-attribute
¶
Whether the chart hides the trend line (wire key hideTrendline).
minimum_detectable_effect
class-attribute
instance-attribute
¶
Experiment sizing input (wire key minimumDetectableEffect).
one_sided
class-attribute
instance-attribute
¶
Whether an experiment tests this metric one-sided (wire key oneSided).
power
class-attribute
instance-attribute
¶
Experiment statistical power for this metric.
mixpanel_headless.MetricGoal
¶
Bases: BaseModel
A goal of a saved metric: a label and dated target values.
Read from SavedMetric.goals and written through CreateMetricParams
and UpdateMetricParams. The deprecated goal keys unit and
direction still appear in stored rows. The model keeps them as
unknown keys (model_extra); the server no longer reads them, and the
library never writes them.
On a write, a goal without an id gets a new UUID, and a date or
datetime checkpoint is written as a naive ISO timestamp
("2026-12-31T00:00:00"), the form the web app stores.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Goal identifier (a UUID string).
TYPE:
|
label |
Goal label shown in the web app.
TYPE:
|
checkpoints |
TYPE:
|
target_type |
TYPE:
|
target_input |
The value the user typed for the target, if any.
TYPE:
|
Example
id
class-attribute
instance-attribute
¶
Goal identifier (a UUID string). None on a new goal.
checkpoints
class-attribute
instance-attribute
¶
(timestamp, value) pairs; the value is absolute.
Stored goals read back with ISO timestamp strings.
target_type
class-attribute
instance-attribute
¶
"absolute" or "relative".
target_input
class-attribute
instance-attribute
¶
The value the user typed for the target, if any.
Create and update¶
The write methods take these params. The kind of a saved metric comes from its definition (MetricDefinition): Metric, CohortMetric, FunnelMetric, or RetentionMetric gives a behavior metric, a Formula with its own operands gives a saved formula, WarehouseMetric gives a warehouse metric, and RawMetricDefinition gives the kind it names.
A saved behavior takes a BehaviorDefinition, and its wire type comes from that value:
SimpleBehavior,FunnelBehavior, orRetentionBehavior(see Insights Query Types): use one of these to build a new behavior in code. The library compiles it with the builders of an inline behavior, without a name, and the wire type issimple,funnel, orretention.RawBehaviorDefinition: use it for a wire definition dict, for example thedefinitionof aSavedBehaviorthat you copy or edit. The wire type comes fromdefinition["behavior"]["type"].
mixpanel_headless.CreateMetricParams
¶
Bases: BaseModel
Parameters for :meth:Workspace.create_metric.
The kind of the saved metric comes from the definition; the caller never
writes a wire type. create_metric checks the params before any
request: the name is not empty (SM1_EMPTY_NAME), the name and
description are at most 255 characters (SM2_NAME_TOO_LONG), a
Formula holds its own operands (SM7_FORMULA_WITHOUT_OPERANDS),
and the definition passes the mirror of the server POST schema
(SM4_SCHEMA).
owned_by and verified go in a second request, because the server
drops them from a create.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Metric name, unique among the active metrics of the project. Surrounding whitespace is stripped.
TYPE:
|
definition |
What the metric counts.
TYPE:
|
description |
Metric description.
TYPE:
|
display |
Presentation settings. Replaces a
TYPE:
|
goals |
Goals. Replace a
TYPE:
|
owned_by |
User id of the owner.
TYPE:
|
verified |
TYPE:
|
Example
mixpanel_headless.UpdateMetricParams
¶
Bases: BaseModel
Parameters for :meth:Workspace.update_metric.
Every field is optional; None leaves the stored value as it is.
update_metric runs the same checks as create_metric, because the
server stores an update as sent, without its own schema check.
A new definition replaces the stored one in full, but keeps the stored
display and goals unless the params or the new definition set
them.
display merges into the stored display (or into the display of the
new definition, when it has one): the keys that you set replace the
stored ones, a key that you set to None is removed, and the other
keys keep their stored values. So MetricDisplay(precision=2) keeps
a stored prefix and suffix. goals is a list and replaces the stored
goals in full; pass goals=[] to remove them.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
New name (stripped).
TYPE:
|
description |
New description;
TYPE:
|
definition |
New definition, of the same kind as the stored metric.
TYPE:
|
display |
Presentation settings to merge into the stored display;
a key set to
TYPE:
|
goals |
New goals, which replace the stored goals in full;
TYPE:
|
owned_by |
User id of the new owner. An owner cannot be removed.
TYPE:
|
verified |
TYPE:
|
Example
definition
class-attribute
instance-attribute
¶
New definition, of the same kind as the stored metric.
display
class-attribute
instance-attribute
¶
Presentation settings to merge into the stored display.
goals
class-attribute
instance-attribute
¶
New goals, which replace the stored goals in full; [] removes them.
mixpanel_headless.BulkUpdateMetricEntry
¶
Bases: BaseModel
One entry of :meth:Workspace.bulk_update_metrics.
Holds the id plus the five fields that the server reads on a bulk update. Its main use is to verify or reassign many metrics in one request.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The saved metric id.
TYPE:
|
name |
New name (stripped).
TYPE:
|
description |
New description.
TYPE:
|
definition |
New definition, of the same kind as the stored metric.
TYPE:
|
owned_by |
User id of the new owner.
TYPE:
|
verified |
New verified state.
TYPE:
|
definition
class-attribute
instance-attribute
¶
New definition, of the same kind as the stored metric.
mixpanel_headless.WarehouseMetric
dataclass
¶
WarehouseMetric(
source_id: int,
sql: str,
metric_type: Literal["numeric", "timeseries"],
value_column: str | None = None,
time_column: str | None = None,
aggregation: WarehouseAggregation | None = None,
sync_interval: WarehouseSyncInterval | None = None,
)
The definition of a saved warehouse metric: a SQL query on a warehouse source.
Valid only as the definition of :class:CreateMetricParams or
:class:UpdateMetricParams. The server runs the SQL of the saved metric
at query time, so a warehouse metric is queried by reference, never
inline.
The server stores the request as sent and does not fill in defaults for
aggregation and syncInterval. So when aggregation or
sync_interval is None, create_metric writes the server
defaults ("none" and "hourly"), and update_metric (or
bulk_update_metrics) keeps the stored value. An update that changes
only the SQL keeps a stored "sum" and "daily". A set value is
always written.
| ATTRIBUTE | DESCRIPTION |
|---|---|
source_id |
The warehouse source to run the query on (see the project's warehouse sources in the web app).
TYPE:
|
sql |
The SQL query.
TYPE:
|
metric_type |
TYPE:
|
value_column |
The result column that holds the value.
TYPE:
|
time_column |
The result column that holds the time, for a timeseries.
TYPE:
|
aggregation |
How the metric aggregates the query rows;
TYPE:
|
sync_interval |
How long a query result stays cached;
TYPE:
|
Example
metric_type
instance-attribute
¶
"numeric" or "timeseries" (wire key metricType).
value_column
class-attribute
instance-attribute
¶
The result column that holds the value (wire key valueColumn).
time_column
class-attribute
instance-attribute
¶
The result column that holds the time (wire key timeColumn).
aggregation
class-attribute
instance-attribute
¶
How the metric aggregates the query rows; None writes "none" on
a create and keeps the stored value on an update.
sync_interval
class-attribute
instance-attribute
¶
How long a query result stays cached (wire key syncInterval);
None writes "hourly" on a create and keeps the stored value on an
update.
mixpanel_headless.RawMetricDefinition
dataclass
¶
RawMetricDefinition(
type: Literal["metric", "formula", "warehouse"],
definition: Mapping[str, Any],
warehouse_source_id: int | None = None,
)
A saved metric definition as a wire dict, with its kind.
Use it for a definition that no typed value covers (for example a
profile metric), or to send back a definition as get_metric
returned it: :meth:SavedMetric.to_raw_definition builds one with the
kind and, for a warehouse metric, the source that the server keeps
outside the definition. The write methods check the dict with the
mirror of the server's POST schema before they send it.
Stored definitions can carry legacy keys (for example a behavior
filter, or the id and type of a measurement) that the
server reads past at query time but refuses on a create.
create_metric removes them from the copy that it sends, so a copy
of a stored metric works. An update sends the dict as given, because
the server stores an update as sent.
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
The metric kind:
TYPE:
|
definition |
The wire definition dict.
TYPE:
|
warehouse_source_id |
The warehouse source of a warehouse metric.
Required by
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
|
warehouse_source_id
class-attribute
instance-attribute
¶
The warehouse source of a warehouse metric.
__post_init__
¶
Check the kind, the definition container, and the source id.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
A rule of the server POST schema fails
( |
Source code in src/mixpanel_headless/types.py
mixpanel_headless.CreateBehaviorParams
¶
Bases: BaseModel
Parameters for :meth:Workspace.create_behavior.
The wire type of the saved behavior comes from the behavior value.
create_behavior checks the name (SM1_EMPTY_NAME,
SM2_NAME_TOO_LONG) and the definition (SM4_SCHEMA) before the
request.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Behavior name, unique among the active behaviors of the project. Surrounding whitespace is stripped.
TYPE:
|
behavior |
What users did: a
TYPE:
|
description |
Behavior description.
TYPE:
|
Example
mixpanel_headless.UpdateBehaviorParams
¶
Bases: BaseModel
Parameters for :meth:Workspace.update_behavior.
Every field is optional; None leaves the stored value as it is. A
new behavior replaces the stored definition in full and must have the
same type as the stored behavior.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
New name (stripped).
TYPE:
|
description |
New description;
TYPE:
|
behavior |
New definition, of the same type as the stored behavior:
a
TYPE:
|
verified |
TYPE:
|
behavior
class-attribute
instance-attribute
¶
New definition, of the same type as the stored behavior.
mixpanel_headless.RawBehaviorDefinition
dataclass
¶
A saved behavior definition as a wire dict: {"behavior": {...}}.
Send back a definition as get_behavior returned it:
RawBehaviorDefinition(behavior.definition). The wire type of the
saved behavior comes from definition["behavior"]["type"]. The write
methods check the dict with the mirror of the server's POST schema
before they send it.
Stored definitions can carry legacy keys (for example a behavior
filter, or a legacy funnel step key of an exclusion) that the
server reads past at query time but refuses on a create.
create_behavior removes them from the copy that it sends, so a copy
of a stored behavior works. An update sends the dict as given, because
the server stores an update as sent.
| ATTRIBUTE | DESCRIPTION |
|---|---|
definition |
The wire definition dict.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
|
Example
behavior_type
property
¶
The wire type of the behavior.
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
|
str | None
|
otherwise None. |
__post_init__
¶
Check the definition container.
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
|
Source code in src/mixpanel_headless/types.py
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:
|