# Users

## List Organization Users

`client.Organizations.Users.ListMembers(ctx, organizationID) (*[]OrganizationMember, error)`

**get** `/api/v1/organizations/{organization_id}/users`

Get all users in an organization.

### Parameters

- `organizationID string`

### Returns

- `type OrganizationUserListMembersResponse []OrganizationMember`

  - `ID string`

    Unique identifier

  - `OrganizationID string`

    The organization's ID.

  - `Roles []UserOrganizationRole`

    The roles of the user in the organization.

    - `ID string`

      Unique identifier

    - `OrganizationID string`

      The organization's ID.

    - `Role Role`

      The role.

      - `ID string`

        Unique identifier

      - `Name string`

        A name for the role.

      - `Permissions []RolePermission`

        The actual permissions of the role.

        - `ID string`

          Unique identifier

        - `Access bool`

          Whether the permission is granted or not.

        - `Description string`

          A description for the permission.

        - `Name string`

          A name for the permission.

        - `CreatedAt Time`

          Creation datetime

        - `UpdatedAt Time`

          Update datetime

      - `CreatedAt Time`

        Creation datetime

      - `UpdatedAt Time`

        Update datetime

    - `UserID string`

      The user's ID.

    - `CreatedAt Time`

      Creation datetime

    - `ProjectIDs []string`

      The project ID scope.

    - `UpdatedAt Time`

      Update datetime

  - `CreatedAt Time`

    Creation datetime

  - `Email string`

    The user's email address.

  - `InvitedByUserEmail string`

    The email address of the user who added the user to the organization.

  - `InvitedByUserID string`

    The user ID of the user who added the user to the organization.

  - `Pending bool`

    Whether the user's membership is pending account signup.

  - `UpdatedAt Time`

    Update datetime

  - `UserID string`

    The user's ID.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llamacloud-admin-go"
  "github.com/run-llama/llamacloud-admin-go/option"
)

func main() {
  client := llamacloudadmin.NewClient(
    option.WithAPIKey("My API Key"),
  )
  organizationMembers, err := client.Organizations.Users.ListMembers(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationMembers)
}
```

#### Response

```json
[
  {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "organization_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "roles": [
      {
        "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "organization_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "role": {
          "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
          "name": "x",
          "permissions": [
            {
              "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
              "access": true,
              "description": "description",
              "name": "x",
              "created_at": "2019-12-27T18:11:19.117Z",
              "updated_at": "2019-12-27T18:11:19.117Z"
            }
          ],
          "created_at": "2019-12-27T18:11:19.117Z",
          "updated_at": "2019-12-27T18:11:19.117Z"
        },
        "user_id": "user_id",
        "created_at": "2019-12-27T18:11:19.117Z",
        "project_ids": [
          "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
        ],
        "updated_at": "2019-12-27T18:11:19.117Z"
      }
    ],
    "created_at": "2019-12-27T18:11:19.117Z",
    "email": "dev@stainless.com",
    "invited_by_user_email": "dev@stainless.com",
    "invited_by_user_id": "invited_by_user_id",
    "pending": true,
    "updated_at": "2019-12-27T18:11:19.117Z",
    "user_id": "user_id"
  }
]
```

## Add Users To Organization

`client.Organizations.Users.Add(ctx, organizationID, body) (*[]OrganizationMember, error)`

**put** `/api/v1/organizations/{organization_id}/users`

Add a user to an organization.

### Parameters

- `organizationID string`

- `body OrganizationUserAddParams`

  - `Body param.Field[[]OrganizationUserAddParamsBody]`

    - `ProjectIDs []string`

      The project IDs to add the user to.

    - `Email string`

      The user's email address.

    - `RoleID string`

      The role ID to assign to the user.

    - `UserID string`

      The user's ID.

### Returns

- `type OrganizationUserAddResponse []OrganizationMember`

  - `ID string`

    Unique identifier

  - `OrganizationID string`

    The organization's ID.

  - `Roles []UserOrganizationRole`

    The roles of the user in the organization.

    - `ID string`

      Unique identifier

    - `OrganizationID string`

      The organization's ID.

    - `Role Role`

      The role.

      - `ID string`

        Unique identifier

      - `Name string`

        A name for the role.

      - `Permissions []RolePermission`

        The actual permissions of the role.

        - `ID string`

          Unique identifier

        - `Access bool`

          Whether the permission is granted or not.

        - `Description string`

          A description for the permission.

        - `Name string`

          A name for the permission.

        - `CreatedAt Time`

          Creation datetime

        - `UpdatedAt Time`

          Update datetime

      - `CreatedAt Time`

        Creation datetime

      - `UpdatedAt Time`

        Update datetime

    - `UserID string`

      The user's ID.

    - `CreatedAt Time`

      Creation datetime

    - `ProjectIDs []string`

      The project ID scope.

    - `UpdatedAt Time`

      Update datetime

  - `CreatedAt Time`

    Creation datetime

  - `Email string`

    The user's email address.

  - `InvitedByUserEmail string`

    The email address of the user who added the user to the organization.

  - `InvitedByUserID string`

    The user ID of the user who added the user to the organization.

  - `Pending bool`

    Whether the user's membership is pending account signup.

  - `UpdatedAt Time`

    Update datetime

  - `UserID string`

    The user's ID.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llamacloud-admin-go"
  "github.com/run-llama/llamacloud-admin-go/option"
)

func main() {
  client := llamacloudadmin.NewClient(
    option.WithAPIKey("My API Key"),
  )
  organizationMembers, err := client.Organizations.Users.Add(
    context.TODO(),
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    llamacloudadmin.OrganizationUserAddParams{
      Body: []llamacloudadmin.OrganizationUserAddParamsBody{llamacloudadmin.OrganizationUserAddParamsBody{
        ProjectIDs: []string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"},
      }},
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationMembers)
}
```

#### Response

```json
[
  {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "organization_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "roles": [
      {
        "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "organization_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "role": {
          "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
          "name": "x",
          "permissions": [
            {
              "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
              "access": true,
              "description": "description",
              "name": "x",
              "created_at": "2019-12-27T18:11:19.117Z",
              "updated_at": "2019-12-27T18:11:19.117Z"
            }
          ],
          "created_at": "2019-12-27T18:11:19.117Z",
          "updated_at": "2019-12-27T18:11:19.117Z"
        },
        "user_id": "user_id",
        "created_at": "2019-12-27T18:11:19.117Z",
        "project_ids": [
          "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
        ],
        "updated_at": "2019-12-27T18:11:19.117Z"
      }
    ],
    "created_at": "2019-12-27T18:11:19.117Z",
    "email": "dev@stainless.com",
    "invited_by_user_email": "dev@stainless.com",
    "invited_by_user_id": "invited_by_user_id",
    "pending": true,
    "updated_at": "2019-12-27T18:11:19.117Z",
    "user_id": "user_id"
  }
]
```

## Remove Users From Organization

`client.Organizations.Users.Delete(ctx, memberUserID, params) error`

**delete** `/api/v1/organizations/{organization_id}/users/{member_user_id}`

Remove users from an organization.

### Parameters

- `memberUserID string`

- `params OrganizationUserDeleteParams`

  - `OrganizationID param.Field[string]`

    Path param

  - `Body param.Field[[]string]`

    Body param

### Example

```go
package main

import (
  "context"

  "github.com/run-llama/llamacloud-admin-go"
  "github.com/run-llama/llamacloud-admin-go/option"
)

func main() {
  client := llamacloudadmin.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.Organizations.Users.Delete(
    context.TODO(),
    "member_user_id",
    llamacloudadmin.OrganizationUserDeleteParams{
      OrganizationID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    },
  )
  if err != nil {
    panic(err.Error())
  }
}
```

## Assign Role To User In Organization

`client.Organizations.Users.AssignRole(ctx, organizationID, body) (*UserOrganizationRole, error)`

**put** `/api/v1/organizations/{organization_id}/users/roles`

Assign a role to a user in an organization.

### Parameters

- `organizationID string`

- `body OrganizationUserAssignRoleParams`

  - `OrganizationID param.Field[string]`

    The organization's ID.

  - `RoleID param.Field[string]`

    The role's ID.

  - `UserID param.Field[string]`

    The user's ID.

### Returns

- `type UserOrganizationRole struct{…}`

  Schema for a user's role in an organization.

  - `ID string`

    Unique identifier

  - `OrganizationID string`

    The organization's ID.

  - `Role Role`

    The role.

    - `ID string`

      Unique identifier

    - `Name string`

      A name for the role.

    - `Permissions []RolePermission`

      The actual permissions of the role.

      - `ID string`

        Unique identifier

      - `Access bool`

        Whether the permission is granted or not.

      - `Description string`

        A description for the permission.

      - `Name string`

        A name for the permission.

      - `CreatedAt Time`

        Creation datetime

      - `UpdatedAt Time`

        Update datetime

    - `CreatedAt Time`

      Creation datetime

    - `UpdatedAt Time`

      Update datetime

  - `UserID string`

    The user's ID.

  - `CreatedAt Time`

    Creation datetime

  - `ProjectIDs []string`

    The project ID scope.

  - `UpdatedAt Time`

    Update datetime

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llamacloud-admin-go"
  "github.com/run-llama/llamacloud-admin-go/option"
)

func main() {
  client := llamacloudadmin.NewClient(
    option.WithAPIKey("My API Key"),
  )
  userOrganizationRole, err := client.Organizations.Users.AssignRole(
    context.TODO(),
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    llamacloudadmin.OrganizationUserAssignRoleParams{
      OrganizationID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      RoleID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      UserID: "user_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", userOrganizationRole.ID)
}
```

#### Response

```json
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "organization_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "role": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "name": "x",
    "permissions": [
      {
        "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "access": true,
        "description": "description",
        "name": "x",
        "created_at": "2019-12-27T18:11:19.117Z",
        "updated_at": "2019-12-27T18:11:19.117Z"
      }
    ],
    "created_at": "2019-12-27T18:11:19.117Z",
    "updated_at": "2019-12-27T18:11:19.117Z"
  },
  "user_id": "user_id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "project_ids": [
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
  ],
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## List Projects By User

`client.Organizations.Users.ListProjects(ctx, userID, query) (*[]OrganizationUserListProjectsResponse, error)`

**get** `/api/v1/organizations/{organization_id}/users/{user_id}/projects`

List all projects for a user in an organization.

### Parameters

- `userID string`

- `query OrganizationUserListProjectsParams`

  - `OrganizationID param.Field[string]`

### Returns

- `type OrganizationUserListProjectsResponse []OrganizationUserListProjectsResponse`

  - `ID string`

    Unique identifier

  - `Name string`

  - `OrganizationID string`

    The Organization ID the project is under.

  - `CreatedAt Time`

    Creation datetime

  - `IsDefault bool`

    Whether this project is the default project for the user.

  - `UpdatedAt Time`

    Update datetime

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llamacloud-admin-go"
  "github.com/run-llama/llamacloud-admin-go/option"
)

func main() {
  client := llamacloudadmin.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Organizations.Users.ListProjects(
    context.TODO(),
    "user_id",
    llamacloudadmin.OrganizationUserListProjectsParams{
      OrganizationID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
```

#### Response

```json
[
  {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "name": "x",
    "organization_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "created_at": "2019-12-27T18:11:19.117Z",
    "is_default": true,
    "updated_at": "2019-12-27T18:11:19.117Z"
  }
]
```

## Add User To Project

`client.Organizations.Users.AddToProject(ctx, userID, params) (*OrganizationUserAddToProjectResponse, error)`

**put** `/api/v1/organizations/{organization_id}/users/{user_id}/projects`

Add a user to a project.

### Parameters

- `userID string`

- `params OrganizationUserAddToProjectParams`

  - `OrganizationID param.Field[string]`

    Path param

  - `ProjectID param.Field[string]`

    Query param

### Returns

- `type OrganizationUserAddToProjectResponse interface{…}`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llamacloud-admin-go"
  "github.com/run-llama/llamacloud-admin-go/option"
)

func main() {
  client := llamacloudadmin.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Organizations.Users.AddToProject(
    context.TODO(),
    "user_id",
    llamacloudadmin.OrganizationUserAddToProjectParams{
      OrganizationID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
```

#### Response

```json
{}
```

## Remove User From Project

`client.Organizations.Users.RemoveFromProject(ctx, projectID, body) (*OrganizationUserRemoveFromProjectResponse, error)`

**delete** `/api/v1/organizations/{organization_id}/users/{user_id}/projects/{project_id}`

Remove a user from a project.

### Parameters

- `projectID string`

- `body OrganizationUserRemoveFromProjectParams`

  - `OrganizationID param.Field[string]`

  - `UserID param.Field[string]`

### Returns

- `type OrganizationUserRemoveFromProjectResponse interface{…}`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llamacloud-admin-go"
  "github.com/run-llama/llamacloud-admin-go/option"
)

func main() {
  client := llamacloudadmin.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Organizations.Users.RemoveFromProject(
    context.TODO(),
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    llamacloudadmin.OrganizationUserRemoveFromProjectParams{
      OrganizationID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      UserID: "user_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
```

#### Response

```json
{}
```
