# Get User By ID GET http://localhost:5000/myinstance1/users/{userId} Returns user details given their userId. We recommend a rate limit of 5 req/sec for this endpoint. Reference: https://docs.moveworks.com/api-reference/identity-gateway/get-user-by-id ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Get User By ID version: endpoint_.getUserById paths: /users/{userId}: get: operationId: get-user-by-id summary: Get User By ID description: >- Returns user details given their userId. We recommend a rate limit of 5 req/sec for this endpoint. tags: - [] parameters: - name: userId in: path description: ID of user to fetch details for required: true schema: type: string - name: Authorization in: header description: >- Bearer authentication of the form `Bearer `, where token is your auth token. required: true schema: type: string responses: '200': description: A single user content: application/json: schema: $ref: '#/components/schemas/User' components: schemas: UserUserState: type: string enum: - value: ACTIVE - value: INACTIVE UserUserWorkStatus: type: string enum: - value: UNKNOWN_WORK_STATUS - value: CONTINGENT - value: INTERN - value: FULL_TIME UserUserEmploymentInfoEmploymentLocation: type: object properties: location: type: string description: Specifies the location of the office office: type: string description: Denotes the name of the office country_code: type: string description: Specifies the country code of the employee in E.164 format region: type: string description: The geographical region to which the office is assigned timezone: type: string description: Indicates the time zone in which the office is located UserUserEmploymentInfo: type: object properties: employee_start_date_ts: type: string format: timestamp description: Joining date of the employee in in ISO-8601 UTC. role: type: string description: Role of the user in the organisation manager_email: type: string format: email description: Email address of the manager of the user cost_center_id: type: string description: Cost center id for the user cost_center_name: type: string description: Cost center name for the user department: type: string description: Specifies the department the user belongs to office_phone_number: type: string description: Specifies the office phone number of the user assistant_full_name: type: string description: Assistant's full name of the user employment_location: $ref: '#/components/schemas/UserUserEmploymentInfoEmploymentLocation' UserUser: type: object properties: state: $ref: '#/components/schemas/UserUserState' description: Specifies the state of the user universal_identifier: type: string description: >- Unique identifier of the user. This field should always be populated. It will be used to uniquely identify a user across different systems. email_addr: type: string format: email description: Email address of the user first_name: type: string description: First name of the user last_name: type: string description: Last name of the user full_name: type: string description: Full name of the user work_status: $ref: '#/components/schemas/UserUserWorkStatus' description: Employement type of the user employment_info: $ref: '#/components/schemas/UserUserEmploymentInfo' required: - state - universal_identifier UserSystemIdentity: type: object properties: id: type: string description: >- Refers to the unique identifier assigned to the user in the identity gateway. This is usually primary key of the external system username: type: string description: >- Refers to the username of the user in the identity system. This is usually lookup key of the external system required: - id User: type: object properties: user: $ref: '#/components/schemas/UserUser' system_identity: $ref: '#/components/schemas/UserSystemIdentity' last_updated_at: type: string format: timestamp description: >- Represents the timestamp indicating the most recent modification or update made to the user's information (in ISO-8601 UTC) required: - user - system_identity - last_updated_at ``` ## SDK Code Examples ```python import requests url = "http://localhost:5000/myinstance1/users/userId" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript const url = 'http://localhost:5000/myinstance1/users/userId'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; 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" "net/http" "io" ) func main() { url := "http://localhost:5000/myinstance1/users/userId" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") 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("http://localhost:5000/myinstance1/users/userId") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:5000/myinstance1/users/userId") .header("Authorization", "Bearer ") .asString(); ``` ```php request('GET', 'http://localhost:5000/myinstance1/users/userId', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("http://localhost:5000/myinstance1/users/userId"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5000/myinstance1/users/userId")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers 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() ```