Skip to main content

Overview

The Permissions API allows platform administrators to:
  • Create and manage global permissions
  • List and search permissions
  • Update permission details
  • Delete unused permissions
Permissions define what actions users can perform globally across the platform. These are different from company-scoped roles and permissions.

Authentication

All endpoints require:
  1. Authentication using a Bearer token in the Authorization header
  2. Platform admin privileges

Create Permission

curl -X POST https://api.example.com/api/permissions \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "COMPANY:CREATE",
    "description": "Allows creating new companies",
    "scope": "GLOBAL"
  }'
Creates a new global permission.

Endpoint

POST /api/permissions

Request Body

key
string
required
Permission key in format RESOURCE:ACTION (e.g., COMPANY:CREATE, USER:DELETE). Must be uppercase with underscores. Max 120 characters.
description
string
Human-readable description of what this permission allows (max 255 characters)
scope
string
default:"COMPANY"
Permission scope. Options: GLOBAL or COMPANY. Defaults to COMPANY.

Response

success
boolean
required
Indicates if the request was successful
data
object
required
The created permission object

Response Example

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "key": "COMPANY:CREATE",
    "description": "Allows creating new companies",
    "scope": "GLOBAL",
    "_count": {
      "roles": 0,
      "userGlobalPermissions": 0
    }
  }
}

Error Responses

400 Bad Request
Invalid permission key format
{
  "success": false,
  "error": "Key must follow format RESOURCE:ACTION (e.g., COMPANY:CREATE)"
}
409 Conflict
Permission key already exists
{
  "success": false,
  "error": "Permission key already exists"
}

List Permissions

curl -X GET "https://api.example.com/api/permissions?page=1&limit=50&scope=GLOBAL" \
  -H "Authorization: Bearer YOUR_TOKEN"
Retrieves a paginated list of permissions with optional filtering.

Endpoint

GET /api/permissions

Query Parameters

page
number
default:"1"
Page number for pagination (min: 1)
limit
number
default:"50"
Number of items per page (min: 1, max: 100)
Search term to filter by key or description (case-insensitive)
scope
string
Filter by scope: GLOBAL or COMPANY

Response

success
boolean
required
Indicates if the request was successful
data
array
required
Array of permission objects
pagination
object
required
Pagination metadata

Response Example

{
  "success": true,
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "key": "COMPANY:CREATE",
      "description": "Allows creating new companies",
      "scope": "GLOBAL",
      "_count": {
        "roles": 2,
        "userGlobalPermissions": 5
      }
    },
    {
      "id": "660e8400-e29b-41d4-a716-446655440001",
      "key": "USER:DELETE",
      "description": "Allows deleting user accounts",
      "scope": "GLOBAL",
      "_count": {
        "roles": 1,
        "userGlobalPermissions": 2
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 2,
    "totalPages": 1
  }
}

Get All Permissions

curl -X GET https://api.example.com/api/permissions/all \
  -H "Authorization: Bearer YOUR_TOKEN"
Retrieves all permissions without pagination. Useful for dropdowns and select components.

Endpoint

GET /api/permissions/all

Response

success
boolean
required
Indicates if the request was successful
data
array
required
Array of all permission objects (simplified, without count data)

Response Example

{
  "success": true,
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "key": "COMPANY:CREATE",
      "description": "Allows creating new companies",
      "scope": "GLOBAL"
    },
    {
      "id": "660e8400-e29b-41d4-a716-446655440001",
      "key": "USER:DELETE",
      "description": "Allows deleting user accounts",
      "scope": "GLOBAL"
    }
  ]
}

Get Permission by ID

curl -X GET https://api.example.com/api/permissions/{id} \
  -H "Authorization: Bearer YOUR_TOKEN"
Retrieves a specific permission by its ID.

Endpoint

GET /api/permissions/{id}

Path Parameters

id
string
required
The unique identifier of the permission

Response

success
boolean
required
Indicates if the request was successful
data
object
required
The permission object

Response Example

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "key": "COMPANY:CREATE",
    "description": "Allows creating new companies",
    "scope": "GLOBAL",
    "_count": {
      "roles": 2,
      "userGlobalPermissions": 5
    }
  }
}

Error Responses

404 Not Found
Permission not found
{
  "success": false,
  "error": "Permission not found"
}

Update Permission

curl -X PATCH https://api.example.com/api/permissions/{id} \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Updated description for this permission"
  }'
Updates a permission’s details. All fields are optional.

Endpoint

PATCH /api/permissions/{id}

Path Parameters

id
string
required
The unique identifier of the permission to update

Request Body

key
string
New permission key (must follow RESOURCE:ACTION format)
description
string
New description (max 255 characters)
scope
string
New scope: GLOBAL or COMPANY

Response

success
boolean
required
Indicates if the request was successful
data
object
required
The updated permission object

Response Example

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "key": "COMPANY:CREATE",
    "description": "Updated description for this permission",
    "scope": "GLOBAL",
    "_count": {
      "roles": 2,
      "userGlobalPermissions": 5
    }
  }
}

Error Responses

404 Not Found
Permission not found
409 Conflict
New permission key already exists
{
  "success": false,
  "error": "Permission key already exists"
}

Delete Permission

curl -X DELETE https://api.example.com/api/permissions/{id} \
  -H "Authorization: Bearer YOUR_TOKEN"
Deletes a permission. Only permissions that are not assigned to any role or user can be deleted.

Endpoint

DELETE /api/permissions/{id}

Path Parameters

id
string
required
The unique identifier of the permission to delete

Response

success
boolean
required
Indicates if the request was successful
message
string
required
Success message

Response Example

{
  "success": true,
  "message": "Permission deleted successfully"
}

Error Responses

400 Bad Request
Permission is currently in use and cannot be deleted
{
  "success": false,
  "error": "Cannot delete permission. It is assigned to 2 roles and 5 users."
}
404 Not Found
Permission not found
{
  "success": false,
  "error": "Permission not found"
}

Permission Scopes

Permissions can have two scopes:

GLOBAL

Global permissions apply across the entire platform and are not tied to any specific company. Examples:
  • COMPANY:CREATE - Create new companies
  • USER:DELETE - Delete user accounts
  • PLATFORM:ADMIN - Full platform administration

COMPANY

Company-scoped permissions are managed within individual companies and assigned through roles. Examples:
  • MEMBER:INVITE - Invite members to a company
  • PROJECT:CREATE - Create projects within a company
  • TIMESHEET:APPROVE - Approve timesheets
Global permissions can be requested by users through the Permission Requests API and must be approved by platform administrators.

Build docs developers (and LLMs) love