Import Survey

POST {{baseUrl}}/surveys

The Import Survey API allows you to import a survey's definition from a file. The possible file types include QSF (Qualtrics Survey Format), TXT, and DOC files.

Lower Request Limit

This API allows 15 concurrent requests, which is different from the standard API Requests Limit.

See Import Survey for allowed content types.

For more information about using the survey APIs, see Managing Surveys.

For a discussion of these file types, see Import and Export Surveys.

For a detailed discussion of the Qualtrics .txt file format, see Preparing a Simple Format TXT File and Preparing an Advanced Format TXT File. <!-- theme: info -->

Get Survey Format

Note that the Import Survey API does not accept the same survey format that is returned by the Get Survey API.

The following example imports the survey Simple.qsf that was exported from the survey user interface (see Import and Export Surveys). The example imports a survey with a mime type of application/vnd.qualtrics.survey.qsf. Available import formats are listed at Import Survey.

# Import Survey 

import os
import requests

# Setting user Parameters
apiToken = os.environ["Q_API_TOKEN"] # 1
dataCenter = os.environ["Q_DATA_CENTER"]  # 2

baseUrl = "https://{0}.qualtrics.com/API/v3/surveys".format(dataCenter)
headers = {
    "x-api-token": apiToken,
    }

files = {
    'file': ('Simple.qsf', open('Simple.qsf', 'rb'), 'application/vnd.qualtrics.survey.qsf')
  }

data = { "name": "Test" }
response = requests.post(baseUrl, files=files, data=data, headers=headers)
print(response.text)

Delay

There is sometimes a delay before the newly created survey appears in the survey dashboard.

Import Survey from URL

You can import a survey that is located on a website. The file needs to be accessible to the Qualtrics servers, so it should be publicly accessible. Possible servers include Amazon's S3, Dropbox shared files, or public Google Drive files.

The example below shows how to import a .qsf file (with a mime type of application/vnd.qualtrics.survey.qsf). Available import formats are listed at Import Survey.

To import, you'll need

  • Your API token (needed for all API calls), item 1 in the sample below
  • Your data center ID (needed for all API calls), item 2 in the sample below
  • A survey name, item 3 in the sample below
  • The location of the import file (URL), item 4 in the sample below

To find these IDs, see Finding Qualtrics IDs.

Library Required

This first sample uses the requests_toolbelt library to create the multipart form data required by this API. Use pip to install it.

# Import Survey from URL

import os
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder

# Setting user Parameters
apiToken = os.environ["Q_API_TOKEN"] # 1
dataCenter = os.environ["Q_DATA_CENTER"]  # 2
surveyName = "NAME TO GIVE YOUR NEW SURVEY" # 3
fileUrl = "URL TO SURVEY" # 4 

baseUrl = "https://{0}.qualtrics.com/API/v3/surveys".format(dataCenter)

multipartData = MultipartEncoder(
  fields = { 
            "name": surveyName,
            "contentType": "application/vnd.qualtrics.survey.qsf",
            "fileUrl": fileUrl
        }
    )

headers = {
    "x-api-token": apiToken,
    "Content-Type": multipartData.content_type
    }

response = requests.post(baseUrl, data=multipartData, headers=headers)
print(response.text)

# Import Survey from URL

import os
import requests

# Setting user Parameters
apiToken = os.environ["Q_API_TOKEN"]      # 1
dataCenter = os.environ["Q_DATA_CENTER"]  # 2
surveyName = "Test Survey" # 3
fileUrl = "https://s3-us-west-2.amazonaws.com/S3bucketname/Test.qsf" # 4
baseUrl = "https://{0}.qualtrics.com/API/v3/surveys".format(dataCenter)

files = {
            "name": (None, surveyName),
            "contentType": (None, "application/vnd.qualtrics.survey.qsf"),
            "fileUrl": (None, fileUrl),
}

headers = {
    "x-api-token": apiToken,
    }

response = requests.post(baseUrl, files=files, headers=headers)
print(response.text)

Delay

There is sometimes a delay of several minutes before surveys imported with this API appear in the survey dashboard.

Request Body

[{"name"=>"name", "value"=>"<string>", "datatype"=>"string"}]

HEADERS

KeyDatatypeRequiredDescription
X-COPY-SOURCEstringThe surveyId for the survey to be copied
X-COPY-DESTINATION-OWNERstringThe userId for the user receiving the copied survey
Content-Typestring
Acceptstring

RESPONSES

status: OK

{&quot;result&quot;:{&quot;id&quot;:&quot;\u003cstring\u003e&quot;},&quot;meta&quot;:{&quot;httpStatus&quot;:&quot;\u003cstring\u003e&quot;,&quot;requestId&quot;:&quot;\u003cstring\u003e&quot;,&quot;notice&quot;:&quot;\u003cstring\u003e&quot;}}