# mv.teams

> The teams methods of @morevoice/sdk: Teams of users.

Teams of users. These methods are on `mv.teams`, 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()`

**Create a team.** Returns the new `Team`.

```ts
mv.teams.create(body: TeamsCreateData["body"], options?: RequestOptions): Promise<TeamsCreateResponse>
```

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

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.name` | `string` | yes |  |
| `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

`Team`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The team's ID. |
| `object` | `"team"` | Always `team`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `member_count` | `integer` | Active members in the team. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

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

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

const team = await mv.teams.create({
	name: "Sales",
});
console.log(team);
```

## `delete()`

**Delete a team.** Deletes the team. Its members stay in the organisation, in no team; queues that list the team no longer reach them through it.

```ts
mv.teams.delete(id: TeamsDeleteData["path"]["id"], options?: RequestOptions): Promise<TeamsDeleteResponse>
```

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

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A team ID (`team_…`). |
| `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

`DeletedTeam`:

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

### Example

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

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

const deletedTeam = await mv.teams.delete("team_7Hk2Lm9Qp");
console.log(deletedTeam);
```

## `list()`

**List teams.** Returns a page of `Team` objects, newest first. Pass `next_cursor` as `starting_after` for the next page; the SDKs iterate every page for you.

```ts
mv.teams.list(query?: NonNullable<TeamsListData["query"]>, options?: RequestOptions): PagedList<TeamsListResponse["data"][number], NonNullable<TeamsListData["query"]>>
```

`GET /teams` · [API reference](https://docs.morevoice.ai/api/operations/teams_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 team of mv.teams.list()) {
	console.log(team);
}
```

## `retrieve()`

**Retrieve a team.** Returns the `Team` object. Answers `404` with the code `resource_missing` when nothing has this ID in this organisation and mode.

```ts
mv.teams.retrieve(id: TeamsRetrieveData["path"]["id"], options?: RequestOptions): Promise<TeamsRetrieveResponse>
```

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

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A team ID (`team_…`). |
| `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

`Team`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The team's ID. |
| `object` | `"team"` | Always `team`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `member_count` | `integer` | Active members in the team. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

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

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

const team = await mv.teams.retrieve("team_7Hk2Lm9Qp");
console.log(team);
```

## `update()`

**Rename a team.** Changes only the fields you send. Returns the updated `Team`. Answers `404` with the code `resource_missing` when nothing has this ID in this organisation and mode.

```ts
mv.teams.update(id: TeamsUpdateData["path"]["id"], body: TeamsUpdateData["body"], options?: RequestOptions): Promise<TeamsUpdateResponse>
```

`PATCH /teams/{id}` · [API reference](https://docs.morevoice.ai/api/operations/teams_update/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A team ID (`team_…`). |
| `body.name` | `string` | yes |  |
| `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

`Team`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The team's ID. |
| `object` | `"team"` | Always `team`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `member_count` | `integer` | Active members in the team. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

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

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

const team = await mv.teams.update("team_7Hk2Lm9Qp", {
	name: "Sales",
});
console.log(team);
```
