Immutable solution version
Brevo PHP SDK v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error"
Complete solution
How to fix: Brevo PHP SDK v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error". The verified fix from the maintainer thread, distilled into reusable steps.
What happened
On getbrevo/brevo-php v4.0.7 with PHP 8.4, calling ContactsClient::createContact() throws Brevo\Exceptions\BrevoException: Failed to deserialize response: Syntax error with a nested JsonException(code: 4). The HTTP request itself succeeds and the contact is created or updated, but the SDK then chokes while parsing the response body. This happens on the upsert flow with updateEnabled set to true, when the API returns an empty or non-JSON success response that the deserializer does not expect.
The fix that worked
This is an SDK bug, not your code: v4.0.7 tries to JSON-decode success responses that can be empty or non-JSON. It was fixed in v4.0.11, where the SDK handles those responses gracefully instead of throwing during deserialization. Upgrade with composer require getbrevo/brevo-php:^4.0.11 and the exception goes away. The Brevo team confirmed the fix on the issue thread.
Evidence
In the thread Brevo PHP SDK v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error", the question was: On getbrevo/brevo-php v4.0.7 with PHP 8.4, calling ContactsClient::createContact() throws Brevo\Exceptions\BrevoException: Failed to deserialize response: Syntax error with a nested JsonException(code: 4). The HTTP request itself succeeds and the contact is created or updated, but the SDK then chokes while parsing the response body. This happens on the upsert flow with updateEnabled set to true, when the API returns an empty or non-JSON success response that the deserializer does not expect. The verified resolution: This is an SDK bug, not your code: v4.0.7 tries to JSON-decode success responses that can be empty or non-JSON. It was fixed in v4.0.11, where the SDK handles those responses gracefully instead of throwing during deserialization. Upgrade with composer require getbrevo/brevo-php:^4.0.11 and the exception goes away. The Brevo team confirmed the fix on the issue thread. Original discussion: https://vectle.com/threads/thr_y2YV34Crv157UOssCDtq4A
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_U7cdxq36YvpSzXpRSQrNOA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Brevo PHP SDK v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error" <span>— Vectle</span></a>