{
  "openapi": "3.1.0",
  "info": {
    "title": "MilkTrace API",
    "version": "1.0",
    "summary": "Read-only farm data API for MilkTrace (API key).",
    "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",
    "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)."
    },
    {
      "url": "https://milktrace.com.tr/api/v1",
      "description": "Production."
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "animals",
      "description": "Herd records."
    },
    {
      "name": "deliveries",
      "description": "Milk tank deliveries to the dairy, compared with the meters."
    },
    {
      "name": "exports",
      "description": "Per-animal daily yield for external systems."
    },
    {
      "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"
    }
  ],
  "paths": {
    "/animals": {
      "get": {
        "tags": [
          "animals"
        ],
        "operationId": "listAnimals",
        "summary": "List animals",
        "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",
        "parameters": [
          {
            "name": "speciesId",
            "in": "query",
            "required": false,
            "description": "Only animals of this species (the `speciesId` of an animal). Empty means all.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Animals. `data` is `null` when the farm has no animals (or none of the species).",
            "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",
        "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",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Animal id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The animal.",
            "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",
        "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",
        "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.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deliveries and the farm's limits.",
            "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",
        "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",
        "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.",
            "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.",
            "schema": {
              "type": "string",
              "examples": [
                "2026-10-07"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Animal-day rows (an empty array when nothing was milked).",
            "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",
        "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",
        "security": [],
        "responses": {
          "200": {
            "description": "The gateway is up.",
            "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"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing, invalid or revoked API key (`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.",
        "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`).",
        "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.",
        "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.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "Internal": {
        "description": "Unexpected server error (`INTERNAL`); details are never returned.",
        "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.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      }
    },
    "schemas": {
      "Envelope": {
        "type": "object",
        "description": "Response envelope shared by every endpoint.",
        "required": [
          "success",
          "msg"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "`true` on success, `false` on error."
          },
          "data": {
            "description": "The payload; see each endpoint."
          },
          "msg": {
            "type": "string",
            "description": "Short human-readable message in the request language (`Accept-Language`)."
          },
          "totalPages": {
            "type": "integer",
            "description": "Legacy field, not meaningful for these endpoints; ignore it."
          },
          "total": {
            "type": "integer",
            "description": "Legacy field, omitted by these endpoints."
          },
          "traceId": {
            "type": "string",
            "description": "Request trace id; quote it when contacting support."
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "ErrorEnvelope": {
        "description": "Error response.",
        "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.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable error code.",
            "enum": [
              "VALIDATION",
              "NOT_FOUND",
              "CONFLICT",
              "UNAUTHORIZED",
              "FORBIDDEN",
              "UNAVAILABLE",
              "TOO_MANY_REQUESTS",
              "INTERNAL"
            ]
          },
          "message": {
            "type": "string",
            "description": "Human-readable message in the request language."
          }
        }
      },
      "Animal": {
        "type": "object",
        "description": "An animal of the herd. Optional fields are omitted when empty.",
        "required": [
          "id",
          "speciesId",
          "earTag",
          "lactationNo",
          "status",
          "yieldClass"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Animal id."
          },
          "speciesId": {
            "type": "string",
            "format": "uuid",
            "description": "Species id (cow, sheep, goat …)."
          },
          "earTag": {
            "type": "string",
            "description": "Ear tag number, unique within the farm."
          },
          "rfid": {
            "type": "string",
            "description": "RFID tag read at the milking point."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "breed": {
            "type": "string",
            "description": "Breed."
          },
          "birthDate": {
            "type": "string",
            "format": "date-time",
            "description": "Birth date (calendar day at 00:00 UTC)."
          },
          "lastCalvingDate": {
            "type": "string",
            "format": "date-time",
            "description": "Last calving date (calendar day at 00:00 UTC)."
          },
          "lactationNo": {
            "type": "integer",
            "minimum": 0,
            "description": "Lactation number."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dry",
              "sold",
              "slaughtered",
              "dead"
            ],
            "description": "`active` milking, `dry` dried off, `sold`, `slaughtered`, `dead` (left the herd)."
          },
          "yieldClass": {
            "type": "string",
            "enum": [
              "high",
              "normal",
              "declining",
              "dry_off_candidate",
              "no_milk"
            ],
            "description": "Yield class from the nightly calculation."
          },
          "yieldClassAt": {
            "type": "string",
            "format": "date-time",
            "description": "Day the yield class was calculated; it freezes when the animal stops milking."
          },
          "withdrawalUntil": {
            "type": "string",
            "format": "date-time",
            "description": "Last day of a treatment withdrawal period; until then its milk does not go into the tank."
          },
          "pregnancy": {
            "$ref": "#/components/schemas/Pregnancy"
          },
          "groupId": {
            "type": "string",
            "format": "uuid",
            "description": "Animal group id."
          },
          "groupName": {
            "type": "string",
            "description": "Animal group name."
          },
          "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)."
          },
          "exitedOn": {
            "type": "string",
            "format": "date-time",
            "description": "Day the animal left the herd."
          },
          "damId": {
            "type": "string",
            "format": "uuid",
            "description": "Dam (mother) in the herd."
          },
          "damEarTag": {
            "type": "string",
            "description": "Dam's ear tag."
          },
          "sireCode": {
            "type": "string",
            "description": "Sire (bull or semen) code."
          },
          "offspring": {
            "type": "array",
            "description": "Offspring; only when reading a single animal.",
            "items": {
              "$ref": "#/components/schemas/AnimalBrief"
            }
          }
        }
      },
      "AnimalBrief": {
        "type": "object",
        "description": "Short animal row (offspring).",
        "required": [
          "id",
          "earTag",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Animal id."
          },
          "earTag": {
            "type": "string",
            "description": "Ear tag number."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "birthDate": {
            "type": "string",
            "format": "date-time",
            "description": "Birth date (calendar day at 00:00 UTC)."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "dry",
              "sold",
              "slaughtered",
              "dead"
            ],
            "description": "Status, as in `Animal.status`."
          }
        }
      },
      "Pregnancy": {
        "type": "object",
        "description": "Breeding status; omitted when the animal has no breeding record.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "open",
              "inseminated",
              "pregnant"
            ],
            "description": "`open` not pregnant, `inseminated` awaiting a pregnancy check, `pregnant`."
          },
          "lastInsemination": {
            "type": "string",
            "format": "date-time",
            "description": "Last insemination day."
          },
          "expectedCalving": {
            "type": "string",
            "format": "date-time",
            "description": "Expected calving (last insemination + the species' gestation)."
          },
          "dryOffDate": {
            "type": "string",
            "format": "date-time",
            "description": "Suggested dry-off day (expected calving − dry period)."
          },
          "lastHeat": {
            "type": "string",
            "format": "date-time",
            "description": "Last observed heat in this lactation."
          },
          "expectedHeat": {
            "type": "string",
            "format": "date-time",
            "description": "Next expected heat (last heat + 21 days) when not inseminated since and not pregnant."
          }
        }
      },
      "Deliveries": {
        "type": "object",
        "description": "Delivery list with the farm's limits.",
        "required": [
          "tolerancePct",
          "sccLimitK",
          "items"
        ],
        "properties": {
          "tolerancePct": {
            "type": "number",
            "description": "Allowed difference between delivered and metered milk (%); above it `mismatch` is true."
          },
          "sccLimitK": {
            "type": "integer",
            "description": "Somatic cell count limit (thousand cells/mL); above it `highScc` is true."
          },
          "items": {
            "type": "array",
            "description": "Deliveries, newest first.",
            "items": {
              "$ref": "#/components/schemas/Delivery"
            }
          }
        }
      },
      "Delivery": {
        "type": "object",
        "description": "One tank delivery (at most one per day) and its comparison with the meters.",
        "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."
          },
          "deliveredOn": {
            "type": "string",
            "format": "date",
            "description": "Delivery day (Istanbul calendar)."
          },
          "volumeMl": {
            "type": "integer",
            "format": "int64",
            "description": "Delivered volume (mL)."
          },
          "note": {
            "type": "string",
            "description": "Free note; may be empty."
          },
          "authorName": {
            "type": "string",
            "description": "Name of the person who entered the delivery."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the delivery was entered (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."
          },
          "periodFrom": {
            "type": "string",
            "format": "date",
            "description": "First day of the comparison window; only when `compared` is true."
          },
          "meteredMl": {
            "type": "integer",
            "format": "int64",
            "description": "Milk measured by the meters in the window that went into the tank (mL)."
          },
          "withheldMl": {
            "type": "integer",
            "format": "int64",
            "description": "Milk measured in the window but withheld (treatment withdrawal), not in the tank (mL)."
          },
          "diffPct": {
            "type": "number",
            "description": "(metered − delivered) / delivered × 100, one decimal."
          },
          "mismatch": {
            "type": "boolean",
            "description": "`|diffPct|` is above `tolerancePct`."
          },
          "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)."
          },
          "fatPct": {
            "type": [
              "number",
              "null"
            ],
            "description": "Dairy analysis — fat (%)."
          },
          "proteinPct": {
            "type": [
              "number",
              "null"
            ],
            "description": "Dairy analysis — protein (%)."
          },
          "sccK": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Dairy analysis — somatic cell count (thousand/mL)."
          },
          "bacteriaK": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Dairy analysis — bacteria count (thousand/mL)."
          },
          "highScc": {
            "type": "boolean",
            "description": "`sccK` is above `sccLimitK`."
          }
        }
      },
      "DailyYield": {
        "type": "object",
        "description": "One animal's milk on one day.",
        "required": [
          "animalId",
          "earTag",
          "date",
          "totalMl",
          "withheldMl",
          "milkings"
        ],
        "properties": {
          "animalId": {
            "type": "string",
            "format": "uuid",
            "description": "Animal id."
          },
          "earTag": {
            "type": "string",
            "description": "Ear tag number."
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "Day (Europe/Istanbul)."
          },
          "totalMl": {
            "type": "integer",
            "format": "int64",
            "description": "Total milk of the day (mL), withheld milk included."
          },
          "withheldMl": {
            "type": "integer",
            "format": "int64",
            "description": "Part of `totalMl` withheld from the tank (treatment withdrawal, mL)."
          },
          "milkings": {
            "type": "integer",
            "description": "Number of milkings that day."
          }
        }
      }
    }
  }
}
