Overview
The Roles API allows you to manage user roles in the Blog Marketing Platform. The system includes 6 predefined roles with different permission levels, and you can create custom roles to fit your organization’s needs.Available Roles
The platform includes the following predefined roles:Creador
Complete system access with all permissions
Administrador
System management and configuration capabilities
Editor
Content editing and moderation permissions
Escritor
Content creation and drafting capabilities
Autor
Post publishing and authoring permissions
Comentador
Basic commenting and interaction permissions
Get All Roles
Function Reference:
getAllRoles() - rbacService.ts:31Request
Response
Returns an array of role objects.Array of role objects
Example
Create Role
Function Reference:
createRol(data) - rbacService.ts:55Request
Parameters
Name of the role. Should be descriptive and unique.
Optional description explaining the role’s purpose and permissions.
Response
Returns the created role object ornull if creation fails.
The newly created role object with all fields populated
Example
Delete Role
Function Reference:
deleteRol(id) - rbacService.ts:83Request
Parameters
The unique identifier of the role to delete
Response
Returns a boolean indicating success or failure.true if the role was successfully deleted, false otherwiseExample
Delete Multiple Roles
Function Reference:
deleteRoles(ids) - rbacService.ts:98Request
Parameters
Array of role IDs to delete. Each ID must correspond to an existing role.
Response
Returns a boolean indicating whether all deletions succeeded.true if all roles were successfully deleted, false if any deletion failedExample
Type Definitions
Rol Interface
RolConPermisos Interface
Role Types
Thetypes.ts file defines the following role type:
Best Practices
Role Naming Conventions
Role Naming Conventions
- Use descriptive names that clearly indicate the role’s purpose
- Follow consistent naming patterns (e.g., Spanish or English, not mixed)
- Avoid special characters in role names
- Keep names concise but meaningful
Permission Management
Permission Management
- Always verify role assignments before deletion
- Use the RolConPermisos interface when working with roles and their permissions together
- Document custom roles and their intended permissions
- Regularly audit role assignments for security compliance
Error Handling
Error Handling
- Always check for null returns from create operations
- Verify boolean success responses before proceeding with dependent operations
- Implement proper error logging for failed role operations
- Handle edge cases like duplicate role names gracefully
Related Resources
Permissions API
Manage permissions and assign them to roles
User Management
Assign roles to users and manage user permissions