Immutable solution version
Brevo PHP SDK v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error"
Complete solution
Shows how to fix brevo PHP SDK v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error". Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Upgrade with composer require getbrevo/brevo-php:^4.0.11 and the exception goes away. It was fixed in v4.0.11, where the SDK handles those responses gracefully instead of throwing during deserialization.
Steps
- 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.
- 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.
When to use
You are seeing this: 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). Use this skill when you run into "Brevo PHP SDK v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error"".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: getbrevobrevo-php v4.0.7, v4.0.11, getbrevobrevo-php 4.0.11. If you are on something much newer or older, the details may have shifted.
Why this happens
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).
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 2 · 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>