# Create credential pool POST https://api.prolific.com/api/v1/credentials/ Content-Type: application/json Create a new workspace-level credential pool. Credential pools contain username/password pairs that can be assigned to participants when they start a study. This allows researchers to provide pre-provisioned credentials for third-party platforms. The credentials are provided as a CSV string where each line contains a username and password separated by a comma (e.g., "user1,pass1\nuser2,pass2"). Reference: https://beta-docs.prolific.com/api-reference/credentials/create-credential-pool ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create credential pool version: endpoint_credentials.CreateCredentialPool paths: /api/v1/credentials/: post: operationId: create-credential-pool summary: Create credential pool description: >- Create a new workspace-level credential pool. Credential pools contain username/password pairs that can be assigned to participants when they start a study. This allows researchers to provide pre-provisioned credentials for third-party platforms. The credentials are provided as a CSV string where each line contains a username and password separated by a comma (e.g., "user1,pass1\nuser2,pass2"). tags: - - subpackage_credentials parameters: - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string - name: Authorization in: header required: true schema: type: string responses: '201': description: Credential pool created successfully content: application/json: schema: $ref: >- #/components/schemas/Credentials_CreateCredentialPool_Response_201 '400': description: Error content: {} '403': description: Forbidden - User does not have workspace.workspace_update permission content: {} '409': description: >- Conflict - Duplicate credentials detected (username already exists in pool) content: {} '502': description: Bad Gateway - Credentials service unavailable or internal error content: {} requestBody: content: application/json: schema: type: object properties: credentials: type: string description: CSV-formatted credentials (username,password per line) workspace_id: type: string description: The ID of the workspace this credential pool belongs to required: - credentials - workspace_id components: schemas: Credentials_CreateCredentialPool_Response_201: type: object properties: credential_pool_id: type: string description: The unique identifier for the created credential pool ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/credentials/" payload = { "credentials": "user1,password1 user2,password2 user3,password3", "workspace_id": "507f1f77bcf86cd799439011" } 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/credentials/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"credentials":"user1,password1\nuser2,password2\nuser3,password3","workspace_id":"507f1f77bcf86cd799439011"}' }; 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/credentials/" payload := strings.NewReader("{\n \"credentials\": \"user1,password1\\nuser2,password2\\nuser3,password3\",\n \"workspace_id\": \"507f1f77bcf86cd799439011\"\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/credentials/") 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 \"credentials\": \"user1,password1\\nuser2,password2\\nuser3,password3\",\n \"workspace_id\": \"507f1f77bcf86cd799439011\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/credentials/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"credentials\": \"user1,password1\\nuser2,password2\\nuser3,password3\",\n \"workspace_id\": \"507f1f77bcf86cd799439011\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/credentials/', [ 'body' => '{ "credentials": "user1,password1\\nuser2,password2\\nuser3,password3", "workspace_id": "507f1f77bcf86cd799439011" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/credentials/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"credentials\": \"user1,password1\\nuser2,password2\\nuser3,password3\",\n \"workspace_id\": \"507f1f77bcf86cd799439011\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "credentials": "user1,password1 user2,password2 user3,password3", "workspace_id": "507f1f77bcf86cd799439011" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/credentials/")! 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() ```