{"openapi":"3.0.0","info":{"title":"Cruiz Farm API","version":"0.1.0"},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"ErrorDetail":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}},"Ok":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]},"AuthResponse":{"type":"object","properties":{"accessToken":{"type":"string"},"refreshToken":{"type":"string"}},"required":["accessToken","refreshToken"]},"AiAliasListConversationsQuery":{"type":"object","properties":{"farmId":{"type":"string","format":"uuid"}},"required":["farmId"]},"AiAliasListMessagesQuery":{"type":"object","properties":{"farmId":{"type":"string","format":"uuid"},"conversationId":{"type":"string","format":"uuid"}},"required":["farmId","conversationId"]},"AiAliasSendMessageBody":{"type":"object","properties":{"farmId":{"type":"string","format":"uuid"},"conversationId":{"type":"string","format":"uuid"},"message":{"type":"string","minLength":1,"maxLength":4000}},"required":["farmId","conversationId","message"],"additionalProperties":false},"AiConversationListResponse":{"type":"object","properties":{"conversations":{"type":"array","items":{"$ref":"#/components/schemas/AiConversation"}}},"required":["conversations"]},"AiConversation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"createdByUserId":{"type":"string","format":"uuid"},"title":{"type":"string","nullable":true},"status":{"type":"string"},"lastMessageAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","createdByUserId","title","status","lastMessageAt","createdAt","updatedAt"]},"AiHealth":{"type":"object","properties":{"providerMode":{"type":"string","enum":["mock","openrouter"]},"queueDriver":{"type":"string","enum":["inline","bullmq"]},"redis":{"type":"string","enum":["ok","error"]},"queue":{"type":"string","enum":["ok","error"]}},"required":["providerMode","queueDriver","redis","queue"]},"AiMessageListResponse":{"type":"object","properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/AiMessage"}}},"required":["messages"]},"AiMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"conversationId":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userId":{"type":"string","nullable":true,"format":"uuid"},"role":{"type":"string","enum":["user","assistant","system","tool"]},"status":{"type":"string","enum":["pending","processing","completed","failed"]},"contentText":{"type":"string","nullable":true},"contentJson":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"model":{"type":"string","nullable":true},"errorCode":{"type":"string","nullable":true},"errorMessage":{"type":"string","nullable":true},"toolName":{"type":"string","nullable":true},"toolCallId":{"type":"string","nullable":true},"sequence":{"type":"integer"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","conversationId","farmId","userId","role","status","contentText","contentJson","model","errorCode","errorMessage","toolName","toolCallId","sequence","createdAt","updatedAt"]},"AiRun":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"conversationId":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userMessageId":{"type":"string","format":"uuid"},"assistantMessageId":{"type":"string","format":"uuid"},"requestedByUserId":{"type":"string","format":"uuid"},"provider":{"type":"string"},"plannerModel":{"type":"string","nullable":true},"executorModel":{"type":"string","nullable":true},"status":{"type":"string","enum":["queued","processing","completed","failed","cancelled"]},"step":{"type":"string","nullable":true},"toolCallsCount":{"type":"integer"},"errorCode":{"type":"string","nullable":true},"errorMessage":{"type":"string","nullable":true},"startedAt":{"type":"string","nullable":true,"format":"date-time"},"completedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","conversationId","farmId","userMessageId","assistantMessageId","requestedByUserId","provider","plannerModel","executorModel","status","step","toolCallsCount","errorCode","errorMessage","startedAt","completedAt","createdAt","updatedAt"]},"AiSendMessageResponse":{"type":"object","properties":{"userMessage":{"$ref":"#/components/schemas/AiMessage"},"assistantMessage":{"$ref":"#/components/schemas/AiMessage"},"run":{"$ref":"#/components/schemas/AiRun"}},"required":["userMessage","assistantMessage","run"]},"CreateConversationBody":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":160}},"additionalProperties":false},"SendMessageBody":{"type":"object","properties":{"message":{"type":"string","minLength":1,"maxLength":4000}},"required":["message"],"additionalProperties":false},"AssetCategory":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"AssetListResponse":{"type":"object","properties":{"assets":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetTag":{"type":"string"},"name":{"type":"string"},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"lastServiceAt":{"type":"string","nullable":true,"format":"date-time"},"imageAssetId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetTag","name","category","status","location","notes","lastServiceAt","imageAssetId","createdBy","updatedBy","createdAt","updatedAt"]}}},"required":["assets"]},"Asset":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetTag":{"type":"string"},"name":{"type":"string"},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"lastServiceAt":{"type":"string","nullable":true,"format":"date-time"},"imageAssetId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetTag","name","category","status","location","notes","lastServiceAt","imageAssetId","createdBy","updatedBy","createdAt","updatedAt"]},"AssetStatus":{"type":"string","enum":["working","needs_service"]},"CreateAssetBody":{"type":"object","properties":{"assetTag":{"type":"string","minLength":1,"maxLength":64},"name":{"type":"string","minLength":1,"maxLength":255},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","minLength":1,"maxLength":255},"notes":{"type":"string","minLength":1,"maxLength":2000},"lastServiceAt":{"type":"string","format":"date-time"},"imageAssetId":{"type":"string","format":"uuid"}},"required":["assetTag","name","category"],"additionalProperties":false},"PatchAssetBody":{"type":"object","properties":{"assetTag":{"type":"string","minLength":1,"maxLength":64},"name":{"type":"string","minLength":1,"maxLength":255},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"anyOf":[{"type":"string","minLength":1,"maxLength":255},{"nullable":true}]},"notes":{"anyOf":[{"type":"string","minLength":1,"maxLength":2000},{"nullable":true}]},"lastServiceAt":{"anyOf":[{"type":"string","format":"date-time"},{"nullable":true}]},"imageAssetId":{"anyOf":[{"type":"string","format":"uuid"},{"nullable":true}]}},"additionalProperties":false},"BirthEventData":{"type":"object","properties":{"calfSex":{"type":"string","enum":["female","male"]},"calfTagNumber":{"type":"string","minLength":1},"calfCount":{"type":"integer","minimum":1},"birthComplications":{"type":"string","minLength":1},"assisted":{"type":"string","enum":["yes","no"]},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"CalvingEventData":{"type":"object","properties":{"calfSex":{"type":"string","enum":["female","male"]},"calfTagNumber":{"type":"string","minLength":1},"calfCount":{"type":"integer","minimum":1},"calvingEase":{"type":"string","enum":["unassisted","assisted","difficult"]},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"CattleBreedingFlags":{"type":"object","properties":{"awaitingPregCheck":{"type":"boolean"},"pregCheckOverdue":{"type":"boolean"},"calvingWindowActive":{"type":"boolean"}},"required":["awaitingPregCheck","pregCheckOverdue","calvingWindowActive"]},"CattleBreedingMilestones":{"type":"object","properties":{"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"daysSinceService":{"type":"integer","nullable":true},"daysToExpectedCalving":{"type":"integer","nullable":true}},"required":["servedDate","expectedDeliveryDate","daysSinceService","daysToExpectedCalving"]},"CattleBreedingSummary":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]},"applicable":{"type":"boolean"},"reproductiveStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"latestBreedingEvent":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]},"breedingTimeline":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"milestones":{"type":"object","properties":{"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"daysSinceService":{"type":"integer","nullable":true},"daysToExpectedCalving":{"type":"integer","nullable":true}},"required":["servedDate","expectedDeliveryDate","daysSinceService","daysToExpectedCalving"]},"flags":{"type":"object","properties":{"awaitingPregCheck":{"type":"boolean"},"pregCheckOverdue":{"type":"boolean"},"calvingWindowActive":{"type":"boolean"}},"required":["awaitingPregCheck","pregCheckOverdue","calvingWindowActive"]},"nextAction":{"type":"object","nullable":true,"properties":{"title":{"type":"string"},"description":{"type":"string"},"tone":{"type":"string","enum":["info","warning","success"]}},"required":["title","description","tone"]}},"required":["cattle","applicable","reproductiveStatus","latestBreedingEvent","breedingTimeline","milestones","flags","nextAction"]},"CattleEventListResponse":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["events","nextCursor","totalCount"]},"CattleEvent":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]},"CattleEventSortField":{"type":"string","enum":["date","createdAt"]},"CattleEventType":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"CattleHealthCounts":{"type":"object","properties":{"vaccination":{"type":"number"},"deworming":{"type":"number"},"dehorning":{"type":"number"},"treatment":{"type":"number"},"diagnosis":{"type":"number"},"weight":{"type":"number"},"note":{"type":"number"}},"required":["vaccination","deworming","dehorning","treatment","diagnosis","weight","note"]},"CattleHealthFlags":{"type":"object","properties":{"hasOpenTreatmentAttention":{"type":"boolean"},"hasMilkWithdrawalAttention":{"type":"boolean"},"hasWeightStalenessAttention":{"type":"boolean"}},"required":["hasOpenTreatmentAttention","hasMilkWithdrawalAttention","hasWeightStalenessAttention"]},"CattleHealthSummary":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]},"healthScore":{"type":"integer","minimum":0,"maximum":100},"latestHealthEvent":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]},"recentHealthEvents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"counts":{"type":"object","properties":{"vaccination":{"type":"number"},"deworming":{"type":"number"},"dehorning":{"type":"number"},"treatment":{"type":"number"},"diagnosis":{"type":"number"},"weight":{"type":"number"},"note":{"type":"number"}},"required":["vaccination","deworming","dehorning","treatment","diagnosis","weight","note"]},"flags":{"type":"object","properties":{"hasOpenTreatmentAttention":{"type":"boolean"},"hasMilkWithdrawalAttention":{"type":"boolean"},"hasWeightStalenessAttention":{"type":"boolean"}},"required":["hasOpenTreatmentAttention","hasMilkWithdrawalAttention","hasWeightStalenessAttention"]},"nextAction":{"type":"object","nullable":true,"properties":{"title":{"type":"string"},"description":{"type":"string"},"tone":{"type":"string","enum":["info","warning","success"]}},"required":["title","description","tone"]}},"required":["cattle","healthScore","latestHealthEvent","recentHealthEvents","counts","flags","nextAction"]},"CattleImageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"CattleListResponse":{"type":"object","properties":{"cattle":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["cattle","nextCursor","totalCount"]},"CattleOverviewFacts":{"type":"object","properties":{"ageLabel":{"type":"string"},"breed":{"type":"string","nullable":true},"currentLocation":{"type":"string","nullable":true},"source":{"type":"string","enum":["born_on_farm","purchased"]},"sex":{"type":"string","enum":["female","male"]}},"required":["ageLabel","breed","currentLocation","source","sex"]},"CattleOverviewSummary":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]},"statusChips":{"type":"object","properties":{"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]}},"required":["status","productionStatus","reproStatus"]},"photo":{"type":"object","properties":{"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5}},"required":["profileMediaId","imageMediaIds"]},"facts":{"type":"object","properties":{"ageLabel":{"type":"string"},"breed":{"type":"string","nullable":true},"currentLocation":{"type":"string","nullable":true},"source":{"type":"string","enum":["born_on_farm","purchased"]},"sex":{"type":"string","enum":["female","male"]}},"required":["ageLabel","breed","currentLocation","source","sex"]},"latestEvent":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"required":["cattle","statusChips","photo","facts","latestEvent"]},"CattlePhotoSummary":{"type":"object","properties":{"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5}},"required":["profileMediaId","imageMediaIds"]},"CattleProductionStatus":{"type":"string","enum":["calf","heifer","lactating","dry"]},"CattleReproStatus":{"type":"string","enum":["open","served","pregnant"]},"Cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]},"CattleSex":{"type":"string","enum":["female","male"]},"CattleSortField":{"type":"string","enum":["createdAt","updatedAt","tagNumber","status"]},"CattleSource":{"type":"string","enum":["born_on_farm","purchased"]},"CattleStatusChipSummary":{"type":"object","properties":{"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]}},"required":["status","productionStatus","reproStatus"]},"CattleStatus":{"type":"string","enum":["active","sold","dead"]},"CattleSummary":{"type":"object","properties":{"total":{"type":"number"},"active":{"type":"number"},"sold":{"type":"number"},"dead":{"type":"number"},"lactating":{"type":"number"},"dry":{"type":"number"},"pregnant":{"type":"number"},"heifers":{"type":"number"},"calves":{"type":"number"}},"required":["total","active","sold","dead","lactating","dry","pregnant","heifers","calves"]},"CattleTabActionTone":{"type":"string","enum":["info","warning","success"]},"CattleTabNextAction":{"type":"object","properties":{"title":{"type":"string"},"description":{"type":"string"},"tone":{"type":"string","enum":["info","warning","success"]}},"required":["title","description","tone"]},"DeathEventData":{"type":"object","properties":{"cause":{"type":"string","minLength":1},"vetReport":{"type":"string","minLength":1},"foundAt":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"DehorningEventData":{"type":"object","properties":{"method":{"type":"string","minLength":1},"performedBy":{"type":"string","minLength":1},"ageAtProcedure":{"type":"string","minLength":1},"painManagement":{"type":"string","minLength":1},"complications":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"DewormingEventData":{"type":"object","properties":{"drug":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["drug"],"additionalProperties":false},"DiagnosisEventData":{"type":"object","properties":{"diagnosis":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["diagnosis"],"additionalProperties":false},"HeatEventData":{"type":"object","properties":{"observedBy":{"type":"string","minLength":1},"signs":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"InseminationEventData":{"type":"object","properties":{"method":{"type":"string","enum":["AI","BULL"]},"bullTagOrName":{"type":"string","minLength":1},"semenBatch":{"type":"string","minLength":1},"technician":{"type":"string","minLength":1},"heatObservedAt":{"type":"string","format":"date-time"},"observedBy":{"type":"string","minLength":1},"serviceLocation":{"type":"string","minLength":1},"cost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"required":["method"],"additionalProperties":false},"NoteEventData":{"type":"object","properties":{"note":{"type":"string","minLength":1}},"required":["note"],"additionalProperties":false},"OptionalNotes":{"type":"object","properties":{"notes":{"type":"string","minLength":1}}},"PregCheckEventData":{"type":"object","properties":{"result":{"type":"string","enum":["pregnant","not_pregnant"]},"method":{"type":"string","enum":["palpation","ultrasound"]},"expectedCalvingDate":{"type":"string","format":"date-time"},"fetusCount":{"type":"integer","minimum":1},"notes":{"type":"string","minLength":1}},"required":["result"],"additionalProperties":false},"PurchaseEventData":{"type":"object","properties":{"seller":{"type":"string","minLength":1},"amount":{"type":"number","minimum":0},"currency":{"type":"string","minLength":1},"purchaseLocation":{"type":"string","minLength":1},"transportCost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"SaleEventData":{"type":"object","properties":{"buyer":{"type":"string","minLength":1},"buyerContact":{"type":"string","minLength":1},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"reason":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["amount"],"additionalProperties":false},"TreatmentEventData":{"type":"object","properties":{"condition":{"type":"string","minLength":1},"drug":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"route":{"type":"string","minLength":1},"withdrawalDaysMilk":{"type":"integer","minimum":0},"withdrawalDaysMeat":{"type":"integer","minimum":0},"treatmentOutcome":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"cost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"required":["drug"],"additionalProperties":false},"VaccinationEventData":{"type":"object","properties":{"vaccine":{"type":"string","minLength":1},"batch":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"method":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["vaccine"],"additionalProperties":false},"WeightEventData":{"type":"object","properties":{"weightKg":{"type":"number","minimum":0,"exclusiveMinimum":true},"method":{"type":"string","enum":["tape","scale"]},"bodyConditionScore":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["weightKg"],"additionalProperties":false},"CattleEventListQuery":{"type":"object","properties":{"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"cursor":{"type":"string","minLength":1},"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"cattleId":{"type":"string","format":"uuid"},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, type, cattleId. Individual query parameters take precedence over values in this JSON."},"sortBy":{"type":"string","enum":["date","createdAt"],"description":"Sort cattle event field. Allowed values: date, createdAt. Default: date (desc)."},"sortDir":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected cattle event field. Allowed values: asc, desc. Default: date (desc)."}},"additionalProperties":false},"CattleListQuery":{"type":"object","properties":{"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"cursor":{"type":"string","minLength":1},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","enum":["calf","heifer","lactating","dry"]},"reproStatus":{"type":"string","enum":["open","served","pregnant"]},"sex":{"type":"string","enum":["female","male"]},"source":{"type":"string","enum":["born_on_farm","purchased"]},"q":{"type":"string","minLength":1},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: status, productionStatus, reproStatus, sex, source, q. Individual query parameters take precedence over values in this JSON."},"sortBy":{"type":"string","enum":["createdAt","updatedAt","tagNumber","status"],"description":"Sort cattle field. Allowed values: createdAt, updatedAt, tagNumber, status. Default: createdAt (desc)."},"sortDir":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected cattle field. Allowed values: asc, desc. Default: createdAt (desc)."}},"additionalProperties":false},"CreateCattleBody":{"type":"object","properties":{"tagNumber":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","minLength":1},"dob":{"type":"string","format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","format":"date-time"},"purchasePrice":{"type":"number","minimum":0},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","enum":["calf","heifer","lactating","dry"]},"reproStatus":{"type":"string","enum":["open","served","pregnant"]},"servedDate":{"type":"string","format":"date-time"},"expectedDeliveryDate":{"type":"string","format":"date-time"},"currentLocation":{"type":"string","minLength":1,"maxLength":255},"notes":{"type":"string","minLength":1},"profileMediaId":{"type":"string","format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5}},"required":["tagNumber","sex","source"],"additionalProperties":false},"CreateEventBody":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["BIRTH"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"calfSex":{"type":"string","enum":["female","male"]},"calfTagNumber":{"type":"string","minLength":1},"calfCount":{"type":"integer","minimum":1},"birthComplications":{"type":"string","minLength":1},"assisted":{"type":"string","enum":["yes","no"]},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["PURCHASE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"seller":{"type":"string","minLength":1},"amount":{"type":"number","minimum":0},"currency":{"type":"string","minLength":1},"purchaseLocation":{"type":"string","minLength":1},"transportCost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["WEIGHT"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"weightKg":{"type":"number","minimum":0,"exclusiveMinimum":true},"method":{"type":"string","enum":["tape","scale"]},"bodyConditionScore":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["weightKg"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["HEAT"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"observedBy":{"type":"string","minLength":1},"signs":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["INSEMINATION"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"method":{"type":"string","enum":["AI","BULL"]},"bullTagOrName":{"type":"string","minLength":1},"semenBatch":{"type":"string","minLength":1},"technician":{"type":"string","minLength":1},"heatObservedAt":{"type":"string","format":"date-time"},"observedBy":{"type":"string","minLength":1},"serviceLocation":{"type":"string","minLength":1},"cost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"required":["method"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["PREG_CHECK"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"result":{"type":"string","enum":["pregnant","not_pregnant"]},"method":{"type":"string","enum":["palpation","ultrasound"]},"expectedCalvingDate":{"type":"string","format":"date-time"},"fetusCount":{"type":"integer","minimum":1},"notes":{"type":"string","minLength":1}},"required":["result"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["CALVING"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"calfSex":{"type":"string","enum":["female","male"]},"calfTagNumber":{"type":"string","minLength":1},"calfCount":{"type":"integer","minimum":1},"calvingEase":{"type":"string","enum":["unassisted","assisted","difficult"]},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["VACCINATION"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"vaccine":{"type":"string","minLength":1},"batch":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"method":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["vaccine"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DEWORMING"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"drug":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["drug"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DEHORNING"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"method":{"type":"string","minLength":1},"performedBy":{"type":"string","minLength":1},"ageAtProcedure":{"type":"string","minLength":1},"painManagement":{"type":"string","minLength":1},"complications":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["TREATMENT"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"condition":{"type":"string","minLength":1},"drug":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"route":{"type":"string","minLength":1},"withdrawalDaysMilk":{"type":"integer","minimum":0},"withdrawalDaysMeat":{"type":"integer","minimum":0},"treatmentOutcome":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"cost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"required":["drug"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DIAGNOSIS"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"diagnosis":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["diagnosis"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["SALE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"buyer":{"type":"string","minLength":1},"buyerContact":{"type":"string","minLength":1},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"reason":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["amount"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DEATH"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"cause":{"type":"string","minLength":1},"vetReport":{"type":"string","minLength":1},"foundAt":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"note":{"type":"string","minLength":1}},"required":["note"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false}]},"PatchCattleBody":{"type":"object","properties":{"tagNumber":{"type":"string","minLength":1},"name":{"type":"string","nullable":true,"minLength":1},"breed":{"type":"string","nullable":true,"minLength":1},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true,"minimum":0},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"anyOf":[{"type":"string","minLength":1,"maxLength":255},{"nullable":true}]},"notes":{"type":"string","nullable":true,"minLength":1},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5}},"additionalProperties":false},"PatchEventBody":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"}},"additionalProperties":false},"ErrorEvent":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"requestId":{"type":"string","nullable":true},"traceId":{"type":"string","nullable":true},"code":{"type":"string"},"domain":{"type":"string"},"type":{"type":"string"},"severity":{"type":"string"},"exposure":{"type":"string"},"status":{"type":"integer"},"message":{"type":"string"},"displayTitle":{"type":"string","nullable":true},"displayMessage":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"causeMessage":{"type":"string","nullable":true},"stack":{"type":"string","nullable":true},"service":{"type":"string"},"component":{"type":"string","nullable":true},"operation":{"type":"string","nullable":true},"method":{"type":"string","nullable":true},"path":{"type":"string","nullable":true},"userId":{"type":"string","nullable":true,"format":"uuid"},"farmId":{"type":"string","nullable":true,"format":"uuid"},"metadata":{"type":"object","additionalProperties":{"nullable":true}},"firstSeenAt":{"type":"string","format":"date-time"},"lastSeenAt":{"type":"string","format":"date-time"},"occurredAt":{"type":"string","format":"date-time"},"resolvedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","requestId","traceId","code","domain","type","severity","exposure","status","message","displayTitle","displayMessage","details","causeMessage","stack","service","component","operation","method","path","userId","farmId","metadata","firstSeenAt","lastSeenAt","occurredAt","resolvedAt"]},"ErrorEventSortField":{"type":"string","enum":["occurredAt","firstSeenAt","lastSeenAt","status","severity","code"]},"ErrorEventsListResponse":{"type":"object","properties":{"errorEvents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"requestId":{"type":"string","nullable":true},"traceId":{"type":"string","nullable":true},"code":{"type":"string"},"domain":{"type":"string"},"type":{"type":"string"},"severity":{"type":"string"},"exposure":{"type":"string"},"status":{"type":"integer"},"message":{"type":"string"},"displayTitle":{"type":"string","nullable":true},"displayMessage":{"type":"string","nullable":true},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"causeMessage":{"type":"string","nullable":true},"stack":{"type":"string","nullable":true},"service":{"type":"string"},"component":{"type":"string","nullable":true},"operation":{"type":"string","nullable":true},"method":{"type":"string","nullable":true},"path":{"type":"string","nullable":true},"userId":{"type":"string","nullable":true,"format":"uuid"},"farmId":{"type":"string","nullable":true,"format":"uuid"},"metadata":{"type":"object","additionalProperties":{"nullable":true}},"firstSeenAt":{"type":"string","format":"date-time"},"lastSeenAt":{"type":"string","format":"date-time"},"occurredAt":{"type":"string","format":"date-time"},"resolvedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","requestId","traceId","code","domain","type","severity","exposure","status","message","displayTitle","displayMessage","details","causeMessage","stack","service","component","operation","method","path","userId","farmId","metadata","firstSeenAt","lastSeenAt","occurredAt","resolvedAt"]}},"count":{"type":"integer","minimum":0}},"required":["errorEvents","count"]},"ErrorEventsQuery":{"type":"object","properties":{"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":200,"default":50,"example":50,"description":"Maximum number of recent error events to return."},"code":{"type":"string","minLength":1},"domain":{"type":"string","minLength":1},"severity":{"type":"string","minLength":1},"status":{"type":"integer","minimum":100,"maximum":599},"requestId":{"type":"string","minLength":1},"userId":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"component":{"type":"string","minLength":1},"operation":{"type":"string","minLength":1},"method":{"type":"string","minLength":1},"path":{"type":"string","minLength":1,"description":"Substring match against the stored request path."},"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"sortBy":{"type":"string","enum":["occurredAt","firstSeenAt","lastSeenAt","status","severity","code"],"description":"Sort error event field. Allowed values: occurredAt, firstSeenAt, lastSeenAt, status, severity, code. Default: occurredAt (desc)."},"sortDir":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected error event field. Allowed values: asc, desc. Default: occurredAt (desc)."}},"additionalProperties":false},"CreateFarmImageBody":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"caption":{"anyOf":[{"type":"string","minLength":1,"maxLength":500},{"nullable":true}]},"category":{"anyOf":[{"type":"string","enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other"]},{"nullable":true}]},"sortOrder":{"type":"integer","minimum":0},"isPrimary":{"type":"boolean"}},"required":["assetId"],"additionalProperties":false},"FarmIdParam":{"type":"object","properties":{"farmId":{"type":"string","format":"uuid"}},"required":["farmId"]},"FarmImageCategory":{"type":"string","enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other"]},"FarmImageIdParam":{"type":"object","properties":{"imageId":{"type":"string","format":"uuid"}},"required":["imageId"]},"FarmImageList":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"caption":{"type":"string","nullable":true},"category":{"type":"string","nullable":true,"enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other",null]},"sortOrder":{"type":"integer"},"isPrimary":{"type":"boolean"},"image":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetId","caption","category","sortOrder","isPrimary","image","createdAt","updatedAt"]}}},"required":["items"]},"FarmImage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"caption":{"type":"string","nullable":true},"category":{"type":"string","nullable":true,"enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other",null]},"sortOrder":{"type":"integer"},"isPrimary":{"type":"boolean"},"image":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetId","caption","category","sortOrder","isPrimary","image","createdAt","updatedAt"]},"FarmImageSortField":{"type":"string","enum":["isPrimary","sortOrder","createdAt","updatedAt","category"]},"FarmProfile":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"locationName":{"type":"string","nullable":true},"googleMapsUrl":{"type":"string","nullable":true,"format":"uri"},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"coverImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"coverImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","name","description","locationName","googleMapsUrl","profileImageAssetId","coverImageAssetId","profileImage","coverImage","createdAt","updatedAt"]},"FarmResolvedImage":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"PatchFarmBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"description":{"anyOf":[{"type":"string","minLength":1,"maxLength":2000},{"nullable":true}]},"locationName":{"anyOf":[{"type":"string","minLength":1,"maxLength":255},{"nullable":true}]},"googleMapsUrl":{"anyOf":[{"type":"string","maxLength":2048,"format":"uri"},{"nullable":true}]},"profileImageAssetId":{"anyOf":[{"type":"string","format":"uuid"},{"nullable":true}]},"coverImageAssetId":{"anyOf":[{"type":"string","format":"uuid"},{"nullable":true}]}},"additionalProperties":false},"PatchFarmImageBody":{"type":"object","properties":{"caption":{"anyOf":[{"type":"string","minLength":1,"maxLength":500},{"nullable":true}]},"category":{"anyOf":[{"type":"string","enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other"]},{"nullable":true}]},"sortOrder":{"type":"integer","minimum":0},"isPrimary":{"type":"boolean"}},"additionalProperties":false},"ReorderFarmImagesBody":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"imageId":{"type":"string","format":"uuid"},"sortOrder":{"type":"integer","minimum":0}},"required":["imageId","sortOrder"]},"minItems":1}},"required":["items"],"additionalProperties":false},"BudgetListResponse":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"categoryId":{"type":"string","format":"uuid"},"name":{"type":"string"},"periodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"budgetAmount":{"type":"number"},"alertThresholdPercent":{"type":"integer","nullable":true},"isActive":{"type":"boolean"},"createdBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","categoryId","name","periodType","startDate","endDate","budgetAmount","alertThresholdPercent","isActive","createdBy","createdAt","updatedAt"]}}},"required":["items"]},"BudgetPeriodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"Budget":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"categoryId":{"type":"string","format":"uuid"},"name":{"type":"string"},"periodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"budgetAmount":{"type":"number"},"alertThresholdPercent":{"type":"integer","nullable":true},"isActive":{"type":"boolean"},"createdBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","categoryId","name","periodType","startDate","endDate","budgetAmount","alertThresholdPercent","isActive","createdBy","createdAt","updatedAt"]},"BudgetSortField":{"type":"string","enum":["startDate","endDate","createdAt","budgetAmount","name"]},"BudgetVsActual":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"items":{"type":"array","items":{"type":"object","properties":{"budgetId":{"type":"string","format":"uuid"},"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"budgetAmount":{"type":"number"},"actualSpend":{"type":"number"},"variance":{"type":"number"},"percentUsed":{"type":"number","nullable":true},"status":{"type":"string","enum":["ok","warning","over_budget"]}},"required":["budgetId","categoryId","categoryName","budgetAmount","actualSpend","variance","percentUsed","status"]}}},"required":["period","items"]},"CashFlowGroupBy":{"type":"string","enum":["day","week","month"]},"CashFlowReport":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"groupBy":{"type":"string","enum":["day","week","month"]}},"required":["startDate","endDate","groupBy"]},"moneyIn":{"type":"number"},"moneyOut":{"type":"number"},"netMovement":{"type":"number"},"groups":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"moneyIn":{"type":"number"},"moneyOut":{"type":"number"},"netMovement":{"type":"number"}},"required":["key","moneyIn","moneyOut","netMovement"]}}},"required":["period","moneyIn","moneyOut","netMovement","groups"]},"CostPerLitre":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalMilkLitres":{"type":"number"},"totalDairyExpenses":{"type":"number"},"costPerLitre":{"type":"number","nullable":true},"averageSellingPricePerLitre":{"type":"number","nullable":true},"grossMarginPerLitre":{"type":"number","nullable":true}},"required":["period","totalMilkLitres","totalDairyExpenses","costPerLitre","averageSellingPricePerLitre","grossMarginPerLitre"]},"CounterpartySortField":{"type":"string","enum":["name","type","createdAt","updatedAt"]},"CounterpartyType":{"type":"string","enum":["customer","supplier"]},"CowProfitabilityItem":{"type":"object","properties":{"cattleId":{"type":"string","format":"uuid"},"cattleTag":{"type":"string"},"cattleName":{"type":"string","nullable":true},"milkLitres":{"type":"number"},"revenue":{"type":"number"},"feedCost":{"type":"number"},"vetCost":{"type":"number"},"breedingCost":{"type":"number"},"otherDirectCost":{"type":"number"},"totalCost":{"type":"number"},"profit":{"type":"number"},"marginPercent":{"type":"number","nullable":true}},"required":["cattleId","cattleTag","cattleName","milkLitres","revenue","feedCost","vetCost","breedingCost","otherDirectCost","totalCost","profit","marginPercent"]},"CowProfitability":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"items":{"type":"array","items":{"type":"object","properties":{"cattleId":{"type":"string","format":"uuid"},"cattleTag":{"type":"string"},"cattleName":{"type":"string","nullable":true},"milkLitres":{"type":"number"},"revenue":{"type":"number"},"feedCost":{"type":"number"},"vetCost":{"type":"number"},"breedingCost":{"type":"number"},"otherDirectCost":{"type":"number"},"totalCost":{"type":"number"},"profit":{"type":"number"},"marginPercent":{"type":"number","nullable":true}},"required":["cattleId","cattleTag","cattleName","milkLitres","revenue","feedCost","vetCost","breedingCost","otherDirectCost","totalCost","profit","marginPercent"]}}},"required":["period","items"]},"ExpenseCategoryGroup":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"ExpenseCategorySummary":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]},"ExpenseGroupSummary":{"type":"object","properties":{"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]},"ExpenseListResponse":{"type":"object","properties":{"expenses":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"countsTowardsCostPerLitre":{"type":"boolean"}},"required":["id","name","group","countsTowardsCostPerLitre"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"},"summary":{"type":"object","properties":{"totalExpense":{"type":"number"}},"required":["totalExpense"]}},"required":["expenses","nextCursor","totalCount","summary"]},"Expense":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"countsTowardsCostPerLitre":{"type":"boolean"}},"required":["id","name","group","countsTowardsCostPerLitre"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]},"ExpenseSortField":{"type":"string","enum":["date","amount","createdAt","categoryName","paymentMethod"]},"ExpenseStatus":{"type":"string","enum":["normal","reversed"]},"ExpenseSummary":{"type":"object","properties":{"totalExpense":{"type":"number"},"byGroup":{"type":"array","items":{"type":"object","properties":{"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]}},"byCategory":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]}}},"required":["totalExpense","byGroup","byCategory"]},"FeedCostAnalytics":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalFeedExpense":{"type":"number"},"totalExpense":{"type":"number"},"feedExpenseSharePercent":{"type":"number","nullable":true},"feedCostPerLitre":{"type":"number","nullable":true},"averageDailyFeedCostPerCow":{"type":"number","nullable":true}},"required":["period","totalFeedExpense","totalExpense","feedExpenseSharePercent","feedCostPerLitre","averageDailyFeedCostPerCow"]},"FinanceAttachmentEntity":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"FinanceAttachment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]},"FinanceAuditAction":{"type":"string","enum":["created","updated","deleted","approved","cancelled","paid","voided","issued","attached","detached","reversed"]},"FinanceAuditLogList":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string"},"entityId":{"type":"string","format":"uuid"},"action":{"type":"string","enum":["created","updated","deleted","approved","cancelled","paid","voided","issued","attached","detached","reversed"]},"actorId":{"type":"string","nullable":true,"format":"uuid"},"actorName":{"type":"string","nullable":true},"beforeJson":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"afterJson":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"ipAddress":{"type":"string","nullable":true},"userAgent":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","action","actorId","actorName","beforeJson","afterJson","ipAddress","userAgent","createdAt"]}}},"required":["items"]},"FinanceAuditLog":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string"},"entityId":{"type":"string","format":"uuid"},"action":{"type":"string","enum":["created","updated","deleted","approved","cancelled","paid","voided","issued","attached","detached","reversed"]},"actorId":{"type":"string","nullable":true,"format":"uuid"},"actorName":{"type":"string","nullable":true},"beforeJson":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"afterJson":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"ipAddress":{"type":"string","nullable":true},"userAgent":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","action","actorId","actorName","beforeJson","afterJson","ipAddress","userAgent","createdAt"]},"FinanceAuditLogSortField":{"type":"string","enum":["createdAt","action","entityType"]},"FinanceCategoryGroup":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"FinanceCategory":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense","income"]},"code":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"isSystem":{"type":"boolean"},"countsTowardsCostPerLitre":{"type":"boolean"},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","code","name","description","group","isSystem","countsTowardsCostPerLitre","isActive","createdAt","updatedAt"]},"FinanceCategorySortField":{"type":"string","enum":["name","code","group","createdAt","updatedAt"]},"FinanceCounterpartyListResponse":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string"},"code":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","name","code","phone","email","notes","isActive","createdAt","updatedAt"]}}},"required":["items"]},"FinanceCounterparty":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string"},"code":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","name","code","phone","email","notes","isActive","createdAt","updatedAt"]},"FinanceSummaryAlert":{"type":"object","properties":{"code":{"type":"string","enum":["invoice_overdue","budget_exceeded","feed_cost_spike","milk_revenue_drop","high_vet_spend","missing_attachment"]},"severity":{"type":"string","enum":["info","warning","critical"]},"message":{"type":"string"}},"required":["code","severity","message"]},"FinanceSummary":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalIncome":{"type":"number"},"totalExpenses":{"type":"number"},"netProfit":{"type":"number"},"milkRevenue":{"type":"number"},"feedExpenses":{"type":"number"},"costPerLitre":{"type":"number","nullable":true},"unpaidInvoices":{"type":"number"},"overBudgetCategories":{"type":"number"},"alerts":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["invoice_overdue","budget_exceeded","feed_cost_spike","milk_revenue_drop","high_vet_spend","missing_attachment"]},"severity":{"type":"string","enum":["info","warning","critical"]},"message":{"type":"string"}},"required":["code","severity","message"]}}},"required":["period","totalIncome","totalExpenses","netProfit","milkRevenue","feedExpenses","costPerLitre","unpaidInvoices","overBudgetCategories","alerts"]},"IncomeCategoryGroup":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"IncomeCategorySummary":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]},"IncomeGroupSummary":{"type":"object","properties":{"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]},"IncomeListResponse":{"type":"object","properties":{"income":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["income"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}},"required":["id","name","group"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"bonusAmount":{"type":"number","nullable":true},"deductionAmount":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","bonusAmount","deductionAmount","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","source","sourceRef","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"},"summary":{"type":"object","properties":{"totalIncome":{"type":"number"}},"required":["totalIncome"]}},"required":["income","nextCursor","totalCount","summary"]},"Income":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["income"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}},"required":["id","name","group"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"bonusAmount":{"type":"number","nullable":true},"deductionAmount":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","bonusAmount","deductionAmount","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","source","sourceRef","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]},"IncomeSortField":{"type":"string","enum":["date","amount","createdAt","categoryName","paymentMethod"]},"IncomeSource":{"type":"string","enum":["manual","milk_module","import"]},"IncomeStatus":{"type":"string","enum":["normal","reversed"]},"IncomeSummary":{"type":"object","properties":{"totalIncome":{"type":"number"},"byGroup":{"type":"array","items":{"type":"object","properties":{"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]}},"byCategory":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]}},"milkLitresTotal":{"type":"number"},"averageMilkPrice":{"type":"number","nullable":true}},"required":["totalIncome","byGroup","byCategory","milkLitresTotal","averageMilkPrice"]},"InvoiceItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]},"InvoiceItemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"InvoiceListResponse":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}},"required":["items"]},"Invoice":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]},"InvoiceSortField":{"type":"string","enum":["issueDate","dueDate","totalAmount","balanceDue","createdAt"]},"InvoiceStatus":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"OutstandingInvoicesReport":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"invoiceId":{"type":"string","format":"uuid"},"invoiceNumber":{"type":"string"},"customerName":{"type":"string"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"}},"required":["invoiceId","invoiceNumber","customerName","dueDate","status","totalAmount","amountPaid","balanceDue"]}}},"required":["items"]},"PaymentAllocationEntity":{"type":"string","enum":["invoice","expense","income"]},"PaymentAllocation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]},"PaymentDirection":{"type":"string","enum":["incoming","outgoing"]},"PaymentImportSmsResult":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}},"unparsedMessages":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string"},"reason":{"type":"string"}},"required":["message","reason"]}}},"required":["items","unparsedMessages"]},"PaymentImportStatementEntry":{"type":"object","properties":{"direction":{"type":"string","enum":["incoming","outgoing"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currencyCode":{"type":"string","minLength":1},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true,"minLength":1},"payerName":{"type":"string","nullable":true,"minLength":1},"payerPhone":{"type":"string","nullable":true,"minLength":1},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true,"minLength":1}},"required":["direction","amount","paymentMethod"]},"PaymentListResponse":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}},"required":["items"]},"PaymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"PaymentProofType":{"type":"string","enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other"]},"PaymentProvider":{"type":"string","enum":["mpesa","bank","cash","other"]},"PaymentRelatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"Payment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]},"PaymentSortField":{"type":"string","enum":["paidAt","createdAt","amount","status","paymentMethod"]},"PaymentStatusTracking":{"type":"string","enum":["pending","completed","failed","reversed"]},"ProfitLossReport":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalIncome":{"type":"number"},"totalExpenses":{"type":"number"},"netProfit":{"type":"number"},"incomeBreakdown":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"amount":{"type":"number"}},"required":["categoryId","categoryName","amount"]}},"expenseBreakdown":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"amount":{"type":"number"}},"required":["categoryId","categoryName","amount"]}}},"required":["period","totalIncome","totalExpenses","netProfit","incomeBreakdown","expenseBreakdown"]},"SettlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"CreateCategoryBody":{"type":"object","properties":{"type":{"type":"string","enum":["expense","income"]},"code":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"description":{"type":"string","nullable":true,"minLength":1},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"countsTowardsCostPerLitre":{"type":"boolean","default":true},"isActive":{"type":"boolean"}},"required":["name","group"],"additionalProperties":false},"CreateCounterpartyBody":{"type":"object","properties":{"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string","minLength":1},"code":{"type":"string","nullable":true,"minLength":1},"phone":{"type":"string","nullable":true,"minLength":1},"email":{"type":"string","nullable":true,"format":"email"},"notes":{"type":"string","nullable":true,"minLength":1},"isActive":{"type":"boolean"}},"required":["type","name"],"additionalProperties":false},"CreateExpenseBody":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","minLength":1},"unitPrice":{"type":"number","minimum":0,"exclusiveMinimum":true},"counterpartyId":{"type":"string","format":"uuid"},"counterpartyName":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1},"receiptMediaId":{"type":"string","format":"uuid"},"linkedCattleId":{"type":"string","format":"uuid"}},"required":["date","categoryId","paymentMethod"],"additionalProperties":false},"CreateIncomeBody":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","minLength":1},"unitPrice":{"type":"number","minimum":0,"exclusiveMinimum":true},"bonusAmount":{"type":"number","minimum":0},"deductionAmount":{"type":"number","minimum":0},"counterpartyId":{"type":"string","format":"uuid"},"counterpartyName":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1},"receiptMediaId":{"type":"string","format":"uuid"},"linkedCattleId":{"type":"string","format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","minLength":1}},"required":["date","categoryId","paymentMethod"],"additionalProperties":false},"ExpenseExportQuery":{"type":"object","properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"q":{"type":"string","minLength":1},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, group, paymentMethod, q"},"format":{"type":"string","enum":["csv"],"default":"csv"}},"additionalProperties":false},"ExpenseListQuery":{"type":"object","properties":{"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"cursor":{"type":"string","minLength":1},"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"counterpartyId":{"type":"string","format":"uuid"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"q":{"type":"string","minLength":1},"openOnly":{"type":"boolean","nullable":true},"minOutstanding":{"type":"number","minimum":0,"exclusiveMinimum":true},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q, openOnly, minOutstanding"},"sortBy":{"type":"string","enum":["date","amount","createdAt","categoryName","paymentMethod"],"description":"Sort expense field. Allowed values: date, amount, createdAt, categoryName, paymentMethod. Default: date (desc)."},"sortDir":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected expense field. Allowed values: asc, desc. Default: date (desc)."}},"additionalProperties":false},"ExpenseSummaryQuery":{"type":"object","properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"counterpartyId":{"type":"string","format":"uuid"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"q":{"type":"string","minLength":1},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q"}},"additionalProperties":false},"IncomeExportQuery":{"type":"object","properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"q":{"type":"string","minLength":1},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, group, paymentMethod, q"},"format":{"type":"string","enum":["csv"],"default":"csv"}},"additionalProperties":false},"IncomeListQuery":{"type":"object","properties":{"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"cursor":{"type":"string","minLength":1},"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"counterpartyId":{"type":"string","format":"uuid"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"q":{"type":"string","minLength":1},"openOnly":{"type":"boolean","nullable":true},"minOutstanding":{"type":"number","minimum":0,"exclusiveMinimum":true},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q, openOnly, minOutstanding"},"sortBy":{"type":"string","enum":["date","amount","createdAt","categoryName","paymentMethod"],"description":"Sort income field. Allowed values: date, amount, createdAt, categoryName, paymentMethod. Default: date (desc)."},"sortDir":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected income field. Allowed values: asc, desc. Default: date (desc)."}},"additionalProperties":false},"IncomeSummaryQuery":{"type":"object","properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"counterpartyId":{"type":"string","format":"uuid"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"q":{"type":"string","minLength":1},"filters":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q"}},"additionalProperties":false},"ListCategoriesQuery":{"type":"object","properties":{"type":{"type":"string","enum":["expense","income"]},"sortBy":{"type":"string","enum":["name","code","group","createdAt","updatedAt"],"description":"Sort category field. Allowed values: name, code, group, createdAt, updatedAt. Default: name (asc)."},"sortDir":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected category field. Allowed values: asc, desc. Default: name (asc)."}},"additionalProperties":false},"ListCounterpartiesQuery":{"type":"object","properties":{"type":{"type":"string","enum":["customer","supplier"]},"sortBy":{"type":"string","enum":["name","type","createdAt","updatedAt"],"description":"Sort counterparty field. Allowed values: name, type, createdAt, updatedAt. Default: name (asc)."},"sortDir":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected counterparty field. Allowed values: asc, desc. Default: name (asc)."}},"additionalProperties":false},"PatchCategoryBody":{"type":"object","properties":{"code":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"description":{"type":"string","nullable":true,"minLength":1},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"countsTowardsCostPerLitre":{"type":"boolean"},"isActive":{"type":"boolean"}},"additionalProperties":false},"PatchCounterpartyBody":{"type":"object","properties":{"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string","minLength":1},"code":{"type":"string","nullable":true,"minLength":1},"phone":{"type":"string","nullable":true,"minLength":1},"email":{"type":"string","nullable":true,"format":"email"},"notes":{"type":"string","nullable":true,"minLength":1},"isActive":{"type":"boolean"}},"additionalProperties":false},"PatchExpenseBody":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","nullable":true,"minLength":1},"unitPrice":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true,"minLength":1},"notes":{"type":"string","nullable":true,"minLength":1},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"}},"additionalProperties":false},"PatchIncomeBody":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","nullable":true,"minLength":1},"unitPrice":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"bonusAmount":{"type":"number","nullable":true,"minimum":0},"deductionAmount":{"type":"number","nullable":true,"minimum":0},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true,"minLength":1},"notes":{"type":"string","nullable":true,"minLength":1},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true,"minLength":1}},"additionalProperties":false},"AssetIdParam":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"}},"required":["assetId"]},"AttachBody":{"type":"object","properties":{"entityType":{"type":"string","enum":["user","farm","finance_proof","instruction"],"description":"Target entity type/slot to attach to.","example":"farm"},"entityId":{"type":"string","minLength":1,"description":"Target entity identifier.","example":"11111111-1111-4111-8111-111111111111"},"purpose":{"type":"string","enum":["profile_image","farm_profile","farm_cover","farm_gallery","finance_proof","instruction_image","cattle_profile","cattle_event","asset_profile"],"description":"Purpose that must match the underlying asset purpose.","example":"farm_profile"}},"required":["entityType","entityId","purpose"],"additionalProperties":false},"FinalizeResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Media asset identifier.","example":"22222222-2222-4222-8222-222222222222"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"],"description":"Current post-finalize lifecycle state. Finalize is idempotent and returns the current state if already processed.","example":"processing"},"processingAttempt":{"type":"integer","minimum":0,"description":"How many processing attempts have been started for this asset.","example":1},"errorCode":{"type":"string","nullable":true,"description":"Failure code when status is failed.","example":"MEDIA_ENQUEUE_FAILED"},"errorMessage":{"type":"string","nullable":true,"description":"Failure message when status is failed.","example":"Media processing queue unavailable"}},"required":["id","status","processingAttempt"]},"MediaAsset":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Media asset identifier."},"ownerUserId":{"type":"string","format":"uuid","description":"User who initiated the upload and owns the asset."},"farmId":{"type":"string","nullable":true,"format":"uuid","description":"Farm scope when the asset belongs to a farm-scoped feature."},"purpose":{"type":"string","enum":["profile_image","farm_profile","farm_cover","farm_gallery","finance_proof","instruction_image","cattle_profile","cattle_event","asset_profile"],"description":"Declared asset purpose used for authorization and variant generation."},"profileVersion":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Version of the media processing profile used to generate the current variants.","example":2},"status":{"type":"string","enum":["staged","uploaded","processing","ready","failed","deleted"],"description":"Complete asset lifecycle state.","example":"ready"},"mime":{"type":"string","nullable":true,"description":"Detected canonical MIME type after processing.","example":"image/jpeg"},"mimeType":{"type":"string","nullable":true,"description":"Detected canonical MIME type alias for client convenience.","example":"image/jpeg"},"bytes":{"type":"integer","nullable":true,"description":"Canonical original file size in bytes.","example":3200000},"width":{"type":"integer","nullable":true,"description":"Canonical original pixel width.","example":3024},"height":{"type":"integer","nullable":true,"description":"Canonical original pixel height.","example":4032},"blurhash":{"type":"string","nullable":true,"description":"Preferred blurhash derived from generated variants for placeholder rendering.","example":"LEHV6nWB2yk8pyo0adR*.7kCMdnj"},"readyAt":{"type":"string","nullable":true,"format":"date-time","description":"Timestamp when the asset became ready.","example":"2026-03-15T12:05:00.000Z"},"errorCode":{"type":"string","nullable":true,"description":"Last processing or enqueue error code, when present.","example":"MEDIA_PROCESSING_FAILED"},"errorMessage":{"type":"string","nullable":true,"description":"Last processing or enqueue error message, when present.","example":"Unsupported media type"},"variants":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Variant row identifier."},"kind":{"type":"string","description":"Variant name generated from the purpose profile, such as thumb, card, detail, banner, preview, or fallback.","example":"detail"},"format":{"type":"string","description":"Encoded output format.","example":"webp"},"mime":{"type":"string","description":"Variant MIME type.","example":"image/webp"},"mimeType":{"type":"string","description":"Variant MIME type alias for client convenience.","example":"image/webp"},"width":{"type":"integer","minimum":0,"description":"Variant pixel width.","example":1080},"height":{"type":"integer","minimum":0,"description":"Variant pixel height.","example":1080},"bytes":{"type":"integer","minimum":0,"description":"Variant file size in bytes.","example":248120},"quality":{"type":"integer","nullable":true,"description":"Encoder quality setting when applicable.","example":86},"encoder":{"type":"string","nullable":true,"description":"Encoder identifier used to generate the variant.","example":"sharp@webp"},"blurhash":{"type":"string","nullable":true,"description":"Blurhash preview string when generated for the variant.","example":"LEHV6nWB2yk8pyo0adR*.7kCMdnj"},"storageKey":{"type":"string","description":"Canonical storage key for this variant. URLs are derived from this key and delivery policy.","example":"assets/22222222-2222-4222-8222-222222222222/variants/detail.webp"},"url":{"type":"string","nullable":true,"format":"uri","description":"Resolved public delivery URL when the asset is publicly cacheable; null for private/protected delivery.","example":"https://farm-media.cruizp.com/assets/22222222-2222-4222-8222-222222222222/variants/detail.webp"}},"required":["id","kind","format","mime","mimeType","width","height","bytes","quality","encoder","blurhash","storageKey","url"]}}},"required":["id","ownerUserId","farmId","purpose","profileVersion","status","mime","mimeType","bytes","width","height","blurhash","readyAt","errorCode","errorMessage","variants"]},"MediaEntityType":{"type":"string","enum":["user","farm","finance_proof","instruction"]},"MediaPurpose":{"type":"string","enum":["profile_image","farm_profile","farm_cover","farm_gallery","finance_proof","instruction_image","cattle_profile","cattle_event","asset_profile"]},"MediaVariant":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Variant row identifier."},"kind":{"type":"string","description":"Variant name generated from the purpose profile, such as thumb, card, detail, banner, preview, or fallback.","example":"detail"},"format":{"type":"string","description":"Encoded output format.","example":"webp"},"mime":{"type":"string","description":"Variant MIME type.","example":"image/webp"},"mimeType":{"type":"string","description":"Variant MIME type alias for client convenience.","example":"image/webp"},"width":{"type":"integer","minimum":0,"description":"Variant pixel width.","example":1080},"height":{"type":"integer","minimum":0,"description":"Variant pixel height.","example":1080},"bytes":{"type":"integer","minimum":0,"description":"Variant file size in bytes.","example":248120},"quality":{"type":"integer","nullable":true,"description":"Encoder quality setting when applicable.","example":86},"encoder":{"type":"string","nullable":true,"description":"Encoder identifier used to generate the variant.","example":"sharp@webp"},"blurhash":{"type":"string","nullable":true,"description":"Blurhash preview string when generated for the variant.","example":"LEHV6nWB2yk8pyo0adR*.7kCMdnj"},"storageKey":{"type":"string","description":"Canonical storage key for this variant. URLs are derived from this key and delivery policy.","example":"assets/22222222-2222-4222-8222-222222222222/variants/detail.webp"},"url":{"type":"string","nullable":true,"format":"uri","description":"Resolved public delivery URL when the asset is publicly cacheable; null for private/protected delivery.","example":"https://farm-media.cruizp.com/assets/22222222-2222-4222-8222-222222222222/variants/detail.webp"}},"required":["id","kind","format","mime","mimeType","width","height","bytes","quality","encoder","blurhash","storageKey","url"]},"SignedUrlQuery":{"type":"object","properties":{"variant":{"type":"string","default":"orig","description":"Variant to resolve. Use orig for the canonical original. Legacy aliases such as web are still accepted for compatibility.","example":"detail"}}},"SignedUrlResponse":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Public CDN URL for public assets, or a short-lived signed/proxy URL for private assets.","example":"https://signed.example/media.webp"},"expiresAt":{"type":"string","nullable":true,"format":"date-time","description":"Expiration timestamp for private signed/proxy URLs. Null for deterministic public CDN URLs.","example":"2026-03-15T12:10:00.000Z"}},"required":["url","expiresAt"]},"UploadBinaryQuery":{"type":"object","properties":{"token":{"type":"string","minLength":1,"description":"Short-lived upload token used only for backend-hosted upload flows."}},"required":["token"]},"UploadIntentBody":{"type":"object","properties":{"purpose":{"type":"string","enum":["profile_image","farm_profile","farm_cover","farm_gallery","finance_proof","instruction_image","cattle_profile","cattle_event","asset_profile"],"description":"How the asset will be used. Purpose controls permissions, validation, and generated variants.","example":"cattle_profile"},"filename":{"type":"string","minLength":1,"description":"Original client filename. Optional; the backend will infer one when omitted.","example":"cow-17.jpg"},"contentType":{"type":"string","minLength":1,"description":"Preferred request field for the upload MIME type.","example":"image/jpeg"},"mimeType":{"type":"string","minLength":1,"description":"Backward-compatible alias for contentType.","example":"image/jpeg"},"bytes":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Preferred request field for expected upload size in bytes.","example":3200000},"byteSize":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Backward-compatible alias for bytes.","example":3200000},"farmId":{"type":"string","format":"uuid","description":"Farm scope for non-user media. Required for farm, finance, and cattle assets.","example":"11111111-1111-4111-8111-111111111111"},"targetUserId":{"type":"string","format":"uuid","description":"Optional target user when uploading profile media on behalf of another user.","example":"33333333-3333-4333-8333-333333333333"}},"required":["purpose"],"additionalProperties":false},"UploadIntentResponse":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid","description":"Newly created staged asset id.","example":"22222222-2222-4222-8222-222222222222"},"uploadUrl":{"type":"string","format":"uri","description":"Presigned storage URL or backend upload endpoint for the raw upload.","example":"https://api.example.com/v1/media/upload/22222222-2222-4222-8222-222222222222?token=..."},"uploadMethod":{"type":"string","enum":["PUT"],"description":"HTTP method to use when uploading the binary payload.","example":"PUT"},"headersToSend":{"type":"object","additionalProperties":{"type":"string"},"description":"Headers the client must send when uploading.","example":{"content-type":"image/jpeg"}},"expiresAt":{"type":"string","format":"date-time","description":"Expiration timestamp for the upload target.","example":"2026-03-15T12:00:00.000Z"},"maxBytes":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Maximum allowed byte size for this purpose.","example":10485760}},"required":["assetId","uploadUrl","uploadMethod","headersToSend","expiresAt","maxBytes"]},"MilkingAlertListResponse":{"type":"object","properties":{"alerts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","nullable":true,"format":"uuid"},"milkingSessionId":{"type":"string","nullable":true,"format":"uuid"},"type":{"type":"string","enum":["yield_drop","yield_spike","missed_session","duplicate_session"]},"severity":{"type":"string","enum":["low","medium","high"]},"title":{"type":"string"},"message":{"type":"string"},"expectedValue":{"type":"number","nullable":true},"actualValue":{"type":"number","nullable":true},"meta":{"type":"object","additionalProperties":{"nullable":true}},"resolvedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","milkingSessionId","type","severity","title","message","expectedValue","actualValue","meta","resolvedAt","createdAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["alerts","nextCursor","totalCount"]},"MilkingAlert":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","nullable":true,"format":"uuid"},"milkingSessionId":{"type":"string","nullable":true,"format":"uuid"},"type":{"type":"string","enum":["yield_drop","yield_spike","missed_session","duplicate_session"]},"severity":{"type":"string","enum":["low","medium","high"]},"title":{"type":"string"},"message":{"type":"string"},"expectedValue":{"type":"number","nullable":true},"actualValue":{"type":"number","nullable":true},"meta":{"type":"object","additionalProperties":{"nullable":true}},"resolvedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","milkingSessionId","type","severity","title","message","expectedValue","actualValue","meta","resolvedAt","createdAt"]},"MilkingAlertSeverity":{"type":"string","enum":["low","medium","high"]},"MilkingAlertSortField":{"type":"string","enum":["createdAt"]},"MilkingAlertType":{"type":"string","enum":["yield_drop","yield_spike","missed_session","duplicate_session"]},"MilkingAlertsSummary":{"type":"object","properties":{"unresolvedCount":{"type":"number"},"highSeverityCount":{"type":"number"}},"required":["unresolvedCount","highSeverityCount"]},"MilkingCowSummary":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"todayTotalLitres":{"type":"number"},"sevenDayTotalLitres":{"type":"number"},"thirtyDayTotalLitres":{"type":"number"},"averagePerSession":{"type":"number"},"latestSessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]}},"trendPoints":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string"},"date":{"type":"string"},"litres":{"type":"number"}},"required":["label","date","litres"]}},"alertCounts":{"type":"object","properties":{"unresolved":{"type":"number"},"total":{"type":"number"}},"required":["unresolved","total"]},"currentStatusSummary":{"type":"object","properties":{"latestStatus":{"type":"string","nullable":true,"enum":["normal","low","high","flagged",null]},"lastRecordedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["latestStatus","lastRecordedAt"]}},"required":["cattle","todayTotalLitres","sevenDayTotalLitres","thirtyDayTotalLitres","averagePerSession","latestSessions","trendPoints","alertCounts","currentStatusSummary"]},"MilkingDashboardResponse":{"type":"object","properties":{"today":{"type":"object","properties":{"date":{"type":"string"},"totalLitres":{"type":"number"},"changePctVsYesterday":{"type":"number","nullable":true}},"required":["date","totalLitres","changePctVsYesterday"]},"avgPerCow":{"type":"object","properties":{"value":{"type":"number"},"changePctVsPreviousWeek":{"type":"number","nullable":true},"activeMilkingCows":{"type":"number"}},"required":["value","changePctVsPreviousWeek","activeMilkingCows"]},"weeklyYield":{"type":"object","properties":{"totalLitres":{"type":"number"},"points":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string"},"date":{"type":"string"},"litres":{"type":"number"}},"required":["label","date","litres"]}}},"required":["totalLitres","points"]},"recentSessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattleName":{"type":"string","nullable":true},"tagNumber":{"type":"string"},"quantityLitres":{"type":"number"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"recordedAt":{"type":"string","format":"date-time"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]}},"required":["id","cattleId","cattleName","tagNumber","quantityLitres","status","recordedAt","sessionType"]}},"alertsSummary":{"type":"object","properties":{"unresolvedCount":{"type":"number"},"highSeverityCount":{"type":"number"}},"required":["unresolvedCount","highSeverityCount"]}},"required":["today","avgPerCow","weeklyYield","recentSessions","alertsSummary"]},"MilkingRecentSession":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattleName":{"type":"string","nullable":true},"tagNumber":{"type":"string"},"quantityLitres":{"type":"number"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"recordedAt":{"type":"string","format":"date-time"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]}},"required":["id","cattleId","cattleName","tagNumber","quantityLitres","status","recordedAt","sessionType"]},"MilkingSessionCattleSummary":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"MilkingSessionInsight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]},"MilkingSessionListResponse":{"type":"object","properties":{"sessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["sessions","nextCursor","totalCount"]},"MilkingSession":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]},"MilkingSessionSortField":{"type":"string","enum":["recordedAt","quantityLitres","createdAt"]},"MilkingSessionSource":{"type":"string","enum":["manual","imported","estimated"]},"MilkingSessionStatus":{"type":"string","enum":["normal","low","high","flagged"]},"MilkingSessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"MilkingWeeklyPoint":{"type":"object","properties":{"label":{"type":"string"},"date":{"type":"string"},"litres":{"type":"number"}},"required":["label","date","litres"]},"InviteIdParam":{"type":"object","properties":{"inviteId":{"type":"string","format":"uuid"}},"required":["inviteId"]},"InviteListItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"expiresAt":{"type":"string","format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","email","role","expiresAt","acceptedAt","createdAt"]},"MembershipIdParam":{"type":"object","properties":{"membershipId":{"type":"string","format":"uuid"}},"required":["membershipId"]},"MembershipListItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"}},"required":["id","email","name"]},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"status":{"type":"string"},"invitedAt":{"type":"string","nullable":true,"format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","user","role","status","invitedAt","acceptedAt"]},"MembershipRoleAssignment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"roleId":{"type":"string","format":"uuid"},"status":{"type":"string"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","userId","roleId","status","acceptedAt"]},"ProvisionUserResponse":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]},"membership":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"roleId":{"type":"string","format":"uuid"},"status":{"type":"string"},"invitedAt":{"type":"string","nullable":true,"format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","userId","roleId","status","invitedAt","acceptedAt"]},"invitation":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"expiresAt":{"type":"string","format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","email","role","expiresAt","acceptedAt","createdAt"]},"inviteUrl":{"type":"string","nullable":true,"format":"uri"}},"required":["user","membership","invitation","inviteUrl"]},"ProvisionedMembership":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"roleId":{"type":"string","format":"uuid"},"status":{"type":"string"},"invitedAt":{"type":"string","nullable":true,"format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","userId","roleId","status","invitedAt","acceptedAt"]},"RoleIdParam":{"type":"object","properties":{"roleId":{"type":"string","format":"uuid"}},"required":["roleId"]},"Role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"permissions":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","name","description","permissions","createdAt"]},"UserIdParam":{"type":"object","properties":{"userId":{"type":"string","format":"uuid"}},"required":["userId"]},"UserProfile":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]}},"parameters":{}},"paths":{"/health":{"get":{"tags":["System"],"responses":{"200":{"description":"Health check","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}}}}},"/errors.json":{"get":{"tags":["System"],"summary":"Get Error Catalog","description":"Returns the structured application error catalog used by the API for stable error codes and client-side handling.","responses":{"200":{"description":"Current application error catalog","content":{"application/json":{"schema":{"type":"object","properties":{"generatedAt":{"type":"string","format":"date-time"},"count":{"type":"integer","minimum":0},"errorCatalog":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"status":{"type":"integer"},"code":{"type":"string"},"domain":{"type":"string"},"type":{"type":"string"},"severity":{"type":"string"},"exposure":{"type":"string"},"message":{"type":"string"},"displayTitle":{"type":"string"},"displayMessage":{"type":"string"}},"required":["key","status","code","domain","type","severity","exposure","message","displayTitle","displayMessage"]}}},"required":["generatedAt","count","errorCatalog"]}}}}}}},"/v1/auth/sign-in":{"post":{"tags":["Auth"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"password":{"type":"string","minLength":1}},"required":["email","password"]}}}},"responses":{"200":{"description":"Signed in","content":{"application/json":{"schema":{"type":"object","properties":{"accessToken":{"type":"string"},"refreshToken":{"type":"string"}},"required":["accessToken","refreshToken"]}}}},"400":{"description":"Invalid request body","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/auth/refresh":{"post":{"tags":["Auth"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"refreshToken":{"type":"string","minLength":1}},"required":["refreshToken"]}}}},"responses":{"200":{"description":"Refreshed","content":{"application/json":{"schema":{"type":"object","properties":{"accessToken":{"type":"string"},"refreshToken":{"type":"string"}},"required":["accessToken","refreshToken"]}}}},"400":{"description":"Invalid request body","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Invalid refresh token","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/auth/forgot-password":{"post":{"tags":["Auth"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"}},"required":["email"]}}}},"responses":{"200":{"description":"Request accepted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request body","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/auth/reset-password":{"post":{"tags":["Auth"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string","minLength":1},"newPassword":{"type":"string","minLength":8}},"required":["token","newPassword"]}}}},"responses":{"200":{"description":"Password updated","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request, invalid/expired token, or weak password","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/auth/change-password":{"post":{"tags":["Auth"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"currentPassword":{"type":"string","minLength":1},"newPassword":{"type":"string","minLength":8}},"required":["currentPassword","newPassword"]}}}},"responses":{"200":{"description":"Password updated","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request body or weak password","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized or invalid current password","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/invitations/accept":{"post":{"tags":["Auth"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string","minLength":1},"password":{"type":"string","minLength":8}},"required":["token","password"]}}}},"responses":{"200":{"description":"Invitation accepted","content":{"application/json":{"schema":{"type":"object","properties":{"accessToken":{"type":"string"},"refreshToken":{"type":"string"}},"required":["accessToken","refreshToken"]}}}},"400":{"description":"Invalid request, invalid/expired invite, or weak password","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/me":{"get":{"tags":["Session"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Current user + memberships","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"name":{"type":"string"}},"required":["id","email","name"]},"memberships":{"type":"array","items":{"type":"object","properties":{"farmId":{"type":"string"},"role":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"]},"permissions":{"type":"array","items":{"type":"string"}}},"required":["farmId","role","permissions"]}}},"required":["user","memberships"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/ai/health":{"get":{"tags":["AI"],"summary":"AI runtime health","responses":{"200":{"description":"AI runtime ready","content":{"application/json":{"schema":{"type":"object","properties":{"providerMode":{"type":"string","enum":["mock","openrouter"]},"queueDriver":{"type":"string","enum":["inline","bullmq"]},"redis":{"type":"string","enum":["ok","error"]},"queue":{"type":"string","enum":["ok","error"]}},"required":["providerMode","queueDriver","redis","queue"]}}}},"503":{"description":"AI runtime unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"providerMode":{"type":"string","enum":["mock","openrouter"]},"queueDriver":{"type":"string","enum":["inline","bullmq"]},"redis":{"type":"string","enum":["ok","error"]},"queue":{"type":"string","enum":["ok","error"]}},"required":["providerMode","queueDriver","redis","queue"]}}}}}}},"/v1/farms/{farmId}/ai/conversations":{"post":{"tags":["AI"],"summary":"Create AI conversation","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":160}},"additionalProperties":false}}}},"responses":{"200":{"description":"Conversation created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiConversation"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"get":{"tags":["AI"],"summary":"List AI conversations","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"responses":{"200":{"description":"Conversation list","content":{"application/json":{"schema":{"type":"object","properties":{"conversations":{"type":"array","items":{"$ref":"#/components/schemas/AiConversation"}}},"required":["conversations"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/ai/conversations/{conversationId}/messages":{"get":{"tags":["AI"],"summary":"List AI conversation messages","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"conversationId","in":"path"}],"responses":{"200":{"description":"Message list","content":{"application/json":{"schema":{"type":"object","properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/AiMessage"}}},"required":["messages"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Conversation not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["AI"],"summary":"Send AI conversation message","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"conversationId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","minLength":1,"maxLength":4000}},"required":["message"],"additionalProperties":false}}}},"responses":{"200":{"description":"Message queued","content":{"application/json":{"schema":{"type":"object","properties":{"userMessage":{"$ref":"#/components/schemas/AiMessage"},"assistantMessage":{"$ref":"#/components/schemas/AiMessage"},"run":{"$ref":"#/components/schemas/AiRun"}},"required":["userMessage","assistantMessage","run"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Conversation not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"503":{"description":"AI queue unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/ai/conversations/{conversationId}/runs/{runId}":{"get":{"tags":["AI"],"summary":"Get AI run status","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"conversationId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"runId","in":"path"}],"responses":{"200":{"description":"Run status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiRun"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Run not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/ai/conversations":{"get":{"tags":["AI"],"summary":"List AI conversations","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"query"}],"responses":{"200":{"description":"Conversation list","content":{"application/json":{"schema":{"type":"object","properties":{"conversations":{"type":"array","items":{"$ref":"#/components/schemas/AiConversation"}}},"required":["conversations"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/ai/messages":{"get":{"tags":["AI"],"summary":"List AI messages","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"conversationId","in":"query"}],"responses":{"200":{"description":"Message list","content":{"application/json":{"schema":{"type":"object","properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/AiMessage"}}},"required":["messages"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Conversation not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/ai/message":{"post":{"tags":["AI"],"summary":"Send AI message","security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"farmId":{"type":"string","format":"uuid"},"conversationId":{"type":"string","format":"uuid"},"message":{"type":"string","minLength":1,"maxLength":4000}},"required":["farmId","conversationId","message"],"additionalProperties":false}}}},"responses":{"200":{"description":"Message queued","content":{"application/json":{"schema":{"type":"object","properties":{"userMessage":{"$ref":"#/components/schemas/AiMessage"},"assistantMessage":{"$ref":"#/components/schemas/AiMessage"},"run":{"$ref":"#/components/schemas/AiRun"}},"required":["userMessage","assistantMessage","run"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Conversation not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"503":{"description":"AI queue unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/ai/conversations/{conversationId}/events":{"get":{"tags":["Realtime"],"summary":"Stream AI conversation events","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"conversationId","in":"path"}],"responses":{"200":{"description":"SSE stream","content":{"text/event-stream":{"schema":{"type":"string"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Conversation not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/media/upload/{assetId}":{"put":{"tags":["Media"],"summary":"Upload Media Binary","description":"Uploads raw media bytes only for backend-hosted uploads. Direct storage uploads bypass this route and upload to the presigned target returned by upload-intent.","parameters":[{"schema":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"},"required":true,"description":"Media asset identifier","name":"assetId","in":"path"},{"schema":{"type":"string","minLength":1,"description":"Short-lived upload token used only for backend-hosted upload flows."},"required":true,"description":"Short-lived upload token used only for backend-hosted upload flows.","name":"token","in":"query"}],"requestBody":{"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"responses":{"200":{"description":"Upload content accepted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid upload token or payload","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Asset not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/media/upload-intent":{"post":{"tags":["Media"],"summary":"Create Media Upload Intent","description":"Creates a staged media asset and returns either a presigned storage upload target or a backend-hosted upload URL. Direct-to-storage upload is preferred; the app-hosted upload route remains a fallback for local/dev setups. Accepts both contentType/bytes and backward-compatible mimeType/byteSize request fields.","security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"purpose":{"type":"string","enum":["profile_image","farm_profile","farm_cover","farm_gallery","finance_proof","instruction_image","cattle_profile","cattle_event","asset_profile"],"description":"How the asset will be used. Purpose controls permissions, validation, and generated variants.","example":"cattle_profile"},"filename":{"type":"string","minLength":1,"description":"Original client filename. Optional; the backend will infer one when omitted.","example":"cow-17.jpg"},"contentType":{"type":"string","minLength":1,"description":"Preferred request field for the upload MIME type.","example":"image/jpeg"},"mimeType":{"type":"string","minLength":1,"description":"Backward-compatible alias for contentType.","example":"image/jpeg"},"bytes":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Preferred request field for expected upload size in bytes.","example":3200000},"byteSize":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Backward-compatible alias for bytes.","example":3200000},"farmId":{"type":"string","format":"uuid","description":"Farm scope for non-user media. Required for farm, finance, and cattle assets.","example":"11111111-1111-4111-8111-111111111111"},"targetUserId":{"type":"string","format":"uuid","description":"Optional target user when uploading profile media on behalf of another user.","example":"33333333-3333-4333-8333-333333333333"}},"required":["purpose"],"additionalProperties":false},"example":{"purpose":"cattle_profile","mimeType":"image/jpeg","byteSize":3200000,"farmId":"11111111-1111-4111-8111-111111111111","filename":"cow-17.jpg"}}}},"responses":{"200":{"description":"Upload intent created","content":{"application/json":{"schema":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid","description":"Newly created staged asset id.","example":"22222222-2222-4222-8222-222222222222"},"uploadUrl":{"type":"string","format":"uri","description":"Presigned storage URL or backend upload endpoint for the raw upload.","example":"https://api.example.com/v1/media/upload/22222222-2222-4222-8222-222222222222?token=..."},"uploadMethod":{"type":"string","enum":["PUT"],"description":"HTTP method to use when uploading the binary payload.","example":"PUT"},"headersToSend":{"type":"object","additionalProperties":{"type":"string"},"description":"Headers the client must send when uploading.","example":{"content-type":"image/jpeg"}},"expiresAt":{"type":"string","format":"date-time","description":"Expiration timestamp for the upload target.","example":"2026-03-15T12:00:00.000Z"},"maxBytes":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Maximum allowed byte size for this purpose.","example":10485760}},"required":["assetId","uploadUrl","uploadMethod","headersToSend","expiresAt","maxBytes"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/media/{assetId}/finalize":{"post":{"tags":["Media"],"summary":"Finalize Media Upload","description":"Verifies the staged object exists, validates size/type expectations, moves the asset into processing, and enqueues image processing. This endpoint is idempotent and returns the current state when the asset is already processing, ready, or failed.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"},"required":true,"description":"Media asset identifier","name":"assetId","in":"path"}],"responses":{"200":{"description":"Finalize started or current state returned","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Media asset identifier.","example":"22222222-2222-4222-8222-222222222222"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"],"description":"Current post-finalize lifecycle state. Finalize is idempotent and returns the current state if already processed.","example":"processing"},"processingAttempt":{"type":"integer","minimum":0,"description":"How many processing attempts have been started for this asset.","example":1},"errorCode":{"type":"string","nullable":true,"description":"Failure code when status is failed.","example":"MEDIA_ENQUEUE_FAILED"},"errorMessage":{"type":"string","nullable":true,"description":"Failure message when status is failed.","example":"Media processing queue unavailable"}},"required":["id","status","processingAttempt"]}}}},"400":{"description":"Finalize failed validation","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Asset not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"503":{"description":"Media queue unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/media/{assetId}":{"get":{"tags":["Media"],"summary":"Get Media Asset","description":"Returns media metadata, lifecycle state, and generated variants for a single asset. Ready public assets include deterministic CDN URLs for each generated variant.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"},"required":true,"description":"Media asset identifier","name":"assetId","in":"path"}],"responses":{"200":{"description":"Media asset details with variants","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Media asset identifier."},"ownerUserId":{"type":"string","format":"uuid","description":"User who initiated the upload and owns the asset."},"farmId":{"type":"string","nullable":true,"format":"uuid","description":"Farm scope when the asset belongs to a farm-scoped feature."},"purpose":{"type":"string","enum":["profile_image","farm_profile","farm_cover","farm_gallery","finance_proof","instruction_image","cattle_profile","cattle_event","asset_profile"],"description":"Declared asset purpose used for authorization and variant generation."},"profileVersion":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Version of the media processing profile used to generate the current variants.","example":2},"status":{"type":"string","enum":["staged","uploaded","processing","ready","failed","deleted"],"description":"Complete asset lifecycle state.","example":"ready"},"mime":{"type":"string","nullable":true,"description":"Detected canonical MIME type after processing.","example":"image/jpeg"},"mimeType":{"type":"string","nullable":true,"description":"Detected canonical MIME type alias for client convenience.","example":"image/jpeg"},"bytes":{"type":"integer","nullable":true,"description":"Canonical original file size in bytes.","example":3200000},"width":{"type":"integer","nullable":true,"description":"Canonical original pixel width.","example":3024},"height":{"type":"integer","nullable":true,"description":"Canonical original pixel height.","example":4032},"blurhash":{"type":"string","nullable":true,"description":"Preferred blurhash derived from generated variants for placeholder rendering.","example":"LEHV6nWB2yk8pyo0adR*.7kCMdnj"},"readyAt":{"type":"string","nullable":true,"format":"date-time","description":"Timestamp when the asset became ready.","example":"2026-03-15T12:05:00.000Z"},"errorCode":{"type":"string","nullable":true,"description":"Last processing or enqueue error code, when present.","example":"MEDIA_PROCESSING_FAILED"},"errorMessage":{"type":"string","nullable":true,"description":"Last processing or enqueue error message, when present.","example":"Unsupported media type"},"variants":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Variant row identifier."},"kind":{"type":"string","description":"Variant name generated from the purpose profile, such as thumb, card, detail, banner, preview, or fallback.","example":"detail"},"format":{"type":"string","description":"Encoded output format.","example":"webp"},"mime":{"type":"string","description":"Variant MIME type.","example":"image/webp"},"mimeType":{"type":"string","description":"Variant MIME type alias for client convenience.","example":"image/webp"},"width":{"type":"integer","minimum":0,"description":"Variant pixel width.","example":1080},"height":{"type":"integer","minimum":0,"description":"Variant pixel height.","example":1080},"bytes":{"type":"integer","minimum":0,"description":"Variant file size in bytes.","example":248120},"quality":{"type":"integer","nullable":true,"description":"Encoder quality setting when applicable.","example":86},"encoder":{"type":"string","nullable":true,"description":"Encoder identifier used to generate the variant.","example":"sharp@webp"},"blurhash":{"type":"string","nullable":true,"description":"Blurhash preview string when generated for the variant.","example":"LEHV6nWB2yk8pyo0adR*.7kCMdnj"},"storageKey":{"type":"string","description":"Canonical storage key for this variant. URLs are derived from this key and delivery policy.","example":"assets/22222222-2222-4222-8222-222222222222/variants/detail.webp"},"url":{"type":"string","nullable":true,"format":"uri","description":"Resolved public delivery URL when the asset is publicly cacheable; null for private/protected delivery.","example":"https://farm-media.cruizp.com/assets/22222222-2222-4222-8222-222222222222/variants/detail.webp"}},"required":["id","kind","format","mime","mimeType","width","height","bytes","quality","encoder","blurhash","storageKey","url"]}}},"required":["id","ownerUserId","farmId","purpose","profileVersion","status","mime","mimeType","bytes","width","height","blurhash","readyAt","errorCode","errorMessage","variants"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Asset not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Media"],"summary":"Delete Media Asset","description":"Soft-deletes media metadata and removes the canonical original plus generated variants from storage.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"},"required":true,"description":"Media asset identifier","name":"assetId","in":"path"}],"responses":{"200":{"description":"Media deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Asset not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/media/{assetId}/url":{"get":{"tags":["Media"],"summary":"Get Media Signed URL","description":"Returns a deterministic public CDN URL for public assets, or a short-lived signed/proxy URL for private assets. Variant aliases such as web are resolved for backward compatibility.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"},"required":true,"description":"Media asset identifier","name":"assetId","in":"path"},{"schema":{"type":"string","default":"orig","description":"Variant to resolve. Use orig for the canonical original. Legacy aliases such as web are still accepted for compatibility.","example":"detail"},"required":false,"description":"Variant to resolve. Use orig for the canonical original. Legacy aliases such as web are still accepted for compatibility.","name":"variant","in":"query"}],"responses":{"200":{"description":"Short-lived signed URL for asset/variant","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Public CDN URL for public assets, or a short-lived signed/proxy URL for private assets.","example":"https://signed.example/media.webp"},"expiresAt":{"type":"string","nullable":true,"format":"date-time","description":"Expiration timestamp for private signed/proxy URLs. Null for deterministic public CDN URLs.","example":"2026-03-15T12:10:00.000Z"}},"required":["url","expiresAt"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Asset or variant not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/media/{assetId}/content":{"get":{"tags":["Media"],"summary":"Proxy Media Content","description":"Streams media bytes through the API when direct storage delivery is not used. Successful responses include immutable browser cache headers for canonical assets and variants.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"},"required":true,"description":"Media asset identifier","name":"assetId","in":"path"},{"schema":{"type":"string","default":"orig","description":"Variant to resolve. Use orig for the canonical original. Legacy aliases such as web are still accepted for compatibility.","example":"detail"},"required":false,"description":"Variant to resolve. Use orig for the canonical original. Legacy aliases such as web are still accepted for compatibility.","name":"variant","in":"query"}],"responses":{"200":{"description":"Binary media content (proxy mode)","headers":{"Cache-Control":{"schema":{"type":"string"},"description":"Canonical browser cache policy. Media responses are immutable and cacheable for one year."},"ETag":{"schema":{"type":"string"},"description":"Object ETag when available from storage."}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Asset or variant not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/media/{assetId}/attach":{"post":{"tags":["Media"],"summary":"Attach Media Asset","description":"Attaches a ready asset to a slot-style entity target such as a user, farm, finance proof slot, or instruction slot.","security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Media asset identifier","example":"22222222-2222-4222-8222-222222222222"},"required":true,"description":"Media asset identifier","name":"assetId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"entityType":{"type":"string","enum":["user","farm","finance_proof","instruction"],"description":"Target entity type/slot to attach to.","example":"farm"},"entityId":{"type":"string","minLength":1,"description":"Target entity identifier.","example":"11111111-1111-4111-8111-111111111111"},"purpose":{"type":"string","enum":["profile_image","farm_profile","farm_cover","farm_gallery","finance_proof","instruction_image","cattle_profile","cattle_event","asset_profile"],"description":"Purpose that must match the underlying asset purpose.","example":"farm_profile"}},"required":["entityType","entityId","purpose"],"additionalProperties":false}}}},"responses":{"200":{"description":"Media attached to entity slot","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Asset not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/assets":{"get":{"tags":["assets"],"summary":"List farm assets","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"required":false,"name":"category","in":"query"},{"schema":{"type":"string","enum":["working","needs_service"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":100},"required":false,"name":"q","in":"query"}],"responses":{"200":{"description":"Farm assets","content":{"application/json":{"schema":{"type":"object","properties":{"assets":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetTag":{"type":"string"},"name":{"type":"string"},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"lastServiceAt":{"type":"string","nullable":true,"format":"date-time"},"imageAssetId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetTag","name","category","status","location","notes","lastServiceAt","imageAssetId","createdBy","updatedBy","createdAt","updatedAt"]}}},"required":["assets"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["assets"],"summary":"Create farm asset","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"assetTag":{"type":"string","minLength":1,"maxLength":64},"name":{"type":"string","minLength":1,"maxLength":255},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","minLength":1,"maxLength":255},"notes":{"type":"string","minLength":1,"maxLength":2000},"lastServiceAt":{"type":"string","format":"date-time"},"imageAssetId":{"type":"string","format":"uuid"}},"required":["assetTag","name","category"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created asset","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetTag":{"type":"string"},"name":{"type":"string"},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"lastServiceAt":{"type":"string","nullable":true,"format":"date-time"},"imageAssetId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetTag","name","category","status","location","notes","lastServiceAt","imageAssetId","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/assets/{assetId}":{"get":{"tags":["assets"],"summary":"Get farm asset","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"assetId","in":"path"}],"responses":{"200":{"description":"Asset details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetTag":{"type":"string"},"name":{"type":"string"},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"lastServiceAt":{"type":"string","nullable":true,"format":"date-time"},"imageAssetId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetTag","name","category","status","location","notes","lastServiceAt","imageAssetId","createdBy","updatedBy","createdAt","updatedAt"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["assets"],"summary":"Update farm asset","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"assetId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"assetTag":{"type":"string","minLength":1,"maxLength":64},"name":{"type":"string","minLength":1,"maxLength":255},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"anyOf":[{"type":"string","minLength":1,"maxLength":255},{"nullable":true}]},"notes":{"anyOf":[{"type":"string","minLength":1,"maxLength":2000},{"nullable":true}]},"lastServiceAt":{"anyOf":[{"type":"string","format":"date-time"},{"nullable":true}]},"imageAssetId":{"anyOf":[{"type":"string","format":"uuid"},{"nullable":true}]}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated asset","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetTag":{"type":"string"},"name":{"type":"string"},"category":{"type":"string","enum":["tractors","robotics","implements","utility","other"]},"status":{"type":"string","enum":["working","needs_service"]},"location":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"lastServiceAt":{"type":"string","nullable":true,"format":"date-time"},"imageAssetId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetTag","name","category","status","location","notes","lastServiceAt","imageAssetId","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["assets"],"summary":"Delete farm asset","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"assetId","in":"path"}],"responses":{"200":{"description":"Asset deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}":{"get":{"tags":["Farm Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"responses":{"200":{"description":"Farm profile details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"locationName":{"type":"string","nullable":true},"googleMapsUrl":{"type":"string","nullable":true,"format":"uri"},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"coverImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"coverImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","name","description","locationName","googleMapsUrl","profileImageAssetId","coverImageAssetId","profileImage","coverImage","createdAt","updatedAt"]}}}},"400":{"description":"Invalid params","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Farm Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"description":{"anyOf":[{"type":"string","minLength":1,"maxLength":2000},{"nullable":true}]},"locationName":{"anyOf":[{"type":"string","minLength":1,"maxLength":255},{"nullable":true}]},"googleMapsUrl":{"anyOf":[{"type":"string","maxLength":2048,"format":"uri"},{"nullable":true}]},"profileImageAssetId":{"anyOf":[{"type":"string","format":"uuid"},{"nullable":true}]},"coverImageAssetId":{"anyOf":[{"type":"string","format":"uuid"},{"nullable":true}]}},"additionalProperties":false}}}},"responses":{"200":{"description":"Farm profile updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"locationName":{"type":"string","nullable":true},"googleMapsUrl":{"type":"string","nullable":true,"format":"uri"},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"coverImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"coverImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","name","description","locationName","googleMapsUrl","profileImageAssetId","coverImageAssetId","profileImage","coverImage","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/images":{"get":{"tags":["Farm Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","enum":["isPrimary","sortOrder","createdAt","updatedAt","category"],"description":"Sort farm image field. Allowed values: isPrimary, sortOrder, createdAt, updatedAt, category."},"required":false,"description":"Sort farm image field. Allowed values: isPrimary, sortOrder, createdAt, updatedAt, category.","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected farm image field. Allowed values: asc, desc."},"required":false,"description":"Sort direction for the selected farm image field. Allowed values: asc, desc.","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Farm image gallery","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"caption":{"type":"string","nullable":true},"category":{"type":"string","nullable":true,"enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other",null]},"sortOrder":{"type":"integer"},"isPrimary":{"type":"boolean"},"image":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetId","caption","category","sortOrder","isPrimary","image","createdAt","updatedAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid params","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["Farm Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"caption":{"anyOf":[{"type":"string","minLength":1,"maxLength":500},{"nullable":true}]},"category":{"anyOf":[{"type":"string","enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other"]},{"nullable":true}]},"sortOrder":{"type":"integer","minimum":0},"isPrimary":{"type":"boolean"}},"required":["assetId"],"additionalProperties":false}}}},"responses":{"201":{"description":"Farm image created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"caption":{"type":"string","nullable":true},"category":{"type":"string","nullable":true,"enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other",null]},"sortOrder":{"type":"integer"},"isPrimary":{"type":"boolean"},"image":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetId","caption","category","sortOrder","isPrimary","image","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"409":{"description":"Duplicate image","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/images/reorder":{"patch":{"tags":["Farm Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"imageId":{"type":"string","format":"uuid"},"sortOrder":{"type":"integer","minimum":0}},"required":["imageId","sortOrder"]},"minItems":1}},"required":["items"],"additionalProperties":false}}}},"responses":{"200":{"description":"Farm images reordered","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"caption":{"type":"string","nullable":true},"category":{"type":"string","nullable":true,"enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other",null]},"sortOrder":{"type":"integer"},"isPrimary":{"type":"boolean"},"image":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetId","caption","category","sortOrder","isPrimary","image","createdAt","updatedAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/images/{imageId}":{"patch":{"tags":["Farm Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"imageId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"caption":{"anyOf":[{"type":"string","minLength":1,"maxLength":500},{"nullable":true}]},"category":{"anyOf":[{"type":"string","enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other"]},{"nullable":true}]},"sortOrder":{"type":"integer","minimum":0},"isPrimary":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Farm image updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"caption":{"type":"string","nullable":true},"category":{"type":"string","nullable":true,"enum":["facility","pasture","milking_area","storage","animals","equipment","staff","other",null]},"sortOrder":{"type":"integer"},"isPrimary":{"type":"boolean"},"image":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","assetId","caption","category","sortOrder","isPrimary","image","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Farm Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"imageId","in":"path"}],"responses":{"200":{"description":"Farm image removed","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/me":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"responses":{"200":{"description":"Current user profile in farm context","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]}}}},"400":{"description":"Invalid farmId","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Not a member of farm","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/users/{userId}":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"User profile","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]}}}},"400":{"description":"Invalid params","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"userId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1},"phone":{"anyOf":[{"type":"string","minLength":1},{"nullable":true}]},"disabledAt":{"anyOf":[{"type":"string","format":"date-time"},{"nullable":true}]}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated user profile","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/users":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"roleId","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: q, roleId"},"required":false,"description":"JSON object with optional keys: q, roleId","name":"filters","in":"query"},{"schema":{"type":"string","enum":["createdAt","name","email"],"description":"Sort user field. Allowed values: createdAt, name, email. Default: createdAt (desc)."},"required":false,"description":"Sort user field. Allowed values: createdAt, name, email. Default: createdAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected user field. Allowed values: asc, desc. Default: createdAt (desc)."},"required":false,"description":"Sort direction for the selected user field. Allowed values: asc, desc. Default: createdAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"User list for farm","content":{"application/json":{"schema":{"type":"object","properties":{"users":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]}},"nextCursor":{"type":"string","nullable":true}},"required":["users","nextCursor"]}}}},"400":{"description":"Invalid farmId","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/users/provision":{"post":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"roleId":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"phone":{"type":"string","minLength":1},"sendInvite":{"type":"boolean","default":true},"expiresDays":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":365}},"required":["email","roleId"],"additionalProperties":false}}}},"responses":{"200":{"description":"Existing user provisioned in farm","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]},"membership":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"roleId":{"type":"string","format":"uuid"},"status":{"type":"string"},"invitedAt":{"type":"string","nullable":true,"format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","userId","roleId","status","invitedAt","acceptedAt"]},"invitation":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"expiresAt":{"type":"string","format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","email","role","expiresAt","acceptedAt","createdAt"]},"inviteUrl":{"type":"string","nullable":true,"format":"uri"}},"required":["user","membership","invitation","inviteUrl"]}}}},"201":{"description":"New user created and provisioned in farm","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string","nullable":true},"profileImageAssetId":{"type":"string","nullable":true,"format":"uuid"},"profileImage":{"type":"object","nullable":true,"properties":{"assetId":{"type":"string","format":"uuid"},"purpose":{"type":"string"},"status":{"type":"string","enum":["uploaded","processing","ready","failed"]},"url":{"type":"string","nullable":true,"format":"uri"},"variants":{"type":"object","additionalProperties":{"type":"string","format":"uri"}}},"required":["assetId","purpose","status","url","variants"]},"disabledAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","email","name","phone","profileImageAssetId","profileImage","disabledAt"]},"membership":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"roleId":{"type":"string","format":"uuid"},"status":{"type":"string"},"invitedAt":{"type":"string","nullable":true,"format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","userId","roleId","status","invitedAt","acceptedAt"]},"invitation":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"expiresAt":{"type":"string","format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","email","role","expiresAt","acceptedAt","createdAt"]},"inviteUrl":{"type":"string","nullable":true,"format":"uri"}},"required":["user","membership","invitation","inviteUrl"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/users/{userId}/disable":{"post":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"Disabled","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid params","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/users/{userId}/enable":{"post":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"userId","in":"path"}],"responses":{"200":{"description":"Enabled","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid params","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/memberships":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"roleId","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: q, roleId"},"required":false,"description":"JSON object with optional keys: q, roleId","name":"filters","in":"query"},{"schema":{"type":"string","enum":["createdAt","userName","roleName"],"description":"Sort membership field. Allowed values: createdAt, userName, roleName. Default: createdAt (desc)."},"required":false,"description":"Sort membership field. Allowed values: createdAt, userName, roleName. Default: createdAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected membership field. Allowed values: asc, desc. Default: createdAt (desc)."},"required":false,"description":"Sort direction for the selected membership field. Allowed values: asc, desc. Default: createdAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Membership list for farm","content":{"application/json":{"schema":{"type":"object","properties":{"memberships":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"name":{"type":"string"}},"required":["id","email","name"]},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"status":{"type":"string"},"invitedAt":{"type":"string","nullable":true,"format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","user","role","status","invitedAt","acceptedAt"]}},"nextCursor":{"type":"string","nullable":true}},"required":["memberships","nextCursor"]}}}},"400":{"description":"Invalid params","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/memberships/{membershipId}":{"delete":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"membershipId","in":"path"}],"responses":{"200":{"description":"Membership removed","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/invitations":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"roleId","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: q, roleId"},"required":false,"description":"JSON object with optional keys: q, roleId","name":"filters","in":"query"},{"schema":{"type":"string","enum":["createdAt","email","expiresAt"],"description":"Sort invitation field. Allowed values: createdAt, email, expiresAt. Default: createdAt (desc)."},"required":false,"description":"Sort invitation field. Allowed values: createdAt, email, expiresAt. Default: createdAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected invitation field. Allowed values: asc, desc. Default: createdAt (desc)."},"required":false,"description":"Sort direction for the selected invitation field. Allowed values: asc, desc. Default: createdAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Pending invitations for farm","content":{"application/json":{"schema":{"type":"object","properties":{"invitations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"expiresAt":{"type":"string","format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","email","role","expiresAt","acceptedAt","createdAt"]}},"nextCursor":{"type":"string","nullable":true}},"required":["invitations","nextCursor"]}}}},"400":{"description":"Invalid farmId","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"roleId":{"type":"string","format":"uuid"},"expiresDays":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":365}},"required":["email","roleId"],"additionalProperties":false}}}},"responses":{"200":{"description":"Invitation created","content":{"application/json":{"schema":{"type":"object","properties":{"invitation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"expiresAt":{"type":"string","format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","email","role","expiresAt","acceptedAt","createdAt"]},"inviteUrl":{"type":"string","format":"uri"}},"required":["invitation","inviteUrl"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/invitations/{inviteId}":{"delete":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"inviteId","in":"path"}],"responses":{"200":{"description":"Invitation deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/invitations/{inviteId}/resend":{"post":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"inviteId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"expiresDays":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":365}},"additionalProperties":false}}}},"responses":{"200":{"description":"Invitation resent with new token","content":{"application/json":{"schema":{"type":"object","properties":{"invitation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"email":{"type":"string","format":"email"},"role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]},"expiresAt":{"type":"string","format":"date-time"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","email","role","expiresAt","acceptedAt","createdAt"]},"inviteUrl":{"type":"string","format":"uri"}},"required":["invitation","inviteUrl"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/permissions":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"responses":{"200":{"description":"Permission catalog","content":{"application/json":{"schema":{"type":"object","properties":{"permissions":{"type":"array","items":{"type":"string"}}},"required":["permissions"]}}}},"400":{"description":"Invalid farmId","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/roles":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: q"},"required":false,"description":"JSON object with optional keys: q","name":"filters","in":"query"},{"schema":{"type":"string","enum":["createdAt","name"],"description":"Sort role field. Allowed values: createdAt, name. Default: createdAt (desc)."},"required":false,"description":"Sort role field. Allowed values: createdAt, name. Default: createdAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected role field. Allowed values: asc, desc. Default: createdAt (desc)."},"required":false,"description":"Sort direction for the selected role field. Allowed values: asc, desc. Default: createdAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Roles in farm","content":{"application/json":{"schema":{"type":"object","properties":{"roles":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"permissions":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","name","description","permissions","createdAt"]}},"nextCursor":{"type":"string","nullable":true}},"required":["roles","nextCursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string","nullable":true,"minLength":1},"permissions":{"type":"array","items":{"type":"string"},"default":[]}},"required":["name"],"additionalProperties":false}}}},"responses":{"200":{"description":"Role created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"permissions":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","name","description","permissions","createdAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/roles/{roleId}":{"get":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"roleId","in":"path"}],"responses":{"200":{"description":"Role details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"permissions":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","name","description","permissions","createdAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"roleId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string","nullable":true,"minLength":1},"permissions":{"type":"array","items":{"type":"string"}}},"additionalProperties":false}}}},"responses":{"200":{"description":"Role updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"permissions":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","name","description","permissions","createdAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"roleId","in":"path"}],"responses":{"200":{"description":"Role deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/memberships/{membershipId}/role":{"patch":{"tags":["User Management"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"membershipId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"roleId":{"type":"string","format":"uuid"}},"required":["roleId"],"additionalProperties":false}}}},"responses":{"200":{"description":"Membership role updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"roleId":{"type":"string","format":"uuid"},"status":{"type":"string"},"acceptedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["id","farmId","userId","roleId","status","acceptedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["active","sold","dead"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["calf","heifer","lactating","dry"]},"required":false,"name":"productionStatus","in":"query"},{"schema":{"type":"string","enum":["open","served","pregnant"]},"required":false,"name":"reproStatus","in":"query"},{"schema":{"type":"string","enum":["female","male"]},"required":false,"name":"sex","in":"query"},{"schema":{"type":"string","enum":["born_on_farm","purchased"]},"required":false,"name":"source","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: status, productionStatus, reproStatus, sex, source, q. Individual query parameters take precedence over values in this JSON."},"required":false,"description":"JSON object with optional keys: status, productionStatus, reproStatus, sex, source, q. Individual query parameters take precedence over values in this JSON.","name":"filters","in":"query"},{"schema":{"type":"string","enum":["createdAt","updatedAt","tagNumber","status"],"description":"Sort cattle field. Allowed values: createdAt, updatedAt, tagNumber, status. Default: createdAt (desc)."},"required":false,"description":"Sort cattle field. Allowed values: createdAt, updatedAt, tagNumber, status. Default: createdAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected cattle field. Allowed values: asc, desc. Default: createdAt (desc)."},"required":false,"description":"Sort direction for the selected cattle field. Allowed values: asc, desc. Default: createdAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Cattle list","content":{"application/json":{"schema":{"type":"object","properties":{"cattle":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["cattle","nextCursor","totalCount"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"tagNumber":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","minLength":1},"dob":{"type":"string","format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","format":"date-time"},"purchasePrice":{"type":"number","minimum":0},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","enum":["calf","heifer","lactating","dry"]},"reproStatus":{"type":"string","enum":["open","served","pregnant"]},"servedDate":{"type":"string","format":"date-time"},"expectedDeliveryDate":{"type":"string","format":"date-time"},"currentLocation":{"type":"string","minLength":1,"maxLength":255},"notes":{"type":"string","minLength":1},"profileMediaId":{"type":"string","format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5}},"required":["tagNumber","sex","source"],"additionalProperties":false}}}},"responses":{"201":{"description":"Cattle created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/summary":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"responses":{"200":{"description":"Cattle summary","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"number"},"active":{"type":"number"},"sold":{"type":"number"},"dead":{"type":"number"},"lactating":{"type":"number"},"dry":{"type":"number"},"pregnant":{"type":"number"},"heifers":{"type":"number"},"calves":{"type":"number"}},"required":["total","active","sold","dead","lactating","dry","pregnant","heifers","calves"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/{cattleId}/overview":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"responses":{"200":{"description":"Cattle overview summary","content":{"application/json":{"schema":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]},"statusChips":{"type":"object","properties":{"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]}},"required":["status","productionStatus","reproStatus"]},"photo":{"type":"object","properties":{"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5}},"required":["profileMediaId","imageMediaIds"]},"facts":{"type":"object","properties":{"ageLabel":{"type":"string"},"breed":{"type":"string","nullable":true},"currentLocation":{"type":"string","nullable":true},"source":{"type":"string","enum":["born_on_farm","purchased"]},"sex":{"type":"string","enum":["female","male"]}},"required":["ageLabel","breed","currentLocation","source","sex"]},"latestEvent":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"required":["cattle","statusChips","photo","facts","latestEvent"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/{cattleId}/health":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"responses":{"200":{"description":"Cattle health summary","content":{"application/json":{"schema":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]},"healthScore":{"type":"integer","minimum":0,"maximum":100},"latestHealthEvent":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]},"recentHealthEvents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"counts":{"type":"object","properties":{"vaccination":{"type":"number"},"deworming":{"type":"number"},"dehorning":{"type":"number"},"treatment":{"type":"number"},"diagnosis":{"type":"number"},"weight":{"type":"number"},"note":{"type":"number"}},"required":["vaccination","deworming","dehorning","treatment","diagnosis","weight","note"]},"flags":{"type":"object","properties":{"hasOpenTreatmentAttention":{"type":"boolean"},"hasMilkWithdrawalAttention":{"type":"boolean"},"hasWeightStalenessAttention":{"type":"boolean"}},"required":["hasOpenTreatmentAttention","hasMilkWithdrawalAttention","hasWeightStalenessAttention"]},"nextAction":{"type":"object","nullable":true,"properties":{"title":{"type":"string"},"description":{"type":"string"},"tone":{"type":"string","enum":["info","warning","success"]}},"required":["title","description","tone"]}},"required":["cattle","healthScore","latestHealthEvent","recentHealthEvents","counts","flags","nextAction"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/{cattleId}/breeding":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"responses":{"200":{"description":"Cattle breeding summary","content":{"application/json":{"schema":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]},"applicable":{"type":"boolean"},"reproductiveStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"latestBreedingEvent":{"type":"object","nullable":true,"properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]},"breedingTimeline":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"milestones":{"type":"object","properties":{"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"daysSinceService":{"type":"integer","nullable":true},"daysToExpectedCalving":{"type":"integer","nullable":true}},"required":["servedDate","expectedDeliveryDate","daysSinceService","daysToExpectedCalving"]},"flags":{"type":"object","properties":{"awaitingPregCheck":{"type":"boolean"},"pregCheckOverdue":{"type":"boolean"},"calvingWindowActive":{"type":"boolean"}},"required":["awaitingPregCheck","pregCheckOverdue","calvingWindowActive"]},"nextAction":{"type":"object","nullable":true,"properties":{"title":{"type":"string"},"description":{"type":"string"},"tone":{"type":"string","enum":["info","warning","success"]}},"required":["title","description","tone"]}},"required":["cattle","applicable","reproductiveStatus","latestBreedingEvent","breedingTimeline","milestones","flags","nextAction"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/events":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"cattleId","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, type, cattleId. Individual query parameters take precedence over values in this JSON."},"required":false,"description":"JSON object with optional keys: from, to, type, cattleId. Individual query parameters take precedence over values in this JSON.","name":"filters","in":"query"},{"schema":{"type":"string","enum":["date","createdAt"],"description":"Sort cattle event field. Allowed values: date, createdAt. Default: date (desc)."},"required":false,"description":"Sort cattle event field. Allowed values: date, createdAt. Default: date (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected cattle event field. Allowed values: asc, desc. Default: date (desc)."},"required":false,"description":"Sort direction for the selected cattle event field. Allowed values: asc, desc. Default: date (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Farm cattle events","content":{"application/json":{"schema":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["events","nextCursor","totalCount"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/{cattleId}":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"responses":{"200":{"description":"Cattle details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"tagNumber":{"type":"string","minLength":1},"name":{"type":"string","nullable":true,"minLength":1},"breed":{"type":"string","nullable":true,"minLength":1},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true,"minimum":0},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"anyOf":[{"type":"string","minLength":1,"maxLength":255},{"nullable":true}]},"notes":{"type":"string","nullable":true,"minLength":1},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5}},"additionalProperties":false}}}},"responses":{"200":{"description":"Cattle updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true},"sex":{"type":"string","enum":["female","male"]},"breed":{"type":"string","nullable":true},"dob":{"type":"string","nullable":true,"format":"date-time"},"dobEstimated":{"type":"boolean"},"source":{"type":"string","enum":["born_on_farm","purchased"]},"purchaseDate":{"type":"string","nullable":true,"format":"date-time"},"purchasePrice":{"type":"number","nullable":true},"status":{"type":"string","enum":["active","sold","dead"]},"productionStatus":{"type":"string","nullable":true,"enum":["calf","heifer","lactating","dry",null]},"reproStatus":{"type":"string","nullable":true,"enum":["open","served","pregnant",null]},"servedDate":{"type":"string","nullable":true,"format":"date-time"},"expectedDeliveryDate":{"type":"string","nullable":true,"format":"date-time"},"currentLocation":{"type":"string","nullable":true,"maxLength":255},"notes":{"type":"string","nullable":true},"profileMediaId":{"type":"string","nullable":true,"format":"uuid"},"imageMediaIds":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":5},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","tagNumber","name","sex","breed","dob","dobEstimated","source","purchaseDate","purchasePrice","status","productionStatus","reproStatus","servedDate","expectedDeliveryDate","currentLocation","notes","profileMediaId","imageMediaIds","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"responses":{"200":{"description":"Cattle deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/{cattleId}/events":{"post":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["BIRTH"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"calfSex":{"type":"string","enum":["female","male"]},"calfTagNumber":{"type":"string","minLength":1},"calfCount":{"type":"integer","minimum":1},"birthComplications":{"type":"string","minLength":1},"assisted":{"type":"string","enum":["yes","no"]},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["PURCHASE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"seller":{"type":"string","minLength":1},"amount":{"type":"number","minimum":0},"currency":{"type":"string","minLength":1},"purchaseLocation":{"type":"string","minLength":1},"transportCost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["WEIGHT"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"weightKg":{"type":"number","minimum":0,"exclusiveMinimum":true},"method":{"type":"string","enum":["tape","scale"]},"bodyConditionScore":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["weightKg"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["HEAT"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"observedBy":{"type":"string","minLength":1},"signs":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["INSEMINATION"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"method":{"type":"string","enum":["AI","BULL"]},"bullTagOrName":{"type":"string","minLength":1},"semenBatch":{"type":"string","minLength":1},"technician":{"type":"string","minLength":1},"heatObservedAt":{"type":"string","format":"date-time"},"observedBy":{"type":"string","minLength":1},"serviceLocation":{"type":"string","minLength":1},"cost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"required":["method"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["PREG_CHECK"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"result":{"type":"string","enum":["pregnant","not_pregnant"]},"method":{"type":"string","enum":["palpation","ultrasound"]},"expectedCalvingDate":{"type":"string","format":"date-time"},"fetusCount":{"type":"integer","minimum":1},"notes":{"type":"string","minLength":1}},"required":["result"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["CALVING"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"calfSex":{"type":"string","enum":["female","male"]},"calfTagNumber":{"type":"string","minLength":1},"calfCount":{"type":"integer","minimum":1},"calvingEase":{"type":"string","enum":["unassisted","assisted","difficult"]},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["VACCINATION"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"vaccine":{"type":"string","minLength":1},"batch":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"method":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["vaccine"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DEWORMING"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"drug":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["drug"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DEHORNING"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"method":{"type":"string","minLength":1},"performedBy":{"type":"string","minLength":1},"ageAtProcedure":{"type":"string","minLength":1},"painManagement":{"type":"string","minLength":1},"complications":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["TREATMENT"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"condition":{"type":"string","minLength":1},"drug":{"type":"string","minLength":1},"dose":{"type":"string","minLength":1},"route":{"type":"string","minLength":1},"withdrawalDaysMilk":{"type":"integer","minimum":0},"withdrawalDaysMeat":{"type":"integer","minimum":0},"treatmentOutcome":{"type":"string","minLength":1},"vet":{"type":"string","minLength":1},"cost":{"type":"number","minimum":0},"notes":{"type":"string","minLength":1}},"required":["drug"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DIAGNOSIS"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"diagnosis":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["diagnosis"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["SALE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"buyer":{"type":"string","minLength":1},"buyerContact":{"type":"string","minLength":1},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"reason":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"required":["amount"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["DEATH"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"cause":{"type":"string","minLength":1},"vetReport":{"type":"string","minLength":1},"foundAt":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1}},"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","properties":{"note":{"type":"string","minLength":1}},"required":["note"],"additionalProperties":false},"attachmentMediaId":{"type":"string","format":"uuid"}},"required":["type","date","data"],"additionalProperties":false}]}}}},"responses":{"201":{"description":"Event created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, type, cattleId. Individual query parameters take precedence over values in this JSON."},"required":false,"description":"JSON object with optional keys: from, to, type, cattleId. Individual query parameters take precedence over values in this JSON.","name":"filters","in":"query"},{"schema":{"type":"string","enum":["date","createdAt"],"description":"Sort cattle event field. Allowed values: date, createdAt. Default: date (desc)."},"required":false,"description":"Sort cattle event field. Allowed values: date, createdAt. Default: date (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected cattle event field. Allowed values: asc, desc. Default: date (desc)."},"required":false,"description":"Sort direction for the selected cattle event field. Allowed values: asc, desc. Default: date (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Cattle events","content":{"application/json":{"schema":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["events","nextCursor","totalCount"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/cattle/events/{eventId}":{"get":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"eventId","in":"path"}],"responses":{"200":{"description":"Cattle event","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"eventId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Event updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["BIRTH","PURCHASE","WEIGHT","HEAT","INSEMINATION","PREG_CHECK","CALVING","VACCINATION","DEWORMING","DEHORNING","TREATMENT","DIAGNOSIS","SALE","DEATH","NOTE"]},"date":{"type":"string","format":"date-time"},"data":{"type":"object","additionalProperties":{"nullable":true}},"attachmentMediaId":{"type":"string","nullable":true,"format":"uuid"},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","type","date","data","attachmentMediaId","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Cattle"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"eventId","in":"path"}],"responses":{"200":{"description":"Event deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/milking/sessions":{"post":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"cattleId":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":100},"recordedAt":{"type":"string","format":"date-time"},"notes":{"type":"string","minLength":1,"maxLength":1000}},"required":["cattleId","sessionType","quantityLitres","recordedAt"],"additionalProperties":false}}}},"responses":{"201":{"description":"Milking session created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"get":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"cattleId","in":"query"},{"schema":{"type":"string","enum":["morning","evening","midday","custom"]},"required":false,"name":"sessionType","in":"query"},{"schema":{"type":"string","enum":["normal","low","high","flagged"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["recordedAt","quantityLitres","createdAt"],"description":"Sort milking session. Allowed values: recordedAt, quantityLitres, createdAt. Default: recordedAt (desc)."},"required":false,"description":"Sort milking session. Allowed values: recordedAt, quantityLitres, createdAt. Default: recordedAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected milking session. Allowed values: asc, desc. Default: recordedAt (desc)."},"required":false,"description":"Sort direction for the selected milking session. Allowed values: asc, desc. Default: recordedAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Milking sessions list","content":{"application/json":{"schema":{"type":"object","properties":{"sessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["sessions","nextCursor","totalCount"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/milking/sessions/{sessionId}":{"get":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"}],"responses":{"200":{"description":"Milking session","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":100},"recordedAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true,"minLength":1,"maxLength":1000}},"additionalProperties":false}}}},"responses":{"200":{"description":"Milking session updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"sessionId","in":"path"}],"responses":{"200":{"description":"Milking session deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/milking/dashboard":{"get":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"responses":{"200":{"description":"Milking dashboard","content":{"application/json":{"schema":{"type":"object","properties":{"today":{"type":"object","properties":{"date":{"type":"string"},"totalLitres":{"type":"number"},"changePctVsYesterday":{"type":"number","nullable":true}},"required":["date","totalLitres","changePctVsYesterday"]},"avgPerCow":{"type":"object","properties":{"value":{"type":"number"},"changePctVsPreviousWeek":{"type":"number","nullable":true},"activeMilkingCows":{"type":"number"}},"required":["value","changePctVsPreviousWeek","activeMilkingCows"]},"weeklyYield":{"type":"object","properties":{"totalLitres":{"type":"number"},"points":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string"},"date":{"type":"string"},"litres":{"type":"number"}},"required":["label","date","litres"]}}},"required":["totalLitres","points"]},"recentSessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattleName":{"type":"string","nullable":true},"tagNumber":{"type":"string"},"quantityLitres":{"type":"number"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"recordedAt":{"type":"string","format":"date-time"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]}},"required":["id","cattleId","cattleName","tagNumber","quantityLitres","status","recordedAt","sessionType"]}},"alertsSummary":{"type":"object","properties":{"unresolvedCount":{"type":"number"},"highSeverityCount":{"type":"number"}},"required":["unresolvedCount","highSeverityCount"]}},"required":["today","avgPerCow","weeklyYield","recentSessions","alertsSummary"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/milking/cattle/{cattleId}/summary":{"get":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"cattleId","in":"path"}],"responses":{"200":{"description":"Cow milking summary","content":{"application/json":{"schema":{"type":"object","properties":{"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"todayTotalLitres":{"type":"number"},"sevenDayTotalLitres":{"type":"number"},"thirtyDayTotalLitres":{"type":"number"},"averagePerSession":{"type":"number"},"latestSessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","format":"uuid"},"cattle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"tagNumber":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["id","tagNumber","name"]},"recordedBy":{"type":"string","format":"uuid"},"sessionType":{"type":"string","enum":["morning","evening","midday","custom"]},"quantityLitres":{"type":"number"},"recordedAt":{"type":"string","format":"date-time"},"shiftDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["normal","low","high","flagged"]},"notes":{"type":"string","nullable":true},"source":{"type":"string","enum":["manual","imported","estimated"]},"sourceRef":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","nullable":true,"format":"date-time"},"insight":{"type":"object","properties":{"baselineAverageLitres":{"type":"number","nullable":true},"deviationPct":{"type":"number","nullable":true}},"required":["baselineAverageLitres","deviationPct"]}},"required":["id","farmId","cattleId","cattle","recordedBy","sessionType","quantityLitres","recordedAt","shiftDate","status","notes","source","sourceRef","createdAt","updatedAt","deletedAt"]}},"trendPoints":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string"},"date":{"type":"string"},"litres":{"type":"number"}},"required":["label","date","litres"]}},"alertCounts":{"type":"object","properties":{"unresolved":{"type":"number"},"total":{"type":"number"}},"required":["unresolved","total"]},"currentStatusSummary":{"type":"object","properties":{"latestStatus":{"type":"string","nullable":true,"enum":["normal","low","high","flagged",null]},"lastRecordedAt":{"type":"string","nullable":true,"format":"date-time"}},"required":["latestStatus","lastRecordedAt"]}},"required":["cattle","todayTotalLitres","sevenDayTotalLitres","thirtyDayTotalLitres","averagePerSession","latestSessions","trendPoints","alertCounts","currentStatusSummary"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/milking/alerts":{"get":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["yield_drop","yield_spike","missed_session","duplicate_session"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"resolved","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"cattleId","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","enum":["low","medium","high"]},"required":false,"name":"severity","in":"query"},{"schema":{"type":"string","enum":["createdAt"],"description":"Sort milking alert. Allowed values: createdAt. Default: createdAt (desc)."},"required":false,"description":"Sort milking alert. Allowed values: createdAt. Default: createdAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected milking alert. Allowed values: asc, desc. Default: createdAt (desc)."},"required":false,"description":"Sort direction for the selected milking alert. Allowed values: asc, desc. Default: createdAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Milking alerts","content":{"application/json":{"schema":{"type":"object","properties":{"alerts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","nullable":true,"format":"uuid"},"milkingSessionId":{"type":"string","nullable":true,"format":"uuid"},"type":{"type":"string","enum":["yield_drop","yield_spike","missed_session","duplicate_session"]},"severity":{"type":"string","enum":["low","medium","high"]},"title":{"type":"string"},"message":{"type":"string"},"expectedValue":{"type":"number","nullable":true},"actualValue":{"type":"number","nullable":true},"meta":{"type":"object","additionalProperties":{"nullable":true}},"resolvedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","milkingSessionId","type","severity","title","message","expectedValue","actualValue","meta","resolvedAt","createdAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"}},"required":["alerts","nextCursor","totalCount"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/milking/alerts/{alertId}/resolve":{"post":{"tags":["Milking"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"alertId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":false}}}},"responses":{"200":{"description":"Milking alert resolved","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"cattleId":{"type":"string","nullable":true,"format":"uuid"},"milkingSessionId":{"type":"string","nullable":true,"format":"uuid"},"type":{"type":"string","enum":["yield_drop","yield_spike","missed_session","duplicate_session"]},"severity":{"type":"string","enum":["low","medium","high"]},"title":{"type":"string"},"message":{"type":"string"},"expectedValue":{"type":"number","nullable":true},"actualValue":{"type":"number","nullable":true},"meta":{"type":"object","additionalProperties":{"nullable":true}},"resolvedAt":{"type":"string","nullable":true,"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","cattleId","milkingSessionId","type","severity","title","message","expectedValue","actualValue","meta","resolvedAt","createdAt"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/categories":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","enum":["expense","income"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","enum":["name","code","group","createdAt","updatedAt"],"description":"Sort category field. Allowed values: name, code, group, createdAt, updatedAt. Default: name (asc)."},"required":false,"description":"Sort category field. Allowed values: name, code, group, createdAt, updatedAt. Default: name (asc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected category field. Allowed values: asc, desc. Default: name (asc)."},"required":false,"description":"Sort direction for the selected category field. Allowed values: asc, desc. Default: name (asc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Expense categories","content":{"application/json":{"schema":{"type":"object","properties":{"categories":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense","income"]},"code":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"isSystem":{"type":"boolean"},"countsTowardsCostPerLitre":{"type":"boolean"},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","code","name","description","group","isSystem","countsTowardsCostPerLitre","isActive","createdAt","updatedAt"]}}},"required":["categories"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["expense","income"]},"code":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"description":{"type":"string","nullable":true,"minLength":1},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"countsTowardsCostPerLitre":{"type":"boolean","default":true},"isActive":{"type":"boolean"}},"required":["name","group"],"additionalProperties":false}}}},"responses":{"201":{"description":"Category created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense","income"]},"code":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"isSystem":{"type":"boolean"},"countsTowardsCostPerLitre":{"type":"boolean"},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","code","name","description","group","isSystem","countsTowardsCostPerLitre","isActive","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/categories/{categoryId}":{"patch":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"categoryId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"description":{"type":"string","nullable":true,"minLength":1},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"countsTowardsCostPerLitre":{"type":"boolean"},"isActive":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Category updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense","income"]},"code":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"group":{"anyOf":[{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}]},"isSystem":{"type":"boolean"},"countsTowardsCostPerLitre":{"type":"boolean"},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","code","name","description","group","isSystem","countsTowardsCostPerLitre","isActive","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/categories/{categoryId}/deactivate":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"categoryId","in":"path"}],"responses":{"200":{"description":"Category deactivated","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/counterparties":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","enum":["customer","supplier"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","enum":["name","type","createdAt","updatedAt"],"description":"Sort counterparty field. Allowed values: name, type, createdAt, updatedAt. Default: name (asc)."},"required":false,"description":"Sort counterparty field. Allowed values: name, type, createdAt, updatedAt. Default: name (asc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected counterparty field. Allowed values: asc, desc. Default: name (asc)."},"required":false,"description":"Sort direction for the selected counterparty field. Allowed values: asc, desc. Default: name (asc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Finance counterparties","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string"},"code":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","name","code","phone","email","notes","isActive","createdAt","updatedAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string","minLength":1},"code":{"type":"string","nullable":true,"minLength":1},"phone":{"type":"string","nullable":true,"minLength":1},"email":{"type":"string","nullable":true,"format":"email"},"notes":{"type":"string","nullable":true,"minLength":1},"isActive":{"type":"boolean"}},"required":["type","name"],"additionalProperties":false}}}},"responses":{"201":{"description":"Counterparty created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string"},"code":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","name","code","phone","email","notes","isActive","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/counterparties/{counterpartyId}":{"patch":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"counterpartyId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string","minLength":1},"code":{"type":"string","nullable":true,"minLength":1},"phone":{"type":"string","nullable":true,"minLength":1},"email":{"type":"string","nullable":true,"format":"email"},"notes":{"type":"string","nullable":true,"minLength":1},"isActive":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Counterparty updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["customer","supplier"]},"name":{"type":"string"},"code":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"isActive":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","name","code","phone","email","notes","isActive","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/expenses":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","minLength":1},"unitPrice":{"type":"number","minimum":0,"exclusiveMinimum":true},"counterpartyId":{"type":"string","format":"uuid"},"counterpartyName":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1},"receiptMediaId":{"type":"string","format":"uuid"},"linkedCattleId":{"type":"string","format":"uuid"}},"required":["date","categoryId","paymentMethod"],"additionalProperties":false}}}},"responses":{"201":{"description":"Expense created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"countsTowardsCostPerLitre":{"type":"boolean"}},"required":["id","name","group","countsTowardsCostPerLitre"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"categoryId","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"counterpartyId","in":"query"},{"schema":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"required":false,"name":"group","in":"query"},{"schema":{"type":"string","enum":["cash","mobile","bank","cheque"]},"required":false,"name":"paymentMethod","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"openOnly","in":"query"},{"schema":{"type":"number","minimum":0,"exclusiveMinimum":true},"required":false,"name":"minOutstanding","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q, openOnly, minOutstanding"},"required":false,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q, openOnly, minOutstanding","name":"filters","in":"query"},{"schema":{"type":"string","enum":["date","amount","createdAt","categoryName","paymentMethod"],"description":"Sort expense field. Allowed values: date, amount, createdAt, categoryName, paymentMethod. Default: date (desc)."},"required":false,"description":"Sort expense field. Allowed values: date, amount, createdAt, categoryName, paymentMethod. Default: date (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected expense field. Allowed values: asc, desc. Default: date (desc)."},"required":false,"description":"Sort direction for the selected expense field. Allowed values: asc, desc. Default: date (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Expense list","content":{"application/json":{"schema":{"type":"object","properties":{"expenses":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"countsTowardsCostPerLitre":{"type":"boolean"}},"required":["id","name","group","countsTowardsCostPerLitre"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"},"summary":{"type":"object","properties":{"totalExpense":{"type":"number"}},"required":["totalExpense"]}},"required":["expenses","nextCursor","totalCount","summary"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/income":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","minLength":1},"unitPrice":{"type":"number","minimum":0,"exclusiveMinimum":true},"bonusAmount":{"type":"number","minimum":0},"deductionAmount":{"type":"number","minimum":0},"counterpartyId":{"type":"string","format":"uuid"},"counterpartyName":{"type":"string","minLength":1},"notes":{"type":"string","minLength":1},"receiptMediaId":{"type":"string","format":"uuid"},"linkedCattleId":{"type":"string","format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","minLength":1}},"required":["date","categoryId","paymentMethod"],"additionalProperties":false}}}},"responses":{"201":{"description":"Income created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["income"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}},"required":["id","name","group"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"bonusAmount":{"type":"number","nullable":true},"deductionAmount":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","bonusAmount","deductionAmount","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","source","sourceRef","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"categoryId","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"counterpartyId","in":"query"},{"schema":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"required":false,"name":"group","in":"query"},{"schema":{"type":"string","enum":["cash","mobile","bank","cheque"]},"required":false,"name":"paymentMethod","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"openOnly","in":"query"},{"schema":{"type":"number","minimum":0,"exclusiveMinimum":true},"required":false,"name":"minOutstanding","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q, openOnly, minOutstanding"},"required":false,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q, openOnly, minOutstanding","name":"filters","in":"query"},{"schema":{"type":"string","enum":["date","amount","createdAt","categoryName","paymentMethod"],"description":"Sort income field. Allowed values: date, amount, createdAt, categoryName, paymentMethod. Default: date (desc)."},"required":false,"description":"Sort income field. Allowed values: date, amount, createdAt, categoryName, paymentMethod. Default: date (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected income field. Allowed values: asc, desc. Default: date (desc)."},"required":false,"description":"Sort direction for the selected income field. Allowed values: asc, desc. Default: date (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Income list","content":{"application/json":{"schema":{"type":"object","properties":{"income":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["income"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}},"required":["id","name","group"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"bonusAmount":{"type":"number","nullable":true},"deductionAmount":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","bonusAmount","deductionAmount","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","source","sourceRef","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}},"nextCursor":{"type":"string","nullable":true},"totalCount":{"type":"number"},"summary":{"type":"object","properties":{"totalIncome":{"type":"number"}},"required":["totalIncome"]}},"required":["income","nextCursor","totalCount","summary"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/expenses/summary":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"categoryId","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"counterpartyId","in":"query"},{"schema":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"required":false,"name":"group","in":"query"},{"schema":{"type":"string","enum":["cash","mobile","bank","cheque"]},"required":false,"name":"paymentMethod","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q"},"required":false,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q","name":"filters","in":"query"}],"responses":{"200":{"description":"Expense summary","content":{"application/json":{"schema":{"type":"object","properties":{"totalExpense":{"type":"number"},"byGroup":{"type":"array","items":{"type":"object","properties":{"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]}},"byCategory":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]}}},"required":["totalExpense","byGroup","byCategory"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/income/summary":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"categoryId","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"counterpartyId","in":"query"},{"schema":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"required":false,"name":"group","in":"query"},{"schema":{"type":"string","enum":["cash","mobile","bank","cheque"]},"required":false,"name":"paymentMethod","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q"},"required":false,"description":"JSON object with optional keys: from, to, categoryId, counterpartyId, group, paymentMethod, q","name":"filters","in":"query"}],"responses":{"200":{"description":"Income summary","content":{"application/json":{"schema":{"type":"object","properties":{"totalIncome":{"type":"number"},"byGroup":{"type":"array","items":{"type":"object","properties":{"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]}},"byCategory":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]}},"milkLitresTotal":{"type":"number"},"averageMilkPrice":{"type":"number","nullable":true}},"required":["totalIncome","byGroup","byCategory","milkLitresTotal","averageMilkPrice"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/expenses/export":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"categoryId","in":"query"},{"schema":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"required":false,"name":"group","in":"query"},{"schema":{"type":"string","enum":["cash","mobile","bank","cheque"]},"required":false,"name":"paymentMethod","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, group, paymentMethod, q"},"required":false,"description":"JSON object with optional keys: from, to, categoryId, group, paymentMethod, q","name":"filters","in":"query"},{"schema":{"type":"string","enum":["csv"],"default":"csv"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"CSV export of expenses","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/income/export":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"categoryId","in":"query"},{"schema":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"required":false,"name":"group","in":"query"},{"schema":{"type":"string","enum":["cash","mobile","bank","cheque"]},"required":false,"name":"paymentMethod","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","minLength":1,"description":"JSON object with optional keys: from, to, categoryId, group, paymentMethod, q"},"required":false,"description":"JSON object with optional keys: from, to, categoryId, group, paymentMethod, q","name":"filters","in":"query"},{"schema":{"type":"string","enum":["csv"],"default":"csv"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"CSV export of income","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/invoices":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"q","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"openOnly","in":"query"},{"schema":{"type":"number","minimum":0,"exclusiveMinimum":true},"required":false,"name":"minOutstanding","in":"query"},{"schema":{"type":"string","enum":["issueDate","dueDate","totalAmount","balanceDue","createdAt"],"description":"Sort invoice field. Allowed values: issueDate, dueDate, totalAmount, balanceDue, createdAt. Default: issueDate (desc)."},"required":false,"description":"Sort invoice field. Allowed values: issueDate, dueDate, totalAmount, balanceDue, createdAt. Default: issueDate (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected invoice field. Allowed values: asc, desc. Default: issueDate (desc)."},"required":false,"description":"Sort direction for the selected invoice field. Allowed values: asc, desc. Default: issueDate (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Invoice list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"customerId":{"type":"string","format":"uuid"},"customerName":{"type":"string","minLength":1},"invoiceNumber":{"type":"string","minLength":1},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"taxAmount":{"type":"number","minimum":0},"discountAmount":{"type":"number","minimum":0},"notes":{"type":"string","nullable":true,"minLength":1},"items":{"type":"array","items":{"type":"object","properties":{"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"}},"required":["itemType","referenceId","description","quantity","unit","unitPrice","lineTotal"]},"minItems":1}},"required":["issueDate","items"],"additionalProperties":false}}}},"responses":{"201":{"description":"Invoice created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/invoices/{invoiceId}":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"invoiceId","in":"path"}],"responses":{"200":{"description":"Invoice details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"invoiceId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string","minLength":1},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"taxAmount":{"type":"number","minimum":0},"discountAmount":{"type":"number","minimum":0},"notes":{"type":"string","nullable":true,"minLength":1},"items":{"type":"array","items":{"type":"object","properties":{"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"}},"required":["itemType","referenceId","description","quantity","unit","unitPrice","lineTotal"]},"minItems":1}},"additionalProperties":false}}}},"responses":{"200":{"description":"Invoice updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"invoiceId","in":"path"}],"responses":{"200":{"description":"Invoice deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/invoices/{invoiceId}/issue":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"invoiceId","in":"path"}],"responses":{"200":{"description":"Invoice issued","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/invoices/{invoiceId}/pay":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"invoiceId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true,"minLength":1},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true,"minLength":1},"payerName":{"type":"string","nullable":true,"minLength":1},"payerPhone":{"type":"string","nullable":true,"minLength":1},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true,"minLength":1}},"required":["amount","paymentMethod"],"additionalProperties":false}}}},"responses":{"200":{"description":"Invoice payment recorded","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/invoices/{invoiceId}/void":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"invoiceId","in":"path"}],"responses":{"200":{"description":"Invoice voided","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"customerId":{"type":"string","nullable":true,"format":"uuid"},"customerName":{"type":"string"},"invoiceNumber":{"type":"string"},"issueDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"subtotal":{"type":"number"},"taxAmount":{"type":"number"},"discountAmount":{"type":"number"},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"notes":{"type":"string","nullable":true},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"invoiceId":{"type":"string","format":"uuid"},"itemType":{"type":"string","enum":["milk","animal","manure","service","other"]},"referenceId":{"type":"string","nullable":true,"format":"uuid"},"description":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string"},"unitPrice":{"type":"number"},"lineTotal":{"type":"number"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","invoiceId","itemType","referenceId","description","quantity","unit","unitPrice","lineTotal","createdAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","customerId","customerName","invoiceNumber","issueDate","dueDate","status","subtotal","taxAmount","discountAmount","totalAmount","amountPaid","balanceDue","amountSettled","amountOutstanding","settlementStatus","notes","items","attachments","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/payments":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","enum":["pending","completed","failed","reversed"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["incoming","outgoing"]},"required":false,"name":"direction","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"invoiceId","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","enum":["paidAt","createdAt","amount","status","paymentMethod"],"description":"Sort payment field. Allowed values: paidAt, createdAt, amount, status, paymentMethod. Default: paidAt (desc)."},"required":false,"description":"Sort payment field. Allowed values: paidAt, createdAt, amount, status, paymentMethod. Default: paidAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected payment field. Allowed values: asc, desc. Default: paidAt (desc)."},"required":false,"description":"Sort direction for the selected payment field. Allowed values: asc, desc. Default: paidAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Payment list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currencyCode":{"type":"string","minLength":1},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true,"minLength":1},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true,"minLength":1},"payerName":{"type":"string","nullable":true,"minLength":1},"payerPhone":{"type":"string","nullable":true,"minLength":1},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true,"minLength":1},"allocations":{"type":"array","items":{"type":"object","properties":{"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number","minimum":0,"exclusiveMinimum":true}},"required":["entityType","entityId","allocatedAmount"]}}},"required":["direction","relatedType","amount","paymentMethod"],"additionalProperties":false}}}},"responses":{"200":{"description":"Payment already created for this idempotency key","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}}},"201":{"description":"Payment created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/payments/import/statement":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"entries":{"type":"array","items":{"type":"object","properties":{"direction":{"type":"string","enum":["incoming","outgoing"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currencyCode":{"type":"string","minLength":1},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true,"minLength":1},"payerName":{"type":"string","nullable":true,"minLength":1},"payerPhone":{"type":"string","nullable":true,"minLength":1},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true,"minLength":1}},"required":["direction","amount","paymentMethod"]},"minItems":1}},"required":["entries"],"additionalProperties":false}}}},"responses":{"201":{"description":"Statement payments imported","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/payments/import/sms":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"messages":{"type":"array","items":{"type":"string","minLength":1},"minItems":1},"defaultDirection":{"type":"string","enum":["incoming","outgoing"]},"defaultPaymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]}},"required":["messages"],"additionalProperties":false}}}},"responses":{"201":{"description":"SMS payments imported","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}},"unparsedMessages":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string"},"reason":{"type":"string"}},"required":["message","reason"]}}},"required":["items","unparsedMessages"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/payments/{paymentId}":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"paymentId","in":"path"}],"responses":{"200":{"description":"Payment details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"paymentId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currencyCode":{"type":"string","minLength":1},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true,"minLength":1},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true,"minLength":1},"payerName":{"type":"string","nullable":true,"minLength":1},"payerPhone":{"type":"string","nullable":true,"minLength":1},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true,"minLength":1},"allocations":{"type":"array","items":{"type":"object","properties":{"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number","minimum":0,"exclusiveMinimum":true}},"required":["entityType","entityId","allocatedAmount"]}}},"required":["direction","relatedType","amount","paymentMethod"],"additionalProperties":false}}}},"responses":{"200":{"description":"Payment updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"paymentId","in":"path"}],"responses":{"200":{"description":"Payment deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/payments/{paymentId}/allocate":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"paymentId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"allocations":{"type":"array","items":{"type":"object","properties":{"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number","minimum":0,"exclusiveMinimum":true}},"required":["entityType","entityId","allocatedAmount"]},"minItems":1}},"required":["allocations"],"additionalProperties":false}}}},"responses":{"200":{"description":"Payment allocations created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/payments/{paymentId}/unallocate":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"paymentId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"allocationIds":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1}},"required":["allocationIds"],"additionalProperties":false}}}},"responses":{"200":{"description":"Payment allocations removed","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["incoming","outgoing"]},"relatedType":{"type":"string","enum":["invoice","income","expense","manual"]},"relatedId":{"type":"string","nullable":true,"format":"uuid"},"invoiceId":{"type":"string","nullable":true,"format":"uuid"},"amount":{"type":"number"},"currencyCode":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"provider":{"type":"string","enum":["mpesa","bank","cash","other"]},"providerReference":{"type":"string","nullable":true},"proofType":{"type":"string","nullable":true,"enum":["mpesa_message","bank_statement","cash_receipt","transfer_slip","other",null]},"proofText":{"type":"string","nullable":true},"payerName":{"type":"string","nullable":true},"payerPhone":{"type":"string","nullable":true},"status":{"type":"string","enum":["pending","completed","failed","reversed"]},"paidAt":{"type":"string","format":"date-time"},"notes":{"type":"string","nullable":true},"allocatedAmount":{"type":"number"},"unallocatedAmount":{"type":"number"},"allocations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"paymentId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["invoice","expense","income"]},"entityId":{"type":"string","format":"uuid"},"allocatedAmount":{"type":"number"},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","paymentId","entityType","entityId","allocatedAmount","createdBy","createdAt","updatedAt"]}},"attachments":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}},"createdBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","direction","relatedType","relatedId","invoiceId","amount","currencyCode","paymentMethod","provider","providerReference","proofType","proofText","payerName","payerPhone","status","paidAt","notes","allocatedAmount","unallocatedAmount","allocations","attachments","createdBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/budgets":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","enum":["startDate","endDate","createdAt","budgetAmount","name"],"description":"Sort budget field. Allowed values: startDate, endDate, createdAt, budgetAmount, name. Default: startDate (desc)."},"required":false,"description":"Sort budget field. Allowed values: startDate, endDate, createdAt, budgetAmount, name. Default: startDate (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected budget field. Allowed values: asc, desc. Default: startDate (desc)."},"required":false,"description":"Sort direction for the selected budget field. Allowed values: asc, desc. Default: startDate (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Budget list","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"categoryId":{"type":"string","format":"uuid"},"name":{"type":"string"},"periodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"budgetAmount":{"type":"number"},"alertThresholdPercent":{"type":"integer","nullable":true},"isActive":{"type":"boolean"},"createdBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","categoryId","name","periodType","startDate","endDate","budgetAmount","alertThresholdPercent","isActive","createdBy","createdAt","updatedAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"periodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"budgetAmount":{"type":"number","minimum":0,"exclusiveMinimum":true},"alertThresholdPercent":{"type":"integer","nullable":true,"minimum":1,"maximum":100},"isActive":{"type":"boolean"}},"required":["categoryId","name","periodType","startDate","endDate","budgetAmount"],"additionalProperties":false}}}},"responses":{"201":{"description":"Budget created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"categoryId":{"type":"string","format":"uuid"},"name":{"type":"string"},"periodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"budgetAmount":{"type":"number"},"alertThresholdPercent":{"type":"integer","nullable":true},"isActive":{"type":"boolean"},"createdBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","categoryId","name","periodType","startDate","endDate","budgetAmount","alertThresholdPercent","isActive","createdBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/budgets/{budgetId}":{"patch":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"budgetId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1},"periodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"budgetAmount":{"type":"number","minimum":0,"exclusiveMinimum":true},"alertThresholdPercent":{"type":"integer","nullable":true,"minimum":1,"maximum":100},"isActive":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Budget updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"categoryId":{"type":"string","format":"uuid"},"name":{"type":"string"},"periodType":{"type":"string","enum":["monthly","quarterly","yearly"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"budgetAmount":{"type":"number"},"alertThresholdPercent":{"type":"integer","nullable":true},"isActive":{"type":"boolean"},"createdBy":{"type":"string","format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","categoryId","name","periodType","startDate","endDate","budgetAmount","alertThresholdPercent","isActive","createdBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"budgetId","in":"path"}],"responses":{"200":{"description":"Budget deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/attachments/presign":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"filename":{"type":"string","minLength":1},"contentType":{"type":"string","minLength":1},"mimeType":{"type":"string","minLength":1},"bytes":{"type":"integer","minimum":0,"exclusiveMinimum":true},"byteSize":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"additionalProperties":false,"description":"Create a staged finance_proof asset and receive a presigned upload target or backend upload URL."}}}},"responses":{"200":{"description":"Attachment upload intent created","content":{"application/json":{"schema":{"type":"object","properties":{"assetId":{"type":"string","format":"uuid","description":"Newly created staged asset id.","example":"22222222-2222-4222-8222-222222222222"},"uploadUrl":{"type":"string","format":"uri","description":"Presigned storage URL or backend upload endpoint for the raw upload.","example":"https://api.example.com/v1/media/upload/22222222-2222-4222-8222-222222222222?token=..."},"uploadMethod":{"type":"string","enum":["PUT"],"description":"HTTP method to use when uploading the binary payload.","example":"PUT"},"headersToSend":{"type":"object","additionalProperties":{"type":"string"},"description":"Headers the client must send when uploading.","example":{"content-type":"image/jpeg"}},"expiresAt":{"type":"string","format":"date-time","description":"Expiration timestamp for the upload target.","example":"2026-03-15T12:00:00.000Z"},"maxBytes":{"type":"integer","minimum":0,"exclusiveMinimum":true,"description":"Maximum allowed byte size for this purpose.","example":10485760}},"required":["assetId","uploadUrl","uploadMethod","headersToSend","expiresAt","maxBytes"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/attachments":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"}},"required":["entityType","entityId","assetId"],"additionalProperties":false,"description":"Use the existing media upload/finalize flow first, then attach the ready finance_proof asset here."}}}},"responses":{"201":{"description":"Attachment created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string","enum":["expense","income","invoice","payment","budget"]},"entityId":{"type":"string","format":"uuid"},"assetId":{"type":"string","format":"uuid"},"originalName":{"type":"string","nullable":true},"mimeType":{"type":"string","nullable":true},"sizeBytes":{"type":"integer","nullable":true},"uploadedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","assetId","originalName","mimeType","sizeBytes","uploadedBy","createdAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/attachments/{attachmentId}":{"delete":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"attachmentId","in":"path"}],"responses":{"200":{"description":"Attachment deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/reports/profit-loss":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"}],"responses":{"200":{"description":"Profit and loss report","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalIncome":{"type":"number"},"totalExpenses":{"type":"number"},"netProfit":{"type":"number"},"incomeBreakdown":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"amount":{"type":"number"}},"required":["categoryId","categoryName","amount"]}},"expenseBreakdown":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"amount":{"type":"number"}},"required":["categoryId","categoryName","amount"]}}},"required":["period","totalIncome","totalExpenses","netProfit","incomeBreakdown","expenseBreakdown"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/reports/cash-flow":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"},{"schema":{"type":"string","enum":["day","week","month"],"default":"day"},"required":false,"name":"groupBy","in":"query"}],"responses":{"200":{"description":"Cash flow report","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"groupBy":{"type":"string","enum":["day","week","month"]}},"required":["startDate","endDate","groupBy"]},"moneyIn":{"type":"number"},"moneyOut":{"type":"number"},"netMovement":{"type":"number"},"groups":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"moneyIn":{"type":"number"},"moneyOut":{"type":"number"},"netMovement":{"type":"number"}},"required":["key","moneyIn","moneyOut","netMovement"]}}},"required":["period","moneyIn","moneyOut","netMovement","groups"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/reports/income-breakdown":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"}],"responses":{"200":{"description":"Income breakdown","content":{"application/json":{"schema":{"type":"object","properties":{"totalIncome":{"type":"number"},"byGroup":{"type":"array","items":{"type":"object","properties":{"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]}},"byCategory":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]}},"milkLitresTotal":{"type":"number"},"averageMilkPrice":{"type":"number","nullable":true}},"required":["totalIncome","byGroup","byCategory","milkLitresTotal","averageMilkPrice"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/reports/expense-breakdown":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"}],"responses":{"200":{"description":"Expense breakdown","content":{"application/json":{"schema":{"type":"object","properties":{"totalExpense":{"type":"number"},"byGroup":{"type":"array","items":{"type":"object","properties":{"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["group","total"]}},"byCategory":{"type":"array","items":{"type":"object","properties":{"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"total":{"type":"number"}},"required":["categoryId","categoryName","group","total"]}}},"required":["totalExpense","byGroup","byCategory"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/reports/outstanding-invoices":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"}],"responses":{"200":{"description":"Outstanding invoices","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"invoiceId":{"type":"string","format":"uuid"},"invoiceNumber":{"type":"string"},"customerName":{"type":"string"},"dueDate":{"type":"string","nullable":true,"format":"date-time"},"status":{"type":"string","enum":["draft","issued","partially_paid","paid","overdue","void"]},"totalAmount":{"type":"number"},"amountPaid":{"type":"number"},"balanceDue":{"type":"number"}},"required":["invoiceId","invoiceNumber","customerName","dueDate","status","totalAmount","amountPaid","balanceDue"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/reports/budget-vs-actual":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"}],"responses":{"200":{"description":"Budget vs actual report","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"items":{"type":"array","items":{"type":"object","properties":{"budgetId":{"type":"string","format":"uuid"},"categoryId":{"type":"string","format":"uuid"},"categoryName":{"type":"string"},"budgetAmount":{"type":"number"},"actualSpend":{"type":"number"},"variance":{"type":"number"},"percentUsed":{"type":"number","nullable":true},"status":{"type":"string","enum":["ok","warning","over_budget"]}},"required":["budgetId","categoryId","categoryName","budgetAmount","actualSpend","variance","percentUsed","status"]}}},"required":["period","items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/analytics/cost-per-litre":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"includeLabour","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"includeUtilities","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"includeBreeding","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"includeMaintenance","in":"query"},{"schema":{"type":"boolean","nullable":true},"required":false,"name":"includeOther","in":"query"}],"responses":{"200":{"description":"Cost per litre analytics","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalMilkLitres":{"type":"number"},"totalDairyExpenses":{"type":"number"},"costPerLitre":{"type":"number","nullable":true},"averageSellingPricePerLitre":{"type":"number","nullable":true},"grossMarginPerLitre":{"type":"number","nullable":true}},"required":["period","totalMilkLitres","totalDairyExpenses","costPerLitre","averageSellingPricePerLitre","grossMarginPerLitre"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/analytics/cow-profitability":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"}],"responses":{"200":{"description":"Cow profitability analytics","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"items":{"type":"array","items":{"type":"object","properties":{"cattleId":{"type":"string","format":"uuid"},"cattleTag":{"type":"string"},"cattleName":{"type":"string","nullable":true},"milkLitres":{"type":"number"},"revenue":{"type":"number"},"feedCost":{"type":"number"},"vetCost":{"type":"number"},"breedingCost":{"type":"number"},"otherDirectCost":{"type":"number"},"totalCost":{"type":"number"},"profit":{"type":"number"},"marginPercent":{"type":"number","nullable":true}},"required":["cattleId","cattleTag","cattleName","milkLitres","revenue","feedCost","vetCost","breedingCost","otherDirectCost","totalCost","profit","marginPercent"]}}},"required":["period","items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/analytics/feed-costs":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"}],"responses":{"200":{"description":"Feed cost analytics","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalFeedExpense":{"type":"number"},"totalExpense":{"type":"number"},"feedExpenseSharePercent":{"type":"number","nullable":true},"feedCostPerLitre":{"type":"number","nullable":true},"averageDailyFeedCostPerCow":{"type":"number","nullable":true}},"required":["period","totalFeedExpense","totalExpense","feedExpenseSharePercent","feedCostPerLitre","averageDailyFeedCostPerCow"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/analytics/summary":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"startDate","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":true,"name":"endDate","in":"query"}],"responses":{"200":{"description":"Finance summary analytics","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["startDate","endDate"]},"totalIncome":{"type":"number"},"totalExpenses":{"type":"number"},"netProfit":{"type":"number"},"milkRevenue":{"type":"number"},"feedExpenses":{"type":"number"},"costPerLitre":{"type":"number","nullable":true},"unpaidInvoices":{"type":"number"},"overBudgetCategories":{"type":"number"},"alerts":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["invoice_overdue","budget_exceeded","feed_cost_spike","milk_revenue_drop","high_vet_spend","missing_attachment"]},"severity":{"type":"string","enum":["info","warning","critical"]},"message":{"type":"string"}},"required":["code","severity","message"]}}},"required":["period","totalIncome","totalExpenses","netProfit","milkRevenue","feedExpenses","costPerLitre","unpaidInvoices","overBudgetCategories","alerts"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/audit-logs":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","minLength":1},"required":false,"name":"entityType","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"entityId","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"action","in":"query"},{"schema":{"type":"string","enum":["createdAt","action","entityType"],"description":"Sort audit log field. Allowed values: createdAt, action, entityType. Default: createdAt (desc)."},"required":false,"description":"Sort audit log field. Allowed values: createdAt, action, entityType. Default: createdAt (desc).","name":"sortBy","in":"query"},{"schema":{"type":"string","enum":["asc","desc"],"description":"Sort direction for the selected audit log field. Allowed values: asc, desc. Default: createdAt (desc)."},"required":false,"description":"Sort direction for the selected audit log field. Allowed values: asc, desc. Default: createdAt (desc).","name":"sortDir","in":"query"}],"responses":{"200":{"description":"Finance audit logs","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"entityType":{"type":"string"},"entityId":{"type":"string","format":"uuid"},"action":{"type":"string","enum":["created","updated","deleted","approved","cancelled","paid","voided","issued","attached","detached","reversed"]},"actorId":{"type":"string","nullable":true,"format":"uuid"},"actorName":{"type":"string","nullable":true},"beforeJson":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"afterJson":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"ipAddress":{"type":"string","nullable":true},"userAgent":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"}},"required":["id","farmId","entityType","entityId","action","actorId","actorName","beforeJson","afterJson","ipAddress","userAgent","createdAt"]}}},"required":["items"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/expenses/{expenseId}":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"expenseId","in":"path"}],"responses":{"200":{"description":"Expense details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"countsTowardsCostPerLitre":{"type":"boolean"}},"required":["id","name","group","countsTowardsCostPerLitre"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"expenseId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","nullable":true,"minLength":1},"unitPrice":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true,"minLength":1},"notes":{"type":"string","nullable":true,"minLength":1},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Expense updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"countsTowardsCostPerLitre":{"type":"boolean"}},"required":["id","name","group","countsTowardsCostPerLitre"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"expenseId","in":"path"}],"responses":{"200":{"description":"Expense deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/income/{incomeId}":{"get":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"incomeId","in":"path"}],"responses":{"200":{"description":"Income details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["income"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}},"required":["id","name","group"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"bonusAmount":{"type":"number","nullable":true},"deductionAmount":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","bonusAmount","deductionAmount","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","source","sourceRef","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"patch":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"incomeId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"categoryId":{"type":"string","format":"uuid"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"amount":{"type":"number","minimum":0,"exclusiveMinimum":true},"currency":{"type":"string","minLength":1},"quantity":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"unit":{"type":"string","nullable":true,"minLength":1},"unitPrice":{"type":"number","nullable":true,"minimum":0,"exclusiveMinimum":true},"bonusAmount":{"type":"number","nullable":true,"minimum":0},"deductionAmount":{"type":"number","nullable":true,"minimum":0},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true,"minLength":1},"notes":{"type":"string","nullable":true,"minLength":1},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true,"minLength":1}},"additionalProperties":false}}}},"responses":{"200":{"description":"Income updated","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["income"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}},"required":["id","name","group"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"bonusAmount":{"type":"number","nullable":true},"deductionAmount":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","bonusAmount","deductionAmount","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","source","sourceRef","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}},"delete":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"incomeId","in":"path"}],"responses":{"200":{"description":"Income deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/expenses/{expenseId}/reverse":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"expenseId","in":"path"}],"responses":{"201":{"description":"Expense reversed","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["expense"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["FEED","VET","LABOUR","FUEL_TRANSPORT","UTILITIES","MAINTENANCE","SUPPLIES","BREEDING","TAXES","OTHER"]},"countsTowardsCostPerLitre":{"type":"boolean"}},"required":["id","name","group","countsTowardsCostPerLitre"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}},"/v1/farms/{farmId}/finance/income/{incomeId}/reverse":{"post":{"tags":["Finance"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"farmId","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"incomeId","in":"path"}],"responses":{"201":{"description":"Income reversed","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"farmId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["income"]},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"currency":{"type":"string"},"paymentMethod":{"type":"string","enum":["cash","mobile","bank","cheque"]},"category":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"group":{"type":"string","enum":["MILK_SALES","ANIMALS","BYPRODUCTS","SERVICES","OTHER"]}},"required":["id","name","group"]},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"unitPrice":{"type":"number","nullable":true},"bonusAmount":{"type":"number","nullable":true},"deductionAmount":{"type":"number","nullable":true},"counterpartyId":{"type":"string","nullable":true,"format":"uuid"},"counterpartyName":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"receiptMediaId":{"type":"string","nullable":true,"format":"uuid"},"linkedCattleId":{"type":"string","nullable":true,"format":"uuid"},"source":{"type":"string","enum":["manual","milk_module","import"]},"sourceRef":{"type":"string","nullable":true},"status":{"type":"string","enum":["normal","reversed"]},"reversalOfId":{"type":"string","nullable":true,"format":"uuid"},"amountSettled":{"type":"number"},"amountOutstanding":{"type":"number"},"settlementStatus":{"type":"string","enum":["unsettled","partially_settled","settled","overallocated"]},"createdBy":{"type":"string","format":"uuid"},"updatedBy":{"type":"string","nullable":true,"format":"uuid"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","farmId","type","date","amount","currency","paymentMethod","category","quantity","unit","unitPrice","bonusAmount","deductionAmount","counterpartyId","counterpartyName","notes","receiptMediaId","linkedCattleId","source","sourceRef","status","reversalOfId","amountSettled","amountOutstanding","settlementStatus","createdBy","updatedBy","createdAt","updatedAt"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"location":{"type":"string","enum":["body","query","params","request","system"]},"message":{"type":"string"}},"required":["message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"example":{"error":{"code":"COMMON.REQUEST.INVALID","title":"Validation Error","message":"Request validation failed.","details":[{"field":"email","location":"body","message":"Invalid email address"}],"requestId":"d8f5f2ae-5ccf-4c4f-935e-1c8c4b2f1f10"}}}}}}}}}}}