Skip to main content

Import Survey

POST 

/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.

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.

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.

python Python 3

# 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')
}

response = requests.post(baseUrl, files=files, 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.

python Python 3

# 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)

python Python 3 without requests_toolbelt

# 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​

Responses​

Successful Import Survey Response