Bildirim Oluştur
Yeni bildirim gönderir.
Endpoint
POST /api/v1/notifications
Authentication
Bu endpoint authentication gerektirir.
Header: Authorization: Bearer \{token\}
Permission
notifications.send- Tüm bildirimleri göndermenotifications.send.own- Sadece kendi bildirimlerini gönderme
Request
Headers
| Header | Değer | Zorunlu |
|---|---|---|
Authorization | Bearer \{token\} | Evet |
Content-Type | application/json | Evet |
Request Body
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
user_id | integer | Evet | Bildirim alıcısı kullanıcı ID'si |
sender_id | integer | Hayır | Bildirim gönderen kullanıcı ID'si (varsayılan: mevcut kullanıcı) |
type | string | Evet | Bildirim tipi (info, warning, error, success) |
title | string | Evet | Bildirim başlığı |
message | string | Evet | Bildirim mesajı |
action_url | string | Hayır | İşlem URL'si |
metadata | object | Hayır | Ek metadata bilgileri (JSON) |
is_active | boolean | Hayır | Aktif durumu (varsayılan: true) |
Example Request
{
"user_id": 1,
"type": "info",
"title": "Yeni Mesaj",
"message": "Size yeni bir mesaj geldi",
"action_url": "/messages/123",
"metadata": {
"priority": "high"
}
}
Response
Success Response (201 Created)
{
"id": 1,
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"user_id": 1,
"sender_id": 2,
"type": "info",
"title": "Yeni Mesaj",
"message": "Size yeni bir mesaj geldi",
"action_url": "/messages/123",
"is_read": false,
"read_at": null,
"is_active": true,
"user": {
"id": 1,
"email": "user@example.com"
},
"sender": {
"id": 2,
"email": "sender@example.com"
},
"created_at": "2025-11-20T12:00:00.000000Z",
"updated_at": "2025-11-20T12:00:00.000000Z"
}
Error Responses
403 Forbidden
{
"message": "Forbidden"
}
422 Unprocessable Entity
{
"message": "Validation failed",
"errors": {
"user_id": ["The user id field is required."],
"type": ["The type field is required."],
"title": ["The title field is required."],
"message": ["The message field is required."]
}
}
Code Examples
cURL
curl -X POST https://api.example.com/api/v1/notifications \
-H "Authorization: Bearer \{token\}" \
-H "Content-Type: application/json" \
-d '{
"user_id": 1,
"type": "info",
"title": "Yeni Mesaj",
"message": "Size yeni bir mesaj geldi",
"action_url": "/messages/123"
}'
Notes
sender_idbelirtilmemişse otomatik olarak mevcut kullanıcı ID'si kullanılıris_activedeğeri belirtilmemişse varsayılan olaraktruekullanılır- Bildirim oluşturulduğunda
is_readvarsayılan olarakfalseolur
Related Endpoints
- Bildirim Listesi - Tüm bildirimleri listele
- Bildirim Detayı - Bildirim detayını getir