Skip to main content
Solved

SMS Consent not updating using Python TrackIdentity API


Forum|alt.badge.img+2

I am creating Klaviyo events in Python using TrackIdentify API. I have added SMS consent to my events using this documentation, i.e. adding `$consent = [‘sms’]` as one of the customer_properties fields. When I export the resulting user, I can see the consent added to their profile in Klaviyo.

But still the SMS gets skipped with a “Missing Consent” error. Is there something I am missing here?

Note: I have seen multiple posts on this topic, but couldn’t find one which was using the Python API.

Best answer by alex.hong

Hi @aarshay and @BrownieDev ,

Thanks for sharing with the Community. 

Are you trying to add consent to customer profiles who have submitted a form or what is the method for collecting customer profiles onto your Klaviyo account first?

Can you also confirm you have create private API keys within your account to work with the Python code?
The 'Subscribe Profiles to List' endpoint requires according to our API documentation:
?name=inline1940628610.png

I'll need a bit more information about how exactly you are structuring your request, and subscribing profiles via this form you've created.  Can you provide a snippet of your code responsible for subscribing profiles when the form is submitted? Can you also show where the error is appearing? Is the profile’s $source property also API and not something else?

I have tried testing in previous situations and found that the API was being picky about how I formatted my phone number:
1. It needs to have the country code (+1), which is expected.
2. In my case, it had to be in single quotes, instead of double quotes. That typically isn't the case as I've ran it in double quotes successfully in the past, but I figured it is worth mentioning.

 

Thanks,

Alex

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

3 replies

BrownieDev
Problem Solver II
Forum|alt.badge.img+3
  • Problem Solver II
  • 5 replies
  • July 25, 2022

I tried to do something similar with email but was unable to get it to work. I don’t think consent can be granted like that.  If someone knows how, I’d like to know too. 


alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • Answer
  • July 25, 2022

Hi @aarshay and @BrownieDev ,

Thanks for sharing with the Community. 

Are you trying to add consent to customer profiles who have submitted a form or what is the method for collecting customer profiles onto your Klaviyo account first?

Can you also confirm you have create private API keys within your account to work with the Python code?
The 'Subscribe Profiles to List' endpoint requires according to our API documentation:
?name=inline1940628610.png

I'll need a bit more information about how exactly you are structuring your request, and subscribing profiles via this form you've created.  Can you provide a snippet of your code responsible for subscribing profiles when the form is submitted? Can you also show where the error is appearing? Is the profile’s $source property also API and not something else?

I have tried testing in previous situations and found that the API was being picky about how I formatted my phone number:
1. It needs to have the country code (+1), which is expected.
2. In my case, it had to be in single quotes, instead of double quotes. That typically isn't the case as I've ran it in double quotes successfully in the past, but I figured it is worth mentioning.

 

Thanks,

Alex


Forum|alt.badge.img
  • Contributor I
  • 1 reply
  • September 9, 2023

Certainly! If you're experiencing issues with updating SMS consent using the Python TrackIdentity API, you can follow these steps to troubleshoot the problem:

Authentication: Ensure that you've properly authenticated your API requests using the appropriate credentials or API key. Double-check that your authorization headers are correctly set up.

API Endpoint: Make sure you are using the correct API endpoint for updating SMS consent. Replace 'your_api_endpoint_here' with the actual endpoint provided by TrackIdentity.

Data Preparation: Construct the data payload with the user's ID and the new SMS consent status you want to set. Replace 'user_id_here' and new_sms_consent with the relevant user ID and consent status (either True or False).

API Request: Utilize the requests library to make a POST request to the API endpoint with the updated data. Check the response status code to confirm the success of the operation. If it's not 200, inspect the response for error details to identify the root cause of the issue.

Error Handling: Implement error handling to gracefully manage any failures in the API request, including logging error messages or taking appropriate corrective actions.

Ensure that you've referred to the TrackIdentity API documentation for any specific requirements or parameters unique to their API. By following these steps and adapting them to your specific use case, you should be able to diagnose and resolve issues related to updating SMS consent.