# Users

## Get User Claims

`client.admin.users.getClaims(stringuserID, RequestOptionsoptions?): UserClaims`

**get** `/api/v1/admin/users/{user_id}/claims`

Get a user's resolved custom claims.

Claims that have not been explicitly set fall back to their system default. Returns 404 if the user does not exist.

Global admin only.

### Parameters

- `userID: string`

### Returns

- `UserClaims`

  A user's fully resolved custom claims after applying system defaults.

  - `claims: CustomClaims`

    The user's resolved custom claims.

    - `allow_org_deletion?: boolean`

      Whether the user is allowed to delete organizations.

    - `allowed_org_creation?: boolean`

      Whether the user is allowed to create organizations.

    - `api_datasource_access?: boolean`

      Whether the user is allowed to access API data sources.

    - `maximum_org_creation?: number | null`

      Cap on how many organizations this user may create. None means unlimited. Only enforced when allowed_org_creation is True.

  - `user_id: string`

    The user ID the claims belong to.

### Example

```typescript
import LlamaCloudAdmin from '@llamaindex/llama-cloud-admin';

const client = new LlamaCloudAdmin({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const userClaims = await client.admin.users.getClaims('user_id');

console.log(userClaims.user_id);
```

#### Response

```json
{
  "claims": {
    "allow_org_deletion": true,
    "allowed_org_creation": true,
    "api_datasource_access": true,
    "maximum_org_creation": 0
  },
  "user_id": "user_id"
}
```

## Update User Claims

`client.admin.users.updateClaims(stringuserID, UserUpdateClaimsParamsbody, RequestOptionsoptions?): UserClaims`

**patch** `/api/v1/admin/users/{user_id}/claims`

Additively update a user's custom claims.

Claims in `set_claims` are added or overwritten; claims named in `remove_claims` are reset to their system default. Claims not referenced by either field are left unchanged, so a single claim can be changed without resending the full set. Returns the user's resolved claims after the update.

Returns 404 if the user does not exist.

Global admin only.

### Parameters

- `userID: string`

- `body: UserUpdateClaimsParams`

  - `remove_claims?: Array<"allow_org_deletion" | "allowed_org_creation" | "api_datasource_access" | "maximum_org_creation"> | null`

    Names of claims to reset to their system default.

    - `"allow_org_deletion"`

    - `"allowed_org_creation"`

    - `"api_datasource_access"`

    - `"maximum_org_creation"`

  - `set_claims?: SetClaims | null`

    A partial set of custom claims for additive updates.

    Every field is optional. Only the claims explicitly provided in a request
    are added or overwritten; claims left unset are not touched, so callers can
    change a single claim without resending the full claim set.

    - `allow_org_deletion?: boolean | null`

      Whether the user is allowed to delete organizations.

    - `allowed_org_creation?: boolean | null`

      Whether the user is allowed to create organizations.

    - `api_datasource_access?: boolean | null`

      Whether the user is allowed to access API data sources.

    - `maximum_org_creation?: number | null`

      Cap on how many organizations this user may create. None means unlimited. Only enforced when allowed_org_creation is True.

### Returns

- `UserClaims`

  A user's fully resolved custom claims after applying system defaults.

  - `claims: CustomClaims`

    The user's resolved custom claims.

    - `allow_org_deletion?: boolean`

      Whether the user is allowed to delete organizations.

    - `allowed_org_creation?: boolean`

      Whether the user is allowed to create organizations.

    - `api_datasource_access?: boolean`

      Whether the user is allowed to access API data sources.

    - `maximum_org_creation?: number | null`

      Cap on how many organizations this user may create. None means unlimited. Only enforced when allowed_org_creation is True.

  - `user_id: string`

    The user ID the claims belong to.

### Example

```typescript
import LlamaCloudAdmin from '@llamaindex/llama-cloud-admin';

const client = new LlamaCloudAdmin({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const userClaims = await client.admin.users.updateClaims('user_id');

console.log(userClaims.user_id);
```

#### Response

```json
{
  "claims": {
    "allow_org_deletion": true,
    "allowed_org_creation": true,
    "api_datasource_access": true,
    "maximum_org_creation": 0
  },
  "user_id": "user_id"
}
```

## Domain Types

### Custom Claims

- `CustomClaims`

  Custom claims that dictate various limits or allowed behaviors.
  Currently these claims reside at a per user level. Claims may expand to a per organization level or project in the future.

  - `allow_org_deletion?: boolean`

    Whether the user is allowed to delete organizations.

  - `allowed_org_creation?: boolean`

    Whether the user is allowed to create organizations.

  - `api_datasource_access?: boolean`

    Whether the user is allowed to access API data sources.

  - `maximum_org_creation?: number | null`

    Cap on how many organizations this user may create. None means unlimited. Only enforced when allowed_org_creation is True.

### User Claims

- `UserClaims`

  A user's fully resolved custom claims after applying system defaults.

  - `claims: CustomClaims`

    The user's resolved custom claims.

    - `allow_org_deletion?: boolean`

      Whether the user is allowed to delete organizations.

    - `allowed_org_creation?: boolean`

      Whether the user is allowed to create organizations.

    - `api_datasource_access?: boolean`

      Whether the user is allowed to access API data sources.

    - `maximum_org_creation?: number | null`

      Cap on how many organizations this user may create. None means unlimited. Only enforced when allowed_org_creation is True.

  - `user_id: string`

    The user ID the claims belong to.
