# Create SCIM user

> Source: https://truto.one/docs/api-reference/admin/scim/create-user/

`POST /scim/v2/Users`

Resource: **SCIM**

Adds a user to the team. `userName` (or `emails[0].value`) is the email address. A user created with `active: false` is a `400`. The user starts with the role and environments of the team's default SSO connection (a `400` if it has no default environments), and the team's group mappings then apply.

## Request body

- **`userName`** _(string)_
- **`externalId`** _(string)_
- **`name`** _(object)_
  - **`formatted`** _(string)_
- **`displayName`** _(string)_
  Used as the name when `name.formatted` is not sent.
- **`active`** _(boolean)_

## Response body

- **`schemas`** _(array<string>)_
- **`id`** _(string)_
  The Truto user ID.
- **`externalId`** _(string)_
  The identity provider's ID for the user.
- **`userName`** _(string)_
  The user's email address, lowercased.
- **`name`** _(object)_
  - **`formatted`** _(string)_
    The user's name, or their email address when no name is set.
- **`active`** _(boolean)_
  Whether the user is an active member of the team.
- **`meta`** _(object)_
  - **`resourceType`** _(string)_
    Allowed: `User`, `Group`
  - **`created`** _(string)_
  - **`lastModified`** _(string)_
  - **`location`** _(string)_

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | No `userName`, `active` is `false`, or the default SSO connection has no default environments. |

## Code examples

### curl

```bash
curl -X POST 'https://api.truto.one/scim/v2/Users' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "userName": "jane@example.com",
  "externalId": "your_externalId",
  "name": {},
  "displayName": "your_displayName",
  "active": true
}'
```

### JavaScript

```javascript
const body = {
  "userName": "jane@example.com",
  "externalId": "your_externalId",
  "name": {},
  "displayName": "your_displayName",
  "active": true
};

const response = await fetch('https://api.truto.one/scim/v2/Users', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/scim/v2/Users"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "userName": "jane@example.com",
    "externalId": "your_externalId",
    "name": {},
    "displayName": "your_displayName",
    "active": True
}

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