{
  "openapi": "3.1.0",
  "info": {
    "title": "MilkTrace API",
    "x-title-tr": "MilkTrace API",
    "version": "1.0",
    "summary": "Read-only farm data API for MilkTrace (API key).",
    "x-summary-tr": "MilkTrace işletme verisi için salt okunur API (API anahtarı).",
    "description": "Read-only access to a farm's herd list, per-animal daily milk yield and\nmilk tank deliveries, for feed programs, accounting or cooperative systems.\n\n**Authentication.** The farm owner creates a key in the MilkTrace app\n(account card → *API keys*). The full key is shown **only once**. Send it\non every request as `Authorization: Bearer mtk_<prefix>_<secret>`.\nA key belongs to one farm, is read-only (`GET` only) and opens only the\nendpoints in this document; every other endpoint answers `403 FORBIDDEN`.\nA revoked key may keep working for up to 1 minute (verification cache).\nThe health check (`GET /health-check/gateway`) needs no key.\n\n**Response envelope.** Every response is a JSON object with `success`,\n`msg` and, on success, `data`; errors carry `error.code` and\n`error.message`. Quote `traceId` when contacting support.\n\n**Units and time.** Volumes are integer millilitres (mL). Calendar days\nare Europe/Istanbul days; timestamps are UTC (RFC 3339).\n\n**Language.** Human-readable messages (`msg`, `error.message`) are Turkish\nby default; send `Accept-Language: en` for English. Codes never change.\n\n**Rate limit.** Requests are limited per client IP address (default\n50 requests/second with bursts of up to 100, per gateway instance).\nExceeding it returns `429`. Poll daily data at most every few minutes —\nyields are written as milkings finish.\n",
    "x-description-tr": "İş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": "This host (the page you are reading).",
      "x-description-tr": "Bu sunucu (okuduğunuz sayfa)."
    },
    {
      "url": "https://milktrace.com.tr/api/v1",
      "description": "Production.",
      "x-description-tr": "Canlı ortam."
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "animals",
      "description": "Herd records.",
      "x-description-tr": "Hayvan kayıtları."
    },
    {
      "name": "deliveries",
      "description": "Milk tank deliveries to the dairy, compared with the meters.",
      "x-description-tr": "Mandıraya tank teslimleri ve sayaçlarla karşılaştırması."
    },
    {
      "name": "exports",
      "description": "Per-animal daily yield for external systems.",
      "x-description-tr": "Dış sistemler için hayvan bazında günlük verim."
    },
    {
      "name": "health",
      "description": "Availability check for integrations. This is the only public health\ncheck; the platform's own infrastructure probes are not reachable from\nthe internet and are not part of this contract.\n",
      "x-description-tr": "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": "List animals",
        "x-summary-tr": "Hayvanları listele",
        "description": "All animals of the farm, every status included (also sold,\nslaughtered and dead ones), ordered by ear tag. `offspring` is not\nfilled in the list; read a single animal for it.\n",
        "x-description-tr": "İş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": "Only animals of this species (the `speciesId` of an animal). Empty means all.",
            "x-description-tr": "Yalnızca bu türün hayvanları (hayvanın `speciesId` alanı). Boşsa hepsi.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Animals. `data` is `null` when the farm has no animals (or none of the species).",
            "x-description-tr": "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": "Get an animal",
        "x-summary-tr": "Tek hayvanı getir",
        "description": "One animal with its offspring (`offspring`: animals whose dam is this\nanimal). An id that does not exist, is not a UUID or belongs to\nanother farm answers `404` — the three cases are indistinguishable on\npurpose.\n",
        "x-description-tr": "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": "Animal id.",
            "x-description-tr": "Hayvan kimliği.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The animal.",
            "x-description-tr": "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": "List tank deliveries",
        "x-summary-tr": "Tank teslimlerini listele",
        "description": "The latest deliveries, newest first, each compared with what the\nmeters measured since the previous delivery. The comparison window is\nthe day after the previous delivery through the delivery day\n(Istanbul calendar). No comparison is made (`compared: false`) for the\nfirst delivery, when the previous one is more than 7 days older, or\nwhen the meters recorded nothing in the window.\n",
        "x-description-tr": "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": "Number of deliveries (default 100, at most 500). Invalid or non-positive values fall back to the default.",
            "x-description-tr": "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": "Deliveries and the farm's limits.",
            "x-description-tr": "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": "Daily yield per animal",
        "x-summary-tr": "Hayvan bazında günlük verim",
        "description": "One row per animal and day for the days `from`–`to` (inclusive,\nEurope/Istanbul days), only for animals milked that day, ordered by\ndate and ear tag. Today is included and grows as milkings finish.\nDefault: the last 7 days ending `to` (default today). At most 92 days.\n",
        "x-description-tr": "`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": "First day, `YYYY-MM-DD` (an RFC 3339 timestamp is also accepted; its date part is used as written). Default `to` − 6 days.",
            "x-description-tr": "İ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": "Last day, same format. Default today (Istanbul). Must not be in the future.",
            "x-description-tr": "Son gün, aynı biçim. Varsayılan bugün (İstanbul). Gelecekte olamaz.",
            "schema": {
              "type": "string",
              "examples": [
                "2026-10-07"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Animal-day rows (an empty array when nothing was milked).",
            "x-description-tr": "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": "Health check",
        "x-summary-tr": "Sağlık denetimi",
        "description": "Answers `200` while the API gateway is up. No API key needed. It does\nnot check the services behind the gateway or the database; a failing\ndata endpoint returns its own `503`. Rate limited like every request.\n",
        "x-description-tr": "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": "The gateway is up.",
            "x-description-tr": "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": "Farm API key in the `Authorization` header:\n`Authorization: Bearer mtk_<prefix>_<secret>`. Created by the farm\nowner in the app; read-only.\n",
        "x-description-tr": "`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": "Missing, invalid or revoked API key (`UNAUTHORIZED`).",
        "x-description-tr": "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": "The API key cannot use this endpoint or method (`FORBIDDEN`). Keys are read-only and open only the endpoints in this document.",
        "x-description-tr": "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": "Record not found (`NOT_FOUND`).",
        "x-description-tr": "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": "Invalid parameter (`VALIDATION`), e.g. a malformed date, a future `to`, `from` after `to` or a period longer than 92 days.",
        "x-description-tr": "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": "Rate limit exceeded (`TOO_MANY_REQUESTS`); retry after a short pause.",
        "x-description-tr": "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": "Unexpected server error (`INTERNAL`); details are never returned.",
        "x-description-tr": "Beklenmeyen sunucu hatası (`INTERNAL`); ayrıntı dönmez.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "Unavailable": {
        "description": "A service is temporarily unreachable or the key could not be verified (`UNAVAILABLE`); retry later.",
        "x-description-tr": "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": "Response envelope shared by every endpoint.",
        "x-description-tr": "Bütün uçların ortak yanıt zarfı.",
        "required": [
          "success",
          "msg"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "`true` on success, `false` on error.",
            "x-description-tr": "Başarıda `true`, hatada `false`."
          },
          "data": {
            "description": "The payload; see each endpoint.",
            "x-description-tr": "Asıl veri; her uçta ayrıca tanımlı."
          },
          "msg": {
            "type": "string",
            "description": "Short human-readable message in the request language (`Accept-Language`).",
            "x-description-tr": "İsteğin dilinde (`Accept-Language`) kısa mesaj."
          },
          "totalPages": {
            "type": "integer",
            "description": "Legacy field, not meaningful for these endpoints; ignore it.",
            "x-description-tr": "Eski uyumluluk alanı, bu uçlarda anlamı yok; yok sayın."
          },
          "total": {
            "type": "integer",
            "description": "Legacy field, omitted by these endpoints.",
            "x-description-tr": "Eski uyumluluk alanı, bu uçlarda gönderilmez."
          },
          "traceId": {
            "type": "string",
            "description": "Request trace id; quote it when contacting support.",
            "x-description-tr": "İsteğin izleme kimliği; destekle yazışırken iletin."
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "ErrorEnvelope": {
        "description": "Error response.",
        "x-description-tr": "Hata yanıtı.",
        "allOf": [
          {
            "$ref": "#/components/schemas/Envelope"
          },
          {
            "type": "object",
            "required": [
              "error"
            ],
            "properties": {
              "success": {
                "const": false
              }
            }
          }
        ]
      },
      "Error": {
        "type": "object",
        "description": "Error detail. Branch on `code`; `message` is for people and may change.",
        "x-description-tr": "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": "Stable error code.",
            "x-description-tr": "Değişmeyen hata kodu.",
            "enum": [
              "VALIDATION",
              "NOT_FOUND",
              "CONFLICT",
              "UNAUTHORIZED",
              "FORBIDDEN",
              "UNAVAILABLE",
              "TOO_MANY_REQUESTS",
              "INTERNAL"
            ]
          },
          "message": {
            "type": "string",
            "description": "Human-readable message in the request language.",
            "x-description-tr": "İsteğin dilinde mesaj."
          }
        }
      },
      "Animal": {
        "type": "object",
        "description": "An animal of the herd. Optional fields are omitted when empty.",
        "x-description-tr": "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": "Animal id.",
            "x-description-tr": "Hayvan kimliği."
          },
          "speciesId": {
            "type": "string",
            "format": "uuid",
            "description": "Species id (cow, sheep, goat …).",
            "x-description-tr": "Tür kimliği (inek, koyun, keçi …)."
          },
          "earTag": {
            "type": "string",
            "description": "Ear tag number, unique within the farm.",
            "x-description-tr": "Küpe numarası, işletme içinde tekil."
          },
          "rfid": {
            "type": "string",
            "description": "RFID tag read at the milking point.",
            "x-description-tr": "Sağım noktasında okunan RFID küpesi."
          },
          "name": {
            "type": "string",
            "description": "Name.",
            "x-description-tr": "Adı."
          },
          "breed": {
            "type": "string",
            "description": "Breed.",
            "x-description-tr": "Irkı."
          },
          "birthDate": {
            "type": "string",
            "format": "date-time",
            "description": "Birth date (calendar day at 00:00 UTC).",
            "x-description-tr": "Doğum tarihi (takvim günü, 00:00 UTC)."
          },
          "lastCalvingDate": {
            "type": "string",
            "format": "date-time",
            "description": "Last calving date (calendar day at 00:00 UTC).",
            "x-description-tr": "Son buzağılama tarihi (takvim günü, 00:00 UTC)."
          },
          "lactationNo": {
            "type": "integer",
            "minimum": 0,
            "description": "Lactation number.",
            "x-description-tr": "Laktasyon numarası."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dry",
              "sold",
              "slaughtered",
              "dead"
            ],
            "description": "`active` milking, `dry` dried off, `sold`, `slaughtered`, `dead` (left the herd).",
            "x-description-tr": "`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": "Yield class from the nightly calculation.",
            "x-description-tr": "Gece hesabının verdiği verim sınıfı."
          },
          "yieldClassAt": {
            "type": "string",
            "format": "date-time",
            "description": "Day the yield class was calculated; it freezes when the animal stops milking.",
            "x-description-tr": "Verim sınıfının hesaplandığı gün; hayvan sağmaldan çıkınca donar."
          },
          "withdrawalUntil": {
            "type": "string",
            "format": "date-time",
            "description": "Last day of a treatment withdrawal period; until then its milk does not go into the tank.",
            "x-description-tr": "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": "Animal group id.",
            "x-description-tr": "Hayvan grubu kimliği."
          },
          "groupName": {
            "type": "string",
            "description": "Animal group name.",
            "x-description-tr": "Hayvan grubunun adı."
          },
          "exitReason": {
            "type": "string",
            "enum": [
              "low_yield",
              "mastitis",
              "fertility",
              "feet",
              "age",
              "accident",
              "disease",
              "other"
            ],
            "description": "Reason for leaving the herd (sold, slaughtered or dead animals only).",
            "x-description-tr": "Sürüden çıkış nedeni (yalnızca satılan, kesilen ya da ölen hayvanda)."
          },
          "exitedOn": {
            "type": "string",
            "format": "date-time",
            "description": "Day the animal left the herd.",
            "x-description-tr": "Hayvanın sürüden çıktığı gün."
          },
          "damId": {
            "type": "string",
            "format": "uuid",
            "description": "Dam (mother) in the herd.",
            "x-description-tr": "Sürüdeki annesi."
          },
          "damEarTag": {
            "type": "string",
            "description": "Dam's ear tag.",
            "x-description-tr": "Annesinin küpe numarası."
          },
          "sireCode": {
            "type": "string",
            "description": "Sire (bull or semen) code.",
            "x-description-tr": "Baba boğa ya da sperma kodu."
          },
          "offspring": {
            "type": "array",
            "description": "Offspring; only when reading a single animal.",
            "x-description-tr": "Yavruları; yalnızca tek hayvan okunurken.",
            "items": {
              "$ref": "#/components/schemas/AnimalBrief"
            }
          }
        }
      },
      "AnimalBrief": {
        "type": "object",
        "description": "Short animal row (offspring).",
        "x-description-tr": "Kısa hayvan satırı (yavru).",
        "required": [
          "id",
          "earTag",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Animal id.",
            "x-description-tr": "Hayvan kimliği."
          },
          "earTag": {
            "type": "string",
            "description": "Ear tag number.",
            "x-description-tr": "Küpe numarası."
          },
          "name": {
            "type": "string",
            "description": "Name.",
            "x-description-tr": "Adı."
          },
          "birthDate": {
            "type": "string",
            "format": "date-time",
            "description": "Birth date (calendar day at 00:00 UTC).",
            "x-description-tr": "Doğum tarihi (takvim günü, 00:00 UTC)."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dry",
              "sold",
              "slaughtered",
              "dead"
            ],
            "description": "Status, as in `Animal.status`.",
            "x-description-tr": "Durum, `Animal.status` ile aynı."
          }
        }
      },
      "Pregnancy": {
        "type": "object",
        "description": "Breeding status; omitted when the animal has no breeding record.",
        "x-description-tr": "Üreme durumu; hayvanın üreme kaydı yoksa gönderilmez.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "open",
              "inseminated",
              "pregnant"
            ],
            "description": "`open` not pregnant, `inseminated` awaiting a pregnancy check, `pregnant`.",
            "x-description-tr": "`open` boş, `inseminated` tohumlandı (kontrol bekliyor), `pregnant` gebe."
          },
          "lastInsemination": {
            "type": "string",
            "format": "date-time",
            "description": "Last insemination day.",
            "x-description-tr": "Son tohumlama günü."
          },
          "expectedCalving": {
            "type": "string",
            "format": "date-time",
            "description": "Expected calving (last insemination + the species' gestation).",
            "x-description-tr": "Beklenen doğum (son tohumlama + türün gebelik süresi)."
          },
          "dryOffDate": {
            "type": "string",
            "format": "date-time",
            "description": "Suggested dry-off day (expected calving − dry period).",
            "x-description-tr": "Önerilen kuruya çıkarma günü (beklenen doğum − kuru dönem)."
          },
          "lastHeat": {
            "type": "string",
            "format": "date-time",
            "description": "Last observed heat in this lactation.",
            "x-description-tr": "Bu laktasyonda gözlenen son kızgınlık."
          },
          "expectedHeat": {
            "type": "string",
            "format": "date-time",
            "description": "Next expected heat (last heat + 21 days) when not inseminated since and not pregnant.",
            "x-description-tr": "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": "Delivery list with the farm's limits.",
        "x-description-tr": "Teslim listesi ve işletmenin eşikleri.",
        "required": [
          "tolerancePct",
          "sccLimitK",
          "items"
        ],
        "properties": {
          "tolerancePct": {
            "type": "number",
            "description": "Allowed difference between delivered and metered milk (%); above it `mismatch` is true.",
            "x-description-tr": "Teslim edilen ile sayaçların ölçtüğü arasındaki izinli fark (%); aşılınca `mismatch` true olur."
          },
          "sccLimitK": {
            "type": "integer",
            "description": "Somatic cell count limit (thousand cells/mL); above it `highScc` is true.",
            "x-description-tr": "Somatik hücre sınırı (bin hücre/mL); aşılınca `highScc` true olur."
          },
          "items": {
            "type": "array",
            "description": "Deliveries, newest first.",
            "x-description-tr": "Teslimler, yeniden eskiye.",
            "items": {
              "$ref": "#/components/schemas/Delivery"
            }
          }
        }
      },
      "Delivery": {
        "type": "object",
        "description": "One tank delivery (at most one per day) and its comparison with the meters.",
        "x-description-tr": "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": "Delivery id.",
            "x-description-tr": "Teslim kimliği."
          },
          "deliveredOn": {
            "type": "string",
            "format": "date",
            "description": "Delivery day (Istanbul calendar).",
            "x-description-tr": "Teslim günü (İstanbul takvimi)."
          },
          "volumeMl": {
            "type": "integer",
            "format": "int64",
            "description": "Delivered volume (mL).",
            "x-description-tr": "Teslim edilen hacim (mL)."
          },
          "note": {
            "type": "string",
            "description": "Free note; may be empty.",
            "x-description-tr": "Serbest not; boş olabilir."
          },
          "authorName": {
            "type": "string",
            "description": "Name of the person who entered the delivery.",
            "x-description-tr": "Teslimi giren kişinin adı."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the delivery was entered (UTC).",
            "x-description-tr": "Teslimin girildiği an (UTC)."
          },
          "compared": {
            "type": "boolean",
            "description": "Whether a comparison with the meters was made. False for the first delivery, after a gap of more than 7 days and when the meters recorded nothing in the window; then `meteredMl`, `withheldMl` and `diffPct` are 0, `mismatch` is false and `periodFrom` is omitted.",
            "x-description-tr": "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": "First day of the comparison window; only when `compared` is true.",
            "x-description-tr": "Karşılaştırma penceresinin ilk günü; yalnızca `compared` true iken."
          },
          "meteredMl": {
            "type": "integer",
            "format": "int64",
            "description": "Milk measured by the meters in the window that went into the tank (mL).",
            "x-description-tr": "Pencerede sayaçların ölçtüğü ve tanka giden süt (mL)."
          },
          "withheldMl": {
            "type": "integer",
            "format": "int64",
            "description": "Milk measured in the window but withheld (treatment withdrawal), not in the tank (mL).",
            "x-description-tr": "Pencerede ölçülen ama ayrılan (arınma süresi) ve tanka girmeyen süt (mL)."
          },
          "diffPct": {
            "type": "number",
            "description": "(metered − delivered) / delivered × 100, one decimal.",
            "x-description-tr": "(sayaç − teslim) / teslim × 100, bir ondalık."
          },
          "mismatch": {
            "type": "boolean",
            "description": "`|diffPct|` is above `tolerancePct`.",
            "x-description-tr": "`|diffPct|`, `tolerancePct`'yi aşıyor."
          },
          "kgPerLitre": {
            "type": "number",
            "description": "Volume-weighted milk density in the window (kg/L), for converting litres to kilograms; 1.03 when the window has no metered milk (also the first delivery).",
            "x-description-tr": "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": "Dairy analysis — fat (%).",
            "x-description-tr": "Mandıra analizi — yağ (%)."
          },
          "proteinPct": {
            "type": [
              "number",
              "null"
            ],
            "description": "Dairy analysis — protein (%).",
            "x-description-tr": "Mandıra analizi — protein (%)."
          },
          "sccK": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Dairy analysis — somatic cell count (thousand/mL).",
            "x-description-tr": "Mandıra analizi — somatik hücre (bin/mL)."
          },
          "bacteriaK": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Dairy analysis — bacteria count (thousand/mL).",
            "x-description-tr": "Mandıra analizi — bakteri (bin/mL)."
          },
          "highScc": {
            "type": "boolean",
            "description": "`sccK` is above `sccLimitK`.",
            "x-description-tr": "`sccK`, `sccLimitK`'yi aşıyor."
          }
        }
      },
      "DailyYield": {
        "type": "object",
        "description": "One animal's milk on one day.",
        "x-description-tr": "Bir hayvanın bir gündeki sütü.",
        "required": [
          "animalId",
          "earTag",
          "date",
          "totalMl",
          "withheldMl",
          "milkings"
        ],
        "properties": {
          "animalId": {
            "type": "string",
            "format": "uuid",
            "description": "Animal id.",
            "x-description-tr": "Hayvan kimliği."
          },
          "earTag": {
            "type": "string",
            "description": "Ear tag number.",
            "x-description-tr": "Küpe numarası."
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "Day (Europe/Istanbul).",
            "x-description-tr": "Gün (Europe/Istanbul)."
          },
          "totalMl": {
            "type": "integer",
            "format": "int64",
            "description": "Total milk of the day (mL), withheld milk included.",
            "x-description-tr": "Günün toplam sütü (mL), ayrılan süt dahil."
          },
          "withheldMl": {
            "type": "integer",
            "format": "int64",
            "description": "Part of `totalMl` withheld from the tank (treatment withdrawal, mL).",
            "x-description-tr": "`totalMl`'nin tanka katılmayan kısmı (arınma süresi, mL)."
          },
          "milkings": {
            "type": "integer",
            "description": "Number of milkings that day.",
            "x-description-tr": "O günkü sağım sayısı."
          }
        }
      }
    }
  }
}
