Skip to main content
Solved

Help with Webhook to Preserve Initial Signup Source and Campaign (HTTP 409 Error)

  • December 27, 2024
  • 2 replies
  • 26 views

Forum|alt.badge.img+4

Hi Klaviyo Community,

I’m working on a flow that uses a webhook to preserve the source and campaign data for where users initially signed up. Here’s what I’m trying to achieve:

  1. All new signups have two properties: recent_signup_source and recent_signup_campaign.
  2. The webhook should take these values and store them in the properties initial_signup_source and initial_signup_campaign, ensuring we track where users originally signed up from.

Here’s the setup I’m using:
 

Headers and Keys:

Authorization: Klaviyo-API-Key YOUR_PRIVATE_API_KEY

Content-Type: application/json

Accept: application/json

revision: 2024-07-15



JSON

{ "data": { "type": "profile", "attributes": { "email": "{{ person.email }}", "properties": { "initial_signup_source": "{{ person.recent_signup_source }}", "initial_signup_campaign": "{{ person.recent_signup_campaign }}" } } } }

 

Problem:

When the flow runs and the webhook attempts to update an existing profile, I receive an HTTP 409 Conflict error.

  • I’ve already verified that there are no duplicate users with the same email or phone number in my account.
  • The error persists, even though the intent is only to update the properties initial_signup_source and initial_signup_campaign.
  •  

Questions:

  • Is my payload correctly structured for this use case?
  • Are there additional headers or steps required to avoid the conflict?
  • Could there be another reason the 409 error is triggered, despite no duplicates being present?

Best answer by Christiannoerbjerg

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:

  • revision: 2024-10-15

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

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

talhahussain
Problem Solver IV
Forum|alt.badge.img+8
  • Problem Solver IV
  • 76 replies
  • December 27, 2024

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:

  1. 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.

  2. 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.


Christiannoerbjerg
Expert Problem Solver II
Forum|alt.badge.img+12

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:

  • revision: 2024-10-15

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