> For the complete documentation index, see [llms.txt](https://docs.pyck.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pyck.cloud/graphql-api/types/user.md).

# User

User Type

Represents a user in the system. Users are authenticated entities that can perform operations within their assigned tenant and roles.

## Fields

| Field         | Type         | Description                                                |
| ------------- | ------------ | ---------------------------------------------------------- |
| `id`          | `ID!`        | Unique identifier of the user                              |
| `createdAt`   | `Time!`      | Creation timestamp                                         |
| `createdBy`   | `UUID!`      | User identifier who created this user                      |
| `updatedAt`   | `Time`       | Last update timestamp                                      |
| `updatedBy`   | `UUID`       | User identifier who last updated this user                 |
| `deletedAt`   | `Time`       | Deletion timestamp                                         |
| `deletedBy`   | `UUID`       | User identifier who deleted this user                      |
| `tenantID`    | `UUID!`      | Tenant identifier                                          |
| `idpID`       | `String!`    | Identity provider user identifier                          |
| `username`    | `String!`    | Username for the user                                      |
| `email`       | `String!`    | Email address of the user                                  |
| `firstName`   | `String!`    | First name of the user                                     |
| `lastName`    | `String!`    | Last name of the user                                      |
| `isAdmin`     | `Boolean!`   | Whether the user has administrative privileges             |
| `legacyRoles` | `[String!]!` | DEPRECATED: Legacy JSONB column for backward compatibility |
| `tenant`      | `Tenant!`    | Associated tenant                                          |

## Connection Fields

The `roles`, `groups`, and `deviceUsersUsers` fields return Connection objects that support pagination, filtering, and ordering.

### roles Connection

```graphql
roles(
  after: Cursor
  first: Int
  before: Cursor
  last: Int
  orderBy: RoleOrder
  where: RoleWhereInput
): RoleConnection!
```

### groups Connection

```graphql
groups(
  after: Cursor
  first: Int
  before: Cursor
  last: Int
  orderBy: GroupOrder
  where: GroupWhereInput
): GroupConnection!
```

### deviceUsersUsers Connection

```graphql
deviceUsersUsers(
  after: Cursor
  first: Int
  before: Cursor
  last: Int
  orderBy: DeviceUserOrder
  where: DeviceUserWhereInput
): DeviceUserConnection!
```

| Argument  | Type          | Description                                     |
| --------- | ------------- | ----------------------------------------------- |
| `after`   | `Cursor`      | Returns elements after this cursor              |
| `first`   | `Int`         | Returns the first n elements                    |
| `before`  | `Cursor`      | Returns elements before this cursor             |
| `last`    | `Int`         | Returns the last n elements                     |
| `orderBy` | `*Order`      | Ordering options (specific to each connection)  |
| `where`   | `*WhereInput` | Filtering options (specific to each connection) |

## Interfaces

* `Node`

## Usage Example

```graphql
query {
  users(first: 10) {
    edges {
      node {
        id
        username
        email
        firstName
        lastName
        isAdmin
        tenant {
          id
          name
        }
        roles(first: 20) {
          edges {
            node {
              id
              name
              description
            }
          }
          totalCount
        }
        groups(first: 20) {
          edges {
            node {
              id
              name
              description
            }
          }
          totalCount
        }
        createdAt
        updatedAt
      }
    }
  }
}
```

### Query with Filtering on Roles

```graphql
query {
  users(first: 10) {
    edges {
      node {
        id
        username
        email
        roles(
          first: 10
          orderBy: { direction: ASC, field: NAME }
        ) {
          edges {
            node {
              id
              name
            }
          }
          totalCount
        }
      }
    }
  }
}
```

## Relations

* **User** `N:1` **Tenant**: A user belongs to one tenant
* **User** `M:N` **Role**: A user can have multiple roles
* **User** `M:N` **Group**: A user can belong to multiple groups
* **User** `1:N` **DeviceUser**: A user can be associated with multiple devices

## Authentication

Users are authenticated through external identity providers (IDP) using the `idpID` field. The system supports role-based access control (RBAC) through the relationships with roles and groups.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pyck.cloud/graphql-api/types/user.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
