> 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 full documentation content, see https://docs.prolific.com/llms-full.txt.

# Create response

POST https://api.prolific.com/api/v1/surveys/{survey_id}/responses/
Content-Type: application/json

Create a Response for a survey.

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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolific API for Data Collectors
  version: 1.0.0
paths:
  /api/v1/surveys/{survey_id}/responses/:
    post:
      operationId: create-response
      summary: Create response
      description: Create a Response for a survey.
      tags:
        - subpackage_surveys
      parameters:
        - name: survey_id
          in: path
          required: true
          schema:
            type: string
        - 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/SurveyResponseOut'
        '400':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SurveyResponseIn'
servers:
  - url: https://api.prolific.com
components:
  schemas:
    SurveyResponseAnswer:
      type: object
      properties:
        answer_id:
          type: string
          format: uuid
          description: The answer ID.
        value:
          type: string
          description: The answer option value selected.
      required:
        - answer_id
        - value
      description: Responsible for defining a response to a question
      title: SurveyResponseAnswer
    SurveyQuestionResponse:
      type: object
      properties:
        answers:
          type: array
          items:
            $ref: '#/components/schemas/SurveyResponseAnswer'
          description: The answers selected.
        question_id:
          type: string
          format: uuid
          description: The question ID.
        question_title:
          type: string
          description: The title of the survey question.
      required:
        - answers
        - question_id
        - question_title
      description: Responsible for defining an answer to a survey question
      title: SurveyQuestionResponse
    SurveyResponseSection:
      type: object
      properties:
        questions:
          type: array
          items:
            $ref: '#/components/schemas/SurveyQuestionResponse'
          description: The questions for a given section.
        section_id:
          type: string
          format: uuid
          description: The section ID.
      required:
        - questions
        - section_id
      description: |-
        Responsible for linking question/answers to a response for a survey.

        This is more of a long term thing, but helps if we add now.
      title: SurveyResponseSection
    SurveyResponseIn:
      type: object
      properties:
        participant_id:
          type: string
          description: The Prolific participant ID.
        sections:
          type: array
          items:
            $ref: '#/components/schemas/SurveyResponseSection'
          description: An array of sections from the survey, otherwise use `questions`.
        questions:
          type: array
          items:
            $ref: '#/components/schemas/SurveyQuestionResponse'
          description: An array of questions from the survey, otherwise use `sections`.
        submission_id:
          type: string
          description: The Prolific submission ID.
      required:
        - participant_id
        - submission_id
      description: The model used to create a `Response`.
      title: SurveyResponseIn
    SurveyResponseOut:
      type: object
      properties:
        _id:
          type: string
        date_created:
          type: string
          format: date-time
          description: The date/time the response was created (UTC).
        date_modified:
          type: string
          format: date-time
          description: The date/time the response was modified (UTC).
        participant_id:
          type: string
          description: The Prolific participant ID.
        sections:
          type: array
          items:
            $ref: '#/components/schemas/SurveyResponseSection'
          description: An array of sections from the survey, otherwise `questions`.
        questions:
          type: array
          items:
            $ref: '#/components/schemas/SurveyQuestionResponse'
          description: An array of questions from the survey, otherwise `sections`.
        submission_id:
          type: string
          description: The Prolific submission ID.
      required:
        - participant_id
        - submission_id
      description: The model used to create a serialised representation a `Response`.
      title: SurveyResponseOut
    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>`.

```

## SDK Code Examples

```python with_sections
import requests

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

payload = {
    "participant_id": "62908f0b98a55b36ac68b992",
    "submission_id": "62908f0b98a55b36ac68b992",
    "sections": [
        {
            "questions": [
                {
                    "answers": [
                        {
                            "answer_id": "8bde0c5f-235e-41e6-bf82-b73e92852ac8",
                            "value": "Potato"
                        }
                    ],
                    "question_id": "827e810a-4b1a-40f6-8bc2-c3dd6fcedc25",
                    "question_title": "What is your favourite root vegetable?"
                }
            ],
            "section_id": "f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8"
        }
    ]
}
headers = {
    "Authorization": "Token <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript with_sections
const url = 'https://api.prolific.com/api/v1/surveys/survey_id/responses/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Token <token>', 'Content-Type': 'application/json'},
  body: '{"participant_id":"62908f0b98a55b36ac68b992","submission_id":"62908f0b98a55b36ac68b992","sections":[{"questions":[{"answers":[{"answer_id":"8bde0c5f-235e-41e6-bf82-b73e92852ac8","value":"Potato"}],"question_id":"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25","question_title":"What is your favourite root vegetable?"}],"section_id":"f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8"}]}'
};

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

```go with_sections
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n              \"value\": \"Potato\"\n            }\n          ],\n          \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n          \"question_title\": \"What is your favourite root vegetable?\"\n        }\n      ],\n      \"section_id\": \"f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8\"\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 with_sections
require 'uri'
require 'net/http'

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

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  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n              \"value\": \"Potato\"\n            }\n          ],\n          \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n          \"question_title\": \"What is your favourite root vegetable?\"\n        }\n      ],\n      \"section_id\": \"f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8\"\n    }\n  ]\n}"

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

```java with_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/survey_id/responses/")
  .header("Authorization", "Token <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n              \"value\": \"Potato\"\n            }\n          ],\n          \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n          \"question_title\": \"What is your favourite root vegetable?\"\n        }\n      ],\n      \"section_id\": \"f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolific.com/api/v1/surveys/survey_id/responses/', [
  'body' => '{
  "participant_id": "62908f0b98a55b36ac68b992",
  "submission_id": "62908f0b98a55b36ac68b992",
  "sections": [
    {
      "questions": [
        {
          "answers": [
            {
              "answer_id": "8bde0c5f-235e-41e6-bf82-b73e92852ac8",
              "value": "Potato"
            }
          ],
          "question_id": "827e810a-4b1a-40f6-8bc2-c3dd6fcedc25",
          "question_title": "What is your favourite root vegetable?"
        }
      ],
      "section_id": "f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Token <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp with_sections
using RestSharp;

var client = new RestClient("https://api.prolific.com/api/v1/surveys/survey_id/responses/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Token <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"sections\": [\n    {\n      \"questions\": [\n        {\n          \"answers\": [\n            {\n              \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n              \"value\": \"Potato\"\n            }\n          ],\n          \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n          \"question_title\": \"What is your favourite root vegetable?\"\n        }\n      ],\n      \"section_id\": \"f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift with_sections
import Foundation

let headers = [
  "Authorization": "Token <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "participant_id": "62908f0b98a55b36ac68b992",
  "submission_id": "62908f0b98a55b36ac68b992",
  "sections": [
    [
      "questions": [
        [
          "answers": [
            [
              "answer_id": "8bde0c5f-235e-41e6-bf82-b73e92852ac8",
              "value": "Potato"
            ]
          ],
          "question_id": "827e810a-4b1a-40f6-8bc2-c3dd6fcedc25",
          "question_title": "What is your favourite root vegetable?"
        ]
      ],
      "section_id": "f5e5c4dc-7d2e-40f1-a895-9bb2f8703fd8"
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/surveys/survey_id/responses/")! 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()
```

```python without_sections
import requests

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

payload = {
    "participant_id": "62908f0b98a55b36ac68b992",
    "submission_id": "62908f0b98a55b36ac68b992",
    "questions": [
        {
            "answers": [
                {
                    "answer_id": "8bde0c5f-235e-41e6-bf82-b73e92852ac8",
                    "value": "Potato"
                }
            ],
            "question_id": "827e810a-4b1a-40f6-8bc2-c3dd6fcedc25",
            "question_title": "What is your favourite root vegetable?"
        }
    ]
}
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/survey_id/responses/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Token <token>', 'Content-Type': 'application/json'},
  body: '{"participant_id":"62908f0b98a55b36ac68b992","submission_id":"62908f0b98a55b36ac68b992","questions":[{"answers":[{"answer_id":"8bde0c5f-235e-41e6-bf82-b73e92852ac8","value":"Potato"}],"question_id":"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25","question_title":"What is your favourite root vegetable?"}]}'
};

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/survey_id/responses/"

	payload := strings.NewReader("{\n  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n          \"value\": \"Potato\"\n        }\n      ],\n      \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n      \"question_title\": \"What is your favourite root vegetable?\"\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/survey_id/responses/")

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  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n          \"value\": \"Potato\"\n        }\n      ],\n      \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n      \"question_title\": \"What is your favourite root vegetable?\"\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/survey_id/responses/")
  .header("Authorization", "Token <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n          \"value\": \"Potato\"\n        }\n      ],\n      \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n      \"question_title\": \"What is your favourite root vegetable?\"\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/survey_id/responses/', [
  'body' => '{
  "participant_id": "62908f0b98a55b36ac68b992",
  "submission_id": "62908f0b98a55b36ac68b992",
  "questions": [
    {
      "answers": [
        {
          "answer_id": "8bde0c5f-235e-41e6-bf82-b73e92852ac8",
          "value": "Potato"
        }
      ],
      "question_id": "827e810a-4b1a-40f6-8bc2-c3dd6fcedc25",
      "question_title": "What is your favourite root vegetable?"
    }
  ]
}',
  '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/survey_id/responses/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Token <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"participant_id\": \"62908f0b98a55b36ac68b992\",\n  \"submission_id\": \"62908f0b98a55b36ac68b992\",\n  \"questions\": [\n    {\n      \"answers\": [\n        {\n          \"answer_id\": \"8bde0c5f-235e-41e6-bf82-b73e92852ac8\",\n          \"value\": \"Potato\"\n        }\n      ],\n      \"question_id\": \"827e810a-4b1a-40f6-8bc2-c3dd6fcedc25\",\n      \"question_title\": \"What is your favourite root vegetable?\"\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 = [
  "participant_id": "62908f0b98a55b36ac68b992",
  "submission_id": "62908f0b98a55b36ac68b992",
  "questions": [
    [
      "answers": [
        [
          "answer_id": "8bde0c5f-235e-41e6-bf82-b73e92852ac8",
          "value": "Potato"
        ]
      ],
      "question_id": "827e810a-4b1a-40f6-8bc2-c3dd6fcedc25",
      "question_title": "What is your favourite root vegetable?"
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/surveys/survey_id/responses/")! 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()
```