External API - Detaylı Dokümantasyon

Bu sayfa, /api/external altındaki endpointlerin detaylı Türkçe dokümantasyonunu içerir.

Firma (Company) İşlemleri

GET /api/external/companies — Firma listesi

Açıklama: Mevcut firmaları listeler. API key'in erişimine göre sonuçlar filtrelenir.

Query Parametreleri

Response (başarılı)

{
  "success": true,
  "data": [
    {
      "id": "uuid",
      "company_name": "Firma A",
      "contact_person_name": "Kişi",
      "contact_person_email": "[email protected]",
      "contact_person_phone": "+90...",
      "company_city": "İstanbul",
      "is_active": true,
      "created_at": "2025-08-26T12:34:56.000000Z"
    }
  ],
  "pagination": { "total_count": 1, "limit": 50, "offset": 0, "has_more": false }
}

POST /api/external/companies — Firma oluştur

Açıklama: Yeni firma oluşturur. (Detaylı kurallar aşağıdadır)

Header

Request Body (JSON)

Başarılı Response (201)

{
  "success": true,
  "message": "Company created successfully",
  "data": {
    "id": "31d26468-b80d-49a9-b241-b954a4e451f9",
    "company_name": "ACME Test Sanayi A.Ş.",
    "contact_person_name": "Ayşe Yılmaz",
    "contact_person_email": "[email protected]",
    "contact_person_phone": "+905551234567",
    "contact_person_title": "Satınalma Müdürü",
    "company_address": "Organize Sanayi...",
    "company_city": "İstanbul",
    "is_active": true,
    "created_at": "2025-08-26T12:34:56.000000Z"
  }
}

Hata Durumları

422 Validation failed — Zorunlu alanlar / format hataları.

409 Email already exists — Aynı contact_person_email daha önce kaydedilmiş.

500 Internal server error — Beklenmeyen hata.


Proje (Project) İşlemleri

GET /api/external/projects — Proje listesi

Query parametreleri: status, user_email, company_id (uuid), date_from, date_to, limit, offset.

Response (başarılı örnek)

{
  "success": true,
  "data": [
    {
      "id": "project-uuid",
      "project_number": "API-2025-0001",
      "name": "CE Marking Project",
      "status": "draft",
      "product_name": "Smart Controller",
      "target_countries": ["Almanya", "Fransa"],
      "excluded_countries": ["Çin"],
      "capacity_report_url": "https://example.com/report.pdf",
      "official_website_url": "https://company.com",
      "average_cost": 1500.50,
      "unit_cost": 125.75,
      "start_date": "2025-08-01",
      "end_date": "2025-09-01",
      "created_at": "2025-08-01T10:00:00.000000Z",
      "company": { "id": "company-uuid", "company_name": "ACME" }
    }
  ],
  "pagination": { "total_count": 1, "limit": 50, "offset": 0, "has_more": false }
}

GET /api/external/projects/{projectId} — Proje detayları

Path param: projectId (uuid)

Response (başarılı)

{
  "success": true,
  "data": {
    "id": "project-uuid",
    "project_number": "API-2025-0001",
    "name": "CE Marking Project",
    "description": "Ürün CE işaretleme süreci...",
    "status": "completed",
    "product_name": "Smart Controller",
    "product_details": "Akıllı kontrol cihazı teknik detayları...",
    "gtip_hs_code": "8537.10.00",
    "target_countries": ["Almanya", "Fransa", "İtalya"],
    "excluded_countries": ["Çin", "Rusya"],
    "product_certificates": "CE, ISO 9001, RoHS belgelerine sahip",
    "capacity_report_url": "https://example.com/capacity-report.pdf",
    "official_website_url": "https://company-website.com",
    "average_cost": 1500.50,
    "unit_cost": 125.75,
    "currency": "USD",
    "priority": "medium",
    "start_date": "2025-08-01",
    "end_date": "2025-09-01",
    "created_at": "2025-08-01T10:00:00.000000Z",
    "updated_at": "2025-08-15T14:30:00.000000Z",
    "files": [
      { "id": "file-uuid", "original_name": "certificate.pdf", "download_url": "/api/external/projects/project-uuid/files/file-uuid/download" }
    ],
    "metadata": {}
  }
}

POST /api/external/projects — Proje oluştur

Request Body (validation)

Başarılı Response (201)

{
  "success": true,
  "data": {
    "id": "project-uuid",
    "project_number": "API-2025-0001",
    "name": "CE Marking Project",
    "company_id": "company-uuid",
    "company_name": "ACME",
    "status": "draft",
    "priority": "medium",
    "currency": "USD",
    "product_name": "Smart Controller",
    "target_countries": ["Almanya", "Fransa", "İtalya"],
    "excluded_countries": ["Çin", "Rusya"],
    "product_certificates": "CE, ISO 9001, RoHS",
    "capacity_report_url": "https://example.com/capacity-report.pdf",
    "official_website_url": "https://company-website.com",
    "average_cost": 1500.50,
    "unit_cost": 125.75,
    "created_at": "2025-08-26T12:34:56.000000Z"
  }
}

PUT /api/external/projects/{projectId}/status — Proje durumu güncelle

Request Body

Başarılı Response

{ "success": true, "message": "Project status updated successfully", "data": { "project_id": "project-uuid", "old_status": "draft", "new_status": "completed" } }

POST /api/external/projects/{projectId}/approve — Proje onayla

Body: approved (boolean), approval_notes (nullable string), revision_requests (nullable array)

Başarılı Response

{ "success": true, "message": "Project approved successfully", "data": { "project_id": "project-uuid", "status": "approved" } }

GET /api/external/projects/{projectId}/files — Proje dosyalarını listele

Query: file_type (document,image,certificate,report,other), include_metadata (boolean)

Response

{
  "success": true,
  "data": {
    "project": { "id": "project-uuid", "project_number": "API-2025-0001" },
    "files": [ { "id": "file-uuid", "filename": "certificate.pdf", "download_url": "/api/external/projects/project-uuid/files/file-uuid/download" } ],
    "total_files": 1
  }
}

POST /api/external/projects/{projectId}/files — Projeye dosya yükle

Request (multipart/form-data)

Başarılı Response

{ "success": true, "message": "File uploaded successfully", "data": { "file_id": "file-uuid", "original_name": "certificate.pdf", "file_type": "certificate", "file_size": 2048576, "uploaded_at": "2025-08-26T12:34:56.000000Z" } }

GET /api/external/projects/{projectId}/files/{fileId}/download — Proje dosyası indir

Response: Dosya stream olarak döner. Eğer dosya bulunamazsa 404 döner.


Abonelik (Subscription) İşlemleri

GET /api/external/subscriptions — Abonelik detayları

Query: user_id (uuid) veya email (email). Döner: kullanıcının abonelikleri, paket ve ürün kullanımları.

Response (örnek)

{
  "success": true,
  "data": [
    {
      "subscription_id": "sub-uuid",
      "status": "active",
      "package": { "id": "pkg-uuid", "name": "Pro Paket" },
      "products": [ { "id": "prod-uuid", "name": "CE Sertifika" } ]
    }
  ]
}

Destek Talepleri (Support Tickets)

GET /api/external/support/tickets — Destek taleplerini listele

Query parametreleri: status, user_id, limit, offset.

POST /api/external/support/tickets — Destek talebi oluştur

Request Body

Başarılı Response

{ "success": true, "data": { "ticket_id": "ticket-uuid", "ticket_number": "TCK-2025-0001" } }

PUT /api/external/support/tickets/{ticketId}/status — Destek talebi durumu güncelle

Body: status (required), örn: open, in_progress, resolved, closed


Notlar: