---
title: "Create role"
method: POST
path: "/api/roles"
tags: ["Roles"]
---

# Create role

`POST /api/roles`

Creates a new role with the specified permissions and project assignments.

## Request body

- object
  - `name` string, required — Name of the role
  - `description` string — Description of the role
  - `idpGroups` string[], nullable — Identity provider groups to map to this role
  - `projectPermissions` string[] — List of project-level permissions to grant
  - `projectFilePermissions` object[], nullable — File-level permissions to grant
    - `id` string, nullable
    - `effect` 'allow' | 'deny', required
    - `actions` string[], nullable
    - `patterns` string, nullable
  - `allProjects` boolean, required — Whether this role should apply to all projects
  - `users` string[] — List of user IDs to assign to this role
  - `projects` string[] — List of project IDs this role applies to (ignored if allProjects is true)

## Response `200`

The created role

- object — The created role
  - `id` string, uuid, required — Unique identifier of the role
  - `name` string, required — Name of the role
  - `description` string, nullable — Description of the role
  - `idpGroups` string[], nullable — Identity provider groups mapped to this role
  - `allProjects` boolean, required — Whether this role applies to all projects
  - `projectPermissions` string[], nullable — List of project-level permissions granted by this role
  - `projectFilePermissions` object[], nullable — File-level permissions granted by this role
    - `id` string, nullable — Unique identifier of the file permission
    - `effect` 'allow' | 'deny', required — Permission effect (allow or deny)
    - `actions` string[], nullable — List of actions this permission applies to
    - `patterns` string, nullable — File path patterns this permission applies to
  - `groups` object[] — Groups associated with this role
    - `id` string, uuid, required — Unique identifier of the group
    - `name` string, required — Name of the group
    - `description` string, nullable — Description of the group
    - `projectId` string, uuid, required — ID of the project this group belongs to
    - `project` object — Project this group belongs to
      - `name` string — Name of the project
    - `roleId` string, uuid, nullable — ID of the role this group is associated with
  - `users` object[] — Users assigned to this role
    - `id` string, uuid, required — Unique identifier of the user
    - `email` string, email, required — Email address of the user
    - `firstName` string, nullable — First name of the user
    - `lastName` string, nullable — Last name of the user
  - `organisationId` string, uuid, required — ID of the organisation this role belongs to
  - `organisation` object — Organisation this role belongs to
    - `id` string, uuid, required — Unique identifier of the organisation
    - `name` string, required — Name of the organisation
  - `createdAt` string, required — Timestamp when the role was created
  - `updatedAt` string, required — Timestamp when the role was last updated

---

[API](https://skmtc.dev/gorules/apis/gorules-agent-api.md) · [All operations](https://skmtc.dev/gorules/apis/gorules-agent-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/gorules/gorules-agent-api/revisions/52c0773fcd80/schema)
