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

# Add a User

> Add someone to your business with a role, or bring back a user removed earlier ➕

## Endpoint

```json theme={null}
POST https://api.connectly.ai/external/v1/businesses/{businessId}/users
```

| Parameter | Location | Description |
| - | - | - |
| `businessId` | Path | Your Connectly business ID. |
| `X-API-Key` | Header | A [User Management key](https://docs.connectly.ai/user-management-api/overview.md#get-an-api-key). |

***

## Request body

```json theme={null}
{
  "email": "ana@example.com",
  "displayName": "Ana Souza",
  "role": "ROLE_AGENT"
}
```

| Field | Type | Required | Description |
| - | - | - | - |
| `email` | string | Yes | The email the person signs in with. |
| `role` | string | Yes | `ROLE_MARKETING`, `ROLE_ANALYTICS` or `ROLE_AGENT`. Owners cannot be added through the API. |
| `displayName` | string | No | The name shown in Connectly. Defaults to the email. Ignored when a removed user comes back (`MEMBERSHIP_REVIVED`): they keep their name. |

***

## Response

The API returns HTTP `201` with the user as added, what the call did with the email, and what became of the invite email.

```json theme={null}
{
  "entity": {
    "id": "2438ac3c-37eb-4902-adef-ed16b4431030",
    "email": "ana@example.com",
    "displayName": "Ana Souza",
    "role": "ROLE_AGENT"
  },
  "outcome": "CREATE_USER_OUTCOME_CREATED",
  "inviteEmail": "INVITE_EMAIL_SENT"
}
```

### `outcome`

| Value | When | Invite email |
| - | - | - |
| `CREATE_USER_OUTCOME_CREATED` | The email had no Connectly account. A new account is created. | Sent |
| `CREATE_USER_OUTCOME_ACCOUNT_RESTORED` | The email belonged to a deleted account that used to be a user of your business. The account is restored. | Sent |
| `CREATE_USER_OUTCOME_MEMBERSHIP_REVIVED` | The email belongs to someone removed from your business earlier who still has their account. They come back with the same `id` and sign in as before. | Not sent |

### `inviteEmail`

The invite is an email with a link to set a password. The link is valid for 24 hours.

| Value | Meaning |
| - | - |
| `INVITE_EMAIL_SENT` | Connectly's mail service accepted the email. |
| `INVITE_EMAIL_FAILED` | The send was not confirmed. The email may still arrive. |
| `INVITE_EMAIL_NOT_SENT` | No invite was due: the user came back with their own account. |

> [!NOTE]
>
> The invite is sent once and never resent automatically. A user who did not get it can use **Forgot password** on the sign-in page, or sign in with SSO if your business uses [Enterprise SSO](https://docs.connectly.ai/enterprise-sso/overview.md).

> [!WARNING]
>
> If your mail server rejects email from Connectly, the people you add receive neither the invite nor a **Forgot password** email. They can still sign in through your company's SSO if your business uses [Enterprise SSO](https://docs.connectly.ai/enterprise-sso/overview.md); otherwise ask your email administrator to accept mail from Connectly.

***

## Error responses

| HTTP status | `errorCode` | Meaning |
| - | - | - |
| `400` | `PRFL.USR.OWNER_PROTECTED` | `role` is `ROLE_OWNER`. |
| `400` | `PRFL.USR.MEMBERSHIP_REVOKED_BY_SSO` | Your identity provider removed this person. Restore them in the identity provider. |
| `400` | | `email` is missing or not an email, or `role` is missing or unknown. |
| `409` | | The email cannot be added: it already belongs to a user of your business, to a user of another business, or to a Connectly account that was never a user of your business. Contact Connectly support for the last two. |

See [Errors](https://docs.connectly.ai/user-management-api/overview.md#errors) for the responses every endpoint can return.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.