Skip to main content
Solved

Sending SMS via the API?


Forum|alt.badge.img+1

Hi there,

 

I’ve looked through the documentation provided and, unfortunately, it is severely lacking complete examples and explanations. Please help us an provide a complete example in cURL of:

 

  1. How can I create and send an SMS campaign completely via the API?
  2. How can I add media (image) to the content of such campaign?
  3. How can I send an SMS to an individual phone that has already double-opted in?

We need an automated way to create a campaign daily and attach an image, all of this through the API.

 

Looking forward to hearing from you. This functionality is critical to us.

Best answer by Brian Turcotte

Hi @MICDEV!

If I understand your use case correctly, I believe the endpoint you’re looking for is Create Campaign Send Job, which is the V3 replacement for the old endpoint you mentioned:

 

Additionally, here is our full comparison guide where you can find the V3 replacements of each legacy endpoint:

 

Best,

Brian

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

6 replies

Brian Turcotte
Forum|alt.badge.img+37

Hi @MICDEV!

As of right now, these SMS capabilities are not possible with API’s - however, SMS functionality is being planned for a future release, so I will mark this thread and update it when that release happens.
 

Best,

Brian


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 3 replies
  • July 13, 2023

Thank you @Brian Turcotte, so officially I cannot even create and send a campaign for SMS delivery at all?

Only way to send SMS campaign is manually through the dashboard?


What is the expected ETA for such features?


Brian Turcotte
Forum|alt.badge.img+37

Hi @MICDEV!

I’m excited to let you know that we actually released this functionality today! The APIs now allow for Create, Read, Update and Delete operations for SMS Campaigns:

 

Thanks for being a valued Community member!

 

Best,

Brian


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 3 replies
  • July 18, 2023

Hi there,

Thank you for this update, I was able to create a new SMS campaign but it did not send, even though I used send immediate. Can you let me know why I did not send out immediately and how I can accomplish this? This is the python code I am using for testing:

 


import requests

url = "https://a.klaviyo.com/api/campaigns/"

payload = { "data": {
        "type": "campaign",
        "attributes": {
            "name": "My new SMS Test  campaign",
            "audiences": {
                "included": ["UimH4a"],
                "excluded": []
            },
            "send_strategy": {
                "method": "immediate",
                
            },
            "campaign-messages": { "data": [
                    {
                        "type": "campaign-message",
                        "attributes": {
                            "channel": "sms",
                            "render_options": {
                                "shorten_links": True,
                                "add_org_prefix": True,
                                "add_info_link": True,
                                "add_opt_out_language": True,
                                "include_contact_card": True
                            },
                            "label": "MIC Test Message",
                            "content": { "body": "test SMS message" },
                        }
                    }
                ] },
            "send_options": { "use_smart_sending": False },
            
        }
    } }
headers = {
    "accept": "application/json",
    "revision": "2023-07-15",
    "content-type": "application/json",
    "Authorization": "Klaviyo-API-Key #################"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
 


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 3 replies
  • July 18, 2023

Hi @Brian Turcotte, while I am trying to figure this out, I noticed that the OLD api had an endpoint for sending the campaign (https://developers.klaviyo.com/en/v1-2/reference/send-campaign)

 

But this has since been removed?

Thanks again, really exciting to see this functionality coming online, we’re almost there next step is just getting it to send the SMS campaign via API, now that we’ve created it successfully.

Looking forward to hearing from you!


Brian Turcotte
Forum|alt.badge.img+37

Hi @MICDEV!

If I understand your use case correctly, I believe the endpoint you’re looking for is Create Campaign Send Job, which is the V3 replacement for the old endpoint you mentioned:

 

Additionally, here is our full comparison guide where you can find the V3 replacements of each legacy endpoint:

 

Best,

Brian


Reply