# Create a test study POST https://api.prolific.com/api/v1/studies/{id}/test-study ### Overview - Make sure atleast one test participant is created and exists against the user before hitting this endpoint. - To create test participant: POST /api/v1/researchers/participants/ - Create and publish a test study from a draft study to all the test participants associated with the workspace. - This will allow a data collector to test the study as a participant. ## Prerequisites ✅ **Required:** - At least one active test participant (created via [`POST /api/v1/researchers/participants/`](#)) - Study must be in draft status - Feature enabled for your workspace (contact support if unavailable) ### Enabling the feature This endpoint is only enabled for select workspaces and will need enabling before the endpoint can be used. Reference: https://beta-docs.prolific.com/api-reference/studies/create-test-study ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create a test study version: endpoint_studies.CreateTestStudy paths: /api/v1/studies/{id}/test-study: post: operationId: create-test-study summary: Create a test study description: > ### Overview - Make sure atleast one test participant is created and exists against the user before hitting this endpoint. - To create test participant: POST /api/v1/researchers/participants/ - Create and publish a test study from a draft study to all the test participants associated with the workspace. - This will allow a data collector to test the study as a participant. ## Prerequisites ✅ **Required:** - At least one active test participant (created via [`POST /api/v1/researchers/participants/`](#)) - Study must be in draft status - Feature enabled for your workspace (contact support if unavailable) ### Enabling the feature This endpoint is only enabled for select workspaces and will need enabling before the endpoint can be used. tags: - - subpackage_studies parameters: - name: id in: path description: Study id required: true schema: type: string - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: Found content: application/json: schema: $ref: '#/components/schemas/TestStudySetUpResponse' '400': description: Error content: {} components: schemas: TestStudySetUpResponse: type: object properties: study_id: type: string format: objectId description: The ID of the study that was created for the test. study_url: type: string format: uri description: The URL of the study that was created for the test. ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/studies/id/test-study" headers = {"Authorization": ""} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/studies/id/test-study'; const options = {method: 'POST', headers: {Authorization: ''}}; 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" "net/http" "io" ) func main() { url := "https://api.prolific.com/api/v1/studies/id/test-study" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "") 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/studies/id/test-study") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/studies/id/test-study") .header("Authorization", "") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/studies/id/test-study', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/studies/id/test-study"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/studies/id/test-study")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers 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() ```