curl -X POST https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '[
{
"action": "read",
"resource": "employees"
},
{
"action": "write",
"resource": "employees",
"conditions": {"department": "engineering"}
},
{
"action": "read",
"resource": "departments"
}
]'
const response = await fetch(
'https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify([
{
action: 'read',
resource: 'employees'
},
{
action: 'write',
resource: 'employees',
conditions: { department: 'engineering' }
},
{
action: 'read',
resource: 'departments'
}
])
}
);
const data = await response.json();
import requests
url = "https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = [
{
"action": "read",
"resource": "employees"
},
{
"action": "write",
"resource": "employees",
"conditions": {"department": "engineering"}
},
{
"action": "read",
"resource": "departments"
}
]
response = requests.post(url, json=payload, headers=headers)
data = response.json()
{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"company_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Senior Developer",
"description": "Senior-level software development position",
"is_system_role": false,
"permissions_cache": [
"employees:read",
"employees:write",
"departments:read"
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T16:20:00Z"
}
}
{
"success": false,
"message": "invalid role_id"
}
{
"success": false,
"message": "unauthorized"
}
Roles & Permissions
Assign Permissions
Replace all permissions for a role
POST
/
roles
/
{role_id}
/
permissions
curl -X POST https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '[
{
"action": "read",
"resource": "employees"
},
{
"action": "write",
"resource": "employees",
"conditions": {"department": "engineering"}
},
{
"action": "read",
"resource": "departments"
}
]'
const response = await fetch(
'https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify([
{
action: 'read',
resource: 'employees'
},
{
action: 'write',
resource: 'employees',
conditions: { department: 'engineering' }
},
{
action: 'read',
resource: 'departments'
}
])
}
);
const data = await response.json();
import requests
url = "https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = [
{
"action": "read",
"resource": "employees"
},
{
"action": "write",
"resource": "employees",
"conditions": {"department": "engineering"}
},
{
"action": "read",
"resource": "departments"
}
]
response = requests.post(url, json=payload, headers=headers)
data = response.json()
{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"company_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Senior Developer",
"description": "Senior-level software development position",
"is_system_role": false,
"permissions_cache": [
"employees:read",
"employees:write",
"departments:read"
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T16:20:00Z"
}
}
{
"success": false,
"message": "invalid role_id"
}
{
"success": false,
"message": "unauthorized"
}
Replace all existing permissions for a role with a new set of permissions. This operation will remove any existing permissions and set only the provided ones. Requires Super Admin or HR Manager permissions.
This endpoint replaces ALL existing permissions. Any permissions not included in the request will be removed.
Path Parameters
string
required
The unique identifier of the role (UUID format)Example:
"550e8400-e29b-41d4-a716-446655440000"Request Body
The request body should be an array of permission objects.string
required
The action that can be performed (e.g., “read”, “write”, “delete”)Example:
"read"string
required
The resource the permission applies to (e.g., “employees”, “departments”)Example:
"employees"object
Optional conditions that must be met for the permission to applyExample:
{"department": "engineering"}Response
boolean
Indicates if the request was successful
object
The updated role object with new permissions
Show Role Object
Show Role Object
string
Unique identifier for the role
string
The company this role belongs to
string
Name of the role
string
Description of the role
boolean
Whether this is a system-defined role
string[]
Array of cached permission strings
string
ISO 8601 timestamp of when the role was created
string
ISO 8601 timestamp of when the role was last updated
curl -X POST https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '[
{
"action": "read",
"resource": "employees"
},
{
"action": "write",
"resource": "employees",
"conditions": {"department": "engineering"}
},
{
"action": "read",
"resource": "departments"
}
]'
const response = await fetch(
'https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify([
{
action: 'read',
resource: 'employees'
},
{
action: 'write',
resource: 'employees',
conditions: { department: 'engineering' }
},
{
action: 'read',
resource: 'departments'
}
])
}
);
const data = await response.json();
import requests
url = "https://api.companyflow.com/roles/550e8400-e29b-41d4-a716-446655440000/permissions"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = [
{
"action": "read",
"resource": "employees"
},
{
"action": "write",
"resource": "employees",
"conditions": {"department": "engineering"}
},
{
"action": "read",
"resource": "departments"
}
]
response = requests.post(url, json=payload, headers=headers)
data = response.json()
{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"company_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Senior Developer",
"description": "Senior-level software development position",
"is_system_role": false,
"permissions_cache": [
"employees:read",
"employees:write",
"departments:read"
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T16:20:00Z"
}
}
{
"success": false,
"message": "invalid role_id"
}
{
"success": false,
"message": "unauthorized"
}