> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.prolific.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.prolific.com/_mcp/server.

# Create survey

POST https://api.prolific.com/api/v1/surveys/
Content-Type: application/json

You can create a survey with either `sections -> questions` or just `questions`. This allows you to decide
how much flexibility you want in your survey design. However, if you want to render the survey in the Prolific Application, you must use `sections`.

Reference: https://docs.prolific.com/api-reference/surveys/create-survey

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolific API for Data Collectors
  version: 1.0.0
paths:
  /api/v1/surveys/:
    post:
      operationId: create-survey
      summary: Create survey
      description: >-
        You can create a survey with either `sections -> questions` or just
        `questions`. This allows you to decide

        how much flexibility you want in your survey design. However, if you
        want to render the survey in the Prolific Application, you must use
        `sections`.
      tags:
        - surveys
      parameters:
        - name: Authorization
          in: header
          description: >-
            The Prolific API uses API token to authenticate requests. You can
            create an API token directly from your settings.


            Your API token does not have an expiry date and carries full
            permission, so be sure to keep them secure.


            If your token is leaked, delete it and create a new one directly in
            the app.


            In your requests add `Authorization` header with the value `Token
            <your token>`.
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SurveyOut'
        '400':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SurveyIn'
servers:
  - url: https://api.prolific.com
    description: Production
components:
  schemas:
    SurveyAnswerOption:
      type: object
      properties:
        id:
          type: string
          format: uuid
        value:
          type: string
          description: The answer option value that can be selected.
      required:
        - value
      description: Responsible for defining an answer model for a given question
      title: SurveyAnswerOption
    SurveyQuestionType:
      type: string
      enum:
        - single
        - multiple
      description: |-
        Responsible for articulating the question type. At the moment we have:

        - single answer
        - multiple answer

        Args:
            str (_type_): The type of question.
            Enum (_type_): The class to define an enum.
      title: SurveyQuestionType
    SurveyQuestion:
      type: object
      properties:
        answers:
          type: array
          items:
            $ref: '#/components/schemas/SurveyAnswerOption'
          description: An array of answer options for a question.
        id:
          type: string
          format: uuid
        title:
          type: string
          description: The question title.
        type:
          $ref: '#/components/schemas/SurveyQuestionType'
          description: The type of question being asked.
      required:
        - answers
        - title
        - type
      description: Responsible for defining a question within a survey.
      title: SurveyQuestion
    SurveySection:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Auto generated by the system.
        questions:
          type: array
          items:
            $ref: '#/components/schemas/SurveyQuestion'
          description: An array of questions a section within a Survey.
        title:
          type: string
          description: The section title.
      required:
        - questions
        - title
      description: |-
        Responsible for providing a section to the survey.

        This is more of a long term thing, but helps if we add now.
      title: SurveySection
    SurveyIn:
      type: object
      properties:
        researcher_id:
          type: string
          description: The Prolific researcher ID.
        sections:
          type: array
          items:
            $ref: '#/components/schemas/SurveySection'
          description: An array of sections in the survey, or use `questions`.
        questions:
          type: array
          items:
            $ref: '#/components/schemas/SurveyQuestion'
          description: An array of questions in the survey, or use `sections`.
        title:
          type: string
          description: The survey title.
      required:
        - researcher_id
        - title
      description: The model used to create a `Survey`.
      title: SurveyIn
    SurveyOut:
      type: object
      properties:
        _id:
          type: string
          description: Auto generated by the system.
        date_created:
          type: string
          format: date-time
          description: The date/time the survey was created (UTC).
        date_modified:
          type: string
          format: date-time
          description: The date/time the survey was modified (UTC).
        researcher_id:
          type: string
          description: The Prolific researcher ID.
        sections:
          type: array
          items:
            $ref: '#/components/schemas/SurveySection'
          description: >-
            Optional: An array of sections in the survey, otherwise `questions`
            will be defined.
        questions:
          type: array
          items:
            $ref: '#/components/schemas/SurveyQuestion'
          description: >-
            Optional: An array of questions in the survey, otherwise `sections`
            will be defined.
        title:
          type: string
          description: The survey title.
      required:
        - researcher_id
        - title
      description: The model used to create a serialised representation a `Survey`.
      title: SurveyOut
    ErrorDetailDetail2:
      type: object
      properties:
        any_field:
          type: array
          items:
            type: string
          description: >-
            Name of the field with a validation error and as a value an array
            with the error descriptions
      description: All fields with validation errors
      title: ErrorDetailDetail2
    ErrorDetailDetail:
      oneOf:
        - type: string
        - type: array
          items:
            type: string
        - $ref: '#/components/schemas/ErrorDetailDetail2'
      description: Error detail
      title: ErrorDetailDetail
    ErrorDetail:
      type: object
      properties:
        status:
          type: integer
          description: Status code as in the http standards
        error_code:
          type: integer
          description: Internal error code
        title:
          type: string
          description: Error title
        detail:
          $ref: '#/components/schemas/ErrorDetailDetail'
          description: Error detail
        additional_information:
          type: string
          description: Optional extra information
        traceback:
          type: string
          description: Optional debug information
        interactive:
          type: boolean
      required:
        - status
        - error_code
        - title
        - detail
      title: ErrorDetail
    Error:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      title: Error
  securitySchemes:
    token:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        The Prolific API uses API token to authenticate requests. You can create
        an API token directly from your settings.


        Your API token does not have an expiry date and carries full permission,
        so be sure to keep them secure.


        If your token is leaked, delete it and create a new one directly in the
        app.


        In your requests add `Authorization` header with the value `Token <your
        token>`.

```

## Examples

### without_sections



**Request**

```json
{
  "researcher_id": "7172727272",
  "title": "A survey with questions",
  "questions": [
    {
      "answers": [
        {
          "value": "Potato",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        }
      ],
      "title": "What is your favourite root vegetable?",
      "type": "single",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    }
  ]
}
```

**Response**

```json
{
  "researcher_id": "7172727272",
  "title": "A survey about vegetables",
  "_id": "string",
  "date_created": "2022-05-27T08:43:12",
  "date_modified": "2022-05-27T08:43:12",
  "sections": [
    {
      "questions": [
        {
          "answers": [
            {
              "value": "Potato",
              "id": "string"
            }
          ],
          "title": "What is your favourite root vegetable?",
          "type": "single",
          "id": "string"
        }
      ],
      "title": "Root vegetables",
      "id": "string"
    }
  ],
  "questions": [
    {
      "answers": [
        {
          "value": "Potato",
          "id": "string"
        }
      ],
      "title": "What is your favourite root vegetable?",
      "type": "single",
      "id": "string"
    }
  ]
}
```

**SDK Code**

```python without_sections
import requests

url = "https://api.prolific.com/api/v1/surveys/"

payload = {
    "researcher_id": "7172727272",
    "title": "A survey with questions",
    "questions": [
        {
            "answers": [
                {
                    "value": "Potato",
                    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
                }
            ],
            "title": "What is your favourite root vegetable?",
            "type": "single",
            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        }
    ]
}
headers = {
    "Authorization": "Token <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript without_sections
const url = 'https://api.prolific.com/api/v1/surveys/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Token <token>', 'Content-Type': 'application/json'},
  body: '{"researcher_id":"7172727272","title":"A survey with questions","questions":[{"answers":[{"value":"Potato","id":"497f6eca-6276-4993-bfeb-53cbbbba6f08"}],"title":"What is your favourite root vegetable?","type":"single","id":"497f6eca-6276-4993-bfeb-53cbbbba6f08"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go without_sections
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.prolific.com/api/v1/surveys/"

	payload := strings.NewReader("{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with questions\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"value\": \"Potato\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"What is your favourite root vegetable?\",\n      \"type\": \"single\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Token <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby without_sections
require 'uri'
require 'net/http'

url = URI("https://api.prolific.com/api/v1/surveys/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Token <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with questions\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"value\": \"Potato\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"What is your favourite root vegetable?\",\n      \"type\": \"single\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java without_sections
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolific.com/api/v1/surveys/")
  .header("Authorization", "Token <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with questions\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"value\": \"Potato\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"What is your favourite root vegetable?\",\n      \"type\": \"single\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}")
  .asString();
```

```php without_sections
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolific.com/api/v1/surveys/', [
  'body' => '{
  "researcher_id": "7172727272",
  "title": "A survey with questions",
  "questions": [
    {
      "answers": [
        {
          "value": "Potato",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        }
      ],
      "title": "What is your favourite root vegetable?",
      "type": "single",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Token <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp without_sections
using RestSharp;

var client = new RestClient("https://api.prolific.com/api/v1/surveys/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Token <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with questions\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"value\": \"Potato\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"What is your favourite root vegetable?\",\n      \"type\": \"single\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift without_sections
import Foundation

let headers = [
  "Authorization": "Token <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "researcher_id": "7172727272",
  "title": "A survey with questions",
  "questions": [
    [
      "answers": [
        [
          "value": "Potato",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        ]
      ],
      "title": "What is your favourite root vegetable?",
      "type": "single",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/surveys/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Example 2



**Request**

```json
{
  "researcher_id": "7172727272",
  "title": "A survey with sections and questions",
  "sections": [
    {
      "questions": [
        {
          "answers": [
            {
              "value": "Potato",
              "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
            }
          ],
          "title": "What is your favourite root vegetable?",
          "type": "single",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        }
      ],
      "title": "Root vegetables",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    }
  ]
}
```

**Response**

```json
{
  "researcher_id": "7172727272",
  "title": "A survey about vegetables",
  "_id": "string",
  "date_created": "2022-05-27T08:43:12",
  "date_modified": "2022-05-27T08:43:12",
  "sections": [
    {
      "questions": [
        {
          "answers": [
            {
              "value": "Potato",
              "id": "string"
            }
          ],
          "title": "What is your favourite root vegetable?",
          "type": "single",
          "id": "string"
        }
      ],
      "title": "Root vegetables",
      "id": "string"
    }
  ],
  "questions": [
    {
      "answers": [
        {
          "value": "Potato",
          "id": "string"
        }
      ],
      "title": "What is your favourite root vegetable?",
      "type": "single",
      "id": "string"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.prolific.com/api/v1/surveys/"

payload = {
    "researcher_id": "7172727272",
    "title": "A survey with sections and questions",
    "sections": [
        {
            "questions": [
                {
                    "answers": [
                        {
                            "value": "Potato",
                            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
                        }
                    ],
                    "title": "What is your favourite root vegetable?",
                    "type": "single",
                    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
                }
            ],
            "title": "Root vegetables",
            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        }
    ]
}
headers = {
    "Authorization": "Token <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.prolific.com/api/v1/surveys/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Token <token>', 'Content-Type': 'application/json'},
  body: '{"researcher_id":"7172727272","title":"A survey with sections and questions","sections":[{"questions":[{"answers":[{"value":"Potato","id":"497f6eca-6276-4993-bfeb-53cbbbba6f08"}],"title":"What is your favourite root vegetable?","type":"single","id":"497f6eca-6276-4993-bfeb-53cbbbba6f08"}],"title":"Root vegetables","id":"497f6eca-6276-4993-bfeb-53cbbbba6f08"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.prolific.com/api/v1/surveys/"

	payload := strings.NewReader("{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with sections and questions\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"value\": \"Potato\",\n              \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n            }\n          ],\n          \"title\": \"What is your favourite root vegetable?\",\n          \"type\": \"single\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"Root vegetables\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Token <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.prolific.com/api/v1/surveys/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Token <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with sections and questions\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"value\": \"Potato\",\n              \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n            }\n          ],\n          \"title\": \"What is your favourite root vegetable?\",\n          \"type\": \"single\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"Root vegetables\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolific.com/api/v1/surveys/")
  .header("Authorization", "Token <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with sections and questions\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"value\": \"Potato\",\n              \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n            }\n          ],\n          \"title\": \"What is your favourite root vegetable?\",\n          \"type\": \"single\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"Root vegetables\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolific.com/api/v1/surveys/', [
  'body' => '{
  "researcher_id": "7172727272",
  "title": "A survey with sections and questions",
  "sections": [
    {
      "questions": [
        {
          "answers": [
            {
              "value": "Potato",
              "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
            }
          ],
          "title": "What is your favourite root vegetable?",
          "type": "single",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        }
      ],
      "title": "Root vegetables",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Token <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.prolific.com/api/v1/surveys/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Token <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"researcher_id\": \"7172727272\",\n  \"title\": \"A survey with sections and questions\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"value\": \"Potato\",\n              \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n            }\n          ],\n          \"title\": \"What is your favourite root vegetable?\",\n          \"type\": \"single\",\n          \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n        }\n      ],\n      \"title\": \"Root vegetables\",\n      \"id\": \"497f6eca-6276-4993-bfeb-53cbbbba6f08\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Token <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "researcher_id": "7172727272",
  "title": "A survey with sections and questions",
  "sections": [
    [
      "questions": [
        [
          "answers": [
            [
              "value": "Potato",
              "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
            ]
          ],
          "title": "What is your favourite root vegetable?",
          "type": "single",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
        ]
      ],
      "title": "Root vegetables",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/surveys/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```