Issues with using the 'where' field in Mixpanel export API causing error 400
whats wrong with export api 'where' field?
$client = new \GuzzleHttp\Client();
$projectId = 3334207;
$fromDate = '2025-12-28';
$toDate = '2025-12-28';
$eventName = 'checkout';
$distinctId = '4612';
$where = urlencode('properties["distinct_id"] == "3147"');
$response = $client->request('GET', 'https://data-eu.mixpanel.com/api/2.0/export', [
'http_errors' => false, // IMPORTANT: lets you read the body on 400
'auth' => [$username, $secret], // better than hardcoding a base64 header
'headers' => [
'accept' => 'text/plain',
],
'query' => [
'project_id' => $projectId,
'from_date' => $fromDate,
'to_date' => $toDate,
'limit' => 1,
'event' => json_encode([$eventName]),
'where' => $where,
],
]);
echo "HTTP: " . $response->getStatusCode() . "\n";
echo (string) $response->getBody();
Error 400
