# Update a workspace PATCH https://api.prolific.com/api/v1/workspaces/{workspace_id}/ Content-Type: application/json Updates a workspace's details. Reference: https://beta-docs.prolific.com/api-reference/workspaces/update-workspace ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Update a workspace version: endpoint_workspaces.UpdateWorkspace paths: /api/v1/workspaces/{workspace_id}/: patch: operationId: update-workspace summary: Update a workspace description: Updates a workspace's details. tags: - - subpackage_workspaces parameters: - name: workspace_id in: path description: Workspace 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: Updated workspace redirect link content: application/json: schema: $ref: '#/components/schemas/Workspace' '400': description: Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/Workspace' components: schemas: WorkspaceUser: type: object properties: id: type: string description: Id of user name: type: string description: Name of user email: type: string description: email of user roles: type: array items: type: string description: User roles in workspace required: - id ProjectShort: type: object properties: id: type: string description: Project id. It is created by Prolific. title: type: string description: Name of project description: type: string description: What is this project used for owner: type: string description: User id of the creator of the project. It is created by Prolific. users: type: array items: $ref: '#/components/schemas/WorkspaceUser' description: Data for all users who have access to this project naivety_distribution_rate: type: - number - 'null' format: double description: The rate at which the studies within this project are distributed. required: - id - title Workspace: type: object properties: id: type: string description: Workspace id. It is created by Prolific. title: type: string description: Name of workspace description: type: string description: What is this workspace used for owner: type: string description: Workspace id. It is created by Prolific. users: type: array items: $ref: '#/components/schemas/WorkspaceUser' description: Data for a user related to a workspace projects: type: array items: $ref: '#/components/schemas/ProjectShort' description: Data for a project related to a workspace wallet: type: string description: Wallet tied to workspace naivety_distribution_rate: type: - number - 'null' format: double description: The rate at which the studies within this workspace are distributed. required: - id - title ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/workspaces/workspace_id/" payload = { "id": "63722982f9cc073ecc730f6b", "title": "My new workspace" } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/workspaces/workspace_id/'; const options = { method: 'PATCH', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"id":"63722982f9cc073ecc730f6b","title":"My new workspace"}' }; 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/workspaces/workspace_id/" payload := strings.NewReader("{\n \"id\": \"63722982f9cc073ecc730f6b\",\n \"title\": \"My new workspace\"\n}") req, _ := http.NewRequest("PATCH", 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/workspaces/workspace_id/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"id\": \"63722982f9cc073ecc730f6b\",\n \"title\": \"My new workspace\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.patch("https://api.prolific.com/api/v1/workspaces/workspace_id/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"id\": \"63722982f9cc073ecc730f6b\",\n \"title\": \"My new workspace\"\n}") .asString(); ``` ```php request('PATCH', 'https://api.prolific.com/api/v1/workspaces/workspace_id/', [ 'body' => '{ "id": "63722982f9cc073ecc730f6b", "title": "My new workspace" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/workspaces/workspace_id/"); var request = new RestRequest(Method.PATCH); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"id\": \"63722982f9cc073ecc730f6b\",\n \"title\": \"My new workspace\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "id": "63722982f9cc073ecc730f6b", "title": "My new workspace" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/workspaces/workspace_id/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" 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() ```