Skip to content

Update a custom role

PATCH
/v1/tenants/me/roles/{slug}
curl --request PATCH \
--url https://api.emite.cr/v1/tenants/me/roles/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "name": "Office Manager", "description": "example", "scopes": [ "example" ] }'

Slug is IMMUTABLE — the column is referenced from tenant_users.role and renaming would orphan existing members. Recreate the role with a new slug and re-assign members if you need to rename.

slug
required
string

Custom role slug.

Media typeapplication/json
object
name

New name for the role, up to 80 characters. Omit it to keep the current one.

string
Example
Office Manager
description

New description, up to 400 characters. Omit it to keep the current one.

string
scopes

Replaces the whole scope list, under the same rules as at creation. The members who hold the role get the new permissions on their next request.

Array<string>

The role after the update.

Media typeapplication/json
object
id
required

Identifier of the role definition.

string format: uuid
slug
required

Stable identifier of the role: the value a member's role takes and the :slug of /v1/tenants/me/roles/:slug. It never changes.

string
name
required

The name people see for the role.

string
description
required

What the role is for; null when no description was given.

string
nullable
scopes
required

The permission scopes the role grants, from the catalog of GET /v1/permissions/roles.

Array<string>
createdAt
required

When the role was created.

string format: date-time
updatedAt
required

When the role was last changed.

string format: date-time
memberCount
required

How many active members hold the role now. While it is above 0 the role cannot be deleted (409 CUSTOM_ROLE_IN_USE).

number
Example
{
"slug": "office_manager",
"name": "Office Manager",
"description": "Manages day-to-day operations.",
"scopes": [
"invoices:read",
"invoices:export",
"reports:read",
"reports:export"
],
"memberCount": 2
}

Missing or invalid JWT.

Custom role management is JWT-only and requires roles:read / roles:manage.

CUSTOM_ROLE_NOT_FOUND.