# Create a new participant group within a workspace POST https://api.prolific.com/api/v1/participant-groups/ Content-Type: application/json Reference: https://beta-docs.prolific.com/api-reference/participant-groups/create-participant-group ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create a new participant group within a workspace version: endpoint_participantGroups.CreateParticipantGroup paths: /api/v1/participant-groups/: post: operationId: create-participant-group summary: Create a new participant group within a workspace tags: - - subpackage_participantGroups parameters: - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '201': description: Participant group created content: application/json: schema: $ref: '#/components/schemas/ParticipantGroupResponse' '400': description: Error content: {} requestBody: content: application/json: schema: type: object properties: workspace_id: type: string description: >- The id of the workspace to create the participant group in. Either a workspace or organisation ID must be specified. organisation_id: type: string description: >- The id of the organisation to create the participant group in. Either a workspace or organisation ID must be specified. name: type: string description: The name of the participant group description: type: string description: A description of the participant group participant_ids: type: array items: type: string description: The ids of participants to be initially added to the group required: - name components: schemas: ParticipantGroupFeederStudiesItemsFeederCompletionCodesItemsAction: type: string enum: - value: ADD_TO_PARTICIPANT_GROUP - value: REMOVE_FROM_PARTICIPANT_GROUP ParticipantGroupFeederStudiesItemsFeederCompletionCodesItems: type: object properties: code: type: string description: The code that will modify the participants in this group. code_type: type: string description: >- The label or code type given to this code within the context of the study. action: $ref: >- #/components/schemas/ParticipantGroupFeederStudiesItemsFeederCompletionCodesItemsAction description: The action that will be taken when this code is used. ParticipantGroupFeederStudiesItems: type: object properties: id: type: string description: The id of the study. name: type: string description: The name of the study. internal_name: type: string description: The internal name of the study. status: type: string description: The current status of the study. feeder_completion_codes: type: array items: $ref: >- #/components/schemas/ParticipantGroupFeederStudiesItemsFeederCompletionCodesItems description: >- The completion codes which will modify the participants in this group. ParticipantGroupResponse: type: object properties: id: type: string description: The id of the participant group name: type: string description: The name of the participant group project_id: type: - string - 'null' description: The id of the project the participant group belongs to workspace_id: type: - string - 'null' description: >- The id of the workspace the participant group belongs to. A participant group can only belong to either a workspace or an organisation. organisation_id: type: - string - 'null' description: >- The id of the organisation the participant group belongs to. A participant group can only belong to either a workspace or an organisation. description: type: - string - 'null' description: The user-provided description of the participant group participant_count: type: integer description: The number of participants in the participant group is_deleted: type: boolean description: Whether the participant group has been deleted feeder_studies: type: array items: $ref: '#/components/schemas/ParticipantGroupFeederStudiesItems' description: >- Details of all studies which are configured to modify the participants in this group through completion codes. ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/participant-groups/" payload = { "name": "Group 1", "workspace_id": "5e9b9c9b0f9c9a0001b1ca2f", "description": "Participants with confirmed special dietary requirements.", "participant_ids": ["5e9b9c9b0f9c9a0001b0b1f4", "5e9b9c9b0f9c9a0001b0b1f5", "5e9b9c9b0f9c9a0001b0b1f6"] } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/participant-groups/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"name":"Group 1","workspace_id":"5e9b9c9b0f9c9a0001b1ca2f","description":"Participants with confirmed special dietary requirements.","participant_ids":["5e9b9c9b0f9c9a0001b0b1f4","5e9b9c9b0f9c9a0001b0b1f5","5e9b9c9b0f9c9a0001b0b1f6"]}' }; 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/participant-groups/" payload := strings.NewReader("{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\",\n \"participant_ids\": [\n \"5e9b9c9b0f9c9a0001b0b1f4\",\n \"5e9b9c9b0f9c9a0001b0b1f5\",\n \"5e9b9c9b0f9c9a0001b0b1f6\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") 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/participant-groups/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\",\n \"participant_ids\": [\n \"5e9b9c9b0f9c9a0001b0b1f4\",\n \"5e9b9c9b0f9c9a0001b0b1f5\",\n \"5e9b9c9b0f9c9a0001b0b1f6\"\n ]\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/participant-groups/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\",\n \"participant_ids\": [\n \"5e9b9c9b0f9c9a0001b0b1f4\",\n \"5e9b9c9b0f9c9a0001b0b1f5\",\n \"5e9b9c9b0f9c9a0001b0b1f6\"\n ]\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/participant-groups/', [ 'body' => '{ "name": "Group 1", "workspace_id": "5e9b9c9b0f9c9a0001b1ca2f", "description": "Participants with confirmed special dietary requirements.", "participant_ids": [ "5e9b9c9b0f9c9a0001b0b1f4", "5e9b9c9b0f9c9a0001b0b1f5", "5e9b9c9b0f9c9a0001b0b1f6" ] }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/participant-groups/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\",\n \"participant_ids\": [\n \"5e9b9c9b0f9c9a0001b0b1f4\",\n \"5e9b9c9b0f9c9a0001b0b1f5\",\n \"5e9b9c9b0f9c9a0001b0b1f6\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "name": "Group 1", "workspace_id": "5e9b9c9b0f9c9a0001b1ca2f", "description": "Participants with confirmed special dietary requirements.", "participant_ids": ["5e9b9c9b0f9c9a0001b0b1f4", "5e9b9c9b0f9c9a0001b0b1f5", "5e9b9c9b0f9c9a0001b0b1f6"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/participant-groups/")! 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 import requests url = "https://api.prolific.com/api/v1/participant-groups/" payload = { "name": "Group 1", "workspace_id": "5e9b9c9b0f9c9a0001b1ca2f", "description": "Participants with confirmed special dietary requirements." } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/participant-groups/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"name":"Group 1","workspace_id":"5e9b9c9b0f9c9a0001b1ca2f","description":"Participants with confirmed special dietary requirements."}' }; 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/participant-groups/" payload := strings.NewReader("{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") 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/participant-groups/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/participant-groups/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/participant-groups/', [ 'body' => '{ "name": "Group 1", "workspace_id": "5e9b9c9b0f9c9a0001b1ca2f", "description": "Participants with confirmed special dietary requirements." }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/participant-groups/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"Group 1\",\n \"workspace_id\": \"5e9b9c9b0f9c9a0001b1ca2f\",\n \"description\": \"Participants with confirmed special dietary requirements.\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "name": "Group 1", "workspace_id": "5e9b9c9b0f9c9a0001b1ca2f", "description": "Participants with confirmed special dietary requirements." ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/participant-groups/")! 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() ```