Create Resource
Create a new resource domain and define its permissions in a single request.
Endpoint
/api/v1/projects/{project_id}/resourcesMethod
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 |
|---|---|---|---|
name | string | Yes | Resource name (max 50 chars) |
code | string | Yes | Resource code identifier (alphanumeric, dash, underscore, max 50 chars) |
description | string | No | Description (max 200 chars) |
permissions | array of objects | No | List of permissions (name, code, description) |
Required Permission
resources:create
Examples
curl --request POST \
--url https://auth.roled.id/api/v1/projects/2JUSLUee46xG6iEwG8JwPc/resources \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJo...' \
--header 'Content-Type: application/json' \
--data '{
"name": "Products",
"code": "products",
"description": "Product catalog",
"permissions": [
{
"name": "Create",
"code": "create",
"description": "Create a new product"
},
{
"name": "Read",
"code": "read",
"description": "List and view products"
},
{
"name": "Update",
"code": "update",
"description": "Edit an existing product"
},
{
"name": "Delete",
"code": "delete",
"description": "Remove a product"
}
]
}'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 |
resource_code_already_used | 409 | Resource with the same code already exists |
system_error | 500 | Internal server error |