Ana içeriğe geç

Rapor Oluştur

Yeni rapor oluşturur.

Endpoint

POST /api/v1/reports

Authentication

Bu endpoint authentication gerektirir.

Header: Authorization: Bearer \{token\}

Permission

  • reports.generate - Tüm raporları oluşturma
  • reports.generate.own - Sadece kendi raporunu oluşturma

Request

Headers

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

Request Body

ParametreTipZorunluAçıklama
titlestringEvetRapor başlığı
report_typestringEvetRapor tipi
parametersobjectHayırRapor parametreleri (JSON)
formatstringHayırRapor formatı (pdf, excel, csv, json)
statusstringHayırRapor durumu (pending, processing, completed, failed)
is_activebooleanHayırAktif durumu (varsayılan: true)

Example Request

{
"title": "Kullanıcı Raporu",
"report_type": "users",
"parameters": {
"date_from": "2025-01-01",
"date_to": "2025-12-31",
"status": "active"
},
"format": "pdf",
"status": "pending"
}

Response

Success Response (201 Created)

{
"id": 1,
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"title": "Kullanıcı Raporu",
"report_type": "users",
"parameters": {
"date_from": "2025-01-01",
"date_to": "2025-12-31",
"status": "active"
},
"format": "pdf",
"status": "pending",
"is_active": true,
"user_id": 1,
"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": {
"title": ["The title field is required."],
"report_type": ["The report type field is required."]
}
}

Code Examples

cURL

curl -X POST https://api.example.com/api/v1/reports \
-H "Authorization: Bearer \{token\}" \
-H "Content-Type: application/json" \
-d '{
"title": "Kullanıcı Raporu",
"report_type": "users",
"parameters": {
"date_from": "2025-01-01",
"date_to": "2025-12-31"
},
"format": "pdf"
}'

Notes

  • .own permission'ı olan kullanıcılar için user_id otomatik olarak atanır
  • is_active değeri belirtilmemişse varsayılan olarak true kullanılır
  • status değeri belirtilmemişse varsayılan olarak "pending" kullanılır
  • Rapor oluşturulduktan sonra arka planda işlenir