Using API for SMS Distribution without Mailing List Feature | XM Community
Skip to main content

Hi everyone,
I'm following this Qualtrics guide in order to use API in order to send a survey as an SMS message. However, I realized that my organization does not have access to the "Mailing List" feature, only "Contacts." I also do not have access to the directory ID/pool ID. The API works in that I do see that surveys are sent in the "Distribution History" ("Distributions" tab of website), but no actual SMS messages are being sent to my phone.
Is there a way for me to use the API to send SMS messages without this "Mailing List"? Such as using the Recipient IDs? Or is it possible to manually enter the Contact's phone numbers I wish to send messages to in the API?
Of note, I am able to send SMS messages directly using the "Distributions" tab on the Qualtrics website, and that works fine. So I am wondering what I am missing in order to use the API to do the same thing.
I would really appreciate any advice. Thank you so much for your help!


Python code I am using:
def sms(apiToken, dataCenter, method):
  headers = {
  "x-api-token": apiToken,
  "Content-Type": "application/json"
  }
    url = "https://{0}.qualtrics.com/API/v3/distributions/sms".format(dataCenter)
  recipients = {}
  recipients'mailingListId'] = mailingListId
  message = {}
  message 'messageId']= messageId
  messagea'libraryId']=libraryId
  data = {}
  data'sendDate'] = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime())
  dataS'method'] = method
  datae'surveyId'] = surveyId
  datav'name'] = "Customer Satisfaction Survey"
  dataS'recipients'] = recipients
  datai'message'] = message
  print(data)
  response = requests.post(url, json=data, headers=headers)
  print(response.text)

I believe you can use individual contact IDs instead of mailing lists, it's just quite a bit more complicated, because you first have to create a transaction for the contact, then add that transaction to a transaction batch, and then use the distribution API with the transaction batch instead of with the mailing list.
API 1: Create Contact Transaction
API 2: Create Transaction Batch
API 3: Create Distribution
And then you would replace this line
# old code
recipients['mailingListId'] = mailingListId
with the following
# new code
recipients["transactionBatchId"] = transactionBatchId
where transactionBatchId is a variable containing the output from API 2.
Are you sure you don't have access to mailing lists? I would be curious if you could create a mailing list using the Create Mailing List API and Create Contact in Mailing List API, just since I've never heard of Mailing List being a specific permission for some brands versus others.


Thank you for response!
In the API for "Create Contact Transaction", it seems that it requires the "directory ID" as a path parameter. Unfortunately, I do not have access to a "directory ID", so I am not able to fill out that space and doesn't seem like I am able to create Transactions.
Also I am fairly sure that I don't have access to mailing lists. In the API for "Create Mailing List", it states that "This API call is only available to XM Directory users" and I unfortunately do not have XM Directory. And it also requires a "directory ID" again, which I do not have.
Would you happen to be aware of any other possible solutions? Just because since I am able to send SMS messages directly through the Qualtrics website and I do have access to the API features, I figured that there should be a way to send SMS using API, even without the mailing list.
Thank you so much again for trying to help me! I'm pretty stumped by this issue.


Leave a Reply