Get Current User Record

AVAILABLE API VERSION
API v66.0 and later

The currentUser type returns the currently logged-in user’s User record data, even if the caller doesn’t know the user ID. The response always represents the current user. You can request any fields that are available on the User record.

To query or aggregate multiple users or use complex filtering, sorting, or pagination, use the RecordQuery type for the User object instead. See Query Objects.

To get the current user record, use currentUser in the uiapi field.

Query currentUser
1{
2  uiapi {
3    currentUser{
4      # User fields
5    }
6  }
7}

Current User Schema 

Query currentUser by using this schema.

Query currentUser Schema
1type UIAPI {
2  currentUser: RecordRepresentation
3}

Example: Query Current User 

This example fetches the ID and name for the current user.

Query Current User ID and Name
1{
2  uiapi {
3    currentUser{
4      Id
5      Name {
6        value
7      }
8    }
9  }
10}

The response includes the fields that you request. For example, the previous query returns this response.

Response for Current User Query
1{
2  "data": {
3    "uiapi": {
4      "currentUser": {
5        "Id": "005xx000001X7sHAAS",
6        "Name": {
7          "value": "User‘s Name"
8        }
9      }
10    }
11  },
12  "errors": [],
13  "extensions": {}
14}