> ## Documentation Index
> Fetch the complete documentation index at: https://docs.labelbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Organization

> A developer guide for querying organization information via the Python SDK.

## Client

### Get the current organization

<CodeGroup>
  ```python Python theme={null}
  organization = client.get_organization()
  ```
</CodeGroup>

## Methods

### Get IAM integrations

<CodeGroup>
  ```python Python theme={null}
  # get the default IAM integration
  default_iam_integration = organization.get_default_iam_integration()

  # get all of the IAM integrations (returns a list of IAMIntegration objects)
  iam_integrations = organization.get_iam_integrations()

  for integration in iam_integrations:
    print(integration)
  ```
</CodeGroup>

### Create a project tag

<CodeGroup>
  ```python Python theme={null}
  organization.create_resource_tag(
    {
      "text": "new-tag-name",
      "color": "ffffff"
    }
  )
  ```
</CodeGroup>

### Get the project tags

<CodeGroup>
  ```python Python theme={null}
  # get the project tags (returns a list of ResourceTag objects)
  tags = organization.get_resource_tags()

  for tag in tags:
    print(tag)
  ```
</CodeGroup>

### Invite users

Depending on the level of access required, you can:

* Invite users to a workspace without assigning them to any projects or user groups.
* Invite users to a workspace and assign them to specific projects or user groups.

<CodeGroup>
  ```python Organization-only theme={null}
  # get and view the available roles
  roles = client.get_roles()
  print("Roles: ", roles)

  # create an invitation for an organization-wide role (in this case, a labeler)
  organization.invite_user(
      email="<email_address>",
      role=roles["LABELER"]
  )
  ```

  ```python Project-based theme={null}
  # get and view the available roles
  roles = client.get_roles()
  print("Roles: ", roles)

  # get a project
  project = client.get_project("<project_id>")

  # create a ProjectRole object for a project-based role, in this case a labeler
  project_role = lb.ProjectRole(project=project, role=roles["LABELER"])

  # create an invitation for the project-based role
  organization.invite_user(
    email="<email_address>",
    # for a project-based role, the org-wide role must be NONE
    role=roles["NONE"],
    project_roles=[project_role]
  )

  # Mass invite users to project
  emails = []
  for email in emails:
    invite = organization.invite_user(emails,
                                    roles["NONE"],
                                    project_roles=[project_role])
  ```

  ```python Group-based theme={null}
  from labelbox import Client, UserGroupRole
  from labelbox.schema.user_group import UserGroup

  roles = client.get_roles()

  # Use an existing UserGroup id (e.g. from the UI / API)
  user_group = UserGroup(client=client, id="<user_group_id>")
  # Create a UserGroupRole object for a group-based role, in this case a reviewer
  user_group_role = UserGroupRole(user_group=user_group, role=roles["REVIEWER"])

  invite = organization.invite_user(
      email="<email_address>",
      # for a group-based role, the org-wide role must be NONE
      role=roles["NONE"],
      user_group_roles=[user_group_role]    
  )
  ```
</CodeGroup>

### Get pending invites

<CodeGroup>
  ```python Python theme={null}
  project_id = "<project_id>"

  # For the entire organization
  org_invites = organization.get_invites()

  # For a specific project
  project_invites = organization.get_project_invites(project_id)
  ```
</CodeGroup>

### Cancel invite

<CodeGroup>
  ```python Python theme={null}
  email = "<email_address>""
  project_id = "<project_id>"

  # Option 1: organization invite
  invite = next(
      invite for invite in organization.get_invites() if invite.email == email
  )

  # Option 2: project invite
  invite = next(
      invite for invite in organization.get_project_invites(project_id) if invite.email == email
  )

  invite.cancel()
  ```
</CodeGroup>

### View the invite limit

<CodeGroup>
  ```python Python theme={null}
  # already accounts for users currently in the organization, thus:
  # 	used = users + invites_sent
  # 	remaining = limit - used
  organization.invite_limit()
  ```
</CodeGroup>

### Remove a user

<CodeGroup>
  ```python Python theme={null}
  # the argument must be a User object
  organization.remove_user(user)
  ```
</CodeGroup>

## Attributes

### Get the basics

<CodeGroup>
  ```python Python theme={null}
  # name (str)
  organization.name

  # created_at (datetime)
  organization.created_at

  # updated_at (datetime)
  organization.updated_at
  ```
</CodeGroup>

### Get the users

<CodeGroup>
  ```python Python theme={null}
  # get the users (relationship to User objects)
  users = organization.users()

  # inspect one user
  next(users)

  # inspect all users
  for user in users:
    print(user)

  # for ease of use, you can convert the paginated collection to a list
  list(users)
  ```
</CodeGroup>

### Get the projects

<CodeGroup>
  ```python Python theme={null}
  # get the projects (relationship to Project objects)
  projects = organization.projects()

  # inspect one project
  next(projects)

  # inspect all projects
  for project in projects:
    print(project)

  # for ease of use, you can convert the paginated collection to a list
  list(projects)
  ```
</CodeGroup>

### Get the webhooks

<CodeGroup>
  ```python Python theme={null}
  # get the webhooks (relationship to Webhook objects)
  webhooks = organization.webhooks()

  # inspect one webhook
  next(webhooks)

  # inspect all webhooks
  for webhook in webhooks:
    print(webhook)

  # for ease of use, you can convert the paginated collection to a list
  list(webhooks)
  ```
</CodeGroup>
