0
votes

In case of surveymonkey api's of version v2, 'https://api.surveymonkey.net/v2/batch/send_flow' with the body containing recepients list in an array will add all the recipients emailID's to the message simply.

But in case of version v3, is there a simple method to add all the recipients on a bulk and send the emails for all those recipients? The below flow to send the message will add only one recipients emailID or else we have to do several POST calls of "POST /collectors/{id}/messages/{id}/recipients" eachtime with a new emailID. How can we add all the emailID's into the recepients list with one api call and send message to that recipients list?

POST /surveys/{id}/collectors -> POST /collectors/{id}/messages -> POST /collectors/{id}/messages/{id}/recipients -> POST /collectors/{id}/messages/{id}/send

1

1 Answers

3
votes

The only way to do it is the way you suggested in V3 right now. The only thing I will add is that there is a bulk recipient endpoint.

So you would

POST /surveys/{id}/collectors
POST /collectors/{id}/messages
POST /collectors/{id}/messages/{id}/recipients/bulk
POST /collectors/{id}/messages/{id}/send

Part of the reason for preferring to split these up is for better transaction management. For example if you call send_flow and you create a collector and a message, then error trying to add recipients for whatever reason, you'll be left with lingering collector/messages. This way you can handle what happens on each error case yourself.

SurveyMonkey is considering releasing some SDKs that have functionality like that encapsulated, as well as potentially a batch request endpoint, but as of right now that is the process for sending a message in the API.

Example use of bulk recipient endpoint:

You can add a list of contacts to your message all at once like this:

POST /collectors/{id}/messages/{id}/recipients/bulk
{
    "contact_ids": ["1000", "10001"]
}

You can add all contacts from a list of Contact Lists all at once like this:

POST /collectors/{id}/messages/{id}/recipients/bulk
{
    "contact_list_ids": ["2000", "20001"]
}

Or you can manually add any number of contacts by email like this:

POST /collectors/{id}/messages/{id}/recipients/bulk
{
    "contacts": [{
        "email": "[email protected]",
        "first_name": "User 1",
        "last_name": "Testing" 
    },{
        "email": "[email protected]",
        "first_name": "User 2",
        "last_name": "Testing" 
    }]
}

I believe you can add from all three of those methods from one request.