> 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/tenant.md).

# Tenant

Tenant Type

Represents a tenant in the multi-tenant system. A tenant is an isolated organizational unit that contains users, roles, groups, and other resources.

## Fields

| Field       | Type      | Description                                 |
| ----------- | --------- | ------------------------------------------- |
| `id`        | `ID!`     | Unique identifier of the tenant             |
| `createdAt` | `Time!`   | Creation timestamp                          |
| `createdBy` | `UUID!`   | User identifier who created the tenant      |
| `updatedAt` | `Time`    | Last update timestamp                       |
| `updatedBy` | `UUID`    | User identifier who last updated the tenant |
| `deletedAt` | `Time`    | Deletion timestamp                          |
| `deletedBy` | `UUID`    | User identifier who deleted the tenant      |
| `name`      | `String!` | Name of the tenant                          |
| `idpOrgRef` | `String!` | Identity provider organization reference    |

## Connection Fields

The `tenantUsers` field returns a Connection object that supports pagination, filtering, and ordering.

### tenantUsers Connection

```graphql
tenantUsers(
  after: Cursor
  first: Int
  before: Cursor
  last: Int
  orderBy: UserOrder
  where: UserWhereInput
): UserConnection!
```

| 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` | `UserOrder`      | Ordering options for users          |
| `where`   | `UserWhereInput` | Filtering options for users         |

## Interfaces

* `Node`

## Usage Example

```graphql
query {
  tenants(first: 10) {
    edges {
      node {
        id
        name
        idpOrgRef
        tenantUsers(first: 50) {
          edges {
            node {
              id
              username
              email
              firstName
              lastName
              isAdmin
            }
          }
          pageInfo {
            hasNextPage
            endCursor
          }
          totalCount
        }
        createdAt
        updatedAt
      }
    }
  }
}
```

### Query with Filtering on Users

```graphql
query {
  tenants(first: 10) {
    edges {
      node {
        id
        name
        tenantUsers(
          first: 20
          orderBy: { direction: ASC, field: USERNAME }
          where: { isAdmin: true }
        ) {
          edges {
            node {
              id
              username
              email
              isAdmin
            }
          }
          totalCount
        }
      }
    }
  }
}
```

## Relations

* **Tenant** `1:N` **User**: A tenant can have multiple users

## Purpose

Tenants provide multi-tenancy support in pyck, allowing complete data isolation between different organizations or customers. Each tenant has its own users, roles, groups, and other resources. The `idpOrgRef` field links the tenant to an organization in the identity provider (Zitadel).


---

# 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/tenant.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.
