How to generate and populate a new sample via API? | XM Community
Skip to main content

We are on XM Directory Lite.

 

I’ve been trying to generate a sample via the Create Sample and/or Create Sample Definition APIs.

https://api.qualtrics.com/a42111b5a99eb-create-sample

https://api.qualtrics.com/d2348a0dfa5ff-create-sample-definition

 

I have multiple questions about how the filters are supposed to interact, but my main one is how to actually populate the sample so that I can download it with Get Sample Contacts (https://api.qualtrics.com/f7b8d90819090-get-sample-contacts)

 

The documentation for Create Sample implies that it will be populated,  but it’s not. Is there yet another API call I’m missing that needs to be used to trigger creation of the actual sample?

 

A post from 4 years ago indicates that there were technical issues with these APIs they were “working on” but I’m assuming this can’t be the same thing… (Could not get contact from Sample, alway return empty list | XM Community (qualtrics.com)

 

Thanks!

It cant be and/or, it has to the AND. You will first need to create a sample definition in which you’ll enter the filters and the sampling criteria. Then you take the sample definition id and call the create sample api specifying the mailing list. 

The filtering details on the api page maybe a little lacking, therefore my preferred method is to create a sample using the GUI using my desired filters. Then get the sample definition of that sample. Extact the filters from there and go from there.

 


Thank you, that was very helpful. I was using both in the proper way, maybe something was off with my criteria that led to zero contacts in the sample. I was thrown too by having criteria required in both places. (I understand how that is useful, just that in this case, I only needed one filter.)

 

The way the API generated sample displays in the GUI is a little odd as well. It implies that there are criteria, and that you can remove them. But you can’t see what they are. ¯\_(ツ)_/¯

 


One follow up question - is it just me or does the filter in the second call, Create Sample, have no effect on the sample? I essentially get 100% of what’s in the sample definition, no matter what.


The sample definition operates at the directory level. The create sample call operates at the mailing list level (specified by the parentId value).

The additional filters in the create sample call are for you ease and they’ll filter the sample further.

 

For example, if you have a sample definition that for high value customer where the amount spent is greater than 5K. You could generate a monthly sample that would use the sample definition id, but specify an additional filter of the last transaction being in the last 30 days.

 


I’ve been successful filtering in the definition, but not the with the sample call. Results are the same regardless of the sample call filter…

For my current needs I only need to get one to work, so I’ll probably set it aside for now.


Leave a Reply