# Create a mutually exclusive study collection. POST https://api.prolific.com/api/v1/study-collections/mutually-exclusive/ Content-Type: application/json Create a mutually exclusive study collection. - Studies and study collections must be created separately and then added to the mutually exclusive study collection. - Both the studies and the study collection must be in the same project. - You can only add draft studies to a mutually exclusive study collection. - Adding studies which are already in one study collection to another study collection will remove the study from the original study collection. Reference: https://beta-docs.prolific.com/api-reference/study-collections/create-mutually-exclusive-study-collection ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create a mutually exclusive study collection. version: endpoint_studyCollections.CreateMutuallyExclusiveStudyCollection paths: /api/v1/study-collections/mutually-exclusive/: post: operationId: create-mutually-exclusive-study-collection summary: Create a mutually exclusive study collection. description: >- Create a mutually exclusive study collection. - Studies and study collections must be created separately and then added to the mutually exclusive study collection. - Both the studies and the study collection must be in the same project. - You can only add draft studies to a mutually exclusive study collection. - Adding studies which are already in one study collection to another study collection will remove the study from the original study collection. tags: - - subpackage_studyCollections parameters: - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/MutuallyExclusiveStudyCollectionList' '400': description: Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/MutuallyExclusiveStudyCollectionCreate' components: schemas: MutuallyExclusiveStudyCollectionCreate: type: object properties: name: type: string description: Mutually exclusive study collection name description: type: string description: A description of the study collection project_id: type: string description: Project id study_ids: type: array items: type: string description: >- List of study ids you wish to include in the collection. Note, this will overwrite the current list of studies in the collection publish_at: type: - string - 'null' description: >- Datetime and timezone the study collection should be scheduled to be published at required: - name - description - project_id MutuallyExclusiveStudyCollectionListStatus: type: string enum: - value: ACTIVE - value: PAUSED - value: UNPUBLISHED - value: PUBLISHING - value: AWAITING_REVIEW - value: SCHEDULED MutuallyExclusiveStudyCollectionList: type: object properties: name: type: string description: Mutually exclusive study collection name description: type: string description: A description of the study collection publish_at: type: - string - 'null' description: >- Datetime and timezone the study collection should be scheduled to be published at study_ids: type: array items: type: string description: >- List of study ids you wish to include in the collection. Note, this will overwrite the current list of studies in the collection id: type: string description: Mutually exclusive study collection id status: $ref: '#/components/schemas/MutuallyExclusiveStudyCollectionListStatus' description: Status of the study collection ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/study-collections/mutually-exclusive/" payload = { "name": "My Mutually Exclusive Study Collection", "description": "This is a description of my mutually exclusive study collection", "project_id": "65786062db3b35bcbeb07bcc", "study_ids": ["5f7b9a7b5f7b9a7b5f7b9a7b", "5f7b9a7b5f7b9a7b5f7b9a6b"] } 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/study-collections/mutually-exclusive/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"name":"My Mutually Exclusive Study Collection","description":"This is a description of my mutually exclusive study collection","project_id":"65786062db3b35bcbeb07bcc","study_ids":["5f7b9a7b5f7b9a7b5f7b9a7b","5f7b9a7b5f7b9a7b5f7b9a6b"]}' }; 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/study-collections/mutually-exclusive/" payload := strings.NewReader("{\n \"name\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\",\n \"study_ids\": [\n \"5f7b9a7b5f7b9a7b5f7b9a7b\",\n \"5f7b9a7b5f7b9a7b5f7b9a6b\"\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/study-collections/mutually-exclusive/") 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\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\",\n \"study_ids\": [\n \"5f7b9a7b5f7b9a7b5f7b9a7b\",\n \"5f7b9a7b5f7b9a7b5f7b9a6b\"\n ]\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/study-collections/mutually-exclusive/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\",\n \"study_ids\": [\n \"5f7b9a7b5f7b9a7b5f7b9a7b\",\n \"5f7b9a7b5f7b9a7b5f7b9a6b\"\n ]\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/study-collections/mutually-exclusive/', [ 'body' => '{ "name": "My Mutually Exclusive Study Collection", "description": "This is a description of my mutually exclusive study collection", "project_id": "65786062db3b35bcbeb07bcc", "study_ids": [ "5f7b9a7b5f7b9a7b5f7b9a7b", "5f7b9a7b5f7b9a7b5f7b9a6b" ] }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/study-collections/mutually-exclusive/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\",\n \"study_ids\": [\n \"5f7b9a7b5f7b9a7b5f7b9a7b\",\n \"5f7b9a7b5f7b9a7b5f7b9a6b\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "name": "My Mutually Exclusive Study Collection", "description": "This is a description of my mutually exclusive study collection", "project_id": "65786062db3b35bcbeb07bcc", "study_ids": ["5f7b9a7b5f7b9a7b5f7b9a7b", "5f7b9a7b5f7b9a7b5f7b9a6b"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/study-collections/mutually-exclusive/")! 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/study-collections/mutually-exclusive/" payload = { "name": "My Mutually Exclusive Study Collection", "description": "This is a description of my mutually exclusive study collection", "project_id": "65786062db3b35bcbeb07bcc" } 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/study-collections/mutually-exclusive/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"name":"My Mutually Exclusive Study Collection","description":"This is a description of my mutually exclusive study collection","project_id":"65786062db3b35bcbeb07bcc"}' }; 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/study-collections/mutually-exclusive/" payload := strings.NewReader("{\n \"name\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\"\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/study-collections/mutually-exclusive/") 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\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/study-collections/mutually-exclusive/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/study-collections/mutually-exclusive/', [ 'body' => '{ "name": "My Mutually Exclusive Study Collection", "description": "This is a description of my mutually exclusive study collection", "project_id": "65786062db3b35bcbeb07bcc" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/study-collections/mutually-exclusive/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"My Mutually Exclusive Study Collection\",\n \"description\": \"This is a description of my mutually exclusive study collection\",\n \"project_id\": \"65786062db3b35bcbeb07bcc\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "name": "My Mutually Exclusive Study Collection", "description": "This is a description of my mutually exclusive study collection", "project_id": "65786062db3b35bcbeb07bcc" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/study-collections/mutually-exclusive/")! 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() ```