Rol Oluştur
Yeni rol oluşturur.
Endpoint
POST /api/v1/roles
Authentication
Bu endpoint authentication gerektirir.
Header: Authorization: Bearer \{token\}
Permission
admin.manage- Admin yönetim işlemleriroles.create- Rol oluşturma
Request
Headers
| Header | Değer | Zorunlu |
|---|---|---|
Authorization | Bearer \{token\} | Evet |
Content-Type | application/json | Evet |
Request Body
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
name | string | Evet | Rol adı (max: 191) |
slug | string | Evet | Rol slug'ı (unique, max: 191) |
priority | integer | Hayır | Rol önceliği (1-1000, varsayılan: 50) |
is_active | boolean | Hayır | Aktif durumu (varsayılan: true) |
secret | string | Hayır | Sistem rolleri için gizli anahtar |
Example Request
{
"name": "Editor",
"slug": "mgmt.editor",
"priority": 40,
"is_active": true
}
Response
Success Response (201 Created)
{
"id": 5,
"name": "Editor",
"slug": "mgmt.editor",
"priority": 40,
"is_active": true,
"created_at": "2025-11-20T12:00:00.000000Z",
"updated_at": "2025-11-20T12:00:00.000000Z"
}
Error Responses
403 Forbidden
{
"message": "Rol oluşturma yetkiniz yok"
}
403 Forbidden (Hiyerarşi Kontrolü)
{
"message": "You cannot create a role with priority equal to or higher than your own role level",
"your_priority": 20,
"requested_priority": 10
}
403 Forbidden (Sistem Rolleri)
{
"message": "Forbidden role slug"
}
Code Examples
cURL
curl -X POST https://api.example.com/api/v1/roles \
-H "Authorization: Bearer \{token\}" \
-H "Content-Type: application/json" \
-d '{
"name": "Editor",
"slug": "mgmt.editor",
"priority": 40,
"is_active": true
}'
Notes
- Kullanıcı sadece kendi seviyesinden düşük seviyeli rolleri oluşturabilir
- Sistem rolleri (
system.toor,server.root) içinX-Role-Secretheader'ı veyasecretparametresi gereklidir prioritydeğeri belirtilmemişse varsayılan olarak 50 kullanılır
Related Endpoints
- Rol Listesi - Tüm rolleri listele
- Rol Detayı - Rol detayını getir