# Teams

Source: https://developers.leonai.io/docs/guides/teams/

Teams let multiple users collaborate on links and analytics. Team management is an
account operation, so these endpoints require a **JWT** (not an API key). Seat limits
depend on your [subscription tier](https://developers.leonai.io/docs/intro/#subscription-tiers) (Free 1, Pro 5,
Business 25, Enterprise unlimited).

## Roles (RBAC)

Members have one of four roles, in ascending privilege:

| Role     | Can                                                                 |
| -------- | ------------------------------------------------------------------- |
| `viewer` | Read team resources and members                                     |
| `member` | Everything a viewer can, plus act within the team                   |
| `admin`  | Invite/remove members, manage invites and roles                     |
| `owner`  | Everything, including managing admins. Assigned to the team creator |

The invite and role-change endpoints accept only `admin`, `member`, or `viewer` —
`owner` is fixed to the creator. Promoting or demoting an **admin** is owner-only.

## Create a team

```bash
curl -X POST https://api.short.leonai.io/api/v1/teams \
  -H "Authorization: Bearer <jwt>" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Growth" }'
```

`REST: POST /api/v1/teams`

## List your teams

```bash
curl https://api.short.leonai.io/api/v1/teams \
  -H "Authorization: Bearer <jwt>"
```

## Members and invites

| Action                 | Endpoint                                         |
| ---------------------- | ------------------------------------------------ |
| List members           | `GET /api/v1/teams/:teamId/members`              |
| Invite a member        | `POST /api/v1/teams/:teamId/invites`             |
| List pending invites   | `GET /api/v1/teams/:teamId/invites`              |
| Revoke an invite       | `DELETE /api/v1/teams/:teamId/invites/:inviteId` |
| Accept an invite       | `POST /api/v1/teams/invites/accept`              |
| Remove a member        | `DELETE /api/v1/teams/:teamId/members/:memberId` |
| Change a member's role | `PATCH /api/v1/teams/:teamId/members/:memberId`  |

### Invite a member

```bash
curl -X POST https://api.short.leonai.io/api/v1/teams/<teamId>/invites \
  -H "Authorization: Bearer <jwt>" \
  -H "Content-Type: application/json" \
  -d '{ "email": "teammate@example.com", "role": "member" }'
```

The invitee receives an invite they accept with the invite token. Once accepted, they
appear in the team's member list and can act within the team's permissions.

:::note[Exact request/response shapes]
Team endpoints are documented at a high level here. See the
[full API reference](https://developers.leonai.io/docs/api-reference/) for exact field names, roles, and response
bodies under the **Teams** tag.
:::
