# Role Permission

**Summary:** Endpoints for Role Permission

- Role: [Developers](https://www.subrite.no/developers)
- Source: https://www.subrite.no/developers/role-permission
- Updated: 2026-10-13
- Markdown index: https://www.subrite.no/developers/llms.txt

<a id="get-api-v1-roles"></a>
## Get all roles of the tenant

`GET /api/v1/roles`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `page` | query | `number` | Default: `1` · `minimum`: `1` |
| `take` | query | `number` | Default: `10` · `minimum`: `1`, `maximum`: `50` |
| `orderBy` | query | `string` | Allowed values: `"createdAt"`, `"id"`, `"updatedAt"` · Default: `"createdAt"` |
| `orderDirection` | query | `string` | Allowed values: `"asc"`, `"desc"` · Default: `"desc"` |

### Responses

#### 200

Content type: `application/json` · `RolePaginated`

| Name | Type | Description |
| --- | --- | --- |
| `items` (Required) | `array of Role` |   |
| `items[].name` (Required when parent is present) | `string` |   |
| `items[].tenantId` (Required when parent is present) | `number` |   |
| `items[].isActive` (Required when parent is present) | `boolean` |   |
| `items[].userRoles` (Required when parent is present) | `array of UserRole` |   |
| `items[].userRoles[].userId` (Required when parent is present) | `number` |   |
| `items[].userRoles[].roleId` (Required when parent is present) | `number` |   |
| `items[].userRoles[].user` (Required when parent is present) | `User` | Nested fields omitted: depth limit. |
| `items[].userRoles[].role` (Required when parent is present) | `Role` | Recursive schema; nested fields are not repeated. |
| `items[].userRoles[].id` (Required when parent is present) | `number` |   |
| `items[].userRoles[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].userRoles[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].userRoles[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].userRoles[].metaData` (Required when parent is present) | `object` |   |
| `items[].rolePermissions` (Required when parent is present) | `array of RolePermission` |   |
| `items[].rolePermissions[].roleId` (Required when parent is present) | `number` |   |
| `items[].rolePermissions[].permissionId` (Required when parent is present) | `number` |   |
| `items[].rolePermissions[].role` (Required when parent is present) | `Role` | Recursive schema; nested fields are not repeated. |
| `items[].rolePermissions[].permission` (Required when parent is present) | `Permission` | Nested fields omitted: depth limit. |
| `items[].rolePermissions[].id` (Required when parent is present) | `number` |   |
| `items[].rolePermissions[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].rolePermissions[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].rolePermissions[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].rolePermissions[].metaData` (Required when parent is present) | `object` |   |
| `items[].tenant` (Required when parent is present) | `Tenant` | Nested fields omitted: field limit. |
| `items[].id` (Required when parent is present) | `number` |   |
| `items[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].metaData` (Required when parent is present) | `object` |   |
| `meta` (Required) | `PageMeta` |   |
| `meta.page` (Required) | `number` |   |
| `meta.take` (Required) | `number` |   |
| `meta.count` (Required) | `number` |   |
| `meta.pageCount` (Required) | `number` |   |
| `meta.hasPreviousPage` (Required) | `boolean` |   |
| `meta.hasNextPage` (Required) | `boolean` |   |

#### 400

Content type: `application/json` · `ErrorResponse`

badRequest

| Name | Type | Description |
| --- | --- | --- |
| `messageCode` (Required) | `string` | Allowed values: `"badRequest"` |
| `message` | `string` |   |
| `errors` (Required) | `array of FieldError` |   |
| `errors[].field` (Required when parent is present) | `string` |   |
| `errors[].fieldValue` (Required when parent is present) | `string` |   |
| `errors[].identifier` (Required when parent is present) | `string` |   |
| `errors[].identifierValue` (Required when parent is present) | `string` |   |
| `errors[].messageCode` (Required when parent is present) | `string` |   |
| `errors[].message` | `string` |   |
| `errors[].errorType` (Required when parent is present) | `string` |   |

**Example response**

`application/json`

```json
{
  "messageCode": "badRequest",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

| Name | Type | Description |
| --- | --- | --- |
| `messageCode` (Required) | `string` |   |
| `message` | `string` |   |
| `errors` (Required) | `array of FieldError` |   |
| `errors[].field` (Required when parent is present) | `string` |   |
| `errors[].fieldValue` (Required when parent is present) | `string` |   |
| `errors[].identifier` (Required when parent is present) | `string` |   |
| `errors[].identifierValue` (Required when parent is present) | `string` |   |
| `errors[].messageCode` (Required when parent is present) | `string` |   |
| `errors[].message` | `string` |   |
| `errors[].errorType` (Required when parent is present) | `string` |   |

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

### Example request

```bash
curl https://api.subrite.no/api/v1/roles \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
{
  "items": [
    {
      "userRoles": [],
      "rolePermissions": [],
      "metaData": {}
    }
  ],
  "meta": {
    "page": 0,
    "take": 0,
    "count": 0,
    "pageCount": 0,
    "hasPreviousPage": true,
    "hasNextPage": true
  }
}
```

<a id="post-api-v1-roles"></a>
## Create a new role

`POST /api/v1/roles`

**Authentication:** Bearer token (JWT)

### Request body

Content type: `application/json` · Required · `CreateRoleDto`

| Name | Type | Description |
| --- | --- | --- |
| `name` (Required) | `string` | `maxLength`: `100` |
| `isActive` | `boolean` | Default: `true` |
| `sectionPermissions` (Required) | `array of SectionPermission` | `uniqueItems`: `true` |
| `sectionPermissions[].sectionId` (Required when parent is present) | `string` | `maxLength`: `255` |
| `sectionPermissions[].sectionName` | `string` | `maxLength`: `255` |
| `sectionPermissions[].readPermission` (Required when parent is present) | `boolean` |   |
| `sectionPermissions[].updatePermission` (Required when parent is present) | `boolean` |   |

### Responses

#### 201

Content type: `application/json` · `RoleResponse`

| Name | Type | Description |
| --- | --- | --- |
| `id` (Required) | `number` |   |
| `name` (Required) | `string` |   |
| `userCount` (Required) | `number` |   |
| `isActive` (Required) | `boolean` |   |
| `tenantId` (Required) | `number` |   |
| `sectionPermissions` (Required) | `array of SectionPermission` |   |
| `sectionPermissions[].sectionId` (Required when parent is present) | `string` | `maxLength`: `255` |
| `sectionPermissions[].sectionName` | `string` | `maxLength`: `255` |
| `sectionPermissions[].readPermission` (Required when parent is present) | `boolean` |   |
| `sectionPermissions[].updatePermission` (Required when parent is present) | `boolean` |   |
| `updatedAt` (Required) | `string (date-time)` |   |

#### 400

Content type: `application/json` · `ErrorResponse`

badRequest (incl. alreadyExists on `name`, unknownPermissionSection in errors\[\]), internalServerError (validation)

| Name | Type | Description |
| --- | --- | --- |
| `messageCode` (Required) | `string` | Allowed values: `"badRequest"`, `"internalServerError"` |
| `message` | `string` |   |
| `errors` (Required) | `array of FieldError` |   |
| `errors[].field` (Required when parent is present) | `string` |   |
| `errors[].fieldValue` (Required when parent is present) | `string` |   |
| `errors[].identifier` (Required when parent is present) | `string` |   |
| `errors[].identifierValue` (Required when parent is present) | `string` |   |
| `errors[].messageCode` (Required when parent is present) | `string` |   |
| `errors[].message` | `string` |   |
| `errors[].errorType` (Required when parent is present) | `string` |   |

**Example response**

`application/json`

```json
{
  "messageCode": "badRequest",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError, permissionSectionNotConfigured

| Name | Type | Description |
| --- | --- | --- |
| `messageCode` (Required) | `string` | Allowed values: `"internalServerError"`, `"permissionSectionNotConfigured"` |
| `message` | `string` |   |
| `errors` (Required) | `array of FieldError` |   |
| `errors[].field` (Required when parent is present) | `string` |   |
| `errors[].fieldValue` (Required when parent is present) | `string` |   |
| `errors[].identifier` (Required when parent is present) | `string` |   |
| `errors[].identifierValue` (Required when parent is present) | `string` |   |
| `errors[].messageCode` (Required when parent is present) | `string` |   |
| `errors[].message` | `string` |   |
| `errors[].errorType` (Required when parent is present) | `string` |   |

**Example response**

`application/json`

```json
{
  "messageCode": "internalServerError",
  "message": "string",
  "errors": [
    {}
  ]
}
```

### Example request

```bash
curl https://api.subrite.no/api/v1/roles \
  --request POST \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string",
  "isActive": true,
  "sectionPermissions": [
    {}
  ]
}'
```

### Example response

201 · `application/json`

```json
{
  "id": 0,
  "name": "string",
  "userCount": 0,
  "isActive": true,
  "tenantId": 0,
  "sectionPermissions": [
    {}
  ],
  "updatedAt": "2019-08-24T14:15:22Z"
}
```

<a id="get-api-v1-roles-sections"></a>
## Get all sections with permissions

`GET /api/v1/roles/sections`

**Authentication:** Bearer token (JWT)

### Responses

#### 200

Content type: `application/json` · `array of SectionPermission`

| Name | Type | Description |
| --- | --- | --- |
| `[].sectionId` (Required when parent is present) | `string` | `maxLength`: `255` |
| `[].sectionName` | `string` | `maxLength`: `255` |
| `[].readPermission` (Required when parent is present) | `boolean` |   |
| `[].updatePermission` (Required when parent is present) | `boolean` |   |

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

### Example request

```bash
curl https://api.subrite.no/api/v1/roles/sections \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
[
  {
    "sectionId": "string",
    "sectionName": "string",
    "readPermission": true,
    "updatePermission": true
  }
]
```

<a id="get-api-v1-roles-id"></a>
## Get a role by id with its section permissions

`GET /api/v1/roles/{id}`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |

### Responses

#### 200

Content type: `application/json` · `RoleResponse`

Same fields as [Create a new role (201)](https://www.subrite.no/developers/role-permission?md=true#post-api-v1-roles).

#### 400

Content type: `application/json` · `ErrorResponse`

badRequest

Same fields as [Get all roles of the tenant (400)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "badRequest",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 404

Content type: `application/json` · `ErrorResponse`

roleNotFound

| Name | Type | Description |
| --- | --- | --- |
| `messageCode` (Required) | `string` | Allowed values: `"roleNotFound"` |
| `message` | `string` |   |
| `errors` (Required) | `array of FieldError` |   |
| `errors[].field` (Required when parent is present) | `string` |   |
| `errors[].fieldValue` (Required when parent is present) | `string` |   |
| `errors[].identifier` (Required when parent is present) | `string` |   |
| `errors[].identifierValue` (Required when parent is present) | `string` |   |
| `errors[].messageCode` (Required when parent is present) | `string` |   |
| `errors[].message` | `string` |   |
| `errors[].errorType` (Required when parent is present) | `string` |   |

**Example response**

`application/json`

```json
{
  "messageCode": "roleNotFound",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

### Example request

```bash
curl 'https://api.subrite.no/api/v1/roles/{id}' \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
{
  "id": 0,
  "name": "string",
  "userCount": 0,
  "isActive": true,
  "tenantId": 0,
  "sectionPermissions": [
    {}
  ],
  "updatedAt": "2019-08-24T14:15:22Z"
}
```

<a id="delete-api-v1-roles-id"></a>
## Delete role

`DELETE /api/v1/roles/{id}`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |

### Responses

#### 200

#### 400

Content type: `application/json` · `ErrorResponse`

badRequest

Same fields as [Get all roles of the tenant (400)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "badRequest",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 404

Content type: `application/json` · `ErrorResponse`

roleNotFound

Same fields as [Get a role by id with its section permissions (404)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles-id).

**Example response**

`application/json`

```json
{
  "messageCode": "roleNotFound",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 409

Content type: `application/json` · `ErrorResponse`

roleIsAssignedToUsers

| Name | Type | Description |
| --- | --- | --- |
| `messageCode` (Required) | `string` | Allowed values: `"roleIsAssignedToUsers"` |
| `message` | `string` |   |
| `errors` (Required) | `array of FieldError` |   |
| `errors[].field` (Required when parent is present) | `string` |   |
| `errors[].fieldValue` (Required when parent is present) | `string` |   |
| `errors[].identifier` (Required when parent is present) | `string` |   |
| `errors[].identifierValue` (Required when parent is present) | `string` |   |
| `errors[].messageCode` (Required when parent is present) | `string` |   |
| `errors[].message` | `string` |   |
| `errors[].errorType` (Required when parent is present) | `string` |   |

**Example response**

`application/json`

```json
{
  "messageCode": "roleIsAssignedToUsers",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

### Example request

```bash
curl 'https://api.subrite.no/api/v1/roles/{id}' \
  --request DELETE \
  --header 'Authorization: Bearer <token>'
```

<a id="patch-api-v1-roles-id"></a>
## Update a role

`PATCH /api/v1/roles/{id}`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |

### Request body

Content type: `application/json` · Required · `UpdateRoleDto`

| Name | Type | Description |
| --- | --- | --- |
| `name` | `string` | `maxLength`: `100` |
| `isActive` | `boolean` | Default: `true` |
| `sectionPermissions` | `array of SectionPermission` | `uniqueItems`: `true` |
| `sectionPermissions[].sectionId` (Required when parent is present) | `string` | `maxLength`: `255` |
| `sectionPermissions[].sectionName` | `string` | `maxLength`: `255` |
| `sectionPermissions[].readPermission` (Required when parent is present) | `boolean` |   |
| `sectionPermissions[].updatePermission` (Required when parent is present) | `boolean` |   |

**Example request body**

`application/json`

```json
{
  "name": "string",
  "isActive": true
}
```

### Responses

#### 200

Content type: `application/json` · `RoleResponse`

Same fields as [Create a new role (201)](https://www.subrite.no/developers/role-permission?md=true#post-api-v1-roles).

#### 400

Content type: `application/json` · `ErrorResponse`

badRequest (incl. alreadyExists on `name`, unknownPermissionSection in errors\[\]), internalServerError (validation)

Same fields as [Create a new role (400)](https://www.subrite.no/developers/role-permission?md=true#post-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "badRequest",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get all roles of the tenant (403)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 404

Content type: `application/json` · `ErrorResponse`

roleNotFound

Same fields as [Get a role by id with its section permissions (404)](https://www.subrite.no/developers/role-permission?md=true#get-api-v1-roles-id).

**Example response**

`application/json`

```json
{
  "messageCode": "roleNotFound",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError, permissionSectionNotConfigured

Same fields as [Create a new role (500)](https://www.subrite.no/developers/role-permission?md=true#post-api-v1-roles).

**Example response**

`application/json`

```json
{
  "messageCode": "internalServerError",
  "message": "string",
  "errors": [
    {}
  ]
}
```

### Example request

```bash
curl 'https://api.subrite.no/api/v1/roles/{id}' \
  --request PATCH \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string",
  "isActive": true,
  "sectionPermissions": [
    {}
  ]
}'
```

### Example response

200 · `application/json`

```json
{
  "id": 0,
  "name": "string",
  "userCount": 0,
  "isActive": true,
  "tenantId": 0,
  "sectionPermissions": [
    {}
  ],
  "updatedAt": "2019-08-24T14:15:22Z"
}
```
