Skip to content

Create a custom role

POST
/v1/tenants/me/roles
curl --request POST \
--url https://api.emite.cr/v1/tenants/me/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "slug": "office_manager", "name": "Office Manager", "description": "Manages day-to-day operations.", "scopes": [ "invoices:read", "invoices:export", "reports:read", "reports:export" ] }'

Slug must be unique within the tenant and cannot collide with a system role (owner, admin, billing_manager, accountant, issuer, viewer). Scopes are validated against the canonical Scope enum; the wildcard *, tenant:transfer_ownership, tenant:delete and legal:accept are rejected — those are reserved to the owner (and, for legal:accept, the admins).

Media typeapplication/json
object
slug
required

Stable identifier of the role: the value a member's role takes and the :slug of /tenants/me/roles/:slug; it cannot be changed later. 3–64 lowercase letters, digits and underscores, starting with a letter and ending with a letter or digit. The name of a system role (owner, admin, billing_manager, accountant, issuer, viewer) answers 409 CUSTOM_ROLE_SLUG_RESERVED, a slug already taken 409 CUSTOM_ROLE_SLUG_EXISTS.

string
Example
office_manager
name
required

The name people see for the role, in the app and in invitation emails.

string
<= 80 characters
Example
Office Manager
description

What the role is for, up to 400 characters.

string
Example
Manages day-to-day operations.
scopes
required

The permissions the role grants: scopes of the catalog (GET /v1/permissions/roles), at least one and at most 50, without repeats. 400 CUSTOM_ROLE_SCOPES_EMPTY for an empty list and CUSTOM_ROLE_SCOPE_UNKNOWN for a scope that does not exist. *, tenant:transfer_ownership, tenant:delete and legal:accept can never be part of a custom role (400 CUSTOM_ROLE_SCOPE_FORBIDDEN).

Array<string>
Example
[
"invoices:read",
"invoices:export",
"reports:read",
"reports:export"
]

The new role (memberCount 0).

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.

Duplicate slug (CUSTOM_ROLE_SLUG_EXISTS) or reserved (CUSTOM_ROLE_SLUG_RESERVED).