# Invitations

Team invitation management

Source: https://keyenv.dev/docs/api/invitations/

Team invitation management

## List team invitations

```http
GET /api/v1/teams/{teamId}/invitations
```

Returns pending invitations for a team

**Operation ID:** `listTeamInvitations` &middot; **Authentication:** `Authorization: Bearer <token>`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `teamId` | `string (uuid)` | yes | Team UUID |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | List of invitations | `object[]` |
| `401` | Authentication required | `Error` |
| `403` | Insufficient permissions | `Error` |

### Response body (`200`)

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string (uuid)` |  |
| `team_id` | `string (uuid)` |  |
| `email` | `string (email)` |  |
| `role` | `enum (admin, member)` |  |
| `invited_by` | `string (uuid)` |  |
| `expires_at` | `string (date-time)` |  |
| `created_at` | `string (date-time)` |  |

### Example

```bash
curl -X GET "https://api.keyenv.dev/api/v1/teams/{teamId}/invitations" \
  -H "Authorization: Bearer $KEYENV_TOKEN"
```

## Revoke invitation

```http
DELETE /api/v1/teams/{teamId}/invitations/{invitationId}
```

Revokes a pending team invitation

**Operation ID:** `revokeInvitation` &middot; **Authentication:** `Authorization: Bearer <token>`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `teamId` | `string (uuid)` | yes | Team UUID |
| `invitationId` | `string (uuid)` | yes |  |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `204` | Invitation revoked |  |
| `401` | Authentication required | `Error` |
| `403` | Insufficient permissions | `Error` |
| `404` | Resource not found | `Error` |

### Example

```bash
curl -X DELETE "https://api.keyenv.dev/api/v1/teams/{teamId}/invitations/{invitationId}" \
  -H "Authorization: Bearer $KEYENV_TOKEN"
```

## Resend invitation

```http
POST /api/v1/teams/{teamId}/invitations/{invitationId}/resend
```

Resends a pending team invitation email

**Operation ID:** `resendInvitation` &middot; **Authentication:** `Authorization: Bearer <token>`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `teamId` | `string (uuid)` | yes | Team UUID |
| `invitationId` | `string (uuid)` | yes |  |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | Invitation resent |  |
| `401` | Authentication required | `Error` |
| `403` | Insufficient permissions | `Error` |
| `404` | Resource not found | `Error` |

### Example

```bash
curl -X POST "https://api.keyenv.dev/api/v1/teams/{teamId}/invitations/{invitationId}/resend" \
  -H "Authorization: Bearer $KEYENV_TOKEN"
```

## List my invitations

```http
GET /api/v1/invitations
```

Returns pending invitations for the current user

**Operation ID:** `listMyInvitations` &middot; **Authentication:** `Authorization: Bearer <token>`

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | List of invitations | `object[]` |
| `401` | Authentication required | `Error` |

### Response body (`200`)

| Field | Type | Description |
| --- | --- | --- |
| `team_name` | `string` |  |
| `invited_by_email` | `string (email)` |  |
| `role` | `enum (admin, member)` |  |
| `email` | `string (email)` |  |
| `expires_at` | `string (date-time)` |  |
| `token` | `string` |  |

### Example

```bash
curl -X GET "https://api.keyenv.dev/api/v1/invitations" \
  -H "Authorization: Bearer $KEYENV_TOKEN"
```

## Get invitation by token

```http
GET /api/v1/invitations/{token}
```

Returns public information about an invitation

**Operation ID:** `getInvitationByToken` &middot; **Authentication:** `Authorization: Bearer <token>`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `token` | `string` | yes |  |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | Invitation details | `InvitationPublicInfo` |
| `401` | Authentication required | `Error` |
| `404` | Resource not found | `Error` |

### Response body (`200`)

| Field | Type | Description |
| --- | --- | --- |
| `team_name` | `string` |  |
| `invited_by_email` | `string (email)` |  |
| `role` | `enum (admin, member)` |  |
| `email` | `string (email)` |  |
| `expires_at` | `string (date-time)` |  |
| `token` | `string` |  |

### Example

```bash
curl -X GET "https://api.keyenv.dev/api/v1/invitations/{token}" \
  -H "Authorization: Bearer $KEYENV_TOKEN"
```

## Accept invitation

```http
POST /api/v1/invitations/{token}/accept
```

Accepts a team invitation and joins the team

**Operation ID:** `acceptInvitation` &middot; **Authentication:** `Authorization: Bearer <token>`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `token` | `string` | yes |  |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | Invitation accepted | `Team` |
| `401` | Authentication required | `Error` |
| `404` | Resource not found | `Error` |

### Response body (`200`)

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string (uuid)` |  |
| `name` | `string` |  |
| `slug` | `string` |  |
| `plan` | `enum (free, team, enterprise)` |  |
| `is_personal` | `boolean` |  |
| `created_at` | `string (date-time)` |  |

### Example

```bash
curl -X POST "https://api.keyenv.dev/api/v1/invitations/{token}/accept" \
  -H "Authorization: Bearer $KEYENV_TOKEN"
```
