---
title: "Invite a person to the agency's staff"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.nicer.travel/llms.txt
> Use this file to discover all available pages before exploring further.

# Invite a person to the agency's staff

Path: Nicer API › identity

`POST /identity/invite`

URL: `https://api.nicer.travel/identity/invite`

Invites a person to the staff of the agency the request acts for, as an advisor or an admin (role), by email, phoneNumber, givenName and familyName, and sends them the invitation unless sendMessage is false. A person who already has a staff account joins the agency at once instead, with the role sent, and the answer is that membership with alreadyMember true; otherwise the answer is the pending invitation. Travelers are invited from the CRM (POST /crm/travelers/{travelerId}/invitation), and a contact that belongs to a traveler's account is refused with 409 ERROR_USER_IS_TRAVELER unless that account was opened from a staff invitation. A body that fails the schema, such as one with another role or with no phone, email or name, is refused with 400 ERROR_BODY_VALIDATION. Agency admins only; only Nicer staff name another agency with companyName.

## Authentication

- `bearerAuth`, http bearer, header `Authorization`, format `JWT`

## Request body

_Required._

- `role` (`identity.invite.create.role`; string, required)
  - one of `"advisor"`, `"admin"`
- `companyName` (`identity.invite.create.companyName`; string, optional)
  - minLength: `1`
- `email` (`identity.invite.create.email`; string, optional)
  - format: `email` · pattern: `^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$`
- `familyName` (`identity.invite.create.familyName`; string, optional)
- `givenName` (`identity.invite.create.givenName`; string, optional)
- `metadata` (`identity.invite.create.metadata`; map of string, optional)
- `phoneNumber` (`identity.invite.create.phoneNumber`; string, optional)
- `sendMessage` (`identity.invite.create.sendMessage`; boolean, optional)
  - default: `true`

## Example request

```json
{
  "companyName": "string",
  "email": "user@example.com",
  "familyName": "string",
  "givenName": "string",
  "metadata": {
    "property1": "string",
    "property2": "string"
  },
  "phoneNumber": "string",
  "role": "advisor",
  "sendMessage": true
}
```

## Code samples

### JavaScript SDK

```javascript
import { createClient } from "@nicertravel/sdk";

const nicer = createClient({
  baseUrl: "https://api.nicer.travel",
  token: process.env.NICER_TOKEN,
});

await nicer.identity.invite.create({
  "role": "advisor"
});
```

### Nicer CLI

```bash
nicer identity invite create --input - <<'JSON'
{
  "role": "advisor"
}
JSON
```

### cURL

```bash
curl --request POST \
  --url https://api.nicer.travel/identity/invite \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "companyName": "string",
  "email": "user@example.com",
  "familyName": "string",
  "givenName": "string",
  "metadata": {
    "property1": "string",
    "property2": "string"
  },
  "phoneNumber": "string",
  "role": "advisor",
  "sendMessage": true
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/identity/invite';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({
    companyName: 'string',
    email: 'user@example.com',
    familyName: 'string',
    givenName: 'string',
    metadata: {property1: 'string', property2: 'string'},
    phoneNumber: 'string',
    role: 'advisor',
    sendMessage: true
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.nicer.travel/identity/invite"

payload = {
    "companyName": "string",
    "email": "user@example.com",
    "familyName": "string",
    "givenName": "string",
    "metadata": {
        "property1": "string",
        "property2": "string"
    },
    "phoneNumber": "string",
    "role": "advisor",
    "sendMessage": True
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "advisorId": "string",
  "companyName": "string",
  "createdBy": "string",
  "deleted": true,
  "email": "string",
  "expiresAt": "string",
  "familyName": "string",
  "fullName": "string",
  "givenName": "string",
  "invitedBy": "string",
  "lastModifiedBy": "string",
  "metadata": {
    "property1": "string",
    "property2": "string"
  },
  "phoneNumber": "string",
  "resendCount": 0,
  "role": "advisor",
  "sendMessage": true,
  "inviteId": "string",
  "userId": "string",
  "createdAt": "string",
  "type": "Invite",
  "updatedAt": "string"
}
```

Any of the following:

- `Invite`
  - `companyName` (`Invite.companyName`; string, required) — The agency the invitation is to.
  - `createdBy` (`Invite.createdBy`; string, required) — The user id of whoever sent it, or SYSTEM for a paid Join.
  - `invitedBy` (`Invite.invitedBy`; string, required) — The user id of whoever sent it, or SYSTEM for a paid Join.
  - `lastModifiedBy` (`Invite.lastModifiedBy`; string, required) — The user id of whoever last changed it, or SYSTEM.
  - `role` (`Invite.role`; string, required) — The role the invitee gets on accepting.
    - one of `"advisor"`, `"traveler"`, `"admin"`, `"superadmin"`
  - `inviteId` (`Invite.inviteId`; string, required) — The invitation's id.
  - `userId` (`Invite.userId`; string, required) — The user id of whoever sent it; JOIN#<registrationId> for a paid Join.
  - `createdAt` (`Invite.createdAt`; string, required) — When it was sent.
  - `type` (`Invite.type`; string, required)
  - `updatedAt` (`Invite.updatedAt`; string, required) — When it last changed.
  - `advisorId` (`Invite.advisorId`; any of, optional) — The advisor some older invitations name.
    - any of the following: `string`, `null`
  - `deleted` (`Invite.deleted`; boolean, optional) — True once it was cancelled.
  - `email` (`Invite.email`; string, optional) — The email it was sent to.
  - `expiresAt` (`Invite.expiresAt`; string, optional) — When it can no longer be accepted; one without it expires seven days after createdAt.
  - `familyName` (`Invite.familyName`; string, optional) — The invitee's last name.
  - `fullName` (`Invite.fullName`; string, optional) — The invitee's first and last name, joined.
  - `givenName` (`Invite.givenName`; string, optional) — The invitee's first name.
  - `metadata` (`Invite.metadata`; map of string, optional) — Details stored with it, such as joinRegistrationId.
  - `phoneNumber` (`Invite.phoneNumber`; string, optional) — The phone it was sent to.
  - `resendCount` (`Invite.resendCount`; number, optional) — How many times it was sent again; four at most.
  - `sendMessage` (`Invite.sendMessage`; boolean, optional) — Whether the request asked to send it, kept on invitations of a person whose traveler account was opened from a staff invitation.
- `object`
  - `alreadyMember` (`identity.invite.create.response.200.2.alreadyMember`; boolean, required)
  - `companyName` (`identity.invite.create.response.200.2.companyName`; string, required) — The agency they joined.
  - `joinedAt` (`identity.invite.create.response.200.2.joinedAt`; string, required) — When they joined it.
  - `role` (`identity.invite.create.response.200.2.role`; string, required) — Their role there, as the request sent it.
    - one of `"advisor"`, `"admin"`
  - `userId` (`identity.invite.create.response.200.2.userId`; string, required) — The person's id.

### 400

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`identity.invite.create.response.400.errorCode`; string, required)
- `errorMessage` (`identity.invite.create.response.400.errorMessage`; string, required)

### 401

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`identity.invite.create.response.401.errorCode`; string, required)
- `errorMessage` (`identity.invite.create.response.401.errorMessage`; string, required)

### 403

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`identity.invite.create.response.403.errorCode`; string, required)
- `errorMessage` (`identity.invite.create.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/identity/identity.invite.create/index.md
