# Invite teammates (https://notert.io/docs/api/reference/invite-teammates)

`POST /api/v1/teammates/invitations`

Invites people to the team as members by their email addresses, as the team page does, as the teammate who holds the token's secret: only an owner or admin can, within the plan's seats. Each is emailed a link to join, and the workspace's owners are emailed who was invited and through which token. Every address is answered, invited or refused with why, and one refusal never stops the rest.

Access: A token with people:write.

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `emails` | email[] | Yes | The addresses to invite, at most 20, each answered once however often sent. |
| `role` | value | No | The role every address is invited as: member, the only one a token invites as. An admin is invited from the team page. Default "member". |

## Response 200

| Field | Type | Description |
| --- | --- | --- |
| `sent` | string[] | The addresses invited, lower-cased, each emailed a link to join. One invited already is sent theirs again, as a member. |
| `refused` | object[] | The addresses not invited, each with why. Nothing was sent to them. |
| `refused.email` | string | The address as you sent it, lower-cased. |
| `refused.code` | string | Why it wasn't invited: NOT_ALLOWED (the token's holder lost the role that invites meanwhile), INVITED_RECENTLY (emailed an invitation three times this hour), ALREADY_MEMBER, BANNED, TOO_MANY_PENDING (as many invitations wait as the workspace takes) or MEMBER_LIMIT_REACHED (no seat left on the plan). One of: `NOT_ALLOWED`, `INVITED_RECENTLY`, `ALREADY_MEMBER`, `BANNED`, `TOO_MANY_PENDING`, `MEMBER_LIMIT_REACHED`. |
| `refused.reason` | string | Why, in a sentence to show a person. |

## Errors

| Status | Code | Message |
| --- | --- | --- |
| 400 | `BAD_REQUEST` | Input validation failed. |
| 401 | `UNAUTHORIZED` | Send a valid API token as a Bearer token. |
| 403 | `FORBIDDEN` | The teammate who holds this API token's secret can't invite teammates. Only an owner or admin can: one of them should roll it in the workspace's settings. |
| 403 | `HOLDER_NOT_ALLOWED` | The teammate who holds this API token's secret can't do this in the workspace now. A teammate who can should roll it in the workspace's settings. |
| 403 | `INSUFFICIENT_SCOPE` | This API token can't change your customers' traits or invite teammates. Create one that may in the workspace's settings. |
| 403 | `NETWORK_NOT_ALLOWED` | This API token works only from the networks it was made for. Call from one of them, or create a token for this one in the workspace's settings. |
| 403 | `NO_SEAT` | This workspace's plan has no seat for you. |
| 403 | `TOKEN_HELD_TO_BOARDS` | A teammate reaches every board, so this token, held to some, can't invite one. Use a token that reaches every board. |
| 403 | `WORKSPACE_SUSPENDED` | This workspace is suspended. |
| 409 | `CHANGED_MEANWHILE` | Something changed meanwhile. Try again. |
| 429 | `TOO_MANY_REQUESTS` | Too Many Requests. Its data holds `retryAfter`. |

## Example request

```sh
curl -X POST https://app.notert.io/api/v1/teammates/invitations \
  -H "Authorization: Bearer $NOTERT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "emails": [
    "sam@example.com",
    "hannah@example.com"
  ],
  "role": "member"
}'
```

## Example response 200

```json
{
  "sent": [
    "sam@example.com"
  ],
  "refused": [
    {
      "email": "hannah@example.com",
      "code": "ALREADY_MEMBER",
      "reason": "They are on the team already."
    }
  ]
}
```
