You're encountering an HTTP 409 Conflict error when your webhook attempts to update existing profiles in Klaviyo. This error typically arises when there's a conflict with unique identifiers, such as email addresses or phone numbers, in your profile data.
Potential Causes:
-
Duplicate Identifiers: Even if there are no exact duplicates, conflicts can occur if multiple profiles share the same phone number but have different email addresses. Klaviyo's API requires unique identifiers for each profile.
-
API Behavior: The createOrUpdateProfile
function may return a 409 error if it detects a duplicate identifier during an upsert operation. This is intended to prevent the creation of conflicting profiles.
GitHub
Recommendations:
-
Ensure Unique Identifiers: Verify that each profile has a unique combination of email and phone number. If your system allows duplicate phone numbers across different profiles, consider omitting the phone number from the webhook payload to avoid conflicts.
-
Review API Documentation: Familiarize yourself with Klaviyo's API error handling and status codes to better understand how to manage such conflicts.
-
Consult Klaviyo Support: If the issue persists, reaching out to Klaviyo's support team can provide personalized assistance tailored to your specific setup.
By addressing these potential causes, you can resolve the 409 Conflict error and successfully preserve the initial signup source and campaign data for your profiles.
Hi @Amir_al_saidi
Thank you for posting in the Community!
Let me share my thoughts below:
1. Verify Your payload structure:
Your payload structure looks almost correct, but the conflict might arise from the way Klaviyo expects properties to be updated. Instead of nesting properties under "attributes"
, Klaviyo’s API typically expects "properties"
directly in the payload.
Here’s the corrected payload structure:
{ "data": { "type": "profile", "attributes": { "email": "{{ person.email }}", "custom_properties": { "initial_signup_source": "{{ person.recent_signup_source }}", "initial_signup_campaign": "{{ person.recent_signup_campaign }}" } } } }
The key change is using "custom_properties"
instead of "properties"
. Klaviyo uses this to differentiate custom profile properties from system attributes.
2. Check for duplicate updates:
Even if there are no duplicate profiles, you could receive a 409 error if:
- The webhook tries to update the same profile multiple times simultaneously.
- The profile already has the properties
initial_signup_source
and initial_signup_campaign
, and the flow doesn’t allow overwrites.
Solution:
- Add a webhook to only update the profile if the
initial_signup_source
and initial_signup_campaign
properties are null
or not already set.
3. Include the correct headers:
Ensure your headers include all required fields:
Authorization: Klaviyo-API-Key YOUR_PRIVATE_API_KEY
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
If you’re using the most recent API version, include:
The right headers:
Authorization: Klaviyo-API-Key YOUR_PRIVATE_API_KEY Content-Type: application/vnd.api+json Accept: application/vnd.api+json revision: 2024-10-15
Hope that helps or else, let me know! :-)
Christian Nørbjerg Enger
Partner & CPO
Web: Segmento.dk
LinkedIn: @christianfromsegmento
Voldbjergvej 22b, 8240 Risskov