Custom Roles API

Overview

The Custom Roles API enables organization administrators and owners to create, manage, and assign custom roles with fine-grained permissions. Custom roles are organization-specific and can be assigned to members alongside built-in roles (owner, admin, member, staff).

Base URL

Authentication

All endpoints require JWT authentication via the Authorization header:

Endpoints

Create Custom Role

POST /:orgId/roles Create a new custom role in the organization. Requires owner or admin role.

Request Body

Parameters

  • name (string, required): Unique role name within the organization
  • description (string, optional): Human-readable role description
  • permissions (array, required): Array of permission strings in resource:action format

Response

201 Created

Errors

  • 400 Bad Request: Validation failed or name already exists in organization
  • 403 Forbidden: User is not a member or lacks admin/owner role

Example


List Custom Roles

GET /:orgId/roles List all custom roles in the organization with pagination support. Requires organization membership.

Query Parameters

  • page (number, optional, default: 1): Page number for pagination
  • pageSize (number, optional, default: 20): Number of roles per page

Response

200 OK

Errors

  • 403 Forbidden: User is not a member of the organization

Example


Get Custom Role

GET /:orgId/roles/:roleId Retrieve a specific custom role by ID. Requires organization membership.

Response

200 OK

Errors

  • 403 Forbidden: User is not a member of the organization
  • 404 Not Found: Role not found or belongs to different organization

Example


Update Custom Role

PATCH /:orgId/roles/:roleId Update permissions or description of a custom role. Requires owner or admin role. Built-in roles cannot be modified.

Request Body

Parameters

  • name (string, optional): New role name
  • description (string, optional): New description (can be set to null)
  • permissions (array, optional): Updated permissions array

Response

200 OK

Errors

  • 400 Bad Request: Validation failed
  • 403 Forbidden: User lacks admin/owner role or role is built-in
  • 404 Not Found: Role not found

Example


Delete Custom Role

DELETE /:orgId/roles/:roleId Delete a custom role. Requires owner or admin role. Built-in roles cannot be deleted. Role must not be assigned to any members.

Response

204 No Content

Errors

  • 400 Bad Request: Role is assigned to members
  • 403 Forbidden: User lacks admin/owner role or role is built-in
  • 404 Not Found: Role not found

Example


Permission Format

Permissions follow the resource:action format:

Supported Resources & Actions

Custom resources and actions can be defined per organization needs.

Member Role Assignment

Custom roles are assigned to members via the organization member API: PATCH /api/v1/organizations/:orgId/members/:memberId
See Organizations API Documentation for full member management details.

Built-in Roles

The following roles are built-in and cannot be modified or deleted:
  • owner: Full organization access (automatically assigned on creation)
  • admin: Organization administration (invite, remove members, manage roles)
  • member: Basic member access (view organization, list members)
  • staff: Limited staff access (organization-specific)

Error Responses

400 Bad Request

403 Forbidden

404 Not Found


Access Control

  • List/View Roles: Any organization member
  • Create/Update/Delete Roles: Owner or Admin only
  • Assign Roles: Owner or Admin only (via member API)

Rate Limiting

All endpoints are subject to rate limiting. See Rate Limiting Documentation for details.

Webhooks (Future)

Role changes will trigger webhooks in a future release:
  • role.created
  • role.updated
  • role.deleted

Examples

Create an Editor Role

List All Roles

Assign Role to Member

Grant Additional Permissions


See Also