# Members endpoints

Every path starts at your [API URL](https://docs.qualithm.com/api.md#find-your-api-url). Every response is JSON, and an error has the [error body](https://docs.qualithm.com/api.md#errors).

## List the team's active members

`GET /v1/teams/{teamId}/members`

By `accountName`, then `id`, ascending. Names compare byte by byte, so uppercase sorts before lowercase.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `team.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `limit` | query | integer | No | Items per page, 1 to 100. Default 50. |
| `cursor` | query | string | No | A previous page's `nextCursor`, to read the page after it |

**Response:** `200` with [TeamMemberPage](#teammemberpage) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/members" \
  -H "Authorization: Bearer <your-api-token>"
```

## Accept an invite to the team

`POST /v1/teams/{teamId}/members`

Only the account whose email the invite names can accept it.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate).

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `Idempotency-Key` | header | string | No | A unique key for this request. A retry with the same key and body returns the first response instead of acting again; keys last 24 hours. |

**Request body:** [CreateTeamMemberRequest](#createteammemberrequest)

**Response:** `201` with [TeamMembership](#teammembership) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `409`, `413`, `415`, `429`, `500`, `503`

```bash
curl -X POST "<your-api-url>/v1/teams/<team-id>/members" \
  -H "Authorization: Bearer <your-api-token>" \
  -H "Content-Type: application/json" \
  -d '{"inviteId":"<invite-id>"}'
```

## Get a member of the team

`GET /v1/teams/{teamId}/members/{memberId}`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `team.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `memberId` | path | string | Yes | A member ID: `mbr_…`; also accepts the legacy `mem_…` |

**Response:** `200` with [TeamMember](#teammember) in `data`.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl "<your-api-url>/v1/teams/<team-id>/members/<member-id>" \
  -H "Authorization: Bearer <your-api-token>"
```

## Change a member's role

`PATCH /v1/teams/{teamId}/members/{memberId}`

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `member.update` permission, which the owner and manager roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `memberId` | path | string | Yes | A member ID: `mbr_…`; also accepts the legacy `mem_…` |

**Request body:** [UpdateTeamMemberRequest](#updateteammemberrequest)

**Response:** `204` with no body.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `413`, `415`, `429`, `500`, `503`

```bash
curl -X PATCH "<your-api-url>/v1/teams/<team-id>/members/<member-id>" \
  -H "Authorization: Bearer <your-api-token>" \
  -H "Content-Type: application/json" \
  -d '{"role":"owner"}'
```

## Remove a member from the team

`DELETE /v1/teams/{teamId}/members/{memberId}`

A viewer can remove only themselves; a manager only viewers and themselves.

Needs an [API token](https://docs.qualithm.com/api.md#authenticate) with the `team.read` permission, which the owner, manager and viewer roles hold.

**Parameters**

| Name | In | Type | Required | Description |
| ---- | -- | ---- | -------- | ----------- |
| `teamId` | path | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `memberId` | path | string | Yes | A member ID: `mbr_…`; also accepts the legacy `mem_…` |

**Response:** `204` with no body.

**[Errors](https://docs.qualithm.com/api.md#errors):** `400`, `401`, `403`, `404`, `429`, `500`, `503`

```bash
curl -X DELETE "<your-api-url>/v1/teams/<team-id>/members/<member-id>" \
  -H "Authorization: Bearer <your-api-token>"
```

## Types

### TeamMemberPage

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `items` | array of [TeamMember](#teammember) | Yes |  |
| `nextCursor` | string or null | Yes | Pass as `cursor` to read the next page; `null` on the last page |

### TeamMember

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | A member ID: `mbr_…`; also accepts the legacy `mem_…` |
| `accountId` | string | Yes | An account ID: `acc_…` |
| `teamId` | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `role` | [MemberRole](#memberrole) | Yes |  |
| `createdAt` | string (date-time) | Yes | UTC time, RFC 3339 |
| `updatedAt` | string (date-time) | Yes | UTC time, RFC 3339 |
| `accountEmail` | string | Yes |  |
| `accountName` | string | Yes |  |
| `teamName` | string | Yes |  |

### MemberRole

A member's role in a team.

one of `"owner"`, `"manager"`, `"viewer"`.

### CreateTeamMemberRequest

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `inviteId` | string | Yes | The invite to accept |

### TeamMembership

A membership row, without the account and team context

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `id` | string | Yes | A member ID: `mbr_…`; also accepts the legacy `mem_…` |
| `accountId` | string | Yes | An account ID: `acc_…` |
| `teamId` | string | Yes | A team ID: `tem_…`; also accepts the legacy `tm_…` |
| `role` | [MemberRole](#memberrole) | Yes |  |
| `status` | one of `"invited"`, `"active"`, `"revoked"`, `"declined"` | Yes |  |
| `createdAt` | string (date-time) | Yes | UTC time, RFC 3339 |
| `updatedAt` | string (date-time) | Yes | UTC time, RFC 3339 |

### UpdateTeamMemberRequest

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `role` | [MemberRole](#memberrole) | Yes |  |
