Skip to main content

Kullanıcı Oluştur

Yeni kullanıcı oluşturur.

Endpoint

POST /api/v1/users

Authentication

Bu endpoint authentication gerektirir.

Header: Authorization: Bearer \{token\}

Permission

users.create - Kullanıcı oluşturma yetkisi gerekir.

Request

Headers

HeaderDeğerZorunlu
AuthorizationBearer \{token\}Evet
Content-Typeapplication/jsonEvet

Request Body

ParametreTipZorunluAçıklama
emailstringEvetE-posta adresi
passwordstringEvetŞifre (min: 8 karakter)
is_activebooleanHayırAktif durumu (varsayılan: true)
role_idsarrayHayırRol ID'leri

Example Request

{
"email": "member@example.com",
"password": "secret123",
"is_active": true,
"role_ids": [2, 3]
}

Response

Success Response (201 Created)

{
"id": 2,
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"email": "member@example.com",
"is_active": true,
"created_at": "2025-11-20T12:00:00.000000Z",
"updated_at": "2025-11-20T12:00:00.000000Z",
"detail": null,
"setting": {
"locale": "tr",
"timezone": "Europe/Istanbul"
},
"roles": [
{
"id": 2,
"name": "Admin",
"slug": "mgmt.admin"
}
]
}

Error Responses

422 Unprocessable Entity

{
"message": "The given data was invalid.",
"errors": {
"email": ["The email has already been taken."],
"password": ["The password must be at least 8 characters."]
}
}

Code Examples

cURL

curl -X POST https://api.example.com/api/v1/users \
-H "Authorization: Bearer \{token\}" \
-H "Content-Type: application/json" \
-d '{
"email": "member@example.com",
"password": "secret123",
"is_active": true
}'

Notes

  • Yeni kullanıcı oluşturulduğunda otomatik olarak UserDetail ve UserSetting kayıtları oluşturulur
  • Rol atanmazsa varsayılan olarak user rolü atanır
  • İlk kayıt olan kullanıcı otomatik olarak superadmin rolü alır