Filters and /api/3/contacts problem

I am using the new version of the API - version 3 to grab all contacts that are active and have a specific tagid.

For some reason the filters are not working in my code?

It’s returning all the contacts instead of just the contacts with status=1 and tagid=187.

What am I doing incorrectly or is the API 3 not working?

This is what my code looks like:

$url = "https://EXAMPLE.api-us1.com";
$api_key = "XXXXXXXXXXXXXXXXXXXXXX";
$filters = "?filters[status]=1&filters[tagid]=187";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url."/api/3/contacts".$filters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Api-Token: ".$api_key));
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
$result = json_decode($output, true);

echo "result meta total: <br />" . $result["meta"]["total"] . "<br />";
echo "The entire result printed out:<br />";
echo "<pre>";
print_r($result);
echo "</pre>";

echo "API Call:<br />".$url."/api/3/contacts".$filters;

It looks like there was a mistake in the v3 API documentation.

Filters shouldn’t be like this:
$filters = "?filters[status]=1&filters[tagid]=187";

They should be like this:
$filters = "?status=1&tagid=187";

1 Like