Data Governance¶
Manage Mixpanel data governance programmatically: Lexicon definitions (events, properties, tags), drop filters, custom properties, custom events, lookup tables, schema registry, schema enforcement, data auditing, volume anomalies, and event deletion requests. Full CRUD operations with bulk support.
Prerequisites
Data governance requires authentication — service account or OAuth credentials.
All data governance operations require a workspace ID — set via MP_WORKSPACE_ID env var, --workspace-id CLI flag, or ws.set_workspace_id(). Find yours with mp inspect info or ws.info().
Read-Only Discovery
For read-only Lexicon schema exploration (listing events/properties with descriptions and metadata), see the Discovery guide — Lexicon Schemas. This guide covers write operations: creating, updating, and deleting definitions.
Lexicon — Event Definitions¶
Get Event Definitions¶
Update an Event Definition¶
Delete an Event Definition¶
Bulk Update Event Definitions¶
Update multiple event definitions in a single API call:
results = ws.bulk_update_event_definitions(
mp.BulkUpdateEventsParams(events=[
mp.BulkEventUpdate(name="OldEvent", hidden=True),
mp.BulkEventUpdate(name="NewEvent", verified=True),
mp.BulkEventUpdate(
name="Purchase",
description="Completed purchase",
tags=["revenue"],
),
])
)
for d in results:
print(f"{d.name}: hidden={d.hidden}, verified={d.verified}")
Lexicon — Property Definitions¶
Get Property Definitions¶
Update a Property Definition¶
Bulk Update Property Definitions¶
Lexicon — Tags¶
Organize event and property definitions with tags.
List Tags¶
Create a Tag¶
Update a Tag¶
Delete a Tag¶
Lexicon — Tracking & History¶
Tracking Metadata¶
Get tracking metadata for an event (sources, SDKs, volume):
Event History¶
View the change history for an event definition:
Property History¶
View the change history for a property definition:
Export Lexicon¶
Export all Lexicon data definitions:
Drop Filters¶
Drop filters suppress events at ingestion time, preventing them from being stored or counted.
List Drop Filters¶
Create a Drop Filter¶
Update a Drop Filter¶
Delete a Drop Filter¶
Drop Filter Limits¶
Custom Properties¶
Custom properties are computed properties defined by formulas or behaviors. They calculate values dynamically from existing event or profile properties.
PUT Semantics
Custom property update uses full replacement (PUT semantics). The resource_type and data_group_id fields are immutable after creation.
List Custom Properties¶
Get a Custom Property¶
Create a Custom Property¶
Custom properties can be formula-based or behavior-based:
# Formula-based custom property
prop = ws.create_custom_property(
mp.CreateCustomPropertyParams(
name="Full Name",
resource_type="events",
display_formula='concat(properties["first"], " ", properties["last"])',
composed_properties={
"first": mp.ComposedPropertyValue(resource_type="event"),
"last": mp.ComposedPropertyValue(resource_type="event"),
},
)
)
print(f"Created: {prop.name} (ID: {prop.custom_property_id})")
Formula vs Behavior
display_formula and behavior are mutually exclusive. If using display_formula, you must also provide composed_properties that map the referenced properties.
Update a Custom Property¶
Delete a Custom Property¶
Validate a Custom Property¶
Check whether a custom property definition is valid before creating it:
Custom Events¶
Custom events are composite events built from combinations of existing events. They share the same EventDefinition type as regular events.
List Custom Events¶
Update a Custom Event¶
Delete a Custom Event¶
Lookup Tables¶
Lookup tables are CSV-based reference data used to enrich event and profile properties. Upload a CSV, and Mixpanel maps its columns to properties for real-time enrichment.
List Lookup Tables¶
Upload a Lookup Table¶
3-Step Upload Process
upload_lookup_table() handles the full workflow automatically:
- Obtains a signed upload URL from the API
- Uploads the CSV file to the signed URL
- Registers the lookup table
For files >= 5 MB, processing is asynchronous. The method automatically polls for completion with configurable timeout.
table = ws.upload_lookup_table(
mp.UploadLookupTableParams(
name="Country Codes",
file_path="/path/to/countries.csv",
),
poll_interval=2.0, # Seconds between polls (async only)
max_poll_seconds=300.0, # Max wait time (async only)
)
print(f"Created: {table.name} (ID: {table.id})")
# Replace an existing lookup table
table = ws.upload_lookup_table(
mp.UploadLookupTableParams(
name="Country Codes",
file_path="/path/to/countries_v2.csv",
data_group_id=456, # Existing table's data group ID
)
)
Update a Lookup Table¶
Delete Lookup Tables¶
Download a Lookup Table¶
Advanced: Upload and Download URLs¶
For manual upload workflows or integration with external tools:
# Get a signed upload URL
url_info = ws.get_lookup_upload_url(content_type="text/csv")
print(url_info.url) # Signed GCS URL
# Check async upload status
status = ws.get_lookup_upload_status("upload-id-123")
print(status)
# Get a signed download URL
download_url = ws.get_lookup_download_url(data_group_id=123)
print(download_url)
Schema Registry¶
Manage JSON Schema Draft 7 definitions in Mixpanel's schema registry. Schemas define the expected structure of events, custom events, and profiles.
List Schema Entries¶
Create a Schema¶
Bulk Create Schemas¶
params = mp.BulkCreateSchemasParams(
entries=[
mp.SchemaEntry(
name="Login",
entity_type="event",
schema_definition={"properties": {"method": {"type": "string"}}},
),
mp.SchemaEntry(
name="Signup",
entity_type="event",
schema_definition={"properties": {"source": {"type": "string"}}},
),
],
truncate=False,
entity_type="event",
)
result = ws.create_schemas_bulk(params)
print(f"Added: {result.added}, Deleted: {result.deleted}")
Update a Schema (Merge Semantics)¶
Bulk Update Schemas¶
Delete Schemas¶
Destructive Operation
Schema deletion is irreversible. The CLI prompts for confirmation before proceeding.
Schema Enforcement¶
Configure how Mixpanel handles events that don't match defined schemas. Enforcement actions include "Warn and Accept", "Warn and Hide", and "Warn and Drop".
Get Enforcement Settings¶
Initialize Enforcement¶
Update Enforcement (PATCH)¶
Replace Enforcement (PUT)¶
Full Replacement
PUT semantics replace the entire enforcement configuration. All fields must be provided. The CLI prompts for confirmation.
Delete Enforcement¶
Destructive Operation
Deleting enforcement configuration is irreversible. The CLI prompts for confirmation.
Data Auditing¶
Audit your project's data against defined schemas to find violations such as unexpected events, missing properties, or type mismatches.
Run Full Audit¶
Run Events-Only Audit¶
A faster variant that only audits event schemas, skipping property-level checks.
Data Volume Anomalies¶
Monitor and manage anomalies detected in data volume patterns. Anomalies indicate unexpected spikes or drops that may signal tracking issues or data pipeline problems.
List Anomalies¶
Update an Anomaly¶
Bulk Update Anomalies¶
Event Deletion Requests¶
Submit and manage requests to delete event data by event name, date range, and optional property filters.
Destructive Operation
Event deletion is irreversible. Use preview to validate filters before creating a deletion request.
List Deletion Requests¶
Preview Deletion Filters¶
Preview what events would be affected before submitting a deletion request. This is a read-only operation with no side effects.
Create a Deletion Request¶
Cancel a Deletion Request¶
Only pending requests can be cancelled. The CLI prompts for confirmation.
Next Steps¶
- API Reference — Workspace — Complete method signatures and docstrings
- API Reference — Types — EventDefinition, DropFilter, CustomProperty, LookupTable, SchemaEntry, SchemaEnforcementConfig, AuditResponse, DataVolumeAnomaly, EventDeletionRequest, and all parameter types
- CLI Reference — Full CLI command documentation
- Entity Management — Manage dashboards, reports, cohorts, feature flags, experiments, alerts, annotations, and webhooks