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

# Me

Current User Query

Audience: Programmer

Returns the user profile of the currently authenticated user, including tenant associations and role assignments.

## Arguments

This query does not take any arguments.

## Return Type

`UserProfile!` - The user profile of the currently authenticated user.

## Usage Example

```graphql
query {
  me {
    UserID
    Username
    Email
    FirstName
    LastName
    TenantID
    TenantName
    # Recommended: Use Tenants for multi-tenant access
    Tenants {
      ID
      Name
      Role
    }
    # Deprecated: Use Tenants instead
    AssignedRoles {
      Role
      TenantID
    }
  }
}
```

## Response Example

```json
{
  "data": {
    "me": {
      "UserID": "550e8400-e29b-41d4-a716-446655440000",
      "Username": "john.doe",
      "Email": "john.doe@example.com",
      "FirstName": "John",
      "LastName": "Doe",
      "TenantID": "123e4567-e89b-12d3-a456-426614174000",
      "TenantName": "Acme Corporation",
      "Tenants": [
        {
          "ID": "123e4567-e89b-12d3-a456-426614174000",
          "Name": "Acme Corporation",
          "Role": "admin"
        },
        {
          "ID": "987f6543-a21b-34c5-d678-123456789012",
          "Name": "Beta Industries",
          "Role": "viewer"
        }
      ]
    }
  }
}
```

## Multi-Tenant Support

The `me` query now supports multi-tenant scenarios through the `Tenants` field:

* **Primary Tenant**: The `TenantID` and `TenantName` fields represent the user's primary tenant
* **All Tenants**: The `Tenants` array contains all accessible tenants with their respective roles
* **Role Isolation**: Each tenant association has its own role assignment

## Field Deprecation

The `AssignedRoles` field is deprecated. Use the `Tenants` field instead:

```graphql
# Old approach (deprecated)
query {
  me {
    AssignedRoles {
      Role
      TenantID
    }
  }
}

# New approach (recommended)
query {
  me {
    Tenants {
      ID
      Name
      Role
    }
  }
}
```

## Common Use Cases

* **Session Initialization**: Retrieve user profile on application startup
* **Tenant Selection**: Display available tenants for user switching
* **Authorization**: Check user roles for the active tenant
* **Profile Display**: Show user information in the application header
* **Audit Context**: Capture user details for logging

## Security Notes

* This query requires authentication
* Returns only the profile of the authenticated user
* Cannot be used to retrieve other users' profiles
* Tenant data is filtered based on user permissions


---

# 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/queries/me.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.
