Trying to call API with php (using symfony)

Hi, i’m using symfony 6 and I want to call the API from there, I searched for my accountid, zone id, created an API Token and even searched for the global api key to try every case but none have worked.

the last I tried is :

$query = json_encode([
            "query" => "{
                viewer {
                    zones(filter: { zoneTag: " . $zone . "}) {
                        httpRequests1dGroups(
                            orderBy: [date_ASC]
                            limit: 1000
                            filter: { date_gt: '2023-08-15' }
                        ) {
                            date: dimensions {
                                date
                            }
                            sum {
                                cachedBytes
                                bytes
                            }
                        }
                    }
                }
            }",
            "variables"=> []
        ]);

        $client = HttpClient::create();

        try {
            $response = $client->request('POST', "https://api.cloudflare.com/client/v4/graphql", [
                'headers' => [
                    "Content-Type" => "application/json",
                    "x-auth-key" => $token,
                    "x-auth-mail" => $xauthmail
                ],
                'body' => $query
            ]);

            $data = $response->toArray();
        }catch (\Exception $e) {
            $data = $e;
        }

this gives me

[Symfony\Component\HttpClient\Exception\ClientException](file:///var/www/dashboardAtixys/vendor/symfony/http-client/Exception/ClientException.php#L21) {#626 ▼ #message: "HTTP/2 400 returned for "https://api.cloudflare.com/client/v4/graphql"." #code: 400 #file: "[/var/www/dashboardAtixys/vendor/symfony/http-client/Response/CommonResponseTrait.php](file:///var/www/dashboardAtixys/vendor/symfony/http-client/Response/CommonResponseTrait.php#L168)" #line: 168 -response: [Symfony\Component\HttpClient\Response\CurlResponse](file:///var/www/dashboardAtixys/vendor/symfony/http-client/Response/CurlResponse.php#L28) {#616 ▶} trace: {▶} }

the only endpoint I managed to call is the GET that check if your API Token is valid, which is, I tried to put my global api key in x-auth-key and my Api token but none worked, I tried to put “Authorization” => $apiToken (with my Api token and my global api key) but this hasn’t worked too, i got account non authorized (though I get All Privileges), someone can help / explain me how to solve this ?