Surveymonkey creates a new survey programmatically?

How do I programmatically create new polls (with new questions and parameters) using the surveillanceymonkey API?

The only suitable API method I could find is create_flow, which works with existing polls / templates. I'm not sure if it allows changing polls to include new questions.

+3


source to share


1 answer


As mentioned, there was no way to do this in version 2 of the API. This is now possible in API v3.

See docs here:

https://developer.surveymonkey.com/api/v3/#surveys

Example:

Create a new survey:

POST /surveys
{
  "title": "Example Survey"
}

      



This will return the survey_id of the survey. Use it to create a new page:

POST /surveys/<survey_id>/pages
{
  "title": "My First Page",
  "description": "Page description",
  "position": 1
}

      

This will return the page_id of the page, use it to create a new question:

POST /surveys/<survey_id>/pages/<page_id>/questions
{
  "family": "single_choice",
  "subtype": "vertical",
  "answers": {
    "choices": [
      {
        "text": "Apple",
        "position": 1
      },
      {
        "text": "Orange",
        "position": 2
      },
      {
        "text": "Banana",
        "position": 3
      }
    ]
  },
  "headings": [
    {
      "heading": "What is your favourite fruit?"
    }
  ],
  "position": 1
}

      

Alternatively, if you already have the entire survey you want to create, you can create it all at once by POSTing to the original endpoint with all the payload:

POST /surveys
{
  "title": "Example Survey",
  "pages": [
    {
      "title": "My First Page",
      "description": "Page description",
      "position": 1,
      "questions": [
        {
          "family": "single_choice",
          "subtype": "vertical",
          "answers": {
            "choices": [
              {
                "text": "Apple",
                "position": 1
              },
              {
                "text": "Orange",
                "position": 2
              },
              {
                "text": "Banana",
                "position": 3
              }
            ]
          },
          "headings": [
            {
              "heading": "What is your favourite fruit?"
            }
          ],
          "position": 1
        }
      ]
    }
  ]
}

      

+1


source







All Articles