---
sidebar:
  hidden: true
title: roboto.domain.orgs.org_invite
---
## Module Contents

### OrgInvite

```python
class roboto.domain.orgs.org_invite.OrgInvite(
    record: roboto.domain.orgs.org_records.OrgInviteRecord,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
)
```

`from roboto.domain.orgs import OrgInvite`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/org_invite.py#L18-L254)

An invitation for a user to join an organization.

A member of an organization can invite a user with [`invite_user()`](/docs/reference/python-sdk/roboto/domain/orgs/org#roboto.domain.orgs.org.Org.invite_user) or `create`, unless the Roboto deployment lets only organization administrators invite, and Roboto emails the invitation to that user. The invited user accepts it with `accept` or declines it with `decline`; the member who sent it, or an organization administrator, revokes it with `decline`. Roboto keeps the invitation after that, and its `status` says what became of it. Fetch existing invitations with `from_id` or `for_org`.

**Parameters**

- **record** (`roboto.domain.orgs.org_records.OrgInviteRecord`)
- **roboto_client** (`Optional[roboto.http.RobotoClient]`)

**Properties**

- **OrgInvite.expires_at** (`datetime.datetime | None`): Time after which the invitation cannot be accepted, unless an organization administrator renews it.

  [`expires_at`](/docs/reference/python-sdk/roboto/domain/orgs/org_records#roboto.domain.orgs.org_records.OrgInviteRecord.expires_at) says when it is `None`.

  Return type: `Optional[datetime.datetime]`

- **OrgInvite.invite_id** (`str`): Unique ID of the invitation, beginning with `in_`.

- **OrgInvite.invited_by_user_id** (`str`): ID of the user who sent the invitation.

- **OrgInvite.invited_user_id** (`str`): ID of the invited user, which for a person is their email address.

- **OrgInvite.org_id** (`str`): ID of the organization the invitation is to join.

- **OrgInvite.role** (`roboto.domain.orgs.org_records.OrgRoleName`): Role the invited user gets in the organization by accepting.

- **OrgInvite.status** (`roboto.domain.orgs.org_records.OrgInviteStatus`): Status of the invitation when Roboto read it.

  [`status`](/docs/reference/python-sdk/roboto/domain/orgs/org_records#roboto.domain.orgs.org_records.OrgInviteRecord.status) says how expiry shows in it.

#### OrgInvite.accept()

```python
def accept() -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/org_invite.py#L188-L219)

Accept this invitation, making the invited user a member of the organization.

Only the invited user can accept it. The new member gets the invitation's `role`, and a user who is already a member keeps their roles. If Roboto has not finished setting up the organization, the user still joins it but cannot work in it yet, and the method raises `RobotoServiceUnavailableException`: try accepting again in a few minutes, and if the organization is still not set up, contact the administrator that the exception's message names. Once the organization is set up, accepting again changes nothing.

The method also raises `RobotoServiceUnavailableException` when another request was changing the invitation, the caller's account, or the organization at the same time, or when the Roboto deployment has not set the email domains it accepts; the exception's message says which. The SDK retries the request before it raises this exception, and accepting again adds no second membership and changes no role.

**Raises**

- [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): The caller is not the invited user, has not verified the invited email address, or is acting as another user.
- [`RobotoConflictException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoConflictException): The invitation was declined or revoked; a newer invitation to the same address replaced it; or it carries the `owner` role and no longer makes the user who accepts it the organization's first owner.
- [`RobotoExpiredException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoExpiredException): The invitation has expired.
- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): The invited email address is outside the email domains the Roboto deployment accepts.
- [`RobotoLimitExceededException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoLimitExceededException): The organization already has as many members as it may, or the invitation carries the `owner` role and the caller already owns as many organizations as they may.

**Returns**

- `None`

**Usage**

```python
from roboto.domain.orgs import OrgInvite
invite = OrgInvite.from_id("in_12345")
invite.accept()
```

#### OrgInvite.create()

```python
@classmethod
def create(
    invited_user_id: str,
    org_id: str,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
    *,
    role: roboto.domain.orgs.org_records.OrgRoleName = OrgRoleName.user,
) -> OrgInvite
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/org_invite.py#L32-L85)

Invite a user to join an organization.

Roboto emails the invitation to the invited user. [`invite_user()`](/docs/reference/python-sdk/roboto/domain/orgs/org#roboto.domain.orgs.org.Org.invite_user) does the same for an organization you already hold as an [`Org`](/docs/reference/python-sdk/roboto/domain/orgs/org#roboto.domain.orgs.org.Org). The invitation expires 14 days after it is sent.

**Parameters**

- **invited_user_id** (`str`): Email address of the user to invite, which is their user ID. The user does not need a Roboto account yet.
- **org_id** (`str`): ID of the organization to invite the user to.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).
- **role** (`roboto.domain.orgs.org_records.OrgRoleName`): Role the invited user gets by accepting. Only an organization owner or a Roboto administrator may invite someone as [`admin`](/docs/reference/python-sdk/roboto/domain/orgs/org_records#roboto.domain.orgs.org_records.OrgRoleName.admin), and no invitation may carry `owner`.

**Returns**

- `OrgInvite`: The new invitation.

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): No organization has this ID.
- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): `role` is `owner`; the user is already a member of the organization or is a service user; the user's email address is outside the email domains the Roboto deployment accepts; or the deployment does not support invitation roles, in which case it still created the invitation, with the `user` role, and declining the invitation withdraws it.
- [`RobotoConflictException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoConflictException): The user already has a pending invitation to the organization.
- [`RobotoLimitExceededException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoLimitExceededException): The organization's members and pending invitations already reach its limit on members.
- [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): `role` is `admin` and the caller is not an owner of the organization, or the Roboto deployment lets only organization administrators invite users and the caller is not one.

**Usage**

```python
from roboto.domain.orgs import OrgInvite
invite = OrgInvite.create("alice@example.com", "og_12345")
```

#### OrgInvite.decline()

```python
def decline() -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/org_invite.py#L221-L241)

Decline this invitation as the invited user, or revoke it as its sender or an organization administrator.

Either way, the invitation can no longer be accepted, and its status becomes [`Declined`](/docs/reference/python-sdk/roboto/domain/orgs/org_records#roboto.domain.orgs.org_records.OrgInviteStatus.Declined) or `Revoked`. Repeating the call changes nothing.

**Raises**

- [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): The caller is not the invited user, the user who sent the invitation, or an administrator or owner of the organization.
- [`RobotoConflictException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoConflictException): The invitation was already accepted; a newer invitation to the same address replaced it; the invited user declines an invitation that was revoked, or the sender or an administrator revokes one that was declined; or the caller would revoke an invitation that carries the `owner` role.
- [`RobotoExpiredException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoExpiredException): The invitation has expired.

**Returns**

- `None`

**Usage**

```python
from roboto.domain.orgs import OrgInvite
invite = OrgInvite.from_id("in_12345")
invite.decline()
```

#### OrgInvite.for_org()

```python
@classmethod
def for_org(
    org_id: str,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> collections.abc.Collection[OrgInvite]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/org_invite.py#L114-L134)

List an organization's pending invitations, oldest first.

Pending invitations past their expiry are included, with the status [`Expired`](/docs/reference/python-sdk/roboto/domain/orgs/org_records#roboto.domain.orgs.org_records.OrgInviteStatus.Expired).

**Parameters**

- **org_id** (`str`): ID of the organization whose invitations to list.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

**Returns**

- `collections.abc.Collection[OrgInvite]`

**Usage**

```python
from roboto.domain.orgs import OrgInvite
for invite in OrgInvite.for_org("og_12345"):
    print(invite.invited_user_id)
```

#### OrgInvite.from_id()

```python
@classmethod
def from_id(
    invite_id: str,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> OrgInvite
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/org_invite.py#L88-L111)

Fetch an invitation by its ID.

Only the invited user and members of the invitation's organization can fetch it. It is returned in any status, so an invitation already accepted, declined, revoked, or expired can still be fetched.

**Parameters**

- **invite_id** (`str`): Unique ID of the invitation, beginning with `in_`.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Client to make requests to Roboto with. Defaults to one configured from the environment, by [`from_env()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_env).

**Raises**

- [`RobotoNotFoundException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): No invitation has this ID.
- [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): The caller is neither the invited user nor a member of the invitation's organization.

**Returns**

- `OrgInvite`

**Usage**

```python
from roboto.domain.orgs import OrgInvite
invite = OrgInvite.from_id("in_12345")
print(invite.invited_user_id)
```

#### OrgInvite.to_dict()

```python
def to_dict() -> dict[str, Any]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/org_invite.py#L243-L254)

Return the invitation's record as a JSON-compatible dictionary.

**Returns**

- `dict[str, Any]`: [`OrgInviteRecord`](/docs/reference/python-sdk/roboto/domain/orgs/org_records#roboto.domain.orgs.org_records.OrgInviteRecord) of the invitation, as a JSON-compatible dictionary.

**Usage**

```python
from roboto.domain.orgs import OrgInvite
invite = OrgInvite.from_id("in_12345")
print(invite.to_dict()["user_id"])
```
