# Create group

`POST /v1/organizations/{organizationId}/groups`

Available as MCP tool `create-org-group` (Write).

Access control endpoints allow you to review and manage user role assignments. Organization and environment roles are managed separately. Furthermore, a user’s organizational role doesn't impact their assigned environment role, and vice versa. [Learn about roles](https://docs.redoxengine.com/permalink/1OBel3inQAjAnDbgd9QLzM). 

Generally, organization owners or admins can retrieve, assign, update, or remove role assignments. However, only organization owners can assign or remove organization roles specifically.

Organization owners and admins can create and manage access control groups. A group allows you to manage role assignments for an entire group of users at once. [Learn about groups](https://docs.redoxengine.com/permalink/1OBel3inQAjAnDbgd9QLzM/#assign-roles-with-groups).

> **Assign or add an organization role**
>
> We don't currently support assigning an organization role (i.e., adding a user to an organization) in the Redox dashboard. [Learn how to add a user](https://docs.redoxengine.com/permalink/5c0Yr43tA3HrfvhX2JR3WS).

### Create group

Create a new group in the specified organization. You can optionally include its members and role assignments in the same request. 

Any listed members immediately gain the group’s access level. You can’t give a group an organization role with permissions you don’t hold.

## Request parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `organizationId` | path | string | Yes | Identifies the Redox organization that you're operating in or on behalf of. |

## Request body

Contains the group's name and, optionally, its role assignments and members.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | Yes | Contains the group's human-readable name. |
| `roleAssignments` | Array of object | No | Contains the role assignments to add to the group. |
| `roleAssignments[].role` | object | Yes |  |
| `roleAssignments[].role.id` | string | Yes | Contains the unique identifier of the role. |
| `roleAssignments[].environment` | object, nullable | No |  |
| `roleAssignments[].environment.id` | string | Yes | Identifies the environment the role applies to. |
| `members` | Array of object | No | Contains the users to add to the group. |
| `members[].user` | object | Yes |  |
| `members[].user.id` | integer | Yes | Contains the unique identifier of the user. |

## Request example

_Generated from the schema: the values are placeholders, not a real payload._

```bash
curl 'https://api.redoxengine.com/platform/v1/organizations/{organizationId}/groups' \
--request POST \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
  "name": "string",
  "roleAssignments": [
    {
      "role": {
        "id": "string"
      },
      "environment": {
        "id": "string"
      }
    }
  ],
  "members": [
    {
      "user": {
        "id": 0
      }
    }
  ]
}'
```

## Responses

### 200

Contains the payload with the new group.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `meta` | object | No |  |
| `meta.version` | string | No | Lists the major and minor version number for the format of the returned payload. The payload format or shape may change between minor versions, like including additional or extended fields in later versions. We include the version data in each response so that you have the option to handle the signaled differences. |
| `payload` | object | No |  |
| `payload.group` | object | No |  |
| `payload.group.id` | string | No | Contains the unique identifier of the group. |
| `payload.group.organization` | integer | No | Identifies the organization the group belongs to. |
| `payload.group.name` | string | No | Contains the group's human-readable name. |
| `payload.group.source` | string | No | Indicates who manages the group's membership. `manual` means your organization's administrators manage it in Redox. Value: manual |
| `payload.group.createdAt` | string (date-time) | No | Displays a timestamp of when the group was created. |
| `payload.group.updatedAt` | string (date-time) | No | Displays a timestamp of when the group was last updated. |
| `payload.group.members` | Array of object | No | Lists all group members. |
| `payload.group.members[].user` | object | No |  |
| `payload.group.members[].user.id` | integer | No | Contains the unique identifier of the user. |
| `payload.group.members[].user.fullname` | string | No | Displays the full name of the user. |
| `payload.group.members[].user.lowcaseEmail` | string | No | Contains the user's email address in lowercase format. |
| `payload.group.roleAssignments` | Array of object | No | Contains the organization and environment roles the group grants. |
| `payload.group.roleAssignments[].role` | object | No |  |
| `payload.group.roleAssignments[].role.id` | string | No | Displays the unique identifier of the role. |
| `payload.group.roleAssignments[].role.name` | string | No | Displays the name of the role. |
| `payload.group.roleAssignments[].environment` | object, nullable | No | Contains the environment that the environment role applies to. Otherwise, this is set to `null` for an organization role assignment. |
| `payload.group.roleAssignments[].environment.id` | string | No | Identifies the environment. |
| `payload.group.roleAssignments[].environment.name` | string | No | Displays the human-readable name of the environment. |
| `payload.group.samlMappings` | Array of object | No | Lists the SAML attribute values that give a user this group's roles when they sign in with your organization's SSO. A mapped user gets the roles for that session but isn't added to the group's members. |
| `payload.group.samlMappings[].id` | string | No | Contains the unique identifier of the mapping. |
| `payload.group.samlMappings[].attributeName` | string | No | Contains the name of the SAML attribute that's matched, such as `groups`. |
| `payload.group.samlMappings[].attributeValue` | string | No | Contains the attribute value that maps a user to this group. |

_Generated from the schema: the values are placeholders, not a real payload._

```json
{
  "meta": {
    "version": "1.0.0"
  },
  "payload": {
    "group": {
      "id": "string",
      "organization": 0,
      "name": "string",
      "source": "manual",
      "createdAt": "2019-08-24T14:15:22Z",
      "updatedAt": "2019-08-24T14:15:22Z",
      "members": [
        {
          "user": {
            "id": 0,
            "fullname": "string",
            "lowcaseEmail": "string"
          }
        }
      ],
      "roleAssignments": [
        {
          "role": {
            "id": "string",
            "name": "string"
          },
          "environment": {
            "id": "string",
            "name": "string"
          }
        }
      ],
      "samlMappings": [
        {
          "id": "string",
          "attributeName": "string",
          "attributeValue": "string"
        }
      ]
    }
  }
}
```

### 400

Bad Request

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.id` | string | No | Contains a unique identifier for the given error instance. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Bad Request`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Bad Request",
      "code": "validation.error.bad.request",
      "detail": "Error details",
      "status": 400,
      "transient": false
    }
  }
}
```

### 403

Forbidden

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.errors` | Array of object | No |  |
| `payload.errors[].title` | string | No | Displays the high-level error message, typically something succinct like `Forbidden`. |
| `payload.errors[].code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |

```json
{
  "payload": {
    "errors": [
      {
        "title": "Forbidden",
        "code": "authorization.forbidden"
      }
    ]
  }
}
```

### 500

Internal Server Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Failed in step X`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Internal Server Error",
      "code": "failed.db.lookup",
      "detail": "Error details",
      "status": 500,
      "transient": true
    }
  }
}
```
