{
  "openapi": "3.0.1",
  "info": {
    "title": "Hepiyiol Tedarikçi Entegrasyon API",
    "description": "Tedarikçi firmalar için ilan, sipariş, e-Fatura/e-Arşiv yükleme, iade/iptal talepleri, kargo ve olay (webhook) API'si. Kimlik doğrulama: X-Api-Key başlığı.",
    "version": "v1"
  },
  "paths": {
    "/api/integration/v1/ping": {
      "get": {
        "tags": [
          "PartnerAccount"
        ],
        "summary": "Bağlantı ve kimlik doğrulama testi.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/webhook": {
      "get": {
        "tags": [
          "PartnerAccount"
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "PartnerAccount"
        ],
        "summary": "Webhook adresini günceller. Adres https olmalı ve iç ağ adresi olmamalıdır.",
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerWebhookRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerWebhookRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerWebhookRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerWebhookRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/webhook/rotate-secret": {
      "post": {
        "tags": [
          "PartnerAccount"
        ],
        "summary": "Webhook imzalama anahtarını yeniler. Yeni anahtar yalnızca bu yanıtta döner.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/webhook/test": {
      "post": {
        "tags": [
          "PartnerAccount"
        ],
        "summary": "Kayıtlı webhook adresine imzalı bir \"webhook.test\" olayı gönderir.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/events": {
      "get": {
        "tags": [
          "PartnerAccount"
        ],
        "summary": "Olay akışı (webhook'a alternatif / yedek). after son işlenen sequence değeridir;\r\nyanıttaki nextCursor bir sonraki çağrıda kullanılır.",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int64",
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/products": {
      "get": {
        "tags": [
          "PartnerListings"
        ],
        "summary": "Platform ürün kataloğunda barkod veya isimle arama.",
        "parameters": [
          {
            "name": "barcode",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/listings": {
      "get": {
        "tags": [
          "PartnerListings"
        ],
        "summary": "Firmaya ait ilanlar (stok, fiyat, miad).",
        "parameters": [
          {
            "name": "barcode",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "PartnerListings"
        ],
        "summary": "İlan ekle/güncelle (toplu, en fazla 1000 kayıt). Barkod + firma deposu + kullanıcı tipi bir ilanı tekil tanımlar.\r\nquantity = 0 gönderilen ilanlar satışa kapatılır.",
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertListingsRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertListingsRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertListingsRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertListingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/listings/deactivate": {
      "post": {
        "tags": [
          "PartnerListings"
        ],
        "summary": "Barkodları verilen ilanları satıştan kaldırır.",
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/DeactivateListingsRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeactivateListingsRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/DeactivateListingsRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/DeactivateListingsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Firmaya ait siparişler. status virgülle ayrılmış birden fazla değer alabilir.\r\nhasInvoice=false ile henüz faturası yüklenmemiş siparişleri filtreleyebilirsiniz.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "hasInvoice",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "invoiceNumber",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hasOpenReturn",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/uninvoiced": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Faturası henüz yüklenmemiş faturalanabilir siparişleri listeler (varsayılan: waiting_approval, preparing, shipped, delivered).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/returns": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Siparişe açılmış iade ve iptal taleplerini listeler.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/invoice": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Siparişe yüklenmiş faturanın üst verisini döner.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Siparişe JSON üzerinden fatura kaydeder veya günceller (idempotent).\r\nHarici e-Arşiv/entegratör linki (externalUrl) ve/veya Base64 kodlu dosya (fileBase64: PDF, UBL-XML, HTML, PNG/JPG) kabul eder.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerInvoiceUpsertRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerInvoiceUpsertRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerInvoiceUpsertRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerInvoiceUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Siparişe hatalı yüklenen faturayı kaldırır.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/invoice/upload": {
      "post": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Siparişe multipart/form-data ile fatura dosyası (PDF, UBL-XML, HTML veya PNG/JPG; en fazla 10 MB) yükler veya günceller.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "File": {
                    "type": "string",
                    "format": "binary"
                  },
                  "InvoiceNumber": {
                    "type": "string"
                  },
                  "InvoiceType": {
                    "type": "string",
                    "description": "earsiv | efatura"
                  },
                  "Ettn": {
                    "type": "string"
                  },
                  "InvoiceDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "TotalAmount": {
                    "type": "number",
                    "format": "double"
                  },
                  "VatAmount": {
                    "type": "number",
                    "format": "double"
                  },
                  "Currency": {
                    "type": "string"
                  },
                  "ExternalUrl": {
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "File": {
                  "style": "form"
                },
                "InvoiceNumber": {
                  "style": "form"
                },
                "InvoiceType": {
                  "style": "form"
                },
                "Ettn": {
                  "style": "form"
                },
                "InvoiceDate": {
                  "style": "form"
                },
                "TotalAmount": {
                  "style": "form"
                },
                "VatAmount": {
                  "style": "form"
                },
                "Currency": {
                  "style": "form"
                },
                "ExternalUrl": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/invoice/file": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Siparişe yüklenmiş fatura dosyasını indirir.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/approve": {
      "post": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Onay bekleyen siparişi onaylar (idempotent).",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/cancel": {
      "post": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Siparişi iptal eder (stok yok vb.). Firma için otomatik iptal yetkisi kapalıysa talep yöneticiye iletilir (202).",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/shipments": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Firma kendi kargo anlaşmasıyla gönderdiğinde takip bilgisini bildirir. Sipariş \"Kargoda\" durumuna geçer.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/shipments/platform": {
      "post": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Platformun kargo anlaşmasıyla (DHL eCommerce/MNG) gönderi ve barkod oluşturur.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerPlatformShipmentRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerPlatformShipmentRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerPlatformShipmentRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerPlatformShipmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/shipments/{shipmentId}": {
      "patch": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Kendi kargonuzla bildirdiğiniz gönderinin bilgilerini düzeltir (yalnızca gönderilen alanlar değişir).",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "shipmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerOwnShipmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/shipments/{shipmentId}/events": {
      "post": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Firma kargosuyla gönderilen siparişlerde kargo hareketi/teslimat bildirir.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "shipmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/AddShipmentEventRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddShipmentEventRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AddShipmentEventRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AddShipmentEventRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/shipments/{shipmentId}/label": {
      "get": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Kargo etiketi. format: html (yazdırılabilir), zpl (Zebra yazıcı), png (açıksa).",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "shipmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "html"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/orders/{orderId}/shipments/{shipmentId}/cancel": {
      "post": {
        "tags": [
          "PartnerOrders"
        ],
        "summary": "Gönderiyi iptal eder (platform gönderilerinde yalnızca kargo şubesine teslim edilmeden önce).",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "shipmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerCancelRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/returns": {
      "get": {
        "tags": [
          "PartnerReturns"
        ],
        "summary": "Firmaya ait siparişler için açılmış müşteri iade ve iptal taleplerini listeler.\r\nstatus virgülle ayrılmış birden fazla değer alabilir (ör. received,awaiting_product).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "orderId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdFrom",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdTo",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/returns/{returnId}": {
      "get": {
        "tags": [
          "PartnerReturns"
        ],
        "summary": "İade veya iptal talebinin kalemlerini, durum geçmişini ve izinli aksiyonlarını döner.",
        "parameters": [
          {
            "name": "returnId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/returns/{returnId}/approve": {
      "post": {
        "tags": [
          "PartnerReturns"
        ],
        "summary": "İade veya iptal talebini onaylar (idempotent).\r\nİade (return) talebinde durum awaiting_product olur ve müşteriye gönderim talimatı iletilir.\r\nİptal (cancel) talebinde (allowOrderCancellation=true ise) sipariş iptal edilir ve ödeme iadesi başlatılır.",
        "parameters": [
          {
            "name": "returnId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnApproveRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnApproveRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnApproveRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnApproveRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/returns/{returnId}/receive": {
      "post": {
        "tags": [
          "PartnerReturns"
        ],
        "summary": "İade kargosunun depoya ulaştığını ve fiziksel olarak teslim alındığını bildirir (awaiting_product → product_received, idempotent).\r\nÖdeme iadesi kontrol sonrasında platform yönetimi tarafından tamamlanır.",
        "parameters": [
          {
            "name": "returnId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnReceiveRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnReceiveRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnReceiveRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnReceiveRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/integration/v1/returns/{returnId}/reject": {
      "post": {
        "tags": [
          "PartnerReturns"
        ],
        "summary": "Sonuçlanmamış iade veya iptal talebini gerekçe belirterek reddeder (idempotent).",
        "parameters": [
          {
            "name": "returnId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnRejectRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnRejectRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnRejectRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReturnRejectRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AddShipmentEventRequest": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "location": {
            "type": "string",
            "nullable": true
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "deliveredTo": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DeactivateListingsRequest": {
        "type": "object",
        "properties": {
          "barcodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerCancelRequest": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerInvoiceUpsertRequest": {
        "type": "object",
        "properties": {
          "invoiceNumber": {
            "type": "string",
            "nullable": true
          },
          "invoiceType": {
            "type": "string",
            "nullable": true
          },
          "ettn": {
            "type": "string",
            "nullable": true
          },
          "invoiceDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "totalAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "vatAmount": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "externalUrl": {
            "type": "string",
            "nullable": true
          },
          "fileBase64": {
            "type": "string",
            "nullable": true
          },
          "fileName": {
            "type": "string",
            "nullable": true
          },
          "contentType": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerOwnShipmentRequest": {
        "type": "object",
        "properties": {
          "carrierName": {
            "type": "string",
            "description": "Kargo firmasının adı (ör. \"Aras Kargo\").",
            "nullable": true
          },
          "trackingNumber": {
            "type": "string",
            "nullable": true
          },
          "trackingUrl": {
            "type": "string",
            "nullable": true
          },
          "invoiceNumber": {
            "type": "string",
            "nullable": true
          },
          "shippedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerPlatformShipmentRequest": {
        "type": "object",
        "properties": {
          "pieceCount": {
            "type": "integer",
            "format": "int32"
          },
          "desi": {
            "type": "number",
            "description": "Toplam desi (boşsa varsayılan).",
            "format": "double",
            "nullable": true
          },
          "kg": {
            "type": "number",
            "description": "Toplam ağırlık kg (boşsa varsayılan).",
            "format": "double",
            "nullable": true
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "invoiceNumber": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerReturnApproveRequest": {
        "type": "object",
        "properties": {
          "instructions": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerReturnReceiveRequest": {
        "type": "object",
        "properties": {
          "note": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerReturnRejectRequest": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PartnerWebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "nullable": true
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "UpsertListingItem": {
        "type": "object",
        "properties": {
          "barcode": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "integer",
            "format": "int32"
          },
          "maxQuantity": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "deadline": {
            "type": "string",
            "nullable": true
          },
          "marketPrice": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "warehousePrice": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpsertListingsRequest": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UpsertListingItem"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "PartnerApiKey": {
        "type": "apiKey",
        "description": "Firma API anahtarı. Örnek: 'X-Api-Key: mdp_live_xxxxxxxxxxxx_...'",
        "name": "X-Api-Key",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "PartnerApiKey": [ ]
    }
  ]
}