Mixpanel Community Icon

Troubleshooting Mixpanel API Where Filter for Profile Requests

·
·

I am attempting to request profiles from the api and unfortunately are not able to get the where filter to work. I am doing the following:

last_seen_after = "2025-03-01"
params = {
  "project_id": self.project_id,
  "page_size": page_size,
  "page": page
}

if last_seen_after:
  params["where"] = f'properties["$last_seen"] > "{last_seen_after}"'

response = requests.get(
    "https://mixpanel.com/api/2.0/engage",
    params=params,
    auth=(self.api_secret, ''),
    timeout=120,
)

It is always returning 0 records. I have verified that there are users that would qualify for this request. What am I missing?

  • Avatar of Kale
    Kale
    ·
    ·

    I just ran a search in this chat and saw that unix time was recommended by another user. However that also failed to work. For example 'where': 'properties["$last_seen"] > "1740787200"' still fails. And your docs are no help. When I view the website, the API is using this payload where the structure is completely different:

    {"filter_by_cohort":{"raw_cohort":{"name":"","id":null,"unsavedId":null,"groups":[{"behavioralFiltersOperator":"and","event":{"resourceType":"cohort","value":"$all_users"},"filters":[{"resourceType":"user","propertyName":"$last_seen","propertyObjectKey":null,"propertyDefaultType":"datetime","propertyType":"datetime","filterOperator":"in the last","filterValue":{"type":"in the last","window":{"value":33,"unit":"day"}},"filterDateUnit":"day"}],"filtersOperator":"and","groupingOperator":null,"property":null,"type":"cohort_group"}]}},"sort_order":"descending","sort_column":{"dataGroupId":"","label":"Updated at","propertyDefaultType":"datetime","resourceType":"user","type":"datetime","value":"$last_seen"},"search":"","columns":[{"value":"$mp_name_with_fallbacks","resourceType":"user","dataGroupId":""},{"dataGroupId":"","label":"Email","propertyDefaultType":"string","resourceType":"user","type":"string","value":"$email"},{"dataGroupId":"","label":"Distinct ID","propertyDefaultType":"string","resourceType":"user","type":"string","value":"$distinct_id"},{"dataGroupId":"","label":"Updated at","propertyDefaultType":"datetime","resourceType":"user","type":"datetime","value":"$last_seen"},{"dataGroupId":"","label":"Country Code","propertyDefaultType":"string","resourceType":"user","type":"string","value":"$country_code"},{"dataGroupId":"","label":"Region","propertyDefaultType":"string","resourceType":"user","type":"string","value":"$region"},{"dataGroupId":"","label":"City","propertyDefaultType":"string","resourceType":"user","type":"string","value":"$city"},{"value":"$avatar","resourceType":"user","dataGroupId":""}],"tracking_props":{"is_main_query_for_report":true,"report_name":"users_sidebar"},"project_id":"PRIVATE","include_all_users":false,"limit":1000,"use_query_sampling":false,"workspace_id":"PRIVATE"}

    There is no where operator or anything displaying that I am filtering by $last_seen why is this so difficult?

  • Avatar of Kale
    Kale
    ·
    ·

    okay, it looks like datetimes need to be formatted like the following "2025-03-01T00:00:00"