Create Role
Create a new role within a project and assign permission IDs to it.
Endpoint
/api/v1/projects/{project_id}/rolesMethod
POST
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | Yes | Unique ID of the project |
Headers
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | application/json |
Authorization | Yes | Bearer access token: Bearer <access_token> |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Role code (alphanumeric, dash, underscore, max 50 chars) |
name | string | Yes | Role name (max 50 chars) |
description | string | No | Description (max 200 chars) |
permission_ids | array of strings | No | List of permission IDs to assign to role |
Required Permission
roles:create
Examples
curl --request POST \
--url https://auth.roled.id/api/v1/projects/2JUSLUee46xG6iEwG8JwPc/roles \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJo...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Store Manager",
"code": "store-manager",
"description": "Manages store operations including products, orders, and staff",
"permission_ids": [
"2JUUyotLUqz5eqsuYXXDet",
"2JUUyotLUr7SuBqkzjRbTc",
"2JUUyotLUrApxL7zcx7Xoy",
"2JUUyotLUrDfBK9iwe25jj",
"2JRjbZKS7f4oRkDaAD4gAF",
"2JRjbZKS7fJAfNjgShH3TE",
"2JRjbZKS7h72qSpPAJBuSj"
]
}'Error Codes
| Code | HTTP Status | Description |
|---|---|---|
invalid_params | 400 | Missing or invalid request params, headers, or body |
invalid_authorization_token | 401 | Missing or invalid authorization token |
insufficient_permission | 403 | Insufficient permission |
project_not_found | 404 | Project not found |
some_permissions_not_found | 404 | One or more specified permission IDs not found |
role_code_already_used | 409 | Role with the same code already exists |
system_error | 500 | Internal server error |