Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

phpMick's avatar
Level 15

PATCH with Guzzle, what am I doing wrong?

Hi,

I am trying this:

$token = getenv('SENDGRID_API_KEY');

        $response = Http::withHeaders([
           'Authorization' => 'Bearer ' . $token
        ])->patch('https://api.sendgrid.com/v3/user/webhooks/event/settings/signed',['enabled' => 'true']);

I get Bad Request (400). What do I have wrong? It works with curl?

This is what I am trying to do:

https://docs.sendgrid.com/for-developers/tracking-events/getting-started-event-webhook-security-features#enabledisable-the-signed-webhook

Mick

0 likes
1 reply
goldeneye's avatar
Level 1

the body should be JSON. enabled should be boolean. Try:

Http::withToken($token)
   ->asJson()
   ->patch('https://api.sendgrid.com/v3/user/webhooks/event/settings/signed', ['enabled' => true]);

Please or to participate in this conversation.