{
  "openapi": "3.1.0",
  "info": {
    "title": "MilkTrace API",
    "version": "1.0",
    "summary": "MilkTrace işletme verisi için salt okunur API (API anahtarı).",
    "description": "İşletmenin hayvan listesine, hayvan bazında günlük süt verimine ve tank\nteslimlerine salt okunur erişim: yem programı, muhasebe ya da kooperatif\nsistemleri için.\n\n**Kimlik doğrulama.** Anahtarı işletme sahibi MilkTrace uygulamasında\nüretir (hesap kartı → *API anahtarları*). Tam anahtar **yalnızca bir kez**\ngösterilir. Her istekte `Authorization: Bearer mtk_<önek>_<sır>` olarak\ngönderin. Anahtar tek bir işletmeye aittir, salt okunurdur (yalnızca\n`GET`) ve yalnızca bu belgedeki uçları açar; diğer her uç\n`403 FORBIDDEN` döner. İptal edilen anahtar en çok 1 dakika daha\nçalışabilir (doğrulama önbelleği). Sağlık denetimi\n(`GET /health-check/gateway`) anahtar istemez.\n\n**Yanıt zarfı.** Her yanıt `success`, `msg` ve başarıda `data` taşıyan bir\nJSON nesnesidir; hatalarda `error.code` ve `error.message` bulunur.\nDestekle yazışırken `traceId`'yi iletin.\n\n**Birim ve zaman.** Hacimler tam sayı mililitredir (mL). Takvim günleri\nEurope/Istanbul günüdür; zaman damgaları UTC'dir (RFC 3339).\n\n**Dil.** İnsan okuyacağı mesajlar (`msg`, `error.message`) varsayılan\nolarak Türkçedir; İngilizce için `Accept-Language: en` gönderin. Kodlar\ndeğişmez.\n\n**Hız sınırı.** İstekler istemci IP adresi başına sınırlıdır (varsayılan\nsaniyede 50 istek, anlık en çok 100; gateway örneği başına). Aşılırsa\n`429` döner. Günlük veriyi en sık birkaç dakikada bir sorgulayın —\nverim sağımlar bittikçe yazılır.\n",
    "contact": {
      "name": "Albiferro Yazılım ve Sistem Limited Şirketi",
      "url": "https://albiferro.com"
    }
  },
  "servers": [
    {
      "url": "/api/v1",
      "description": "Bu sunucu (okuduğunuz sayfa)."
    },
    {
      "url": "https://milktrace.com.tr/api/v1",
      "description": "Canlı ortam."
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "animals",
      "description": "Hayvan kayıtları."
    },
    {
      "name": "deliveries",
      "description": "Mandıraya tank teslimleri ve sayaçlarla karşılaştırması."
    },
    {
      "name": "exports",
      "description": "Dış sistemler için hayvan bazında günlük verim."
    },
    {
      "name": "health",
      "description": "Entegrasyonlar için erişilebilirlik denetimi. Herkese açık tek sağlık\ndenetimi budur; platformun kendi altyapı yoklamaları internetten\nerişilemez ve bu sözleşmenin parçası değildir.\n"
    }
  ],
  "paths": {
    "/animals": {
      "get": {
        "tags": [
          "animals"
        ],
        "operationId": "listAnimals",
        "summary": "Hayvanları listele",
        "description": "İşletmenin bütün hayvanları, her durumda (satılan, kesilen ve ölenler\ndahil), küpe numarasına göre sıralı. `offspring` listede doldurulmaz;\nbunun için tek hayvanı okuyun.\n",
        "parameters": [
          {
            "name": "speciesId",
            "in": "query",
            "required": false,
            "description": "Yalnızca bu türün hayvanları (hayvanın `speciesId` alanı). Boşsa hepsi.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hayvanlar. İşletmenin (ya da o türün) hayvanı yoksa `data` `null` olur.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": [
                            "array",
                            "null"
                          ],
                          "items": {
                            "$ref": "#/components/schemas/Animal"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "msg": "hayvanlar",
                  "totalPages": 10,
                  "traceId": "0f6c2c4e9a1b4d7e",
                  "data": [
                    {
                      "id": "0192a1f0-0b1c-7000-8000-0000000000a1",
                      "speciesId": "0192a1f0-0001-7000-8000-000000000001",
                      "earTag": "TR340001234",
                      "rfid": "982000123456789",
                      "name": "Sarıkız",
                      "breed": "Holstein",
                      "birthDate": "2021-03-14T00:00:00Z",
                      "lastCalvingDate": "2026-08-02T00:00:00Z",
                      "lactationNo": 3,
                      "status": "active",
                      "yieldClass": "normal",
                      "yieldClassAt": "2026-10-29T00:00:00Z",
                      "pregnancy": {
                        "status": "inseminated",
                        "lastInsemination": "2026-10-20T00:00:00Z",
                        "expectedCalving": "2027-07-30T00:00:00Z",
                        "dryOffDate": "2027-05-31T00:00:00Z"
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/animals/{id}": {
      "get": {
        "tags": [
          "animals"
        ],
        "operationId": "getAnimal",
        "summary": "Tek hayvanı getir",
        "description": "Tek hayvan, yavrularıyla birlikte (`offspring`: annesi bu hayvan olan\nhayvanlar). Olmayan, UUID olmayan ya da başka işletmeye ait kimlik\n`404` döner — üçü bilerek ayırt edilemez.\n",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Hayvan kimliği.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hayvan.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/Animal"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/deliveries": {
      "get": {
        "tags": [
          "deliveries"
        ],
        "operationId": "listDeliveries",
        "summary": "Tank teslimlerini listele",
        "description": "Son teslimler, yeniden eskiye; her biri önceki teslimden bu yana\nsayaçların ölçtüğüyle karşılaştırılır. Pencere önceki teslimin ertesi\ngününden bu teslimin gününe kadardır (İstanbul takvimi). İlk teslimde,\nönceki teslim 7 günden eskiyse ya da pencerede sayaç verisi yoksa\nkarşılaştırma yapılmaz (`compared: false`).\n",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Teslim sayısı (varsayılan 100, en çok 500). Geçersiz ya da pozitif olmayan değer varsayılana döner.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Teslimler ve işletmenin eşikleri.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/Deliveries"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "msg": "tank teslimleri",
                  "totalPages": 10,
                  "traceId": "0f6c2c4e9a1b4d7e",
                  "data": {
                    "tolerancePct": 5,
                    "sccLimitK": 400,
                    "items": [
                      {
                        "id": "0192a1f0-0d00-7000-8000-0000000000d1",
                        "deliveredOn": "2026-10-29",
                        "volumeMl": 812000,
                        "note": "",
                        "createdAt": "2026-10-29T07:41:12Z",
                        "compared": true,
                        "periodFrom": "2026-10-28",
                        "meteredMl": 826500,
                        "withheldMl": 14000,
                        "diffPct": 1.8,
                        "mismatch": false,
                        "kgPerLitre": 1.03,
                        "fatPct": 3.9,
                        "proteinPct": 3.3,
                        "sccK": 210,
                        "bacteriaK": null,
                        "highScc": false
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/exports/daily": {
      "get": {
        "tags": [
          "exports"
        ],
        "operationId": "exportDaily",
        "summary": "Hayvan bazında günlük verim",
        "description": "`from`–`to` günleri (dahil, Europe/Istanbul günü) için hayvan ve gün\nbaşına bir satır; yalnızca o gün sağılan hayvanlar, tarih ve küpeye\ngöre sıralı. Bugün dahildir ve sağımlar bittikçe büyür. Varsayılan:\n`to` ile biten son 7 gün (`to` varsayılanı bugün). En çok 92 gün.\n",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "İlk gün, `YYYY-MM-DD` (RFC 3339 zaman damgası da kabul edilir; yazıldığı hâliyle tarih kısmı alınır). Varsayılan `to` − 6 gün.",
            "schema": {
              "type": "string",
              "examples": [
                "2026-10-01"
              ]
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Son gün, aynı biçim. Varsayılan bugün (İstanbul). Gelecekte olamaz.",
            "schema": {
              "type": "string",
              "examples": [
                "2026-10-07"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hayvan-gün satırları (hiç sağım yoksa boş dizi).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/DailyYield"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "msg": "günlük verim",
                  "totalPages": 10,
                  "traceId": "0f6c2c4e9a1b4d7e",
                  "data": [
                    {
                      "animalId": "0192a1f0-0b1c-7000-8000-0000000000a1",
                      "earTag": "TR340001234",
                      "date": "2026-10-01",
                      "totalMl": 24350,
                      "withheldMl": 0,
                      "milkings": 2
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Validation"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/health-check/gateway": {
      "get": {
        "tags": [
          "health"
        ],
        "operationId": "healthCheck",
        "summary": "Sağlık denetimi",
        "description": "API gateway ayaktayken `200` döner. API anahtarı gerekmez. Gateway'in\narkasındaki servisleri ya da veritabanını denetlemez; çalışmayan bir\nveri ucu kendi `503`'ünü döner. Her istek gibi hız sınırına tabidir.\n",
        "security": [],
        "responses": {
          "200": {
            "description": "Gateway ayakta.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Envelope"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "required": [
                            "status"
                          ],
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "ok"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "msg": "success",
                  "totalPages": 10,
                  "traceId": "0f6c2c4e9a1b4d7e",
                  "data": {
                    "status": "ok"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mtk_<prefix>_<secret>",
        "description": "`Authorization` başlığında işletme API anahtarı:\n`Authorization: Bearer mtk_<önek>_<sır>`. Uygulamada işletme sahibi\nüretir; salt okunur.\n"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Anahtar yok, geçersiz ya da iptal edilmiş (`UNAUTHORIZED`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "example": {
              "success": false,
              "msg": "geçersiz API anahtarı",
              "error": {
                "code": "UNAUTHORIZED",
                "message": "geçersiz API anahtarı"
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "API anahtarı bu uca ya da yönteme erişemez (`FORBIDDEN`). Anahtar salt okunurdur ve yalnızca bu belgedeki uçları açar.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "example": {
              "success": false,
              "msg": "API anahtarı bu uca erişemez; yalnızca okuma uçları açık",
              "error": {
                "code": "FORBIDDEN",
                "message": "API anahtarı bu uca erişemez; yalnızca okuma uçları açık"
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Kayıt bulunamadı (`NOT_FOUND`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "example": {
              "success": false,
              "msg": "hayvan bulunamadı",
              "error": {
                "code": "NOT_FOUND",
                "message": "hayvan bulunamadı"
              }
            }
          }
        }
      },
      "Validation": {
        "description": "Geçersiz parametre (`VALIDATION`); örneğin bozuk tarih, gelecekteki `to`, `to`'dan sonraki `from` ya da 92 günden uzun dönem.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "example": {
              "success": false,
              "msg": "dönem en çok 92 gün olabilir",
              "error": {
                "code": "VALIDATION",
                "message": "dönem en çok 92 gün olabilir"
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Hız sınırı aşıldı (`TOO_MANY_REQUESTS`); kısa bir aradan sonra yeniden deneyin.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "Internal": {
        "description": "Beklenmeyen sunucu hatası (`INTERNAL`); ayrıntı dönmez.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "Unavailable": {
        "description": "Bir servise geçici olarak ulaşılamıyor ya da anahtar doğrulanamadı (`UNAVAILABLE`); sonra yeniden deneyin.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      }
    },
    "schemas": {
      "Envelope": {
        "type": "object",
        "description": "Bütün uçların ortak yanıt zarfı.",
        "required": [
          "success",
          "msg"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Başarıda `true`, hatada `false`."
          },
          "data": {
            "description": "Asıl veri; her uçta ayrıca tanımlı."
          },
          "msg": {
            "type": "string",
            "description": "İsteğin dilinde (`Accept-Language`) kısa mesaj."
          },
          "totalPages": {
            "type": "integer",
            "description": "Eski uyumluluk alanı, bu uçlarda anlamı yok; yok sayın."
          },
          "total": {
            "type": "integer",
            "description": "Eski uyumluluk alanı, bu uçlarda gönderilmez."
          },
          "traceId": {
            "type": "string",
            "description": "İsteğin izleme kimliği; destekle yazışırken iletin."
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "ErrorEnvelope": {
        "description": "Hata yanıtı.",
        "allOf": [
          {
            "$ref": "#/components/schemas/Envelope"
          },
          {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "success": {
                "const": false
              }
            }
          }
        ]
      },
      "Error": {
        "type": "object",
        "description": "Hata ayrıntısı. Kararı `code`'a göre verin; `message` insanlar içindir ve değişebilir.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Değişmeyen hata kodu.",
            "enum": [
              "VALIDATION",
              "NOT_FOUND",
              "CONFLICT",
              "UNAUTHORIZED",
              "FORBIDDEN",
              "UNAVAILABLE",
              "TOO_MANY_REQUESTS",
              "INTERNAL"
            ]
          },
          "message": {
            "type": "string",
            "description": "İsteğin dilinde mesaj."
          }
        }
      },
      "Animal": {
        "type": "object",
        "description": "Sürüdeki bir hayvan. İsteğe bağlı alanlar boşken gönderilmez.",
        "required": [
          "id",
          "speciesId",
          "earTag",
          "lactationNo",
          "status",
          "yieldClass"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Hayvan kimliği."
          },
          "speciesId": {
            "type": "string",
            "format": "uuid",
            "description": "Tür kimliği (inek, koyun, keçi …)."
          },
          "earTag": {
            "type": "string",
            "description": "Küpe numarası, işletme içinde tekil."
          },
          "rfid": {
            "type": "string",
            "description": "Sağım noktasında okunan RFID küpesi."
          },
          "name": {
            "type": "string",
            "description": "Adı."
          },
          "breed": {
            "type": "string",
            "description": "Irkı."
          },
          "birthDate": {
            "type": "string",
            "format": "date-time",
            "description": "Doğum tarihi (takvim günü, 00:00 UTC)."
          },
          "lastCalvingDate": {
            "type": "string",
            "format": "date-time",
            "description": "Son buzağılama tarihi (takvim günü, 00:00 UTC)."
          },
          "lactationNo": {
            "type": "integer",
            "minimum": 0,
            "description": "Laktasyon numarası."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dry",
              "sold",
              "slaughtered",
              "dead"
            ],
            "description": "`active` sağmal, `dry` kuruda, `sold` satıldı, `slaughtered` kesildi, `dead` öldü (sürüden çıktı)."
          },
          "yieldClass": {
            "type": "string",
            "enum": [
              "high",
              "normal",
              "declining",
              "dry_off_candidate",
              "no_milk"
            ],
            "description": "Gece hesabının verdiği verim sınıfı."
          },
          "yieldClassAt": {
            "type": "string",
            "format": "date-time",
            "description": "Verim sınıfının hesaplandığı gün; hayvan sağmaldan çıkınca donar."
          },
          "withdrawalUntil": {
            "type": "string",
            "format": "date-time",
            "description": "Tedavi arınma süresinin son günü; o güne kadar sütü tanka katılmaz."
          },
          "pregnancy": {
            "$ref": "#/components/schemas/Pregnancy"
          },
          "groupId": {
            "type": "string",
            "format": "uuid",
            "description": "Hayvan grubu kimliği."
          },
          "groupName": {
            "type": "string",
            "description": "Hayvan grubunun adı."
          },
          "exitReason": {
            "type": "string",
            "enum": [
              "low_yield",
              "mastitis",
              "fertility",
              "feet",
              "age",
              "accident",
              "disease",
              "other"
            ],
            "description": "Sürüden çıkış nedeni (yalnızca satılan, kesilen ya da ölen hayvanda)."
          },
          "exitedOn": {
            "type": "string",
            "format": "date-time",
            "description": "Hayvanın sürüden çıktığı gün."
          },
          "damId": {
            "type": "string",
            "format": "uuid",
            "description": "Sürüdeki annesi."
          },
          "damEarTag": {
            "type": "string",
            "description": "Annesinin küpe numarası."
          },
          "sireCode": {
            "type": "string",
            "description": "Baba boğa ya da sperma kodu."
          },
          "offspring": {
            "type": "array",
            "description": "Yavruları; yalnızca tek hayvan okunurken.",
            "items": {
              "$ref": "#/components/schemas/AnimalBrief"
            }
          }
        }
      },
      "AnimalBrief": {
        "type": "object",
        "description": "Kısa hayvan satırı (yavru).",
        "required": [
          "id",
          "earTag",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Hayvan kimliği."
          },
          "earTag": {
            "type": "string",
            "description": "Küpe numarası."
          },
          "name": {
            "type": "string",
            "description": "Adı."
          },
          "birthDate": {
            "type": "string",
            "format": "date-time",
            "description": "Doğum tarihi (takvim günü, 00:00 UTC)."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dry",
              "sold",
              "slaughtered",
              "dead"
            ],
            "description": "Durum, `Animal.status` ile aynı."
          }
        }
      },
      "Pregnancy": {
        "type": "object",
        "description": "Üreme durumu; hayvanın üreme kaydı yoksa gönderilmez.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "open",
              "inseminated",
              "pregnant"
            ],
            "description": "`open` boş, `inseminated` tohumlandı (kontrol bekliyor), `pregnant` gebe."
          },
          "lastInsemination": {
            "type": "string",
            "format": "date-time",
            "description": "Son tohumlama günü."
          },
          "expectedCalving": {
            "type": "string",
            "format": "date-time",
            "description": "Beklenen doğum (son tohumlama + türün gebelik süresi)."
          },
          "dryOffDate": {
            "type": "string",
            "format": "date-time",
            "description": "Önerilen kuruya çıkarma günü (beklenen doğum − kuru dönem)."
          },
          "lastHeat": {
            "type": "string",
            "format": "date-time",
            "description": "Bu laktasyonda gözlenen son kızgınlık."
          },
          "expectedHeat": {
            "type": "string",
            "format": "date-time",
            "description": "Sonraki beklenen kızgınlık (son kızgınlık + 21 gün); sonrasında tohumlama yoksa ve gebe değilse."
          }
        }
      },
      "Deliveries": {
        "type": "object",
        "description": "Teslim listesi ve işletmenin eşikleri.",
        "required": [
          "tolerancePct",
          "sccLimitK",
          "items"
        ],
        "properties": {
          "tolerancePct": {
            "type": "number",
            "description": "Teslim edilen ile sayaçların ölçtüğü arasındaki izinli fark (%); aşılınca `mismatch` true olur."
          },
          "sccLimitK": {
            "type": "integer",
            "description": "Somatik hücre sınırı (bin hücre/mL); aşılınca `highScc` true olur."
          },
          "items": {
            "type": "array",
            "description": "Teslimler, yeniden eskiye.",
            "items": {
              "$ref": "#/components/schemas/Delivery"
            }
          }
        }
      },
      "Delivery": {
        "type": "object",
        "description": "Bir tank teslimi (günde en çok bir) ve sayaçlarla karşılaştırması.",
        "required": [
          "id",
          "deliveredOn",
          "volumeMl",
          "note",
          "createdAt",
          "compared",
          "meteredMl",
          "withheldMl",
          "diffPct",
          "mismatch",
          "kgPerLitre",
          "fatPct",
          "proteinPct",
          "sccK",
          "bacteriaK",
          "highScc"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Teslim kimliği."
          },
          "deliveredOn": {
            "type": "string",
            "format": "date",
            "description": "Teslim günü (İstanbul takvimi)."
          },
          "volumeMl": {
            "type": "integer",
            "format": "int64",
            "description": "Teslim edilen hacim (mL)."
          },
          "note": {
            "type": "string",
            "description": "Serbest not; boş olabilir."
          },
          "authorName": {
            "type": "string",
            "description": "Teslimi giren kişinin adı."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Teslimin girildiği an (UTC)."
          },
          "compared": {
            "type": "boolean",
            "description": "Sayaçlarla karşılaştırma yapıldı mı. İlk teslimde, 7 günden uzun aradan sonra ve sayaçlar pencerede hiçbir şey ölçmediyse false olur; o zaman `meteredMl`, `withheldMl` ve `diffPct` 0, `mismatch` false olur ve `periodFrom` gelmez."
          },
          "periodFrom": {
            "type": "string",
            "format": "date",
            "description": "Karşılaştırma penceresinin ilk günü; yalnızca `compared` true iken."
          },
          "meteredMl": {
            "type": "integer",
            "format": "int64",
            "description": "Pencerede sayaçların ölçtüğü ve tanka giden süt (mL)."
          },
          "withheldMl": {
            "type": "integer",
            "format": "int64",
            "description": "Pencerede ölçülen ama ayrılan (arınma süresi) ve tanka girmeyen süt (mL)."
          },
          "diffPct": {
            "type": "number",
            "description": "(sayaç − teslim) / teslim × 100, bir ondalık."
          },
          "mismatch": {
            "type": "boolean",
            "description": "`|diffPct|`, `tolerancePct`'yi aşıyor."
          },
          "kgPerLitre": {
            "type": "number",
            "description": "Penceredeki sütün hacim ağırlıklı yoğunluğu (kg/L); litreyi kilograma çevirmek için. Pencerede ölçülmüş süt yoksa (ilk teslim dahil) 1.03."
          },
          "fatPct": {
            "type": [
              "number",
              "null"
            ],
            "description": "Mandıra analizi — yağ (%)."
          },
          "proteinPct": {
            "type": [
              "number",
              "null"
            ],
            "description": "Mandıra analizi — protein (%)."
          },
          "sccK": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Mandıra analizi — somatik hücre (bin/mL)."
          },
          "bacteriaK": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Mandıra analizi — bakteri (bin/mL)."
          },
          "highScc": {
            "type": "boolean",
            "description": "`sccK`, `sccLimitK`'yi aşıyor."
          }
        }
      },
      "DailyYield": {
        "type": "object",
        "description": "Bir hayvanın bir gündeki sütü.",
        "required": [
          "animalId",
          "earTag",
          "date",
          "totalMl",
          "withheldMl",
          "milkings"
        ],
        "properties": {
          "animalId": {
            "type": "string",
            "format": "uuid",
            "description": "Hayvan kimliği."
          },
          "earTag": {
            "type": "string",
            "description": "Küpe numarası."
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "Gün (Europe/Istanbul)."
          },
          "totalMl": {
            "type": "integer",
            "format": "int64",
            "description": "Günün toplam sütü (mL), ayrılan süt dahil."
          },
          "withheldMl": {
            "type": "integer",
            "format": "int64",
            "description": "`totalMl`'nin tanka katılmayan kısmı (arınma süresi, mL)."
          },
          "milkings": {
            "type": "integer",
            "description": "O günkü sağım sayısı."
          }
        }
      }
    }
  }
}
