> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://apidocs.polytomic.com/2023-04-25/api-reference/users/update/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server. # Update User PATCH https://app.polytomic.com/api/organizations/{org_id}/users/{id} Content-Type: application/json Updates a user's assigned permissions roles. > 🚧 Requires partner key > > User endpoints are only accessible using [partner keys](../../../../../guides/obtaining-api-keys#partner-keys). Reference: https://apidocs.polytomic.com/2023-04-25/api-reference/users/update ## Authentication - `Authorization` header (basic auth, required) — This is the Polytomic deployment key (on-premises only) - `Authorization` header (bearer token, required) — This is the Polytomic API key ## Request ### Path parameters - `id` (string, required) — Unique identifier of the user to update. - `org_id` (string, required) — Unique identifier of the organization the user belongs to. ### Body (application/json) This endpoint expects a V2UpdateUserRequestSchema. - `email` (string, required) — Email address used to sign the user in and receive notifications. - `role_ids` (list of string, optional) — Identifiers of the permissions roles to assign to the user. Must contain at least one entry when provided. - `role` (string, optional, deprecated) — Deprecated legacy role name. Use role_ids instead; setting both role and role_ids in the same request is rejected. ## Response ### 200 OK - `data` (V2User, optional) ## Errors ### 401 Unauthorized Error Unauthorized - `code` (integer, optional) — Application-specific error code. - `context` (map from string to any, optional) — Application context. - `error` (string, optional) — Error message. - `status` (string, optional) — Status text. ### 403 Forbidden Error Forbidden - `key` (string, optional) - `message` (string, optional) - `metadata` (map from string to any, optional) - `status` (integer, optional) ### 422 Unprocessable Entity Error Unprocessable Entity - `key` (string, optional) - `message` (string, optional) - `metadata` (map from string to any, optional) - `status` (integer, optional) ### 500 Internal Server Error Internal Server Error - `key` (string, optional) - `message` (string, optional) - `metadata` (map from string to any, optional) - `status` (integer, optional) ## Types ### V2User - `email` (string, optional) — Email address used to sign in and receive notifications. - `id` (string, optional) — Unique identifier of the user. - `organization_id` (string, optional) — Unique identifier of the organization the user belongs to. - `role_ids` (list of string, optional, nullable) — Identifiers of the permissions roles assigned to the user. - `role` (string, optional, deprecated) — Deprecated legacy role name. Use role_ids instead. ## Examples **Request** ```json { "email": "jane.doe@polytomic.com" } ``` **Response** ```json { "data": { "email": "jane.doe@polytomic.com", "id": "a3f1c9e2-7b4d-4f8a-9c2e-1d2f3b4a5c6d", "organization_id": "248df4b7-aa70-47b8-a036-33ac447e668d", "role_ids": [ "f47ac10b-58cc-4372-a567-0e02b2c3d479" ], "role": "admin" } } ``` **SDK Code** ```python import requests url = "https://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d" payload = { "email": "jane.doe@polytomic.com" } headers = { "X-Polytomic-Version": "X-Polytomic-Version" "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d'; const credentials = btoa(":"); const options = { method: 'PATCH', headers: { 'X-Polytomic-Version': 'X-Polytomic-Version', Authorization: `Basic ${credentials}`, 'Content-Type': 'application/json' }, body: '{"email":"jane.doe@polytomic.com"}' }; 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://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d" payload := strings.NewReader("{\n \"email\": \"jane.doe@polytomic.com\"\n}") req, _ := http.NewRequest("PATCH", url, payload) req.Header.Add("X-Polytomic-Version", "X-Polytomic-Version") req.SetBasicAuth("", "") 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://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["X-Polytomic-Version"] = 'X-Polytomic-Version' request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{\n \"email\": \"jane.doe@polytomic.com\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.patch("https://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d") .header("X-Polytomic-Version", "X-Polytomic-Version") .basicAuth("", "") .header("Content-Type", "application/json") .body("{\n \"email\": \"jane.doe@polytomic.com\"\n}") .asString(); ``` ```php request('PATCH', 'https://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d', [ 'body' => '{ "email": "jane.doe@polytomic.com" }', 'headers' => [ 'Content-Type' => 'application/json', 'X-Polytomic-Version' => 'X-Polytomic-Version', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.PATCH); request.AddHeader("X-Polytomic-Version", "X-Polytomic-Version"); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"email\": \"jane.doe@polytomic.com\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let credentials = Data(":".utf8).base64EncodedString() let headers = [ "X-Polytomic-Version": "X-Polytomic-Version", "Authorization": "Basic \(credentials)", "Content-Type": "application/json" ] let parameters = ["email": "jane.doe@polytomic.com"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.polytomic.com/api/organizations/248df4b7-aa70-47b8-a036-33ac447e668d/users/248df4b7-aa70-47b8-a036-33ac447e668d")! 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() ```