Workspace¶
The Workspace class is the unified entry point for all Mixpanel data operations.
Explore on DeepWiki
Ask questions about Workspace methods, explore usage patterns, or understand how services are orchestrated.
Overview¶
Workspace orchestrates internal services and provides direct App API access:
- DiscoveryService — Schema exploration (events, properties, funnels, cohorts)
- LiveQueryService — Real-time analytics queries (legacy) and Insights engine queries
- Streaming — Stream events and profiles directly from Mixpanel
- Entity CRUD — Create, read, update, delete dashboards, reports, and cohorts via Mixpanel App API (workspace-scoped)
- Feature Management — Create, read, update, delete feature flags and experiments via Mixpanel App API (project-scoped)
- Operational Tooling — Manage alerts, annotations, and webhooks via Mixpanel App API (workspace-scoped)
- Data Governance — Manage Lexicon definitions, drop filters, custom properties, custom events, lookup tables, schema registry, schema enforcement, data auditing, volume anomalies, and event deletion requests via Mixpanel App API (workspace-scoped)
- Saved Metrics & Behaviors — List, read, create, update, and delete saved metrics (behavior metrics, formulas, warehouse metrics) and saved behaviors via Mixpanel App API (project-scoped)
- Business Context — Read and write the markdown documentation that grounds AI assistants (org and project scopes, 50,000-char cap)
- Session Replay — Discover, sign, fetch, and analyze rrweb session recordings; project them into session-level DataFrames and an LLM-friendly action timeline
Key Features¶
Entity CRUD¶
Manage dashboards, reports (bookmarks), and cohorts programmatically via the Mixpanel App API (workspace-scoped):
import mixpanel_headless as mp
ws = mp.Workspace()
# Dashboards
dashboards = ws.list_dashboards()
new_dash = ws.create_dashboard(mp.CreateDashboardParams(title="Q1 Metrics"))
ws.update_dashboard(new_dash.id, mp.UpdateDashboardParams(title="Q1 Metrics v2"))
ws.favorite_dashboard(new_dash.id)
# Reports (Bookmarks)
reports = ws.list_bookmarks_v2()
report = ws.create_bookmark(mp.CreateBookmarkParams(
name="Daily Signups",
bookmark_type="insights"
))
# Cohorts
cohorts = ws.list_cohorts_full()
cohort = ws.create_cohort(mp.CreateCohortParams(name="Power Users"))
ws.update_cohort(cohort.id, mp.UpdateCohortParams(name="Super Users"))
Dashboard, report, and cohort operations require a workspace ID, set via MP_WORKSPACE_ID environment variable, --workspace / -w CLI flag, Workspace(workspace=N), or ws.use(workspace=N). List available workspaces with mp workspace list or ws.workspaces().
Feature Flags & Experiments¶
Manage feature flags and experiments programmatically. Unlike dashboards/reports/cohorts, these are project-scoped and do not require a workspace ID.
import mixpanel_headless as mp
ws = mp.Workspace()
# Feature Flags
flags = ws.list_feature_flags()
flag = ws.create_feature_flag(mp.CreateFeatureFlagParams(
name="Dark Mode", key="dark_mode"
))
ws.update_feature_flag(flag.id, mp.UpdateFeatureFlagParams(
name="Dark Mode", key="dark_mode",
status=mp.FeatureFlagStatus.ENABLED,
ruleset=flag.ruleset,
))
# Experiments (full lifecycle)
exp = ws.create_experiment(mp.CreateExperimentParams(name="Checkout Flow Test"))
launched = ws.launch_experiment(exp.id)
concluded = ws.conclude_experiment(exp.id)
decided = ws.decide_experiment(exp.id, mp.ExperimentDecideParams(success=True))
Feature flag update uses PUT semantics (all required fields must be provided). Experiment update uses PATCH semantics (only changed fields needed). See the Entity Management guide for complete coverage.
Data Governance¶
Manage Lexicon definitions, drop filters, custom properties, custom events, and lookup tables programmatically. All operations are workspace-scoped.
import mixpanel_headless as mp
ws = mp.Workspace()
# Lexicon — Event and property definitions
defs = ws.get_event_definitions(names=["Signup", "Login"])
ws.update_event_definition("Signup", mp.UpdateEventDefinitionParams(verified=True))
tags = ws.list_lexicon_tags()
# Drop filters
filters = ws.list_drop_filters()
ws.create_drop_filter(mp.CreateDropFilterParams(
event_name="Debug Event", filters={"property": "env", "value": "test"},
))
# Custom properties
props = ws.list_custom_properties()
prop = ws.get_custom_property("abc123")
# Lookup tables
tables = ws.list_lookup_tables()
table = ws.upload_lookup_table(mp.UploadLookupTableParams(
name="Countries", file_path="/path/to/countries.csv",
))
# Custom events
events = ws.list_custom_events()
See the Data Governance guide for complete coverage.
Saved Metrics & Behaviors¶
List, read, create, update, and delete the saved metrics and saved behaviors of the project. Both collections are project-scoped and do not require a workspace ID. One collection holds all three metric kinds (metric, formula, warehouse).
import mixpanel_headless as mp
ws = mp.Workspace()
# Saved metrics: the full server list, then local filters
metrics = ws.list_metrics()
governed = ws.list_metrics(verified=True, viewable_only=True)
metric = ws.get_metric(104700)
metric.math, metric.formula_expression, metric.referenced_metric_ids
# Create and update; the client checks each write before the request
saved = ws.create_metric(mp.CreateMetricParams(
name="Weekly buyers", definition=mp.Metric("Purchase", math="unique"), verified=True,
))
ws.update_metric(saved.id, mp.UpdateMetricParams(display=mp.MetricDisplay(precision=0)))
# Saved behaviors
funnels = ws.list_behaviors(behavior_type="funnel")
# Deletes go through the bulk routes; the single-id forms read first
ws.delete_metric(104700)
ws.delete_behaviors([3001, 3002])
The list includes metrics that the caller cannot view (can_view is False). See the Saved Metrics and Behaviors guide for complete coverage.
Business Context¶
Read and write the markdown documentation that grounds AI assistants. Two scopes (level="organization" shared across the org, level="project" per-project), 50,000-character cap enforced client-side before any HTTP call.
import mixpanel_headless as mp
ws = mp.Workspace()
# Read
project_ctx = ws.get_business_context(level="project")
org_ctx = ws.get_business_context(level="organization") # auto-resolves org_id
# Read both in one round-trip
chain = ws.get_business_context_chain()
# Write (full-replace; pass "" to clear)
ws.set_business_context("# About Acme\n…", level="project")
ws.clear_business_context(level="organization")
Project-scope writes require edit_project_info permission; org-scope writes require edit_project_info at the org level. See the Business Context guide for full coverage of input modes, error handling, and cross-project audit patterns.
workspaces() vs list_workspaces()
Both methods are exposed. workspaces() (recommended) returns list[WorkspaceRef] from the cached /me response — fast, typed, and consistent with events() / properties() / funnels() / cohorts(). list_workspaces() is a lower-level escape hatch that calls GET /api/app/projects/{pid}/workspaces/public directly and returns list[PublicWorkspace].
Session Replay¶
Discover a user's rrweb session recordings, fetch the raw event stream from the signed CDN, and project them into analysis-ready DataFrames. The methods: list_replays, events_for_replay / events_for_replays, sign_replay / sign_replays, fetch_replay / fetch_replays, stream_replay, replays_for_user, and analyze_replay.
import mixpanel_headless as mp
ws = mp.Workspace()
# Discovery + fetch + Mixpanel-event join in one call → a ReplayBundle
bundle = ws.replays_for_user("user-42", from_date="2025-01-01", to_date="2025-01-31")
print(bundle.sessions_df) # one row per session: duration, n_clicks, n_errors
print(bundle.top_clicks(10)) # most-clicked elements (focus interactions excluded)
print(bundle.replays[0].summary_markdown) # LLM-friendly action timeline
# Single replay, with the raw rrweb stream for the JS player
replay = ws.fetch_replay("0190ebde-d50d-71b1-804c-ec1b4a533ef9")
player_json = replay.to_rrweb_player_json()
Signed CDN URLs are bearer credentials: SignedReplay masks them in repr / str and the library never logs them. A SESSION_RECORDING_SENSITIVE_DATA 403 raises SessionReplayAccessError. See the Session Replay guide for the full surface, the mp replays CLI, and the DataFrame schemas.
Report Links¶
Share a headless query as a Mixpanel URL, or turn a URL back into runnable params. The methods: create_report_link, resolve_report_link, query_report_link, and saved_report_link.
import mixpanel_headless as mp
ws = mp.Workspace()
# Query → shareable URL (one App API POST; the slug record is stored server-side)
result = ws.query(mp.Metric("Login", math="total"), last=7)
link = ws.create_report_link(result, name="Logins, last 7 days")
print(link.url) # https://mixpanel.com/project/3/view/75/app/insights#EBrV5bW2u9Mw
# URL / slug / shortlink → raw params → typed result
r = ws.resolve_report_link("https://mixpanel.com/s/AbC123")
r.report_type, r.params
df = ws.query_report_link(r).df
# Saved report → URL, no network call
ws.saved_report_link(123, report_type="funnels")
Region mismatches raise ReportLinkScopeMismatchError before any HTTP call. Project and pinned-workspace mismatches raise it before the record fetch; for a shortlink that is after the one redirect GET. Legacy ~(...) hashes and board links raise UnsupportedReportLinkError with a hint. See the Report Links guide for the mp reports link / mp reports resolve CLI and the --link flags.
In-Session Switching¶
Workspace.use() swaps the active account, project, workspace, or target without rebuilding the underlying httpx.Client or per-account /me cache. It returns self for fluent chaining, so cross-project iteration is O(1) per swap.
import mixpanel_headless as mp
ws = mp.Workspace()
ws.use(account="team") # implicitly clears workspace
ws.use(project="3018488")
ws.use(workspace=3448414)
ws.use(target="ecom") # apply all three at once
# Persist the new state
ws.use(project="3018488", persist=True) # writes [active]
# Read the resolved state
print(ws.account.name, ws.project.id, ws.workspace.id if ws.workspace else None)
print(ws.session) # full Session snapshot
See Auth → Workspace.use() for the resolution semantics and parallel-snapshot patterns.
Class Reference¶
mixpanel_headless.Workspace
¶
Workspace(
*,
account: str | None = None,
project: str | None = None,
workspace: int | None = None,
target: str | None = None,
session: Session | None = None,
_api_client: MixpanelAPIClient | None = None,
)
Unified entry point for Mixpanel data operations.
The Workspace class is a facade that orchestrates: - DiscoveryService for schema exploration - LiveQueryService for real-time analytics - App API client for CRUD and data governance operations
Examples:
Basic usage with credentials from config:
ws = Workspace()
events = ws.events() # discover schema
result = ws.segmentation(event="login", from_date="2024-01-01", to_date="2024-01-31")
ws.close()
Stream events for external processing:
ws = Workspace()
for event in ws.stream_events(from_date="2024-01-01", to_date="2024-01-31"):
process(event)
ws.close()
Create a new Workspace bound to a resolved :class:Session.
Resolution priority follows FR-017: env vars > kwargs > target >
bridge > [active] > Account.default_project. Pass
session= to bypass the resolver and use a pre-built
:class:Session directly.
| PARAMETER | DESCRIPTION |
|---|---|
account
|
Named account from
TYPE:
|
project
|
Project ID override (digit string).
TYPE:
|
workspace
|
Workspace ID override (positive int).
TYPE:
|
target
|
Apply all three axes from
TYPE:
|
session
|
Pre-built :class:
TYPE:
|
_api_client
|
Injected :class:
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
|
ConfigError
|
Account or project axis cannot be resolved. |
OAuthError
|
Auth header construction fails. |
Source code in src/mixpanel_headless/workspace.py
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | |
workspace
property
¶
Return the resolved :class:WorkspaceRef (or None for lazy).
api
property
¶
Direct access to the Mixpanel API client.
Use this escape hatch for Mixpanel API operations not covered by the Workspace class. The client handles authentication automatically.
The client provides
request(method, url, **kwargs): Make authenticated requests to any Mixpanel API endpoint.project_id: The configured project ID for constructing URLs.region: The configured region ('us', 'eu', or 'in').
| RETURNS | DESCRIPTION |
|---|---|
MixpanelAPIClient
|
The underlying MixpanelAPIClient. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Example
Fetch event schema from the Lexicon Schemas API::
import mixpanel_headless as mp
from urllib.parse import quote
ws = mp.Workspace()
client = ws.api
# Build the URL with proper encoding
event_name = quote("Added To Cart", safe="")
url = f"https://mixpanel.com/api/app/projects/{client.project_id}/schemas/event/{event_name}"
# Make the authenticated request
schema = client.request("GET", url)
print(schema)
close
¶
Close all resources (HTTP client).
This method is idempotent and safe to call multiple times.
Source code in src/mixpanel_headless/workspace.py
use
¶
use(
*,
account: str | None = None,
project: str | None = None,
workspace: int | None = None,
target: str | None = None,
persist: bool = False,
) -> Workspace
Swap one or more session axes in place; return self for chaining.
target= is mutually exclusive with account=/project=/
workspace=. The HTTP transport is preserved across all switches
(per Research R5).
use(workspace=<workspace_id>) explicitly pins the workspace:
subsequent Query API and discovery calls carry that workspace ID as
the workspace_id parameter so Mixpanel data view filters apply,
and App API calls scope via /workspaces/{workspace_id}/...
paths. Raw export streaming
(stream_events() / stream_profiles()) remains project-scoped
by design. Swapping the account or project axis clears the pin
(unless a new workspace is supplied), and the lazy discovery service
— including its result cache — is rebuilt on every switch.
When account= is supplied, the project axis re-resolves through
the FR-017 chain ending at the new account's default_project
(env MP_PROJECT_ID > explicit project= > new account's
default_project). If no source provides a project, the call
raises :class:ConfigError per FR-033 — the prior session's
project is NEVER carried forward across an account swap because
cross-account project access is not guaranteed. The workspace
axis is cleared on account swap (workspaces are project-scoped;
the prior workspace doesn't apply to the new project) — explicit
workspace= or MP_WORKSPACE_ID env override is honored.
| PARAMETER | DESCRIPTION |
|---|---|
account
|
Replacement account name.
TYPE:
|
project
|
Replacement project ID.
TYPE:
|
workspace
|
Replacement workspace ID.
TYPE:
|
target
|
Apply this target's three axes atomically.
TYPE:
|
persist
|
When
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Workspace
|
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
Mutually exclusive args
( |
ValueError
|
Referenced name missing. |
OAuthError
|
New auth header construction fails (atomic on success). |
ConfigError
|
|
Source code in src/mixpanel_headless/workspace.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | |
me
¶
Get /me response for current credentials (cached 24h).
Returns the authenticated user's profile including all accessible organizations, projects, and workspaces.
| PARAMETER | DESCRIPTION |
|---|---|
force_refresh
|
If True, bypass cache and call the API.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
MeResponse with user profile, projects, and workspaces. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials lack /me access (401 or 403). |
QueryError
|
If the API returns a non-403 error. |
Example
Source code in src/mixpanel_headless/workspace.py
projects
¶
List all accessible projects via the /me API (FR-035).
Returns projects from the cached /me response, sorted by name. Each
entry is a v3 :class:Project (id + name + organization_id +
timezone), built from the underlying MeProjectInfo payload —
callers iterate for project in ws.projects(): ws.use(project=project.id)
per the documented cross-project iteration pattern.
Replaces the deprecated discover_projects() (which returned
list[tuple[str, MeProjectInfo]]) — for the raw /me shape
with extra fields (has_workspaces, domain, type, ...),
call self._me_svc.list_projects() directly from internal code.
| PARAMETER | DESCRIPTION |
|---|---|
refresh
|
When True, bypass the on-disk and in-memory
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Project]
|
List of :class: |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials lack /me access. |
Example
Source code in src/mixpanel_headless/workspace.py
workspaces
¶
List workspaces for a project via the /me API (FR-036).
Returns workspaces from the cached /me response, sorted by name.
Defaults to the current project if project_id is not provided.
Replaces the deprecated discover_workspaces() (which returned
list[MeWorkspaceInfo]) — for the raw /me shape with extra
fields (is_global, is_restricted, description, ...),
call self._me_svc.list_workspaces(project_id=) directly from
internal code.
| PARAMETER | DESCRIPTION |
|---|---|
project_id
|
Project ID to list workspaces for. Defaults to the current project.
TYPE:
|
refresh
|
When True, bypass the on-disk and in-memory
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[WorkspaceRef]
|
List of :class: |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials lack /me access. |
Example
Source code in src/mixpanel_headless/workspace.py
list_workspaces
¶
List all public workspaces for the current project.
Delegates to the API client's list_workspaces() method, which
calls GET /api/app/projects/{pid}/workspaces/public.
| RETURNS | DESCRIPTION |
|---|---|
list[PublicWorkspace]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
resolve_workspace_id
¶
Resolve the workspace ID for scoped requests.
Resolution order:
1. Workspace ID already pinned on the resolved session (for example
via Workspace(workspace=N), Workspace.use(workspace=N),
MP_WORKSPACE_ID, saved targets, bridge pins, or persisted
[active].workspace state)
2. Cached auto-discovered workspace ID
3. Auto-discover across the cached /me view, then
GET /projects/{pid}/workspaces/public, then the projects metadata
index — each applying the shared preference of
:func:~mixpanel_headless._internal.me.select_workspace_id (global
view, then "All Project Data", then default, then first visible, then
first). See :meth:MixpanelAPIClient.resolve_workspace_id for the
full source-by-source rules and error behavior.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The resolved workspace ID. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
WorkspaceScopeError
|
If no workspace could be resolved for the project from any source. |
Source code in src/mixpanel_headless/workspace.py
events
¶
events(
*,
limit: int | None = None,
from_date: str | None = None,
to_date: str | None = None,
) -> list[str]
List event names in the Mixpanel project.
Defaults to the widest window the underlying
/events/names endpoint will accept: limit=5000 (the
server-side ceiling), from_date=2000-01-01 (the API's
earliest accepted year — pre-2000 values come back as
"invalid date, bad year"), and to_date set to today.
The endpoint is gated by the per-project
max_data_history_days feature; if the wide from_date
is rejected (HTTP 403, "Date range exceeds N days into the
past"), the call automatically retries with today - N days.
Note that this method reflects events seen during the queried
window — it is not the schema registry. Events that were
registered in Lexicon but never fired in the window are
absent. For the full registered schema, use the Lexicon
endpoints (e.g. :meth:get_event_definitions).
Results are cached per (limit, from_date, to_date) triple
for the lifetime of the Workspace.
| PARAMETER | DESCRIPTION |
|---|---|
limit
|
Maximum events to return. Defaults to the server-side ceiling (5000).
TYPE:
|
from_date
|
TYPE:
|
to_date
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Alphabetically sorted list of event names. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
AuthenticationError
|
If credentials are invalid. |
QueryError
|
403 errors unrelated to date-range gating, or
any other 4xx the |
Source code in src/mixpanel_headless/workspace.py
properties
¶
List all property names for an event.
Results are cached per event for the lifetime of the Workspace.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name to get properties for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Alphabetically sorted list of property names. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
property_values
¶
Get sample values for a property.
Results are cached per (property, event, limit) for the lifetime of the Workspace.
| PARAMETER | DESCRIPTION |
|---|---|
property_name
|
Property to get values for.
TYPE:
|
event
|
Optional event to filter by.
TYPE:
|
limit
|
Maximum number of values to return.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of sample property values as strings. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
subproperties
¶
subproperties(
property_name: str, *, event: str | None = None, sample_size: int = 50
) -> list[SubPropertyInfo]
List inferred subproperties of a list-of-object event property.
Samples values via :meth:property_values, parses each as JSON,
and returns one :class:SubPropertyInfo per discovered scalar
subproperty. Designed for properties like cart whose values
are objects with subkeys (Brand, Category, Price,
Item ID). The returned name and type plug directly
into :meth:GroupBy.list_item and :meth:Filter.list_contains.
Scope: only scalar subproperty values (string / number /
boolean / ISO datetime string) are reported. Subproperties whose
values are themselves dicts or lists are silently skipped — they
cannot be used by GroupBy.list_item or
Filter.list_contains anyway.
| PARAMETER | DESCRIPTION |
|---|---|
property_name
|
Top-level list-of-object property name (e.g.
TYPE:
|
event
|
Optional event name to scope the sample. Strongly recommended; without it the API may return values from across all events.
TYPE:
|
sample_size
|
Number of raw values to sample. Default: 50.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[SubPropertyInfo]
|
Alphabetically sorted list of :class: |
list[SubPropertyInfo]
|
Empty list if no parseable dict values were found. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials cannot be resolved. |
AuthenticationError
|
If credentials are configured but rejected by Mixpanel. |
| WARNS | DESCRIPTION |
|---|---|
UserWarning
|
When a subproperty has values of mixed scalar
types across rows (collapses to |
Example
Source code in src/mixpanel_headless/workspace.py
funnels
¶
List saved funnels in the Mixpanel project.
Results are cached for the lifetime of the Workspace.
| RETURNS | DESCRIPTION |
|---|---|
list[FunnelInfo]
|
List of FunnelInfo objects (funnel_id, name). |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
cohorts
¶
List saved cohorts in the Mixpanel project.
Results are cached for the lifetime of the Workspace.
| RETURNS | DESCRIPTION |
|---|---|
list[SavedCohort]
|
List of SavedCohort objects. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
list_bookmarks
¶
List all saved reports (bookmarks) in the project.
Retrieves metadata for all saved Insights, Funnel, Retention, and Flows reports in the project.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_type
|
Optional filter by report type. Valid values are 'insights', 'funnels', 'retention', 'flows', 'launch-analysis'. If None, returns all bookmark types.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[BookmarkInfo]
|
List of BookmarkInfo objects with report metadata. |
list[BookmarkInfo]
|
Empty list if no bookmarks exist. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
QueryError
|
Permission denied or invalid type parameter. |
Source code in src/mixpanel_headless/workspace.py
top_events
¶
top_events(
*,
type: Literal["general", "average", "unique"] = "general",
limit: int | None = None,
) -> list[TopEvent]
Get today's most active events.
This method is NOT cached (returns real-time data).
| PARAMETER | DESCRIPTION |
|---|---|
type
|
Counting method (general, average, unique).
TYPE:
|
limit
|
Maximum number of events to return.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[TopEvent]
|
List of TopEvent objects with |
list[TopEvent]
|
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Example
Source code in src/mixpanel_headless/workspace.py
lexicon_schemas
¶
List Lexicon schemas in the project.
Retrieves documented event and profile property schemas from the Mixpanel Lexicon (data dictionary).
Results are cached for the lifetime of the Workspace.
| PARAMETER | DESCRIPTION |
|---|---|
entity_type
|
Optional filter by type ("event" or "profile"). If None, returns all schemas.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[LexiconSchema]
|
Alphabetically sorted list of LexiconSchema objects. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
AuthenticationError
|
If credentials are invalid. |
Note
The Lexicon API has a strict 5 requests/minute rate limit. Caching helps avoid hitting this limit; call clear_discovery_cache() only when fresh data is needed.
Source code in src/mixpanel_headless/workspace.py
lexicon_schema
¶
Get a single Lexicon schema by entity type and name.
Retrieves a documented schema for a specific event or profile property from the Mixpanel Lexicon (data dictionary).
Results are cached for the lifetime of the Workspace.
| PARAMETER | DESCRIPTION |
|---|---|
entity_type
|
Entity type ("event" or "profile").
TYPE:
|
name
|
Entity name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LexiconSchema
|
LexiconSchema for the specified entity. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
AuthenticationError
|
If credentials are invalid. |
QueryError
|
If schema not found. |
Note
The Lexicon API has a strict 5 requests/minute rate limit. Caching helps avoid hitting this limit; call clear_discovery_cache() only when fresh data is needed.
Source code in src/mixpanel_headless/workspace.py
schema_graph
¶
schema_graph(
*,
include_density: bool = False,
include_user_properties: bool = True,
force_refresh: bool = False,
) -> SchemaGraphResult
Gather the full Lexicon schema and event<->property relationships.
Adapts the power-tools getSchema view: one call returns the project's
event definitions, event properties, and user properties, plus the
adjacency between events and the properties that appear on them. The
adjacency comes from the query API's per-event properties gather, which
tolerates large projects (the App API join it replaces timed out at the
~120s gateway deadline); on very large projects the gather can still
take minutes. The result is a typed :class:SchemaGraphResult with
DataFrame views (events_df, properties_df,
relationships_df) and a to_graph() networkx export.
Group properties are not gathered yet (headless has no data-groups listing to enumerate them).
Results are cached for the lifetime of the Workspace.
| PARAMETER | DESCRIPTION |
|---|---|
include_density
|
Request the property-level density (
TYPE:
|
include_user_properties
|
Also gather user properties.
TYPE:
|
force_refresh
|
Bypass the cache and re-fetch.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
A
|
class:
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials are not available. |
AuthenticationError
|
If credentials are invalid. |
Example
Source code in src/mixpanel_headless/workspace.py
clear_discovery_cache
¶
Clear cached discovery results.
Subsequent discovery calls will fetch fresh data from the API.
stream_events
¶
stream_events(
*,
from_date: str,
to_date: str,
events: list[str] | None = None,
where: str | None = None,
limit: int | None = None,
raw: bool = False,
) -> Iterator[dict[str, Any]]
Stream events directly from Mixpanel API without storing.
Yields events one at a time as they are received from the API. No database files or tables are created.
| PARAMETER | DESCRIPTION |
|---|---|
from_date
|
Start date inclusive (YYYY-MM-DD format).
TYPE:
|
to_date
|
End date inclusive (YYYY-MM-DD format).
TYPE:
|
events
|
Optional list of event names to filter. If None, all events returned.
TYPE:
|
where
|
Optional Mixpanel filter expression (e.g., 'properties["country"]=="US"').
TYPE:
|
limit
|
Optional maximum number of events to return (max 100000).
TYPE:
|
raw
|
If True, return events in raw Mixpanel API format. If False (default), return normalized format with datetime objects.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
dict[str, Any]
|
dict[str, Any]: Event dictionaries in normalized or raw format. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials are not available. |
AuthenticationError
|
If credentials are invalid. |
RateLimitError
|
If rate limit exceeded after max retries. |
QueryError
|
If filter expression is invalid. |
ValueError
|
If limit is outside valid range (1-100000). |
Example
ws = Workspace()
for event in ws.stream_events(from_date="2024-01-01", to_date="2024-01-31"):
process(event)
ws.close()
With raw format:
Source code in src/mixpanel_headless/workspace.py
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 | |
stream_profiles
¶
stream_profiles(
*,
where: str | None = None,
cohort_id: str | None = None,
output_properties: list[str] | None = None,
raw: bool = False,
distinct_id: str | None = None,
distinct_ids: list[str] | None = None,
group_id: str | None = None,
behaviors: list[dict[str, Any]] | None = None,
as_of_timestamp: int | None = None,
include_all_users: bool = False,
) -> Iterator[dict[str, Any]]
Stream user profiles directly from Mixpanel API without storing.
Yields profiles one at a time as they are received from the API. No database files or tables are created.
| PARAMETER | DESCRIPTION |
|---|---|
where
|
Optional Mixpanel filter expression for profile properties.
TYPE:
|
cohort_id
|
Optional cohort ID to filter by. Only profiles that are members of this cohort will be returned.
TYPE:
|
output_properties
|
Optional list of property names to include in the response. If None, all properties are returned.
TYPE:
|
raw
|
If True, return profiles in raw Mixpanel API format. If False (default), return normalized format.
TYPE:
|
distinct_id
|
Optional single user ID to fetch. Mutually exclusive with distinct_ids.
TYPE:
|
distinct_ids
|
Optional list of user IDs to fetch. Mutually exclusive with distinct_id. Duplicates are automatically removed.
TYPE:
|
group_id
|
Optional group type identifier (e.g., "companies") to fetch group profiles instead of user profiles.
TYPE:
|
behaviors
|
Optional list of behavioral filters. Each dict should have
'window' (e.g., "30d"), 'name' (identifier), and 'event_selectors'
(list of {"event": "Name"}). Use with
TYPE:
|
as_of_timestamp
|
Optional Unix timestamp to query profile state at a specific point in time. Must be in the past.
TYPE:
|
include_all_users
|
If True, include all users and mark cohort membership. Only valid when cohort_id is provided.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
dict[str, Any]
|
dict[str, Any]: Profile dictionaries in normalized or raw format. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials are not available. |
AuthenticationError
|
If credentials are invalid. |
RateLimitError
|
If rate limit exceeded after max retries. |
ValueError
|
If mutually exclusive parameters are provided. |
Example
Filter to premium users:
Filter by cohort and select specific properties:
for profile in ws.stream_profiles(
cohort_id="12345",
output_properties=["$email", "$name"]
):
send_email(profile)
Fetch specific users by ID:
Fetch group profiles:
Source code in src/mixpanel_headless/workspace.py
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 | |
get_business_context
¶
get_business_context(
*,
level: Literal["organization", "project"] = "project",
organization_id: int | None = None,
) -> BusinessContext
Read business context content at the given scope.
Calls GET /api/app/projects/{pid}/business-context (when
level="project") or
GET /api/app/organizations/{org_id}/business-context
(when level="organization"). Returns a populated
BusinessContext with content="" when no context is set.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
TYPE:
|
organization_id
|
Optional explicit org ID, only honored
when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BusinessContext
|
|
BusinessContext
|
current state. |
BusinessContext
|
org-level returns; |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
ConfigError
|
Credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400, 403, 404). |
ServerError
|
Server-side errors (5xx). |
WorkspaceScopeError
|
|
MixpanelHeadlessError
|
API response is missing the |
Example
Source code in src/mixpanel_headless/workspace.py
11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 | |
set_business_context
¶
set_business_context(
content: str,
*,
level: Literal["organization", "project"] = "project",
organization_id: int | None = None,
) -> BusinessContext
Replace business context content at the given scope.
Validates len(content) <= BUSINESS_CONTEXT_MAX_CHARS (50,000)
client-side BEFORE the HTTP call so callers fail fast and avoid
a wasted round-trip to the server (which enforces the same limit
and returns 400 above it). Then calls
PUT /api/app/projects/{pid}/business-context (project) or
PUT /api/app/organizations/{org_id}/business-context (org).
The PUT is full-replace — pass an empty string to clear (or use
clear_business_context for clarity).
| PARAMETER | DESCRIPTION |
|---|---|
content
|
New markdown content. Empty string clears the context at this scope.
TYPE:
|
level
|
TYPE:
|
organization_id
|
Optional explicit org ID, only honored
when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BusinessContext
|
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
BusinessContextValidationError
|
|
ConfigError
|
Credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Caller lacks |
ServerError
|
Server-side errors (5xx). |
WorkspaceScopeError
|
|
MixpanelHeadlessError
|
API response is missing the |
Example
Source code in src/mixpanel_headless/workspace.py
11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 | |
clear_business_context
¶
clear_business_context(
*,
level: Literal["organization", "project"] = "project",
organization_id: int | None = None,
) -> BusinessContext
Clear business context at the given scope.
Convenience wrapper that calls
set_business_context("", level=..., organization_id=...).
Useful for documenting intent — equivalent to passing an empty
string explicitly.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
TYPE:
|
organization_id
|
Optional explicit org ID for
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BusinessContext
|
|
BusinessContext
|
echoed back from the server). |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
ConfigError
|
Credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Caller lacks |
ServerError
|
Server-side errors (5xx). |
WorkspaceScopeError
|
|
Source code in src/mixpanel_headless/workspace.py
get_business_context_chain
¶
Read both organization and project business context together.
Issues exactly one App API request to
GET /api/app/projects/{pid}/business-context/chain —
a server-side convenience that returns both scopes for the
active project. organization.organization_id is populated
on a best-effort basis from the cached /me response (in-memory
or disk); when the cache is cold it is left as None rather
than triggering an extra /me round-trip. Callers that need a
guaranteed org ID should use get_business_context(level=
"organization"), which performs full resolution.
| RETURNS | DESCRIPTION |
|---|---|
BusinessContextChain
|
|
BusinessContextChain
|
|
BusinessContextChain
|
context is set at that scope. |
BusinessContextChain
|
|
BusinessContextChain
|
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
Credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Caller lacks project access (403, 404) or other API error (400). |
ServerError
|
Server-side errors (5xx). |
MixpanelHeadlessError
|
API response is missing |
Example
Source code in src/mixpanel_headless/workspace.py
12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 | |
query
¶
query(
events: str
| Metric
| CohortMetric
| FunnelMetric
| RetentionMetric
| MetricRef
| SavedMetric
| Formula
| Sequence[
str
| Metric
| CohortMetric
| FunnelMetric
| RetentionMetric
| MetricRef
| SavedMetric
| Formula
],
*,
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
unit: QueryTimeUnit = "day",
math: MathType = "total",
math_property: str | None = None,
per_user: PerUserAggregation | None = None,
percentile_value: int | float | None = None,
group_by: str
| GroupBy
| CohortBreakdown
| FrequencyBreakdown
| list[str | GroupBy | CohortBreakdown | FrequencyBreakdown]
| None = None,
where: Filter
| FrequencyFilter
| list[Filter | FrequencyFilter]
| None = None,
formula: str | None = None,
formula_label: str | None = None,
rolling: int | None = None,
cumulative: bool = False,
mode: Literal["timeseries", "total", "table"] = "timeseries",
time_comparison: TimeComparison | None = None,
data_group_id: int | None = None,
limit: int | None = None,
) -> QueryResult
Run a typed insights query against the Mixpanel API.
Generates bookmark params from keyword arguments, POSTs them inline
to /api/query/insights, and returns a structured QueryResult
with lazy DataFrame conversion.
| PARAMETER | DESCRIPTION |
|---|---|
events
|
Event name(s) to query. Accepts a single string,
a Metric object, a CohortMetric object, a FunnelMetric,
a RetentionMetric, a MetricRef or a SavedMetric (from
TYPE:
|
from_date
|
Start date (YYYY-MM-DD). If set, overrides
TYPE:
|
to_date
|
End date (YYYY-MM-DD). Requires
TYPE:
|
last
|
Relative time range in days. Default: 30.
Ignored if
TYPE:
|
unit
|
Time aggregation unit. Default:
TYPE:
|
math
|
Aggregation function for plain-string events.
Default:
TYPE:
|
math_property
|
Property name for property-based math (average, sum, percentiles).
TYPE:
|
per_user
|
Per-user pre-aggregation (average, total, min, max).
TYPE:
|
percentile_value
|
Custom percentile value (e.g. 95 for p95).
Required when
TYPE:
|
group_by
|
Break down results by property or cohort membership.
Accepts a string,
TYPE:
|
where
|
Filter results by conditions. Accepts a Filter, a
FrequencyFilter, or a list mixing both. A
TYPE:
|
formula
|
Formula expression referencing events by position
(A, B, C...). Requires 2+ events. Cannot be combined
with Formula objects in
TYPE:
|
formula_label
|
Display label for formula result.
TYPE:
|
rolling
|
Rolling window size in periods.
Mutually exclusive with
TYPE:
|
cumulative
|
Enable cumulative analysis mode.
Mutually exclusive with
TYPE:
|
mode
|
Result shape.
TYPE:
|
time_comparison
|
Optional period-over-period comparison.
Use
TYPE:
|
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
limit
|
Segments to return, 1 to 50000. Default
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QueryResult
|
QueryResult with series data, DataFrame, and metadata. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If arguments violate validation rules. |
ParamValidationError
|
|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid query parameters. |
RateLimitError
|
Rate limit exceeded. |
Example
ws = Workspace()
# Simple event query
result = ws.query("Login")
print(result.df.head())
# With aggregation and time range
result = ws.query("Login", math="unique", last=7, unit="day")
# Multi-event with formula (top-level parameter)
result = ws.query(
[Metric("Signup", math="unique"), Metric("Purchase", math="unique")],
formula="(B / A) * 100",
formula_label="Conversion Rate",
)
# Multi-event with formula (Formula in list)
result = ws.query(
[Metric("Signup", math="unique"),
Metric("Purchase", math="unique"),
Formula("(B / A) * 100", label="Conversion Rate")],
)
# A saved metric by id, with a report-level override
result = ws.query(MetricRef(88999, segment_method="first"))
Source code in src/mixpanel_headless/workspace.py
2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 | |
build_params
¶
build_params(
events: str
| Metric
| CohortMetric
| FunnelMetric
| RetentionMetric
| MetricRef
| SavedMetric
| Formula
| Sequence[
str
| Metric
| CohortMetric
| FunnelMetric
| RetentionMetric
| MetricRef
| SavedMetric
| Formula
],
*,
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
unit: QueryTimeUnit = "day",
math: MathType = "total",
math_property: str | None = None,
per_user: PerUserAggregation | None = None,
percentile_value: int | float | None = None,
group_by: str
| GroupBy
| CohortBreakdown
| FrequencyBreakdown
| list[str | GroupBy | CohortBreakdown | FrequencyBreakdown]
| None = None,
where: Filter
| FrequencyFilter
| list[Filter | FrequencyFilter]
| None = None,
formula: str | None = None,
formula_label: str | None = None,
rolling: int | None = None,
cumulative: bool = False,
mode: Literal["timeseries", "total", "table"] = "timeseries",
time_comparison: TimeComparison | None = None,
data_group_id: int | None = None,
) -> dict[str, Any]
Build validated bookmark params without executing the API call.
Has the same signature as :meth:query but returns the generated
bookmark params dict instead of querying the Mixpanel API. Useful
for debugging, inspecting generated JSON, persisting via
:meth:create_bookmark, or testing.
| PARAMETER | DESCRIPTION |
|---|---|
events
|
Event name(s) to query. Accepts a single string,
a
TYPE:
|
from_date
|
Start date (YYYY-MM-DD). If set, overrides
TYPE:
|
to_date
|
End date (YYYY-MM-DD). Requires
TYPE:
|
last
|
Relative time range in days. Default: 30.
TYPE:
|
unit
|
Time aggregation unit. Default:
TYPE:
|
math
|
Aggregation function for plain-string events.
Default:
TYPE:
|
math_property
|
Property name for property-based math.
TYPE:
|
per_user
|
Per-user pre-aggregation.
TYPE:
|
percentile_value
|
Custom percentile value (e.g. 95).
Required when
TYPE:
|
group_by
|
Break down results by property or cohort membership.
Accepts a string,
TYPE:
|
where
|
Filter results by conditions. A
TYPE:
|
formula
|
Formula expression referencing events by position.
TYPE:
|
formula_label
|
Display label for formula result.
TYPE:
|
rolling
|
Rolling window size in periods.
TYPE:
|
cumulative
|
Enable cumulative analysis mode.
TYPE:
|
mode
|
Result shape. Default:
TYPE:
|
time_comparison
|
Optional period-over-period comparison.
Use
TYPE:
|
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Bookmark params dict with |
dict[str, Any]
|
keys, ready for use with the insights API or |
dict[str, Any]
|
meth: |
| RAISES | DESCRIPTION |
|---|---|
BookmarkValidationError
|
If arguments violate validation rules. |
ParamValidationError
|
|
Example
ws = Workspace()
# Inspect generated bookmark JSON
params = ws.build_params("Login", math="unique", last=7)
print(json.dumps(params, indent=2))
# Save as a bookmark (dashboard_id required)
ws.create_bookmark(CreateBookmarkParams(
name="Daily Unique Logins",
bookmark_type="insights",
params=params,
dashboard_id=12345,
))
Source code in src/mixpanel_headless/workspace.py
2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 | |
run_params
¶
run_params(
params: dict[str, Any],
*,
limit: int | None = None,
workspace_id: int | None = None,
) -> QueryResult
Run pre-built insights bookmark params against the Mixpanel API.
The execution half of :meth:build_params. Use it when the params
need editing before they run, or when they express something the
typed builders do not cover, such as a lookup-table join breakdown.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Bookmark params dict, normally from
:meth:
TYPE:
|
limit
|
Segments to return, 1 to 50000. Default
TYPE:
|
workspace_id
|
Optional data view to run under. Wins over the pinned session workspace.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QueryResult
|
QueryResult with series data, DataFrame, and metadata. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid bookmark params. |
RateLimitError
|
Rate limit exceeded. |
Example
Source code in src/mixpanel_headless/workspace.py
query_funnel
¶
query_funnel(
steps: list[str | FunnelStep] | BehaviorRef | SavedBehavior,
*,
conversion_window: int = 14,
conversion_window_unit: Literal[
"second", "minute", "hour", "day", "week", "month", "session"
] = "day",
order: Literal["loose", "any"] = "loose",
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
unit: QueryTimeUnit = "day",
math: FunnelMathType = "conversion_rate_unique",
math_property: str | None = None,
group_by: str
| GroupBy
| CohortBreakdown
| list[str | GroupBy | CohortBreakdown]
| None = None,
where: Filter | list[Filter] | None = None,
exclusions: list[str | Exclusion] | None = None,
holding_constant: str
| HoldingConstant
| list[str | HoldingConstant]
| None = None,
mode: Literal["steps", "trends", "table"] = "steps",
reentry_mode: FunnelReentryMode | None = None,
time_comparison: TimeComparison | None = None,
data_group_id: int | None = None,
limit: int | None = None,
) -> FunnelQueryResult
Run a typed funnel query against the Mixpanel API.
Generates funnel bookmark params from keyword arguments, POSTs
them inline to /api/query/insights, and returns a structured
FunnelQueryResult with lazy DataFrame conversion.
| PARAMETER | DESCRIPTION |
|---|---|
steps
|
Funnel step specifications. At least 2 required.
Accepts event name strings or
TYPE:
|
conversion_window
|
How long users have to complete the funnel. Default: 14.
TYPE:
|
conversion_window_unit
|
Time unit for conversion window.
Default:
TYPE:
|
order
|
Step ordering mode.
TYPE:
|
from_date
|
Start date (YYYY-MM-DD). If set, overrides
TYPE:
|
to_date
|
End date (YYYY-MM-DD). Requires
TYPE:
|
last
|
Relative time range in days. Default: 30.
TYPE:
|
unit
|
Time aggregation unit. Default:
TYPE:
|
math
|
Funnel aggregation function. Default:
TYPE:
|
math_property
|
Numeric property name for property-aggregation
math types (
TYPE:
|
group_by
|
Break down results by property or cohort
membership. Accepts a string,
TYPE:
|
where
|
Filter results by conditions. |
exclusions
|
Events to exclude between steps. Accepts
event name strings or
TYPE:
|
holding_constant
|
Properties to hold constant across
steps. Accepts strings,
TYPE:
|
mode
|
Result display mode.
TYPE:
|
reentry_mode
|
Funnel reentry mode controlling how users
re-enter the funnel after conversion. One of
TYPE:
|
time_comparison
|
Optional period-over-period comparison.
Use
TYPE:
|
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
limit
|
Segments to return, 1 to 50000. Default
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FunnelQueryResult
|
FunnelQueryResult with step data, DataFrame, and metadata. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
BookmarkValidationError
|
If arguments violate validation rules (before API call). |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid query parameters. |
RateLimitError
|
Rate limit exceeded. |
Example
ws = Workspace()
# Simple two-step funnel
result = ws.query_funnel(["Signup", "Purchase"])
print(result.overall_conversion_rate)
# Configured funnel
result = ws.query_funnel(
["Signup", "Add to Cart", "Checkout", "Purchase"],
conversion_window=7,
order="loose",
last=90,
)
print(result.df)
# A saved funnel behavior by id
result = ws.query_funnel(BehaviorRef(3120, "funnel"), last=90)
Source code in src/mixpanel_headless/workspace.py
3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 | |
build_funnel_params
¶
build_funnel_params(
steps: list[str | FunnelStep] | BehaviorRef | SavedBehavior,
*,
conversion_window: int = 14,
conversion_window_unit: Literal[
"second", "minute", "hour", "day", "week", "month", "session"
] = "day",
order: Literal["loose", "any"] = "loose",
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
unit: QueryTimeUnit = "day",
math: FunnelMathType = "conversion_rate_unique",
math_property: str | None = None,
group_by: str
| GroupBy
| CohortBreakdown
| list[str | GroupBy | CohortBreakdown]
| None = None,
where: Filter | list[Filter] | None = None,
exclusions: list[str | Exclusion] | None = None,
holding_constant: str
| HoldingConstant
| list[str | HoldingConstant]
| None = None,
mode: Literal["steps", "trends", "table"] = "steps",
reentry_mode: FunnelReentryMode | None = None,
time_comparison: TimeComparison | None = None,
data_group_id: int | None = None,
) -> dict[str, Any]
Build validated funnel bookmark params without executing.
Has the same signature as :meth:query_funnel but returns the
generated bookmark params dict instead of querying the API.
Useful for debugging, inspecting generated JSON, persisting
via :meth:create_bookmark, or testing.
| PARAMETER | DESCRIPTION |
|---|---|
steps
|
Funnel step specifications. At least 2 required.
A
TYPE:
|
conversion_window
|
Conversion window size. Default: 14.
TYPE:
|
conversion_window_unit
|
Time unit. Default:
TYPE:
|
order
|
Step ordering mode. Default:
TYPE:
|
from_date
|
Start date (YYYY-MM-DD) or None.
TYPE:
|
to_date
|
End date (YYYY-MM-DD) or None.
TYPE:
|
last
|
Relative time range in days. Default: 30.
TYPE:
|
unit
|
Time aggregation unit. Default:
TYPE:
|
math
|
Aggregation function. Default:
TYPE:
|
math_property
|
Numeric property name for property-aggregation
math types. Required for
TYPE:
|
group_by
|
Break down results by property or cohort
membership. Accepts a string,
TYPE:
|
where
|
Filter results by conditions. |
exclusions
|
Events to exclude between steps.
TYPE:
|
holding_constant
|
Properties to hold constant.
TYPE:
|
mode
|
Display mode. Default:
TYPE:
|
reentry_mode
|
Funnel reentry mode controlling how users
re-enter the funnel after conversion. One of
TYPE:
|
time_comparison
|
Optional period-over-period comparison.
Use
TYPE:
|
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Bookmark params dict with |
dict[str, Any]
|
|
| RAISES | DESCRIPTION |
|---|---|
BookmarkValidationError
|
If arguments violate validation rules. |
Example
ws = Workspace()
# Inspect generated JSON
params = ws.build_funnel_params(["Signup", "Purchase"])
print(json.dumps(params, indent=2))
# Save as a report (dashboard_id required)
ws.create_bookmark(CreateBookmarkParams(
name="Signup → Purchase Funnel",
bookmark_type="funnels",
params=params,
dashboard_id=12345,
))
Source code in src/mixpanel_headless/workspace.py
3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 | |
run_funnel_params
¶
run_funnel_params(
params: dict[str, Any],
*,
limit: int | None = None,
workspace_id: int | None = None,
) -> FunnelQueryResult
Run pre-built funnel bookmark params against the Mixpanel API.
The execution half of :meth:build_funnel_params.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Funnel bookmark params dict, normally from
:meth:
TYPE:
|
limit
|
Segments to return, 1 to 50000. Default
TYPE:
|
workspace_id
|
Optional data view to run under. Wins over the pinned session workspace.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FunnelQueryResult
|
FunnelQueryResult with step data, DataFrame, and metadata. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid bookmark params. |
RateLimitError
|
Rate limit exceeded. |
Example
Source code in src/mixpanel_headless/workspace.py
query_retention
¶
query_retention(
born_event: str | RetentionEvent | BehaviorRef | SavedBehavior,
return_event: str | RetentionEvent | None = None,
*,
retention_unit: TimeUnit = "week",
alignment: RetentionAlignment = "birth",
bucket_sizes: list[int] | None = None,
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
unit: QueryTimeUnit = "day",
math: RetentionMathType = "retention_rate",
group_by: str
| GroupBy
| CohortBreakdown
| list[str | GroupBy | CohortBreakdown]
| None = None,
where: Filter | list[Filter] | None = None,
mode: RetentionMode = "curve",
unbounded_mode: RetentionUnboundedMode | None = None,
retention_cumulative: bool = False,
time_comparison: TimeComparison | None = None,
data_group_id: int | None = None,
limit: int | None = None,
) -> RetentionQueryResult
Run a typed retention query against the Mixpanel API.
Generates retention bookmark params from keyword arguments, POSTs
them inline to /api/query/insights, and returns a structured
RetentionQueryResult with lazy DataFrame conversion.
| PARAMETER | DESCRIPTION |
|---|---|
born_event
|
Event that defines cohort membership. Accepts
an event name string or a
TYPE:
|
return_event
|
Event that defines return. Accepts an event
name string or a
TYPE:
|
retention_unit
|
Retention period unit. Default:
TYPE:
|
alignment
|
Retention alignment mode. Default:
TYPE:
|
bucket_sizes
|
Custom bucket sizes (positive ints in
ascending order). Default:
TYPE:
|
from_date
|
Start date (YYYY-MM-DD). If set, overrides
TYPE:
|
to_date
|
End date (YYYY-MM-DD). Requires
TYPE:
|
last
|
Relative time range in days. Default: 30.
TYPE:
|
unit
|
Time aggregation unit (
TYPE:
|
math
|
Retention aggregation function. Default:
TYPE:
|
group_by
|
Break down results by property or cohort
membership. Accepts a string,
TYPE:
|
where
|
Filter results by conditions. |
mode
|
Result display mode. Default:
TYPE:
|
unbounded_mode
|
Retention unbounded mode controlling how
retention is counted in unbounded periods. One of
TYPE:
|
retention_cumulative
|
Whether to use cumulative retention
counting. Default:
TYPE:
|
time_comparison
|
Optional period-over-period comparison.
Use
TYPE:
|
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
limit
|
Segments to return, 1 to 50000. Default
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RetentionQueryResult
|
RetentionQueryResult with cohort data, DataFrame, and |
RetentionQueryResult
|
metadata. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
BookmarkValidationError
|
If arguments violate validation rules (before API call). |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid query parameters. |
RateLimitError
|
Rate limit exceeded. |
Example
ws = Workspace()
# Simple retention query
result = ws.query_retention("Signup", "Login")
print(result.average)
# With configuration
result = ws.query_retention(
"Signup", "Login",
retention_unit="day",
bucket_sizes=[1, 3, 7, 14, 30],
last=90,
)
print(result.df)
# A saved retention behavior by id
result = ws.query_retention(BehaviorRef(4410, "retention"))
Source code in src/mixpanel_headless/workspace.py
4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 | |
build_retention_params
¶
build_retention_params(
born_event: str | RetentionEvent | BehaviorRef | SavedBehavior,
return_event: str | RetentionEvent | None = None,
*,
retention_unit: TimeUnit = "week",
alignment: RetentionAlignment = "birth",
bucket_sizes: list[int] | None = None,
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
unit: QueryTimeUnit = "day",
math: RetentionMathType = "retention_rate",
group_by: str
| GroupBy
| CohortBreakdown
| list[str | GroupBy | CohortBreakdown]
| None = None,
where: Filter | list[Filter] | None = None,
mode: RetentionMode = "curve",
unbounded_mode: RetentionUnboundedMode | None = None,
retention_cumulative: bool = False,
time_comparison: TimeComparison | None = None,
data_group_id: int | None = None,
) -> dict[str, Any]
Build validated retention bookmark params without executing.
Accepts the same arguments as :meth:query_retention but returns
the generated bookmark params dict (not a
RetentionQueryResult) instead of querying the API. Useful for
debugging, inspecting generated JSON, persisting via
:meth:create_bookmark, or testing.
| PARAMETER | DESCRIPTION |
|---|---|
born_event
|
Event that defines cohort membership, or a
TYPE:
|
return_event
|
Event that defines return. Required unless
TYPE:
|
retention_unit
|
Retention period unit. Default:
TYPE:
|
alignment
|
Retention alignment mode. Default:
TYPE:
|
bucket_sizes
|
Custom bucket sizes. Default:
TYPE:
|
from_date
|
Start date (YYYY-MM-DD) or None.
TYPE:
|
to_date
|
End date (YYYY-MM-DD) or None.
TYPE:
|
last
|
Relative time range in days. Default: 30.
TYPE:
|
unit
|
Time aggregation unit (
TYPE:
|
math
|
Aggregation function. Default:
TYPE:
|
group_by
|
Break down results by property or cohort
membership. Accepts a string,
TYPE:
|
where
|
Filter results by conditions. |
mode
|
Display mode. Default:
TYPE:
|
unbounded_mode
|
Retention unbounded mode controlling how
retention is counted in unbounded periods. One of
TYPE:
|
retention_cumulative
|
Whether to use cumulative retention
counting. Default:
TYPE:
|
time_comparison
|
Optional period-over-period comparison.
Use
TYPE:
|
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Bookmark params dict with |
dict[str, Any]
|
|
| RAISES | DESCRIPTION |
|---|---|
BookmarkValidationError
|
If arguments violate validation rules. |
Example
ws = Workspace()
# Inspect generated JSON
params = ws.build_retention_params("Signup", "Login")
print(json.dumps(params, indent=2))
# Save as a report (dashboard_id required)
ws.create_bookmark(CreateBookmarkParams(
name="Signup → Login Retention",
bookmark_type="retention",
params=params,
dashboard_id=12345,
))
Source code in src/mixpanel_headless/workspace.py
4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 | |
run_retention_params
¶
run_retention_params(
params: dict[str, Any],
*,
limit: int | None = None,
workspace_id: int | None = None,
) -> RetentionQueryResult
Run pre-built retention bookmark params against the Mixpanel API.
The execution half of :meth:build_retention_params.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Retention bookmark params dict, normally from
:meth:
TYPE:
|
limit
|
Segments to return, 1 to 50000. Default
TYPE:
|
workspace_id
|
Optional data view to run under. Wins over the pinned session workspace.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RetentionQueryResult
|
RetentionQueryResult with cohort data, DataFrame, and |
RetentionQueryResult
|
metadata. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
|
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid bookmark params. |
RateLimitError
|
Rate limit exceeded. |
Example
Source code in src/mixpanel_headless/workspace.py
query_flow
¶
query_flow(
event: str | FlowStep | Sequence[str | FlowStep],
*,
forward: int = 3,
reverse: int = 0,
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
conversion_window: int = 7,
conversion_window_unit: Literal["day", "week", "month", "session"] = "day",
count_type: Literal["unique", "total", "session"] = "unique",
cardinality: int = 3,
collapse_repeated: bool = False,
hidden_events: list[str] | None = None,
mode: Literal["sankey", "paths", "tree"] = "sankey",
where: Filter | list[Filter] | None = None,
data_group_id: int | None = None,
segments: str
| GroupBy
| CohortBreakdown
| FrequencyBreakdown
| list[str | GroupBy | CohortBreakdown | FrequencyBreakdown]
| None = None,
exclusions: list[str] | None = None,
) -> FlowQueryResult
Run a typed flow query against the Mixpanel API.
Generates flow bookmark params from keyword arguments, POSTs
them inline to /arb_funnels, and returns a structured
FlowQueryResult with lazy DataFrame conversion.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event specification. Accepts an event name string,
a |
forward
|
Default number of forward steps to trace from
each anchor event. Overridden by per-step values.
Default:
TYPE:
|
reverse
|
Default number of reverse steps to trace from
each anchor event. Overridden by per-step values.
Default:
TYPE:
|
from_date
|
Start date (YYYY-MM-DD). If set, overrides
TYPE:
|
to_date
|
End date (YYYY-MM-DD). Requires
TYPE:
|
last
|
Relative time range in days. Default: 30.
TYPE:
|
conversion_window
|
Conversion window size. Default: 7.
TYPE:
|
conversion_window_unit
|
Conversion window unit.
Default:
TYPE:
|
count_type
|
Counting method for flow analysis.
Default:
TYPE:
|
cardinality
|
Number of top paths to display.
Default:
TYPE:
|
collapse_repeated
|
Whether to merge consecutive repeated
events. Default:
TYPE:
|
hidden_events
|
Events to hide from the flow visualization.
Default:
TYPE:
|
mode
|
Flow visualization mode. Default:
TYPE:
|
where
|
Filter results by cohort membership or property
conditions. Cohort filters ( |
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
segments
|
Segment (breakdown) specification for flow
results. Accepts a string,
TYPE:
|
exclusions
|
List of event names to exclude from flow
paths. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FlowQueryResult
|
FlowQueryResult with steps, flows, breakdowns, and |
FlowQueryResult
|
metadata. |
| RAISES | DESCRIPTION |
|---|---|
BookmarkValidationError
|
If arguments violate validation rules (before API call). |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid query parameters. |
RateLimitError
|
Rate limit exceeded. |
Example
ws = Workspace()
# Simple flow query
result = ws.query_flow("Login")
print(result.overall_conversion_rate)
# With configuration
result = ws.query_flow(
FlowStep("Login", forward=5, reverse=2),
mode="paths",
last=90,
)
print(result.df)
# With property filter and segments
result = ws.query_flow(
"Login",
where=Filter.equals("country", "US"),
segments=GroupBy("platform"),
exclusions=["Error Event"],
)
Source code in src/mixpanel_headless/workspace.py
4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 | |
build_flow_params
¶
build_flow_params(
event: str | FlowStep | Sequence[str | FlowStep],
*,
forward: int = 3,
reverse: int = 0,
from_date: str | None = None,
to_date: str | None = None,
last: int = 30,
conversion_window: int = 7,
conversion_window_unit: Literal["day", "week", "month", "session"] = "day",
count_type: Literal["unique", "total", "session"] = "unique",
cardinality: int = 3,
collapse_repeated: bool = False,
hidden_events: list[str] | None = None,
mode: Literal["sankey", "paths", "tree"] = "sankey",
where: Filter | list[Filter] | None = None,
data_group_id: int | None = None,
segments: str
| GroupBy
| CohortBreakdown
| FrequencyBreakdown
| list[str | GroupBy | CohortBreakdown | FrequencyBreakdown]
| None = None,
exclusions: list[str] | None = None,
) -> dict[str, Any]
Build validated flow bookmark params without executing.
Accepts the same arguments as :meth:query_flow but returns
the generated bookmark params dict instead of querying
the API. Useful for debugging, inspecting generated JSON,
persisting via :meth:create_bookmark, or testing.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event specification. Accepts an event name string,
a |
forward
|
Default forward step count. Default:
TYPE:
|
reverse
|
Default reverse step count. Default:
TYPE:
|
from_date
|
Start date (YYYY-MM-DD) or
TYPE:
|
to_date
|
End date (YYYY-MM-DD) or
TYPE:
|
last
|
Relative time range in days. Default: 30.
TYPE:
|
conversion_window
|
Conversion window size. Default: 7.
TYPE:
|
conversion_window_unit
|
Conversion window unit.
Default:
TYPE:
|
count_type
|
Counting method. Default:
TYPE:
|
cardinality
|
Number of top paths. Default:
TYPE:
|
collapse_repeated
|
Merge repeated events. Default:
TYPE:
|
hidden_events
|
Events to hide. Default:
TYPE:
|
mode
|
Display mode. Default:
TYPE:
|
where
|
Filter results by cohort membership or property
conditions. Cohort filters produce |
data_group_id
|
Optional data group ID for group-level
analytics. Scopes the query to a specific data group.
Default:
TYPE:
|
segments
|
Segment (breakdown) specification for flow
results. Accepts a string,
TYPE:
|
exclusions
|
List of event names to exclude from flow
paths. Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Flat bookmark params dict with |
dict[str, Any]
|
|
| RAISES | DESCRIPTION |
|---|---|
BookmarkValidationError
|
If arguments violate validation rules. |
Example
Source code in src/mixpanel_headless/workspace.py
4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 | |
run_flow_params
¶
run_flow_params(
params: dict[str, Any],
*,
mode: Literal["sankey", "paths", "tree"] | None = None,
workspace_id: int | None = None,
) -> FlowQueryResult
Run pre-built flow bookmark params against the Mixpanel API.
The execution half of :meth:build_flow_params.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Flow bookmark params dict, normally from
:meth:
TYPE:
|
mode
|
Flow chart mode.
TYPE:
|
workspace_id
|
Optional data view to run under. Wins over the pinned session workspace.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FlowQueryResult
|
FlowQueryResult with steps, paths, or trees, DataFrame, and |
FlowQueryResult
|
metadata. |
| RAISES | DESCRIPTION |
|---|---|
AuthenticationError
|
Invalid credentials. |
QueryError
|
Invalid bookmark params. |
RateLimitError
|
Rate limit exceeded. |
Example
Source code in src/mixpanel_headless/workspace.py
query_user
¶
query_user(
*,
where: Filter | list[Filter] | str | None = None,
cohort: int | CohortDefinition | None = None,
properties: list[str] | None = None,
sort_by: str | None = None,
sort_order: Literal["ascending", "descending"] = "descending",
limit: int | None = 1,
search: str | None = None,
distinct_id: str | None = None,
distinct_ids: list[str] | None = None,
group_id: str | None = None,
as_of: str | int | None = None,
mode: Literal["profiles", "aggregate"] = "aggregate",
aggregate: Literal[
"count", "extremes", "percentile", "numeric_summary"
] = "count",
aggregate_property: str | None = None,
percentile: float | None = None,
segment_by: list[int] | None = None,
parallel: bool = False,
workers: int = 5,
include_all_users: bool = False,
) -> UserQueryResult
Query user profiles from Mixpanel's Engage API.
Provides a high-level interface to Mixpanel's Engage API for
querying user profiles with typed filters, cohort membership,
sorting, and pagination. Results are returned as a structured
UserQueryResult with lazy DataFrame conversion.
| PARAMETER | DESCRIPTION |
|---|---|
where
|
Filter profiles by property values. Accepts a single
|
cohort
|
Filter by cohort membership. An
TYPE:
|
properties
|
Output properties to include in results.
TYPE:
|
sort_by
|
Property name to sort results by.
TYPE:
|
sort_order
|
Sort direction (
TYPE:
|
limit
|
Maximum profiles to return. Defaults to
TYPE:
|
search
|
Full-text search term applied to profile properties.
TYPE:
|
distinct_id
|
Look up a single user by distinct ID.
TYPE:
|
distinct_ids
|
Batch look up multiple users by distinct IDs.
TYPE:
|
group_id
|
Query group profiles instead of user profiles.
TYPE:
|
as_of
|
Point-in-time query. An ISO date string (
TYPE:
|
mode
|
Output mode (
TYPE:
|
aggregate
|
Aggregation function for aggregate mode. One of
TYPE:
|
aggregate_property
|
Property to aggregate on (required for non-count aggregations).
TYPE:
|
percentile
|
Percentile value (0-100 exclusive). Required
when
TYPE:
|
segment_by
|
Cohort IDs for segmented aggregation.
TYPE:
|
parallel
|
Whether to enable concurrent page fetching.
TYPE:
|
workers
|
Maximum concurrent workers for parallel fetching.
TYPE:
|
include_all_users
|
Include non-members in cohort query results.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserQueryResult
|
|
UserQueryResult
|
and execution metadata. |
| RAISES | DESCRIPTION |
|---|---|
BookmarkValidationError
|
If any validation rule fails. |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
RateLimitError
|
API rate limit exceeded (429). |
APIError
|
Other API communication errors. |
Example
ws = Workspace()
# Quick peek at one profile
result = ws.query_user()
print(result.df)
# Filter premium users, sorted by LTV
result = ws.query_user(
where=Filter.equals("plan", "premium"),
sort_by="ltv",
sort_order="descending",
limit=100,
)
print(f"Total premium users: {result.total}")
print(result.df.head())
# Batch lookup specific users
result = ws.query_user(
distinct_ids=["user_001", "user_002"],
limit=None,
)
Source code in src/mixpanel_headless/workspace.py
11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 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 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 | |
build_user_params
¶
build_user_params(
*,
where: Filter | list[Filter] | str | None = None,
cohort: int | CohortDefinition | None = None,
properties: list[str] | None = None,
sort_by: str | None = None,
sort_order: Literal["ascending", "descending"] = "descending",
search: str | None = None,
distinct_id: str | None = None,
distinct_ids: list[str] | None = None,
group_id: str | None = None,
as_of: str | int | None = None,
mode: Literal["profiles", "aggregate"] = "aggregate",
aggregate: Literal[
"count", "extremes", "percentile", "numeric_summary"
] = "count",
aggregate_property: str | None = None,
percentile: float | None = None,
segment_by: list[int] | None = None,
limit: int | None = 1,
parallel: bool = False,
workers: int = 5,
include_all_users: bool = False,
) -> dict[str, Any]
Build engage API params without executing a query.
Validates arguments and constructs the params dict that would be sent to the Engage API, without actually making an API call. Useful for debugging, testing, and inspecting the generated params before execution.
| PARAMETER | DESCRIPTION |
|---|---|
where
|
Filter profiles by property values. Accepts a single
|
cohort
|
Filter by cohort membership. An
TYPE:
|
properties
|
Output properties to include in results.
TYPE:
|
sort_by
|
Property name to sort results by.
TYPE:
|
sort_order
|
Sort direction (
TYPE:
|
search
|
Full-text search term applied to profile properties.
TYPE:
|
distinct_id
|
Look up a single user by distinct ID.
TYPE:
|
distinct_ids
|
Batch look up multiple users by distinct IDs.
TYPE:
|
group_id
|
Query group profiles instead of user profiles.
TYPE:
|
as_of
|
Point-in-time query. An ISO date string (
TYPE:
|
mode
|
Output mode (
TYPE:
|
aggregate
|
Aggregation function for aggregate mode. One of
TYPE:
|
aggregate_property
|
Property to aggregate on (required for non-count aggregations).
TYPE:
|
percentile
|
Percentile value (0-100 exclusive). Required
when
TYPE:
|
segment_by
|
Cohort IDs for segmented aggregation.
TYPE:
|
limit
|
Maximum profiles to return. Defaults to
TYPE:
|
parallel
|
Whether to enable concurrent page fetching.
Accepted for signature compatibility with
TYPE:
|
workers
|
Maximum concurrent workers for parallel fetching.
Accepted for signature compatibility with
TYPE:
|
include_all_users
|
Include non-members in cohort query results.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Engage API params dict. Does not include pagination params |
dict[str, Any]
|
( |
dict[str, Any]
|
execution time by |
| RAISES | DESCRIPTION |
|---|---|
BookmarkValidationError
|
If any validation rule fails at either the argument level (U1-U28) or the param level (UP1-UP4). |
Example
Source code in src/mixpanel_headless/workspace.py
11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 | |
run_user_params
¶
run_user_params(
params: dict[str, Any],
*,
limit: int | None = 1,
parallel: bool = False,
workers: int = 5,
) -> UserQueryResult
Run pre-built Engage API params against the Mixpanel API.
The execution half of :meth:build_user_params. The mode is read
from the params: a dict that carries an aggregate action key
runs as an aggregate query, any other dict runs as a profiles
query. limit, parallel and workers are execution
settings that :meth:build_user_params does not store, so they
are passed here with the same defaults as :meth:query_user.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Engage API params dict, normally from
:meth:
TYPE:
|
limit
|
Maximum profiles to return in profiles mode.
TYPE:
|
parallel
|
Fetch profile pages concurrently. Ignored when
TYPE:
|
workers
|
Maximum concurrent workers for parallel fetching.
Default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserQueryResult
|
|
UserQueryResult
|
count, DataFrame, and execution metadata. |
| RAISES | DESCRIPTION |
|---|---|
AuthenticationError
|
Invalid credentials (401). |
RateLimitError
|
API rate limit exceeded (429). |
APIError
|
Other API communication errors. |
Example
Source code in src/mixpanel_headless/workspace.py
11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 | |
segmentation
¶
segmentation(
event: str,
*,
from_date: str,
to_date: str,
on: str | None = None,
unit: Literal["day", "week", "month"] = "day",
where: str | None = None,
) -> SegmentationResult
Run a segmentation query against Mixpanel API.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name to query.
TYPE:
|
from_date
|
Start date (YYYY-MM-DD).
TYPE:
|
to_date
|
End date (YYYY-MM-DD).
TYPE:
|
on
|
Optional property to segment by.
TYPE:
|
unit
|
Time unit for aggregation.
TYPE:
|
where
|
Optional WHERE clause.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SegmentationResult
|
SegmentationResult with time-series data. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
funnel
¶
funnel(
funnel_id: int,
*,
from_date: str,
to_date: str,
unit: str | None = None,
on: str | None = None,
) -> FunnelResult
Run a funnel analysis query.
| PARAMETER | DESCRIPTION |
|---|---|
funnel_id
|
ID of saved funnel.
TYPE:
|
from_date
|
Start date (YYYY-MM-DD).
TYPE:
|
to_date
|
End date (YYYY-MM-DD).
TYPE:
|
unit
|
Optional time unit.
TYPE:
|
on
|
Optional property to segment by.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FunnelResult
|
FunnelResult with step conversion rates. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
retention
¶
retention(
*,
born_event: str,
return_event: str,
from_date: str,
to_date: str,
born_where: str | None = None,
return_where: str | None = None,
interval: int = 1,
interval_count: int = 10,
unit: Literal["day", "week", "month"] = "day",
) -> RetentionResult
Run a retention analysis query.
| PARAMETER | DESCRIPTION |
|---|---|
born_event
|
Event that defines cohort entry.
TYPE:
|
return_event
|
Event that defines return.
TYPE:
|
from_date
|
Start date (YYYY-MM-DD).
TYPE:
|
to_date
|
End date (YYYY-MM-DD).
TYPE:
|
born_where
|
Optional filter for born event.
TYPE:
|
return_where
|
Optional filter for return event.
TYPE:
|
interval
|
Retention interval.
TYPE:
|
interval_count
|
Number of intervals.
TYPE:
|
unit
|
Time unit.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RetentionResult
|
RetentionResult with cohort retention data. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
event_counts
¶
event_counts(
events: list[str],
*,
from_date: str,
to_date: str,
type: Literal["general", "unique", "average"] = "general",
unit: Literal["day", "week", "month"] = "day",
) -> EventCountsResult
Get event counts for multiple events.
| PARAMETER | DESCRIPTION |
|---|---|
events
|
List of event names.
TYPE:
|
from_date
|
Start date (YYYY-MM-DD).
TYPE:
|
to_date
|
End date (YYYY-MM-DD).
TYPE:
|
type
|
Counting method.
TYPE:
|
unit
|
Time unit.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EventCountsResult
|
EventCountsResult with time-series per event. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
property_counts
¶
property_counts(
event: str,
property_name: str,
*,
from_date: str,
to_date: str,
type: Literal["general", "unique", "average"] = "general",
unit: Literal["day", "week", "month"] = "day",
values: list[str] | None = None,
limit: int | None = None,
) -> PropertyCountsResult
Get event counts broken down by property values.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name.
TYPE:
|
property_name
|
Property to break down by.
TYPE:
|
from_date
|
Start date (YYYY-MM-DD).
TYPE:
|
to_date
|
End date (YYYY-MM-DD).
TYPE:
|
type
|
Counting method.
TYPE:
|
unit
|
Time unit.
TYPE:
|
values
|
Optional list of property values to include.
TYPE:
|
limit
|
Maximum number of property values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PropertyCountsResult
|
PropertyCountsResult with time-series per property value. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
activity_feed
¶
activity_feed(
distinct_ids: list[str],
*,
from_date: str | None = None,
to_date: str | None = None,
limit: int | None = None,
include_events: list[str] | None = None,
exclude_events: list[str] | None = None,
sentinel_event: dict[str, Any] | None = None,
paging_window: int | None = None,
search: str | None = None,
search_properties: list[dict[str, Any]] | None = None,
use_custom_events: bool = False,
) -> ActivityFeedResult
Get activity feed for specific users.
Returns a user's events sorted chronologically (oldest-first within a
page). When limit is set, the most recent events come first; use the
sentinel_event cursor (carried on the result) to page backward to
older events. Backed by the stream/bookmark endpoint; also filterable by
event name or full-text search.
| PARAMETER | DESCRIPTION |
|---|---|
distinct_ids
|
List of user identifiers.
TYPE:
|
from_date
|
Optional start date filter (
TYPE:
|
to_date
|
Optional end date filter (
TYPE:
|
limit
|
Optional max events to return (server ceiling 15000).
TYPE:
|
include_events
|
Optional event names to include; mutually exclusive
with
TYPE:
|
exclude_events
|
Optional event names to exclude; mutually exclusive
with
TYPE:
|
sentinel_event
|
Optional pagination cursor from a prior result's
TYPE:
|
paging_window
|
Optional days (<= 30) bounding each page's scan window.
TYPE:
|
search
|
Optional full-text search string applied to events.
TYPE:
|
search_properties
|
Optional property descriptors to restrict the
TYPE:
|
use_custom_events
|
When
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ActivityFeedResult
|
ActivityFeedResult with user events plus a |
ActivityFeedResult
|
( |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
QueryError
|
If both |
Example
Source code in src/mixpanel_headless/workspace.py
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 | |
query_saved_report
¶
query_saved_report(
bookmark_id: int,
*,
bookmark_type: Literal[
"insights", "funnels", "retention", "flows"
] = "insights",
from_date: str | None = None,
to_date: str | None = None,
) -> SavedReportResult
Query a saved report by bookmark type.
Routes to the appropriate Mixpanel API endpoint based on bookmark_type and returns the normalized result.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
ID of saved report (from list_bookmarks or Mixpanel URL).
TYPE:
|
bookmark_type
|
Type of bookmark to query. Determines which API endpoint is called. Defaults to 'insights'.
TYPE:
|
from_date
|
Start date (YYYY-MM-DD). Required for funnels, optional otherwise.
TYPE:
|
to_date
|
End date (YYYY-MM-DD). Required for funnels, optional otherwise.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SavedReportResult
|
SavedReportResult with report data and report_type property. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
QueryError
|
If bookmark_id is invalid or report not found. |
Source code in src/mixpanel_headless/workspace.py
query_saved_flows
¶
Query a saved Flows report.
Executes a saved Flows report by its bookmark ID, returning step data, breakdowns, and conversion rates.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
ID of saved flows report (from list_bookmarks or Mixpanel URL).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FlowsResult
|
FlowsResult with steps, breakdowns, and conversion rate. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
QueryError
|
If bookmark_id is invalid or report not found. |
Source code in src/mixpanel_headless/workspace.py
frequency
¶
frequency(
*,
from_date: str,
to_date: str,
unit: Literal["day", "week", "month"] = "day",
addiction_unit: Literal["hour", "day"] = "hour",
event: str | None = None,
where: str | None = None,
) -> FrequencyResult
Analyze event frequency distribution.
| PARAMETER | DESCRIPTION |
|---|---|
from_date
|
Start date (YYYY-MM-DD).
TYPE:
|
to_date
|
End date (YYYY-MM-DD).
TYPE:
|
unit
|
Overall time unit.
TYPE:
|
addiction_unit
|
Measurement granularity.
TYPE:
|
event
|
Optional event filter.
TYPE:
|
where
|
Optional WHERE clause.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FrequencyResult
|
FrequencyResult with frequency distribution. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
segmentation_numeric
¶
segmentation_numeric(
event: str,
*,
from_date: str,
to_date: str,
on: str,
unit: Literal["hour", "day"] = "day",
where: str | None = None,
type: Literal["general", "unique", "average"] = "general",
) -> NumericBucketResult
Bucket events by numeric property ranges.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name.
TYPE:
|
from_date
|
Start date.
TYPE:
|
to_date
|
End date.
TYPE:
|
on
|
Numeric property expression.
TYPE:
|
unit
|
Time unit.
TYPE:
|
where
|
Optional filter.
TYPE:
|
type
|
Counting method.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NumericBucketResult
|
NumericBucketResult with bucketed data. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
segmentation_sum
¶
segmentation_sum(
event: str,
*,
from_date: str,
to_date: str,
on: str,
unit: Literal["hour", "day"] = "day",
where: str | None = None,
) -> NumericSumResult
Calculate sum of numeric property over time.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name.
TYPE:
|
from_date
|
Start date.
TYPE:
|
to_date
|
End date.
TYPE:
|
on
|
Numeric property expression.
TYPE:
|
unit
|
Time unit.
TYPE:
|
where
|
Optional filter.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NumericSumResult
|
NumericSumResult with sum values per period. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
segmentation_average
¶
segmentation_average(
event: str,
*,
from_date: str,
to_date: str,
on: str,
unit: Literal["hour", "day"] = "day",
where: str | None = None,
) -> NumericAverageResult
Calculate average of numeric property over time.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
Event name.
TYPE:
|
from_date
|
Start date.
TYPE:
|
to_date
|
End date.
TYPE:
|
on
|
Numeric property expression.
TYPE:
|
unit
|
Time unit.
TYPE:
|
where
|
Optional filter.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NumericAverageResult
|
NumericAverageResult with average values per period. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If API credentials not available. |
Source code in src/mixpanel_headless/workspace.py
list_dashboards
¶
List dashboards for the current project/workspace.
Retrieves all dashboards visible to the authenticated user, optionally filtered by specific IDs.
| PARAMETER | DESCRIPTION |
|---|---|
ids
|
Optional list of dashboard IDs to filter by.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Dashboard]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_dashboard
¶
Create a new dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Dashboard creation parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The newly created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400, 422). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_dashboard
¶
Get a single dashboard by ID.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_dashboard
¶
Update an existing dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
params
|
Fields to update.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found or invalid params (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_dashboard
¶
Delete a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
bulk_delete_dashboards
¶
Delete multiple dashboards.
| PARAMETER | DESCRIPTION |
|---|---|
ids
|
List of dashboard IDs to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
One or more IDs not found (400, 404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
favorite_dashboard
¶
Favorite a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
unfavorite_dashboard
¶
Unfavorite a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
pin_dashboard
¶
Pin a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
unpin_dashboard
¶
Unpin a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
add_report_to_dashboard
¶
Add a report to a dashboard.
Clones the specified bookmark onto the dashboard. The cloned report appears as a new card in the dashboard layout.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
bookmark_id
|
Bookmark/report identifier to add.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard or bookmark not found (404). |
ServerError
|
Server-side errors (5xx). |
MixpanelHeadlessError
|
If the API response is not a valid dashboard dict. |
Source code in src/mixpanel_headless/workspace.py
remove_report_from_dashboard
¶
Remove a report from a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
bookmark_id
|
Bookmark/report identifier to remove.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard or bookmark not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_blueprint_templates
¶
List available dashboard blueprint templates.
| PARAMETER | DESCRIPTION |
|---|---|
include_reports
|
Whether to include report details.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[BlueprintTemplate]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
create_blueprint
¶
Create a dashboard from a blueprint template.
| PARAMETER | DESCRIPTION |
|---|---|
template_type
|
Blueprint template type identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The newly created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid template type (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_blueprint_config
¶
Get the blueprint configuration for a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BlueprintConfig
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_blueprint_cohorts
¶
Update cohorts for blueprint configuration.
| PARAMETER | DESCRIPTION |
|---|---|
cohorts
|
List of cohort configuration dicts.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid cohort configuration (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
finalize_blueprint
¶
Finalize a blueprint dashboard with cards.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Blueprint finalization parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The finalized |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_rca_dashboard
¶
Create an RCA (Root Cause Analysis) dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
RCA dashboard parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dashboard
|
The newly created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_bookmark_dashboard_ids
¶
Get dashboard IDs containing a bookmark/report.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
Bookmark identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int]
|
List of dashboard IDs. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Bookmark not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_dashboard_erf
¶
Get ERF data for a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dict with ERF metrics data. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_report_link
¶
update_report_link(
dashboard_id: int, report_link_id: int, params: UpdateReportLinkParams
) -> None
Update a report link on a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
report_link_id
|
Report link identifier.
TYPE:
|
params
|
Update parameters.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard or link not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
update_text_card
¶
Update a text card on a dashboard.
| PARAMETER | DESCRIPTION |
|---|---|
dashboard_id
|
Dashboard identifier.
TYPE:
|
text_card_id
|
Text card identifier.
TYPE:
|
params
|
Update parameters.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Dashboard or text card not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_bookmarks_v2
¶
list_bookmarks_v2(
*, bookmark_type: BookmarkType | None = None, ids: list[int] | None = None
) -> list[Bookmark]
List bookmarks/reports via the App API v2 endpoint.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_type
|
Optional report type filter (e.g.,
TYPE:
|
ids
|
Optional list of bookmark IDs to filter by.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Bookmark]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_bookmark
¶
Create a new bookmark (saved report).
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Bookmark creation parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Bookmark
|
The newly created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
MixpanelHeadlessError
|
If |
BookmarkValidationError
|
If |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400, 422). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 | |
get_bookmark
¶
Get a single bookmark by ID.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
Bookmark identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Bookmark
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Bookmark not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_bookmark
¶
Update an existing bookmark.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
Bookmark identifier.
TYPE:
|
params
|
Fields to update.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Bookmark
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
BookmarkValidationError
|
If |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Bookmark not found or invalid params (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_bookmark
¶
Delete a bookmark.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
Bookmark identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Bookmark not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
bulk_delete_bookmarks
¶
Delete multiple bookmarks.
| PARAMETER | DESCRIPTION |
|---|---|
ids
|
List of bookmark IDs to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
One or more IDs not found (400, 404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
bulk_update_bookmarks
¶
Update multiple bookmarks.
| PARAMETER | DESCRIPTION |
|---|---|
entries
|
List of bookmark update entries.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid entries or IDs not found (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
bookmark_linked_dashboard_ids
¶
Get dashboard IDs linked to a bookmark.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
Bookmark identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int]
|
List of dashboard IDs. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Bookmark not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_bookmark_history
¶
get_bookmark_history(
bookmark_id: int, *, cursor: str | None = None, page_size: int | None = None
) -> BookmarkHistoryResponse
Get the change history for a bookmark.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
Bookmark identifier.
TYPE:
|
cursor
|
Opaque pagination cursor.
TYPE:
|
page_size
|
Maximum entries per page.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BookmarkHistoryResponse
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Bookmark not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_cohorts_full
¶
list_cohorts_full(
*, data_group_id: str | None = None, ids: list[int] | None = None
) -> list[Cohort]
List cohorts via the App API (full detail).
Unlike cohorts() which uses the discovery endpoint, this method
uses the App API and returns full Cohort objects with all metadata.
| PARAMETER | DESCRIPTION |
|---|---|
data_group_id
|
Optional data group filter.
TYPE:
|
ids
|
Optional list of cohort IDs to filter by.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Cohort]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_cohort
¶
Get a single cohort by ID via the App API.
| PARAMETER | DESCRIPTION |
|---|---|
cohort_id
|
Cohort identifier.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Cohort
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Cohort not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
create_cohort
¶
Create a new cohort.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Cohort creation parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Cohort
|
The newly created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_cohort
¶
Update an existing cohort.
| PARAMETER | DESCRIPTION |
|---|---|
cohort_id
|
Cohort identifier.
TYPE:
|
params
|
Fields to update.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Cohort
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Cohort not found or invalid params (400, 404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
delete_cohort
¶
Delete a cohort.
| PARAMETER | DESCRIPTION |
|---|---|
cohort_id
|
Cohort identifier.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Cohort not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
bulk_delete_cohorts
¶
Delete multiple cohorts.
| PARAMETER | DESCRIPTION |
|---|---|
ids
|
List of cohort IDs to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
One or more IDs not found (400, 404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
bulk_update_cohorts
¶
Update multiple cohorts.
| PARAMETER | DESCRIPTION |
|---|---|
entries
|
List of cohort update entries.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid entries or IDs not found (400, 404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_feature_flags
¶
List feature flags for the current project/workspace.
| PARAMETER | DESCRIPTION |
|---|---|
include_archived
|
When True, include archived flags.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[FeatureFlag]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_feature_flag
¶
Create a new feature flag.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Flag creation parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FeatureFlag
|
The newly created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Duplicate key or invalid parameters (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_feature_flag
¶
Get a single feature flag by ID.
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FeatureFlag
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_feature_flag
¶
Update a feature flag (full replacement, PUT semantics).
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
params
|
Complete flag configuration.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FeatureFlag
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found or invalid params (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_feature_flag
¶
Delete a feature flag.
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
archive_feature_flag
¶
Archive a feature flag (soft-delete).
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
restore_feature_flag
¶
Restore an archived feature flag.
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FeatureFlag
|
The restored |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
duplicate_feature_flag
¶
Duplicate a feature flag.
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FeatureFlag
|
The newly created duplicate |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
set_flag_test_users
¶
Set test user variant overrides for a feature flag.
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
params
|
Test user mapping.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found (404) or invalid payload (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_flag_history
¶
get_flag_history(
flag_id: str, *, page: str | None = None, page_size: int | None = None
) -> FlagHistoryResponse
Get paginated change history for a feature flag.
| PARAMETER | DESCRIPTION |
|---|---|
flag_id
|
Feature flag UUID.
TYPE:
|
page
|
Pagination cursor.
TYPE:
|
page_size
|
Results per page.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FlagHistoryResponse
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Flag not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_flag_limits
¶
Get account-level feature flag limits and usage.
| RETURNS | DESCRIPTION |
|---|---|
FlagLimitsResponse
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_experiments
¶
List experiments for the current project.
| PARAMETER | DESCRIPTION |
|---|---|
include_archived
|
When True, include archived experiments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Experiment]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_experiment
¶
Create a new experiment in Draft status.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Experiment creation parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The newly created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_experiment
¶
Get a single experiment by ID.
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Experiment not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_experiment
¶
Update an experiment (PATCH semantics).
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
params
|
Fields to update.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Experiment not found or invalid params (400, 404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_experiment
¶
Delete an experiment.
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Experiment not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
launch_experiment
¶
Launch an experiment (Draft → Active).
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The launched |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid state transition (400) or not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
conclude_experiment
¶
conclude_experiment(
experiment_id: str, *, params: ExperimentConcludeParams | None = None
) -> Experiment
Conclude an experiment (Active → Concluded).
Always sends a JSON body (empty {} if no params).
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
params
|
Optional conclude parameters (e.g. end date override).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The concluded |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid state transition (400) or not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
decide_experiment
¶
Record the experiment decision (Concluded → Success/Fail).
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
params
|
Decision parameters (success, variant, message).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The decided |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid state transition (400) or not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
archive_experiment
¶
Archive an experiment.
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Experiment not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
restore_experiment
¶
Restore an archived experiment.
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The restored |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Experiment not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
duplicate_experiment
¶
Duplicate an experiment.
A name is required because the Mixpanel API returns an empty response body when duplicating without one.
| PARAMETER | DESCRIPTION |
|---|---|
experiment_id
|
Experiment UUID.
TYPE:
|
params
|
Duplication parameters ( |
| RETURNS | DESCRIPTION |
|---|---|
Experiment
|
The newly created duplicate |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Experiment not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_erf_experiments
¶
List experiments in ERF (Experiment Results Framework) format.
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]]
|
List of experiment dicts in ERF format. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_alerts
¶
list_alerts(
*, bookmark_id: int | None = None, skip_user_filter: bool | None = None
) -> list[CustomAlert]
List custom alerts for the current project.
| PARAMETER | DESCRIPTION |
|---|---|
bookmark_id
|
Filter alerts by linked bookmark ID.
TYPE:
|
skip_user_filter
|
If True, list alerts for all users.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[CustomAlert]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_alert
¶
Create a new custom alert.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Alert creation parameters (bookmark_id, name, condition, frequency, paused, and subscriptions are required).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CustomAlert
|
The created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_alert
¶
Get a single custom alert by ID.
| PARAMETER | DESCRIPTION |
|---|---|
alert_id
|
Alert ID (integer).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CustomAlert
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Alert not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_alert
¶
Update a custom alert (PATCH semantics).
| PARAMETER | DESCRIPTION |
|---|---|
alert_id
|
Alert ID (integer).
TYPE:
|
params
|
Fields to update.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CustomAlert
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Alert not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
delete_alert
¶
Delete a custom alert.
| PARAMETER | DESCRIPTION |
|---|---|
alert_id
|
Alert ID (integer).
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Alert not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
bulk_delete_alerts
¶
Bulk-delete custom alerts.
| PARAMETER | DESCRIPTION |
|---|---|
ids
|
List of alert IDs to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_alert_count
¶
Get alert count and limits.
| PARAMETER | DESCRIPTION |
|---|---|
alert_type
|
Optional filter by alert type.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AlertCount
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_alert_history
¶
get_alert_history(
alert_id: int,
*,
page_size: int | None = None,
next_cursor: str | None = None,
previous_cursor: str | None = None,
) -> AlertHistoryResponse
Get alert trigger history (paginated).
| PARAMETER | DESCRIPTION |
|---|---|
alert_id
|
Alert ID (integer).
TYPE:
|
page_size
|
Number of results per page.
TYPE:
|
next_cursor
|
Cursor for the next page.
TYPE:
|
previous_cursor
|
Cursor for the previous page.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AlertHistoryResponse
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Alert not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
test_alert
¶
Send a test alert notification.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Alert parameters for the test (same shape as create).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with test result status (opaque response). |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_alert_screenshot_url
¶
Get a signed URL for an alert screenshot.
| PARAMETER | DESCRIPTION |
|---|---|
gcs_key
|
GCS object key for the screenshot.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AlertScreenshotResponse
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Screenshot not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
validate_alerts_for_bookmark
¶
validate_alerts_for_bookmark(
params: ValidateAlertsForBookmarkParams,
) -> ValidateAlertsForBookmarkResponse
Validate alerts against a bookmark configuration.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Validation parameters (alert_ids, bookmark_type, bookmark_params are required). |
| RETURNS | DESCRIPTION |
|---|---|
ValidateAlertsForBookmarkResponse
|
|
ValidateAlertsForBookmarkResponse
|
and invalid count. |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_annotations
¶
list_annotations(
*,
from_date: str | None = None,
to_date: str | None = None,
tags: list[int] | None = None,
) -> list[Annotation]
List timeline annotations for the project.
| PARAMETER | DESCRIPTION |
|---|---|
from_date
|
Start date filter (ISO format, e.g.
TYPE:
|
to_date
|
End date filter (ISO format, e.g.
TYPE:
|
tags
|
Tag IDs to filter by.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Annotation]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_annotation
¶
Create a new timeline annotation.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Annotation creation parameters (date, description required).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Annotation
|
The created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_annotation
¶
Get a single annotation by ID.
| PARAMETER | DESCRIPTION |
|---|---|
annotation_id
|
Annotation ID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Annotation
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Annotation not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_annotation
¶
Update an annotation (PATCH semantics).
| PARAMETER | DESCRIPTION |
|---|---|
annotation_id
|
Annotation ID.
TYPE:
|
params
|
Fields to update (description, tags).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Annotation
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Annotation not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_annotation
¶
Delete an annotation.
| PARAMETER | DESCRIPTION |
|---|---|
annotation_id
|
Annotation ID.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Annotation not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_annotation_tags
¶
List annotation tags for the project.
| RETURNS | DESCRIPTION |
|---|---|
list[AnnotationTag]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
create_annotation_tag
¶
Create a new annotation tag.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Tag creation parameters (name required). |
| RETURNS | DESCRIPTION |
|---|---|
AnnotationTag
|
The created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_webhooks
¶
List all webhooks for the current project.
| RETURNS | DESCRIPTION |
|---|---|
list[ProjectWebhook]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_webhook
¶
Create a new webhook.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Webhook creation parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
WebhookMutationResult
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
update_webhook
¶
Update an existing webhook.
| PARAMETER | DESCRIPTION |
|---|---|
webhook_id
|
Webhook UUID string.
TYPE:
|
params
|
Fields to update (PATCH semantics).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
WebhookMutationResult
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Webhook not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_webhook
¶
Delete a webhook.
| PARAMETER | DESCRIPTION |
|---|---|
webhook_id
|
Webhook UUID string.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Webhook not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
test_webhook
¶
Test webhook connectivity.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Webhook test parameters (url is required).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
WebhookTestResult
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
API error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_event_definitions
¶
Get event definitions from Lexicon by name.
Retrieves metadata (description, tags, visibility, etc.) for the specified events from the Mixpanel Lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
names
|
List of event names to look up.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[EventDefinition]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
update_event_definition
¶
Update an event definition in Lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
event_name
|
Name of the event to update.
TYPE:
|
params
|
Fields to update (hidden, dropped, merged, verified, tags, display_name, description). |
| RETURNS | DESCRIPTION |
|---|---|
EventDefinition
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Event not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_event_definition
¶
Delete an event definition from Lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
event_name
|
Name of the event to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Event not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
bulk_update_event_definitions
¶
Bulk-update event definitions in Lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Bulk update parameters containing a list of event updates (name + fields to change).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[EventDefinition]
|
List of updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_property_definitions
¶
get_property_definitions(
*, names: list[str], resource_type: str | None = None
) -> list[PropertyDefinition]
Get property definitions from Lexicon by name.
Retrieves metadata (description, tags, visibility, etc.) for the specified properties from the Mixpanel Lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
names
|
List of property names to look up.
TYPE:
|
resource_type
|
Optional resource type filter (e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[PropertyDefinition]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
update_property_definition
¶
update_property_definition(
property_name: str, params: UpdatePropertyDefinitionParams
) -> PropertyDefinition
Update a property definition in Lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
property_name
|
Name of the property to update.
TYPE:
|
params
|
Fields to update (hidden, dropped, merged, sensitive, display_name, description, example_value, resource_type). |
| RETURNS | DESCRIPTION |
|---|---|
PropertyDefinition
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Property not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
bulk_update_property_definitions
¶
Bulk-update property definitions in Lexicon.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Bulk update parameters containing a list of property updates (name + fields to change). |
| RETURNS | DESCRIPTION |
|---|---|
list[PropertyDefinition]
|
List of updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_lexicon_tags
¶
List all Lexicon tags.
| RETURNS | DESCRIPTION |
|---|---|
list[LexiconTag]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Note
The list endpoint may return plain tag name strings without IDs.
In that case, id is set to 0 as a sentinel value. Do not
pass this sentinel to update_lexicon_tag() — use name-based
operations (e.g. delete_lexicon_tag(tag.name)) for tags
obtained from this method.
Source code in src/mixpanel_headless/workspace.py
create_lexicon_tag
¶
Create a new Lexicon tag.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Tag creation parameters (name is required).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LexiconTag
|
The created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400) or tag already exists. |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_lexicon_tag
¶
Update a Lexicon tag.
| PARAMETER | DESCRIPTION |
|---|---|
tag_id
|
Tag ID (integer).
TYPE:
|
params
|
Fields to update (e.g. name).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LexiconTag
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Tag not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
delete_lexicon_tag
¶
Delete a Lexicon tag by name.
| PARAMETER | DESCRIPTION |
|---|---|
tag_name
|
Name of the tag to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Tag not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_tracking_metadata
¶
Get tracking metadata for an event.
Retrieves information about how an event is being tracked (sources, SDKs, volume, etc.).
| PARAMETER | DESCRIPTION |
|---|---|
event_name
|
Name of the event.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw tracking metadata dictionary. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Event not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_event_history
¶
Get change history for an event definition.
| PARAMETER | DESCRIPTION |
|---|---|
event_name
|
Name of the event.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]]
|
List of history entries (raw dictionaries) showing changes |
list[dict[str, Any]]
|
to the event definition over time. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Event not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_property_history
¶
Get change history for a property definition.
| PARAMETER | DESCRIPTION |
|---|---|
property_name
|
Name of the property.
TYPE:
|
entity_type
|
Entity type (e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]]
|
List of history entries (raw dictionaries) showing changes |
list[dict[str, Any]]
|
to the property definition over time. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Property not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
export_lexicon
¶
Export Lexicon data definitions.
Exports event and property definitions from Lexicon, optionally filtered by type.
| PARAMETER | DESCRIPTION |
|---|---|
export_types
|
Optional list of types to export (e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw export dictionary containing the exported definitions. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_drop_filters
¶
List all drop filters.
| RETURNS | DESCRIPTION |
|---|---|
list[DropFilter]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_drop_filter
¶
Create a new drop filter.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Drop filter creation parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[DropFilter]
|
Full list of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
update_drop_filter
¶
Update a drop filter.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Drop filter update parameters (must include the filter ID).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[DropFilter]
|
Full list of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Filter not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_drop_filter
¶
Delete a drop filter.
| PARAMETER | DESCRIPTION |
|---|---|
drop_filter_id
|
Drop filter ID (integer).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[DropFilter]
|
Full list of remaining |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Filter not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_drop_filter_limits
¶
Get drop filter usage limits.
| RETURNS | DESCRIPTION |
|---|---|
DropFilterLimitsResponse
|
|
DropFilterLimitsResponse
|
drop filters for the project. |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_custom_properties
¶
List all custom properties.
| RETURNS | DESCRIPTION |
|---|---|
list[CustomProperty]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Server-side data corruption (e.g. invalid
|
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_custom_property
¶
Create a new custom property.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Custom property creation parameters (name, display_formula or behavior, resource_type are required). |
| RETURNS | DESCRIPTION |
|---|---|
CustomProperty
|
The created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
ws = Workspace()
prop = ws.create_custom_property(
CreateCustomPropertyParams(
name="Full Name",
display_formula='concat(properties["first"], " ", properties["last"])',
composed_properties={"first": ComposedPropertyValue(resource_type="event"), "last": ComposedPropertyValue(resource_type="event")},
resource_type="event",
)
)
Source code in src/mixpanel_headless/workspace.py
get_custom_property
¶
Get a custom property by ID.
| PARAMETER | DESCRIPTION |
|---|---|
property_id
|
Custom property ID (string).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CustomProperty
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Property not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_custom_property
¶
Update a custom property.
| PARAMETER | DESCRIPTION |
|---|---|
property_id
|
Custom property ID (string).
TYPE:
|
params
|
Fields to update. |
| RETURNS | DESCRIPTION |
|---|---|
CustomProperty
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Property not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_custom_property
¶
Delete a custom property.
| PARAMETER | DESCRIPTION |
|---|---|
property_id
|
Custom property ID (string).
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Property not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
validate_custom_property
¶
Validate a custom property definition without creating it.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Custom property parameters to validate. |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Validation result as a raw dictionary. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
ws = Workspace()
result = ws.validate_custom_property(
CreateCustomPropertyParams(
name="Full Name",
display_formula='concat(properties["first"], " ", properties["last"])',
composed_properties={"first": ComposedPropertyValue(resource_type="event"), "last": ComposedPropertyValue(resource_type="event")},
resource_type="event",
)
)
print(result)
Source code in src/mixpanel_headless/workspace.py
list_lookup_tables
¶
List lookup tables.
| PARAMETER | DESCRIPTION |
|---|---|
data_group_id
|
Optional filter by data group ID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[LookupTable]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
upload_lookup_table
¶
upload_lookup_table(
params: UploadLookupTableParams,
*,
poll_interval: float = 2.0,
max_poll_seconds: float = 300.0,
) -> LookupTable
Upload a CSV file as a new lookup table.
Performs a 3-step upload process: 1. Obtains a signed upload URL from the API. 2. Uploads the CSV file to the signed URL. 3. Registers the lookup table with the uploaded data.
For files >= 5 MB, the API processes the upload asynchronously. This method automatically polls until processing completes.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Upload parameters including
TYPE:
|
poll_interval
|
Seconds between status polls for async uploads.
TYPE:
|
max_poll_seconds
|
Maximum seconds to wait for async processing.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LookupTable
|
The created |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400) or file not found. |
ServerError
|
Server-side errors (5xx). |
FileNotFoundError
|
If the CSV file does not exist. |
MixpanelHeadlessError
|
Async processing timed out or failed. |
Example
Source code in src/mixpanel_headless/workspace.py
8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 | |
mark_lookup_table_ready
¶
Mark a lookup table as ready after upload.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Parameters including |
| RETURNS | DESCRIPTION |
|---|---|
LookupTable
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_lookup_upload_url
¶
Get a signed URL for uploading lookup table data.
| PARAMETER | DESCRIPTION |
|---|---|
content_type
|
MIME type of the file to upload
(default:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LookupTableUploadUrl
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
get_lookup_upload_status
¶
Get the processing status of a lookup table upload.
| PARAMETER | DESCRIPTION |
|---|---|
upload_id
|
Upload ID returned from the upload process.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw status dictionary with processing details. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Upload not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
update_lookup_table
¶
Update a lookup table.
| PARAMETER | DESCRIPTION |
|---|---|
data_group_id
|
Data group ID of the lookup table.
TYPE:
|
params
|
Fields to update.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LookupTable
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Table not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_lookup_tables
¶
Delete one or more lookup tables.
| PARAMETER | DESCRIPTION |
|---|---|
data_group_ids
|
List of data group IDs to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
download_lookup_table
¶
download_lookup_table(
data_group_id: int,
*,
file_name: str | None = None,
limit: int | None = None,
) -> bytes
Download lookup table data as raw bytes (CSV).
| PARAMETER | DESCRIPTION |
|---|---|
data_group_id
|
Data group ID of the lookup table.
TYPE:
|
file_name
|
Optional file name filter.
TYPE:
|
limit
|
Optional row limit.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
Raw CSV bytes of the lookup table data. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Table not found (404). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_lookup_download_url
¶
Get a signed download URL for a lookup table.
| PARAMETER | DESCRIPTION |
|---|---|
data_group_id
|
Data group ID of the lookup table.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Signed URL string for downloading the lookup table data. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Table not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_custom_events
¶
List all custom events.
| RETURNS | DESCRIPTION |
|---|---|
list[EventDefinition]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
update_custom_event
¶
Update a custom event's lexicon entry (description, tags, etc.).
The Mixpanel data-definitions/events/ endpoint matches updates by
the most specific identifier; for custom events that's the
customEventId. This SDK method requires the id (rather than the
display name) to avoid creating orphan lexicon entries — passing a
name alone causes the server to fabricate a new, unlinked entry.
Get the id from :meth:create_custom_event's return value
(CustomEvent.id) or from the custom_event_id field on entries
returned by :meth:list_custom_events.
| PARAMETER | DESCRIPTION |
|---|---|
custom_event_id
|
Server-assigned custom event ID.
TYPE:
|
params
|
Fields to update. See
:class: |
| RETURNS | DESCRIPTION |
|---|---|
EventDefinition
|
The updated |
EventDefinition
|
event, with |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Event not found (404) or validation error (400). |
ServerError
|
Server-side errors (5xx). |
MixpanelHeadlessError
|
Server returned an entry with a different
|
Example
Source code in src/mixpanel_headless/workspace.py
delete_custom_event
¶
Delete a custom event.
Identifies the entry by custom_event_id (not name) for the
same reason :meth:update_custom_event does: a name-only DELETE
against the data-definitions endpoint is ambiguous when multiple
entries share a display name and may silently delete the wrong row,
an auto-derived orphan lexicon entry, or no-op while still
reporting success.
Get the id from :meth:create_custom_event's return value
(CustomEvent.id) or from the custom_event_id field on
entries returned by :meth:list_custom_events.
| PARAMETER | DESCRIPTION |
|---|---|
custom_event_id
|
Server-assigned custom event ID.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Event not found (404). |
ServerError
|
Server-side errors (5xx). |
Source code in src/mixpanel_headless/workspace.py
list_metrics
¶
list_metrics(
*,
metric_type: str | None = None,
verified: bool | None = None,
name_contains: str | None = None,
viewable_only: bool = False,
) -> list[SavedMetric]
List saved metrics: behavior metrics, formulas, and warehouse metrics.
Returns what the server returns, which includes metrics that the
caller cannot view (can_view is False, but the definition is
complete). The server has no pagination, filters, or search, so one
request fetches every active metric, and the filters below apply
locally to that response. On a large project the request can take
more than 30 seconds; the read timeout is at least 120 seconds.
| PARAMETER | DESCRIPTION |
|---|---|
metric_type
|
Keep only metrics of this kind:
TYPE:
|
verified
|
TYPE:
|
name_contains
|
Keep only metrics whose name contains this text, ignoring case.
TYPE:
|
viewable_only
|
Drop the metrics that the server marks
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[SavedMetric]
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller lacks the metrics permission or scope (403). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 | |
get_metric
¶
Get one saved metric by id, with its full definition.
| PARAMETER | DESCRIPTION |
|---|---|
metric_id
|
The saved metric id.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SavedMetric
|
The |
SavedMetric
|
|
SavedMetric
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The metric does not exist or is deleted (404), or the caller lacks permission (403). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
create_metric
¶
Create a saved metric from a typed or raw definition.
The kind comes from the definition: a Metric, CohortMetric,
FunnelMetric, or RetentionMetric gives a behavior metric, a
Formula with its own operands gives a saved formula, a
WarehouseMetric gives a warehouse metric, and a
RawMetricDefinition gives the kind it names. A behavior metric
saves the behavior and measurement that :meth:query writes
for the same value, and a saved formula holds the operands that a
query formula holds, so the saved metric queries the same way as its
inline twin.
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. So the
method removes them from a RawMetricDefinition, with or without
validate, and a copy of a stored metric works. A definition
compiled from a typed value never has one; if it does, the method
refuses it (SM4_SCHEMA).
Before any request, the method checks the name and description and
the definition (see Raises). Then it sends the create. The server
drops owned_by and verified from a create, so when the params
set an owner or verified=True, a second request (an update)
sets them. The two requests are not atomic: if the second one fails,
the metric exists without the owner or the verified flag, and the
method raises an error that names the id of the created metric
(see Raises).
In a project with sharing on, a new metric is private to its creator; this API cannot share it.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Name, definition, and optional description, display, goals, owner, and verified flag.
TYPE:
|
validate
|
Check the definition with the mirror of the server
schema before the request (default), including the refusal
of legacy keys in a compiled definition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SavedMetric
|
The created |
SavedMetric
|
was needed). |
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
Before any request: an empty name
( |
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The server refused the body (400; the message names
the failure and its schema location, and |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
MixpanelHeadlessError
|
The create succeeded, but the second
request (owner or verified flag) failed
( |
Example
Source code in src/mixpanel_headless/workspace.py
9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 | |
update_metric
¶
update_metric(
metric_id: int, params: UpdateMetricParams, *, validate: bool = True
) -> SavedMetric
Update a saved metric: metadata, definition, presentation, owner, or verified.
The server runs no schema check on an update and stores a new
definition as sent, so this method runs the same checks as
:meth:create_metric before any request. It sends one update.
When the params change the definition, the display, or the goals, the method reads the metric first, because the server replaces the definition in full:
- A new definition must have the stored kind and, for a warehouse metric, the stored source. It keeps the stored display and goals unless the params or the new definition set them.
- Display or goals without a definition send the stored definition back with the new values, as the web app does.
- The params 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 set to
Noneis removed, and the other keys stay. The params goals replace the stored goals in full. - A
WarehouseMetricwhoseaggregationorsync_intervalisNonekeeps the stored value, so an update of the SQL alone keeps a stored"sum"and"daily". ARawMetricDefinitionis sent as given.
The read and the update are not atomic; an edit in the web app between them is overwritten. A failed read raises; the method never guesses the stored definition.
| PARAMETER | DESCRIPTION |
|---|---|
metric_id
|
The saved metric id.
TYPE:
|
params
|
The fields to change;
TYPE:
|
validate
|
Check new definition, display, and goal values with the
mirror of the server schema (default).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SavedMetric
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
Before any request: an empty name
( |
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The metric does not exist or is deleted (404), the caller cannot edit it or the pricing-plan gate blocks the write (403), or the new name is taken (409). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 | |
bulk_update_metrics
¶
bulk_update_metrics(
entries: Sequence[BulkUpdateMetricEntry], *, validate: bool = True
) -> list[SavedMetric]
Update several saved metrics with one request, for example to verify them.
Each entry holds a metric id plus the fields to change. The method
runs the checks of :meth:update_metric on every entry before it
sends anything. An entry with a new definition reads its metric
first (one read per such entry) to check the kind and to keep the
stored display and goals. One bad entry stops the whole batch.
The server skips ids that do not name a metric of the project, with no error; compare the ids of the result with the ids you sent.
| PARAMETER | DESCRIPTION |
|---|---|
entries
|
One entry per metric.
TYPE:
|
validate
|
Check new definitions with the mirror of the server schema (default).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[SavedMetric]
|
The updated |
list[SavedMetric]
|
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
An entry breaks a rule of
:meth: |
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The read of an entry's metric failed (404), the caller cannot edit one of the metrics (403), or a new name is taken (409). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 | |
delete_metric
¶
Delete one saved metric, after a read that confirms it exists and is yours to edit.
The server has no working single-metric delete, and its bulk delete skips unknown ids with no error. So this method reads the metric first, then sends the bulk delete with the one id. An unknown id raises instead of passing silently. The delete is a soft delete on the server; reports that refer to the metric keep a copy of its definition but lose the link.
The server's bulk delete lets a project superadmin delete metrics
that other users own, even when the metric's can_update_basic
flag is false for that account. So this method refuses a metric
whose can_update_basic is false, unless force is true. A
read without the flag does not refuse; the server stays the
authority.
| PARAMETER | DESCRIPTION |
|---|---|
metric_id
|
The saved metric id.
TYPE:
|
force
|
Delete even when the read says that the caller cannot edit the metric (a superadmin account can delete metrics that other users own). The existence read still runs.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
The read found no active metric with this
id (404); nothing was deleted ( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller cannot read or edit the metric, or lacks the warehouse permission for a warehouse metric (403). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 | |
delete_metrics
¶
Delete several saved metrics with one bulk request.
The server skips ids that do not name an active metric of the
project, with no error, so a typo in an id passes silently. Use
:meth:delete_metric to delete one metric with an existence check.
An empty sequence sends no request.
The server's bulk delete lets a project superadmin delete metrics
that other users own. So, unless force is true, this method
reads the metric list once and refuses the whole request, before
the delete, when any target has can_update_basic false. Ids that
the list does not hold are not refused; the server skips them.
| PARAMETER | DESCRIPTION |
|---|---|
metric_ids
|
The saved metric ids to delete.
TYPE:
|
force
|
Skip the list read and the permission guard, and send the delete as given.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
A target has |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller cannot edit one of the metrics, or lacks the warehouse permission for a warehouse metric (403); nothing was deleted. |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_behaviors
¶
list_behaviors(
*, behavior_type: str | None = None, name_contains: str | None = None
) -> list[SavedBehavior]
List saved behaviors: simple, funnel, and retention behaviors.
The server has no pagination, filters, or search, so one request fetches every active behavior, and the filters below apply locally to that response. The read timeout is at least 120 seconds.
| PARAMETER | DESCRIPTION |
|---|---|
behavior_type
|
Keep only behaviors of this type:
TYPE:
|
name_contains
|
Keep only behaviors whose name contains this text, ignoring case.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[SavedBehavior]
|
|
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller lacks the behaviors permission or scope (403). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
get_behavior
¶
Get one saved behavior by id, with its full definition.
The server does not answer an unknown or deleted id with 404; it
answers with a 500, which raises ServerError.
| PARAMETER | DESCRIPTION |
|---|---|
behavior_id
|
The saved behavior id.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SavedBehavior
|
The |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller lacks permission (403). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx), including an unknown or deleted behavior id. |
Example
Source code in src/mixpanel_headless/workspace.py
create_behavior
¶
Create a saved behavior: a reusable simple, funnel, or retention behavior.
The wire type of the behavior comes from its definition. Before the request, the method checks the name and description and the definition (see Raises). In a project with sharing on, a new behavior is private to its creator; this API cannot share 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. So the
method removes them from a RawBehaviorDefinition, with or
without validate, and a copy of a stored behavior works. A
definition compiled from a typed value never has one; if it does,
the method refuses it (SM4_SCHEMA).
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Name, behavior definition, and optional description.
TYPE:
|
validate
|
Check the definition with the mirror of the server
schema before the request (default), including the refusal
of legacy keys in a compiled definition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SavedBehavior
|
The created |
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
Before any request: an empty name
( |
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The server refused the body (400); the pricing-plan gate ("Cannot save behavior with your current plan") or a missing permission (403); an active behavior has the same name (409). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
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 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 | |
update_behavior
¶
update_behavior(
behavior_id: int, params: UpdateBehaviorParams, *, validate: bool = True
) -> SavedBehavior
Update a saved behavior: name, description, definition, or verified flag.
The server runs no schema check on an update and ignores the
behavior type, so a new definition goes through the checks of
:meth:create_behavior first. A new definition also makes the method
read the behavior, to refuse a change of type. The server answers
the read of an unknown or deleted id with a 500.
| PARAMETER | DESCRIPTION |
|---|---|
behavior_id
|
The saved behavior id.
TYPE:
|
params
|
The fields to change;
TYPE:
|
validate
|
Check a new definition with the mirror of the server
schema (default).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SavedBehavior
|
The updated |
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
Before any request: an empty name
( |
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller cannot edit the behavior (403), or the new name is taken (409). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx), including the read of an unknown behavior id. |
Source code in src/mixpanel_headless/workspace.py
9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 | |
delete_behavior
¶
Delete one saved behavior, after a read that confirms it exists and is yours to edit.
Sends the bulk delete with the one id, because the bulk route is the
one that checks the caller's permission; the single-behavior route
does not. The bulk route skips unknown ids with no error, so this
method reads the behavior first. For an unknown or deleted id that
read fails with a server 500 (ServerError), and nothing is
deleted.
The server's bulk delete lets a project superadmin delete behaviors
that other users created, even when the behavior's
can_update_basic flag is false for that account. So this method
refuses a behavior whose can_update_basic is false, unless
force is true. A read without the flag does not refuse.
| PARAMETER | DESCRIPTION |
|---|---|
behavior_id
|
The saved behavior id.
TYPE:
|
force
|
Delete even when the read says that the caller cannot edit the behavior. The existence read still runs.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
The read shows |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller cannot read or edit the behavior (403). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx), including the read of an unknown or deleted behavior id. |
Source code in src/mixpanel_headless/workspace.py
delete_behaviors
¶
Delete several saved behaviors with one bulk request.
The server skips ids that do not name a behavior of the project,
with no error, so a typo in an id passes silently. Use
:meth:delete_behavior to delete one behavior with an existence
check. An empty sequence sends no request.
The server's bulk delete lets a project superadmin delete behaviors
that other users created. So, unless force is true, this method
reads the behavior list once and refuses the whole request, before
the delete, when any target has can_update_basic false. Ids that
the list does not hold are not refused; the server skips them.
| PARAMETER | DESCRIPTION |
|---|---|
behavior_ids
|
The saved behavior ids to delete.
TYPE:
|
force
|
Skip the list read and the permission guard, and send the delete as given.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ParamValidationError
|
A target has |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
The caller cannot edit one of the behaviors (403). |
RateLimitError
|
Rate limit exceeded after retries (429). |
ServerError
|
Server-side errors (5xx). |
Example
Source code in src/mixpanel_headless/workspace.py
list_schema_registry
¶
List schema registry entries.
| PARAMETER | DESCRIPTION |
|---|---|
entity_type
|
Filter by entity type ("event", "custom_event", "profile"). If None, returns all schemas.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[SchemaEntry]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
RateLimitError
|
Rate limit exceeded (429). |
Example
Source code in src/mixpanel_headless/workspace.py
create_schema
¶
Create a single schema definition.
| PARAMETER | DESCRIPTION |
|---|---|
entity_type
|
Entity type ("event", "custom_event", "profile").
TYPE:
|
entity_name
|
Entity name (event name or "$user" for profile).
TYPE:
|
schema_json
|
JSON Schema Draft 7 definition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Created schema as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
RateLimitError
|
Rate limit exceeded (429). |
Example
Source code in src/mixpanel_headless/workspace.py
create_schemas_bulk
¶
Bulk create schemas.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Bulk creation parameters with entries list and optional truncate flag.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BulkCreateSchemasResponse
|
Response with |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
RateLimitError
|
Rate limit exceeded (429). |
Example
Source code in src/mixpanel_headless/workspace.py
update_schema
¶
Update a single schema definition (merge semantics).
| PARAMETER | DESCRIPTION |
|---|---|
entity_type
|
Entity type.
TYPE:
|
entity_name
|
Entity name.
TYPE:
|
schema_json
|
Partial JSON Schema to merge with existing.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Updated schema as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Entity not found or validation error (400, 404). |
RateLimitError
|
Rate limit exceeded (429). |
Example
Source code in src/mixpanel_headless/workspace.py
update_schemas_bulk
¶
Bulk update schemas (merge semantics per entry).
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Bulk update parameters with entries list.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[BulkPatchResult]
|
List of per-entry results with status ("ok" or "error"). |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
RateLimitError
|
Rate limit exceeded (429). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_schemas
¶
delete_schemas(
*, entity_type: str | None = None, entity_name: str | None = None
) -> DeleteSchemasResponse
Delete schemas by entity type and/or name.
If both provided, deletes a single schema. If only entity_type, deletes all schemas of that type. If neither, deletes all schemas.
| PARAMETER | DESCRIPTION |
|---|---|
entity_type
|
Filter by entity type.
TYPE:
|
entity_name
|
Filter by entity name (requires entity_type).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DeleteSchemasResponse
|
Response with |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400). |
RateLimitError
|
Rate limit exceeded (429). |
MixpanelHeadlessError
|
If entity_name is provided without entity_type. |
Example
Source code in src/mixpanel_headless/workspace.py
get_schema_enforcement
¶
Get current schema enforcement configuration.
| PARAMETER | DESCRIPTION |
|---|---|
fields
|
Comma-separated field names to return (e.g., "ruleEvent,state"). If None, returns all fields.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SchemaEnforcementConfig
|
Schema enforcement configuration. |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
No enforcement configured (404). |
Source code in src/mixpanel_headless/workspace.py
init_schema_enforcement
¶
Initialize schema enforcement.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Init parameters with rule_event. |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw API response as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Already initialized or invalid rule_event (400). |
Example
Source code in src/mixpanel_headless/workspace.py
update_schema_enforcement
¶
Partially update enforcement configuration.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Partial update parameters. |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw API response as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
No enforcement configured or validation error (400). |
Example
Source code in src/mixpanel_headless/workspace.py
replace_schema_enforcement
¶
Fully replace enforcement configuration.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Complete replacement parameters. |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw API response as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
Example
Source code in src/mixpanel_headless/workspace.py
delete_schema_enforcement
¶
Delete enforcement configuration.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw API response as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
No enforcement configured (404). |
Source code in src/mixpanel_headless/workspace.py
run_audit
¶
Run a full data audit (events + properties).
| RETURNS | DESCRIPTION |
|---|---|
AuditResponse
|
Audit response with violations and |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
No schemas defined (400). |
Example
Source code in src/mixpanel_headless/workspace.py
run_audit_events_only
¶
Run an events-only data audit (faster).
| RETURNS | DESCRIPTION |
|---|---|
AuditResponse
|
Audit response with event violations only. |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
No schemas defined (400). |
Source code in src/mixpanel_headless/workspace.py
list_data_volume_anomalies
¶
list_data_volume_anomalies(
*, query_params: dict[str, str] | None = None
) -> list[DataVolumeAnomaly]
List detected data volume anomalies.
| PARAMETER | DESCRIPTION |
|---|---|
query_params
|
Optional filters (status, limit, event_id, etc.).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[DataVolumeAnomaly]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
Example
Source code in src/mixpanel_headless/workspace.py
update_anomaly
¶
Update the status of a single anomaly.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Update parameters with id, status, and anomaly_class.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw API response as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Anomaly not found or invalid parameters (400). |
Example
Source code in src/mixpanel_headless/workspace.py
bulk_update_anomalies
¶
Bulk update anomaly statuses.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Bulk update with anomalies list and target status.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Raw API response as dict. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid parameters (400). |
Example
Source code in src/mixpanel_headless/workspace.py
list_deletion_requests
¶
List all event deletion requests.
| RETURNS | DESCRIPTION |
|---|---|
list[EventDeletionRequest]
|
List of |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
Source code in src/mixpanel_headless/workspace.py
create_deletion_request
¶
Create a new event deletion request.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Deletion parameters with event_name, from_date, to_date, and optional filters. |
| RETURNS | DESCRIPTION |
|---|---|
list[EventDeletionRequest]
|
Updated full list of deletion requests. |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Validation error (400). |
Example
Source code in src/mixpanel_headless/workspace.py
cancel_deletion_request
¶
Cancel a pending deletion request.
| PARAMETER | DESCRIPTION |
|---|---|
request_id
|
Deletion request ID to cancel.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[EventDeletionRequest]
|
Updated full list of deletion requests. |
| RAISES | DESCRIPTION |
|---|---|
ResponseValidationError
|
Malformed API response payload
( |
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Request not found or not cancellable (400). |
Source code in src/mixpanel_headless/workspace.py
preview_deletion_filters
¶
Preview what events a deletion filter would match.
This is a read-only operation that does not modify any data.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Preview parameters with event_name, date range, and optional filters. |
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]]
|
List of expanded/normalized filters. |
| RAISES | DESCRIPTION |
|---|---|
ConfigError
|
If credentials are not available. |
AuthenticationError
|
Invalid credentials (401). |
QueryError
|
Invalid filter parameters (400). |