Create a custom role
const url = 'https://api.emite.cr/v1/tenants/me/roles';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"slug":"office_manager","name":"Office Manager","description":"Manages day-to-day operations.","scopes":["invoices:read","invoices:export","reports:read","reports:export"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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).
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
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.
Example
office_managerThe name people see for the role, in the app and in invitation emails.
Example
Office ManagerWhat the role is for, up to 400 characters.
Example
Manages day-to-day operations.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).
Example
[ "invoices:read", "invoices:export", "reports:read", "reports:export"]Responses
Section titled “Responses”The new role (memberCount 0).
object
Identifier of the role definition.
Stable identifier of the role: the value a member's role takes and the :slug of /v1/tenants/me/roles/:slug. It never changes.
The name people see for the role.
What the role is for; null when no description was given.
The permission scopes the role grants, from the catalog of GET /v1/permissions/roles.
When the role was created.
When the role was last changed.
How many active members hold the role now. While it is above 0 the role cannot be deleted (409 CUSTOM_ROLE_IN_USE).
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).