# mv.invitations

> The invitations methods of @morevoice/sdk: Invitations to join your organisation (emailed; the link is never returned).

Invitations to join your organisation (emailed; the link is never returned). These methods are on `mv.invitations`, where `mv` is your client (see [the Node.js SDK](https://docs.morevoice.ai/sdk/node/#connect)). Each one returns the response object and throws when the API answers with an error.

## `create()`

**Invite a user.** Invites one person by email. They join with the role you chose when they accept (7 days). A seat is reserved for them: 402 plan_limit when none is free. Inviting an address that already has an open invitation replaces it (the old link stops working). The link is only emailed — the API never returns it.

```ts
mv.invitations.create(body: InvitationsCreateData["body"], options?: RequestOptions): Promise<InvitationsCreateResponse>
```

`POST /invitations` · [API reference](https://docs.morevoice.ai/api/operations/invitations_create/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.email` | `string` | yes | Their email address. The invitation is emailed to it. |
| `body.role` | `"owner" \| "admin" \| "supervisor" \| "agent"` | no | Default `agent`. API keys invite agents and supervisors; `owner` and `admin` invitations come from an owner. |
| `body.team_id` | `string \| null` | no | `team_…` ID. |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`Invitation`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The invitation's ID. |
| `object` | `"invitation"` | Always `invitation`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `email` | `string` | — |
| `role` | `"owner" \| "admin" \| "supervisor" \| "agent"` | The role they get when they accept. |
| `billing` | `boolean` | — |
| `team_id` | `string \| null` | `team_…` ID. |
| `status` | `"pending" \| "expired"` | `pending` until it expires (7 days); accepted and withdrawn invitations are no longer listed. |
| `invited_by` | `string \| null` | The user who invited them (for an API key: the user who created the key). |
| `existing_user` | `boolean` | The address already has an account (in another organisation): they join with it. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `expires` | `string` | An ISO-8601 timestamp in UTC. |
| `emailed` | `boolean` | On create and resend: whether the invitation email went out. False when your organisation's invitation emails are off — share the link from the dashboard. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const invitation = await mv.invitations.create({
	email: "yossi@example.com",
	role: "agent",
});
console.log(invitation);
```

## `delete()`

**Withdraw an invitation.** Returns the deleted object's `id` with `deleted: true`. Answers `404` with the code `resource_missing` when nothing has this ID in this organisation and mode.

```ts
mv.invitations.delete(id: InvitationsDeleteData["path"]["id"], options?: RequestOptions): Promise<InvitationsDeleteResponse>
```

`DELETE /invitations/{id}` · [API reference](https://docs.morevoice.ai/api/operations/invitations_delete/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A invitation ID (`inv_t_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`DeletedInvitation`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | A invitation ID (prefix `inv_t_`). |
| `object` | `"invitation"` | Always `invitation`. |
| `deleted` | `true` | — |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const deletedInvitation = await mv.invitations.delete("inv_t_7Hk2Lm9Qp");
console.log(deletedInvitation);
```

## `list()`

**List invitations.** Open invitations, and those that expired in the last 30 days (resend them).

```ts
mv.invitations.list(query?: NonNullable<InvitationsListData["query"]>, options?: RequestOptions): PagedList<InvitationsListResponse["data"][number], NonNullable<InvitationsListData["query"]>>
```

`GET /invitations` · [API reference](https://docs.morevoice.ai/api/operations/invitations_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `query.limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `query.starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `query.ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

A [`PagedList`](https://docs.morevoice.ai/sdk/typescript/pagination/): `await` it for the first page, `for await` it for every item.

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

for await (const invitation of mv.invitations.list()) {
	console.log(invitation);
}
```

## `resend()`

**Resend an invitation.** Emails a new link, valid 7 more days (the previous link stops working). An expired invitation takes its seat back, so it is seat-checked again.

```ts
mv.invitations.resend(id: InvitationsResendData["path"]["id"], options?: RequestOptions): Promise<InvitationsResendResponse>
```

`POST /invitations/{id}/resend` · [API reference](https://docs.morevoice.ai/api/operations/invitations_resend/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A invitation ID (`inv_t_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["Idempotency-Key"]` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`Invitation`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The invitation's ID. |
| `object` | `"invitation"` | Always `invitation`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `email` | `string` | — |
| `role` | `"owner" \| "admin" \| "supervisor" \| "agent"` | The role they get when they accept. |
| `billing` | `boolean` | — |
| `team_id` | `string \| null` | `team_…` ID. |
| `status` | `"pending" \| "expired"` | `pending` until it expires (7 days); accepted and withdrawn invitations are no longer listed. |
| `invited_by` | `string \| null` | The user who invited them (for an API key: the user who created the key). |
| `existing_user` | `boolean` | The address already has an account (in another organisation): they join with it. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `expires` | `string` | An ISO-8601 timestamp in UTC. |
| `emailed` | `boolean` | On create and resend: whether the invitation email went out. False when your organisation's invitation emails are off — share the link from the dashboard. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const invitation = await mv.invitations.resend("inv_t_7Hk2Lm9Qp");
console.log(invitation);
```

## `retrieve()`

**Retrieve an invitation.** Returns the `Invitation` object. Answers `404` with the code `resource_missing` when nothing has this ID in this organisation and mode.

```ts
mv.invitations.retrieve(id: InvitationsRetrieveData["path"]["id"], options?: RequestOptions): Promise<InvitationsRetrieveResponse>
```

`GET /invitations/{id}` · [API reference](https://docs.morevoice.ai/api/operations/invitations_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A invitation ID (`inv_t_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`Invitation`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The invitation's ID. |
| `object` | `"invitation"` | Always `invitation`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `email` | `string` | — |
| `role` | `"owner" \| "admin" \| "supervisor" \| "agent"` | The role they get when they accept. |
| `billing` | `boolean` | — |
| `team_id` | `string \| null` | `team_…` ID. |
| `status` | `"pending" \| "expired"` | `pending` until it expires (7 days); accepted and withdrawn invitations are no longer listed. |
| `invited_by` | `string \| null` | The user who invited them (for an API key: the user who created the key). |
| `existing_user` | `boolean` | The address already has an account (in another organisation): they join with it. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `expires` | `string` | An ISO-8601 timestamp in UTC. |
| `emailed` | `boolean` | On create and resend: whether the invitation email went out. False when your organisation's invitation emails are off — share the link from the dashboard. |

### Example

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const invitation = await mv.invitations.retrieve("inv_t_7Hk2Lm9Qp");
console.log(invitation);
```
