Ana içeriğe geç

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önderme
  • notifications.send.own - Sadece kendi bildirimlerini gönderme

Request

Headers

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

Request Body

ParametreTipZorunluAçıklama
user_idintegerEvetBildirim alıcısı kullanıcı ID'si
sender_idintegerHayırBildirim gönderen kullanıcı ID'si (varsayılan: mevcut kullanıcı)
typestringEvetBildirim tipi (info, warning, error, success)
titlestringEvetBildirim başlığı
messagestringEvetBildirim mesajı
action_urlstringHayırİşlem URL'si
metadataobjectHayırEk metadata bilgileri (JSON)
is_activebooleanHayırAktif 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_id belirtilmemişse otomatik olarak mevcut kullanıcı ID'si kullanılır
  • is_active değeri belirtilmemişse varsayılan olarak true kullanılır
  • Bildirim oluşturulduğunda is_read varsayılan olarak false olur