Skip to main content

createRole

Requires permission settings:role:create.

Creates a role in your organization. Refused if the name belongs to a soft-deleted role; the error then carries the details so a client can offer to restore that role instead. Needs settings:role:create.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

mutation CreateRole($input: CreateRoleInput!) {
createRole(input: $input) {
id
name
displayName
createdAt
deletedAt
deletedBy
permissions {
id
name
createdAt
action
description
direct
}
}
}

Variables:

{
"input": {
"displayName": "string",
"name": "string"
}
}

Response:

{
"data": {
"createRole": {
"id": "id",
"name": "string",
"displayName": "string",
"createdAt": "2025-01-15T00:00:00Z",
"deletedAt": "2025-01-15T00:00:00Z",
"deletedBy": "string",
"permissions": [
{
"id": "id",
"name": "string",
"createdAt": "2025-01-15T00:00:00Z",
"action": "string",
"description": "string",
"direct": true
}
]
}
}
}
createRole(
input: CreateRoleInput!
): Role!

Arguments​

createRole.input ● CreateRoleInput! non-null input​

The new role's name and settings.

Type​

Role object​

A role: a named set of permissions that can be given to users.