# Create SCIM group

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

`POST /scim/v2/Groups`

Resource: **SCIM**

Map the group to a role and environments with `POST /group-mapping`.

## Request body

- **`displayName`** _(string)_
- **`externalId`** _(string)_
- **`members`** _(array<object>)_
  - **`value`** _(string)_

## Response body

- **`schemas`** _(array<string>)_
- **`id`** _(string)_
- **`externalId`** _(string)_
- **`displayName`** _(string)_
- **`members`** _(array<object>)_
  - **`value`** _(string)_
    The member's user ID.
  - **`display`** _(string)_
- **`meta`** _(object)_
  - **`resourceType`** _(string)_
    Allowed: `User`, `Group`
  - **`created`** _(string)_
  - **`lastModified`** _(string)_
  - **`location`** _(string)_

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | No `displayName`. |
| `409` | The team already has a group with this `externalId` (`scimType` is `uniqueness`). |

## Code examples

### curl

```bash
curl -X POST 'https://api.truto.one/scim/v2/Groups' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "displayName": "your_displayName",
  "externalId": "your_externalId",
  "members": []
}'
```

### JavaScript

```javascript
const body = {
  "displayName": "your_displayName",
  "externalId": "your_externalId",
  "members": []
};

const response = await fetch('https://api.truto.one/scim/v2/Groups', {
  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/Groups"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "displayName": "your_displayName",
    "externalId": "your_externalId",
    "members": []
}

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