{"openapi":"3.0.0","paths":{"/v1/health":{"get":{"operationId":"getHealth","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}},"tags":["System"]}},"/v1/health/ready":{"get":{"operationId":"ready","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}},"tags":["System"]}},"/v1/health/status":{"get":{"operationId":"status","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatusResponse"}}}}},"tags":["System"]}},"/v1/farms/{id}/entries/{entryId}/comments":{"get":{"operationId":"listComments","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}},{"name":"offset","required":false,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CommentResponse"}}}}}},"tags":["Comments"]},"post":{"operationId":"addComment","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommentInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Comments"]}},"/v1/farms/{id}/recent-comments":{"get":{"operationId":"recentComments","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RecentCommentResponse"}}}}}},"tags":["Comments"]}},"/v1/platform/users":{"get":{"description":"Equipo de AgroJefe con sesión, o una clave de API con el scope `platform:users:read` cuyo dueño siga siendo equipo de AgroJefe. Es la única ruta de plataforma que admite una clave.","operationId":"platformUsers","parameters":[{"name":"search","required":false,"in":"query","schema":{"type":"string"}},{"name":"offset","required":false,"in":"query","schema":{"type":"string"}},{"name":"createdAfter","required":false,"in":"query","description":"Solo las cuentas creadas después de este instante (ISO 8601 con zona, p. ej. 2026-11-29T10:00:00.000Z). Para sondear altas, envía el `createdAt` más reciente que ya conoces.","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PlatformUser"}}}}}},"summary":"Cuentas de la plataforma, de la más nueva a la más antigua, 50 por página","tags":["Platform"]},"post":{"operationId":"createUser","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUserInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformUser"}}}}},"tags":["Platform"]}},"/v1/platform/impersonation":{"post":{"operationId":"startImpersonation","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImpersonationResponse"}}}}},"tags":["Platform"]}},"/v1/platform/impersonation/{id}":{"delete":{"operationId":"stopImpersonation","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Platform"]}},"/v1/platform/users/{id}/welcome":{"post":{"operationId":"welcomeUser","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Platform"]}},"/v1/platform/farms/{id}/complimentary":{"patch":{"operationId":"grantFarm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GrantInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Platform"]}},"/v1/platform/users/{id}/free-farms":{"patch":{"operationId":"grantUser","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GrantInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Platform"]}},"/v1/platform/users/{id}/store-orders":{"patch":{"description":"Solo el equipo de AgroJefe con sesión; ninguna clave de API ni asistente. Con el interruptor apagado (lo normal), las fincas de esa persona no muestran «Pedidos» y las rutas de pedidos de sus perfiles de vendedor responden 403. No borra pedidos ni ventas.","operationId":"storeOrders","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GrantInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"summary":"Activa o desactiva los pedidos de la tienda en una cuenta","tags":["Platform"]}},"/v1/me/username-availability":{"get":{"operationId":"usernameAvailability","parameters":[{"name":"username","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsernameAvailability"}}}}},"security":[{"cookie":[]}],"tags":["Account"]}},"/v1/me/username":{"patch":{"operationId":"updateUsername","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsernameInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}}},"security":[{"cookie":[]}],"tags":["Account"]}},"/v1/me/profile":{"patch":{"operationId":"completeProfile","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfileInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}}},"security":[{"cookie":[]}],"tags":["Account"]}},"/v1/me/identity":{"patch":{"operationId":"identity","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfileIdentityInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Account"]}},"/v1/me":{"delete":{"operationId":"deleteAccount","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteAccountInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Account"]},"get":{"operationId":"getMe","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}}},"security":[{"cookie":[]}],"tags":["Account"]}},"/v1/me/api-keys":{"get":{"operationId":"listApiKeys","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ApiKeyResponse"}}}}}},"tags":["Account"]},"post":{"operationId":"createApiKey","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyResponse"}}}}},"tags":["Account"]}},"/v1/me/api-keys/{keyId}":{"delete":{"operationId":"revokeApiKey","parameters":[{"name":"keyId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Account"]}},"/v1/me/connections":{"get":{"operationId":"listConnections","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ConnectionResponse"}}}}}},"tags":["Account"]}},"/v1/me/connections/{id}":{"delete":{"operationId":"revokeConnection","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Account"]}},"/v1/oauth/consent":{"post":{"operationId":"acceptOAuthConsent","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthConsentInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthConsentResponse"}}}}},"tags":["Account"]}},"/v1/oauth/client":{"get":{"operationId":"oauthClient","parameters":[{"name":"client_id","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthClientInfo"}}}}},"tags":["Account"]}},"/v1/farms":{"get":{"operationId":"listFarms","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FarmResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Farms"]},"post":{"operationId":"createFarm","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}":{"delete":{"description":"Solo la sesión del titular, escribiendo el nombre exacto. La finca se archiva y deja de aparecer; sus plantaciones, máquinas, productos, registros y personas se conservan. Nunca se borra nada. No está disponible para claves de API ni para asistentes.","operationId":"deleteFarm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteFarmInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"summary":"Elimina la finca","tags":["Farms"]},"patch":{"description":"Agentes: scope `team:write`, o `farms:manage` si la persona es titular o administración de la finca (403 si no). La ficha se guarda entera: lo que no se envía se borra, salvo `holderNif`, `reaCode` y `advisors`, que se conservan si se omiten.","operationId":"updateFarm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmResponse"}}}}},"security":[{"cookie":[]}],"summary":"Guarda la ficha de la finca","tags":["Farms"]},"get":{"operationId":"getFarm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"cursor","required":false,"in":"query","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","schema":{"type":"number"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmState"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/entries":{"post":{"description":"Agentes: scope `records:write`, o `farms:manage` si la persona es titular o administración de la finca (403 si no). Un importe pide además `money:write`. Un sector es un registro con `kind: sector`: crearlo pide siempre `farms:manage` y ser titular o administración de la finca (403 con solo `records:write`).","operationId":"createEntry","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"idempotency-key","required":true,"in":"header","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntryInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"summary":"Crea un registro (también un sector o una tarea)","tags":["Farms"]}},"/v1/farms/{id}/entries/{entryId}":{"patch":{"description":"Agentes: scope `records:write`, o `farms:manage` si la persona es titular o administración de la finca (403 si no). Un importe pide además `money:write`. El registro se envía entero, con su `version`. Editar un sector pide siempre `farms:manage` y ser titular o administración de la finca (403 con solo `records:write`); el tipo de un registro no se cambia.","operationId":"updateEntry","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntryUpdate"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"summary":"Edita un registro","tags":["Farms"]},"delete":{"description":"La fila se conserva con su fecha de archivado y queda en la auditoría. Agentes: scope `records:write`, o `farms:manage` si la persona es titular o administración de la finca (403 si no); un gasto, una venta, una compra o un ingreso piden además `money:write`. Un sector con registros no se archiva, y archivar un sector pide siempre `farms:manage` y ser titular o administración de la finca (403 con solo `records:write`).","operationId":"archiveEntry","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}},{"name":"version","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"summary":"Archiva un registro. No lo borra","tags":["Farms"]}},"/v1/farms/{id}/entries/{entryId}/series":{"delete":{"operationId":"cancelTaskSeries","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}},{"name":"version","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/audit":{"get":{"operationId":"audit","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"offset","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AuditResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/billing/payments":{"get":{"operationId":"payments","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PaymentResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/contacts":{"get":{"operationId":"contacts","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ContactResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/links":{"get":{"operationId":"listLinks","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/InviteLinkResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Farms"]},"post":{"operationId":"createLink","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteLinkInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteLinkResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/links/{linkId}":{"delete":{"operationId":"revokeLink","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"linkId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/members":{"post":{"operationId":"addMember","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddMemberInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/voice-notes":{"post":{"description":"Transcribe el audio y devuelve un borrador sin guardar nada. Un tratamiento o una fertilización ya hechos llegan en `treatments` y `fertilizations` con lo dicho; lo que el cuaderno exige y no se dijo queda a null y en `pending`. Se guardan con `POST /v1/farms/{id}/entries` (`kind: treatment` o `fertilization`, `source: voice`) cuando la persona lo completa. Un riego ya hecho dicho con su volumen o su duración llega en `irrigations` (`kind: irrigation`): la unidad, el origen del volumen y la duración que no se dijeron quedan a null, nunca se suponen.","operationId":"voiceNote","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VoiceDraftResponse"}}}}},"security":[{"cookie":[]}],"summary":"Borrador a partir de una nota de voz","tags":["Farms"]}},"/v1/farms/{id}/diary/report":{"get":{"operationId":"diaryReport","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"from","required":true,"in":"query","schema":{"type":"string"}},{"name":"to","required":true,"in":"query","schema":{"type":"string"}},{"name":"money","required":false,"in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DiaryReportResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/diary/report.pdf":{"get":{"operationId":"diaryPdf","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"from","required":true,"in":"query","schema":{"type":"string"}},{"name":"to","required":true,"in":"query","schema":{"type":"string"}},{"name":"money","required":false,"in":"query","schema":{"type":"boolean"}},{"name":"intro","required":false,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"The field report as a branded PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/equipment":{"post":{"description":"Agentes: scope `team:write`, o `farms:manage` si la persona es titular o administración de la finca (403 si no). `purchaseCents` pide además `money:write`.","operationId":"addEquipment","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EquipmentInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EquipmentResponse"}}}}},"security":[{"cookie":[]}],"summary":"Añade una máquina","tags":["Farms"]}},"/v1/farms/{id}/equipment/{equipmentId}":{"patch":{"description":"Agentes: scope `team:write`, o `farms:manage` si la persona es titular o administración de la finca (403 si no). La máquina se envía entera; el precio se conserva si se omite.","operationId":"updateEquipment","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"equipmentId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EquipmentInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EquipmentResponse"}}}}},"security":[{"cookie":[]}],"summary":"Edita una máquina","tags":["Farms"]},"delete":{"description":"La máquina se archiva y su historial se conserva. Agentes: scope `team:write`, o `farms:manage` si la persona es titular o administración de la finca (403 si no).","operationId":"removeEquipment","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"equipmentId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"summary":"Da de baja una máquina. No la borra","tags":["Farms"]}},"/v1/farms/{id}/equipment/{equipmentId}/summary":{"get":{"operationId":"equipmentSummary","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"equipmentId","required":true,"in":"path","schema":{"type":"string"}},{"name":"from","required":true,"in":"query","schema":{"type":"string"}},{"name":"to","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EquipmentSummaryResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/plantings":{"get":{"description":"Lo que hay plantado en cada sector, línea a línea (cultivo, variedad, plantas, superficie, polinizadora, año). Lo lee cualquier persona de la finca. Agentes: scope `farms:read`. Por defecto solo las activas; `archived=true` añade las arrancadas o terminadas. `main` y `share` se calculan en cada lectura.","operationId":"plantings","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"sectorId","required":false,"in":"query","schema":{"type":"string"}},{"name":"archived","required":false,"in":"query","schema":{"enum":["true","false"],"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PlantingResponse"}}}}}},"security":[{"cookie":[]}],"summary":"Plantaciones de los sectores","tags":["Farms"]}},"/v1/farms/{id}/sectors/{sectorId}/plantings":{"post":{"description":"Las mismas personas que editan el sector: titular o administración de la finca (403 para coordinación y trabajo). Agentes: además scope `farms:manage` (403 con solo `records:write`). 404 si el sector no es de esta finca; 400 si está archivado. No puede haber dos líneas activas iguales en un sector (mismo cultivo, variedad y año): 409, «Edita la tanda existente o archiva la anterior». El resumen del sector (cultivo, variedad y fecha de la principal, total de plantas) se reescribe en la misma transacción y sube su `version`.","operationId":"addPlanting","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"sectorId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlantingInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlantingResponse"}}}}},"security":[{"cookie":[]}],"summary":"Añade una plantación a un sector","tags":["Farms"]}},"/v1/farms/{id}/plantings/{plantingId}":{"patch":{"description":"Solo cambia lo que se envía; null borra un campo opcional. Pide la `version` leída (409 si cambió). Una plantación terminada solo admite cambiar sus notas (400). Mismos permisos que añadirla.","operationId":"updatePlanting","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"plantingId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlantingPatch"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlantingResponse"}}}}},"security":[{"cookie":[]}],"summary":"Corrige una plantación","tags":["Farms"]}},"/v1/farms/{id}/plantings/{plantingId}/archive":{"post":{"description":"Guarda la fecha de fin (hoy si se omite; ni futura ni anterior a la plantación) y el motivo, y la archiva: la fila se conserva y sigue saliendo en `GET /v1/farms/{id}` y con `archived=true`. No existe ruta de borrado. Un alta por error se archiva con `reason: mistake`. Mismos permisos que añadirla.","operationId":"archivePlanting","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"plantingId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlantingArchiveInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlantingResponse"}}}}},"security":[{"cookie":[]}],"summary":"Arranca o termina una plantación. No la borra","tags":["Farms"]}},"/v1/farms/{id}/products":{"get":{"description":"El catálogo de fitosanitarios y abonos que la finca usa a menudo, sin los archivados. Lo lee cualquier persona de la finca. Agentes: scope `farms:read`. No lleva existencias, lotes ni precios.","operationId":"products","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FarmProductResponse"}}}}}},"security":[{"cookie":[]}],"summary":"Productos habituales de la finca","tags":["Farms"]},"post":{"description":"Solo titular o administración de la finca (403 para coordinación y trabajo). Agentes: además scope `farms:manage`. Entre los productos no archivados no se repite un nº de registro en la finca ni un nombre dentro del mismo tipo (409).","operationId":"addProduct","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmProductInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmProductResponse"}}}}},"security":[{"cookie":[]}],"summary":"Añade un producto al catálogo de la finca","tags":["Farms"]}},"/v1/farms/{id}/products/{productId}":{"patch":{"description":"El producto se envía entero y no cambia de tipo. Los tratamientos y fertilizaciones que lo usaron conservan la copia que guardaron. Solo titular o administración; agentes: además scope `farms:manage`.","operationId":"updateProduct","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"productId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmProductInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmProductResponse"}}}}},"security":[{"cookie":[]}],"summary":"Edita un producto del catálogo","tags":["Farms"]},"delete":{"description":"Deja de ofrecerse al apuntar; la fila se conserva y lo ya apuntado no cambia. Archivado, su nombre y su nº de registro vuelven a quedar libres. Solo titular o administración; agentes: además scope `farms:manage`.","operationId":"archiveProduct","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"productId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"summary":"Archiva un producto del catálogo. No lo borra","tags":["Farms"]}},"/v1/farms/{id}/diary/send":{"post":{"operationId":"sendDiary","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DiarySendInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DiarySendResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/members/{memberId}/remind":{"post":{"operationId":"remindMember","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"memberId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/members/{memberId}":{"patch":{"description":"Agentes: scope `team:write`. Con `farms:manage` (titular o administración de la finca) solo la ficha de aplicador de alguien que ya está en la finca: `nif`, `ropo`, `firstSurname`, `secondSurname` y `companyName`; cualquier otro campo responde 403.","operationId":"updateMember","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"memberId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberUpdateInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberResponse"}}}}},"security":[{"cookie":[]}],"summary":"Cambia el permiso o la ficha de una persona de la finca","tags":["Farms"]},"delete":{"operationId":"removeMember","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"memberId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/people":{"post":{"operationId":"addPerson","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/people/{personId}/summary":{"get":{"operationId":"personSummary","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"personId","required":true,"in":"path","schema":{"type":"string"}},{"name":"from","required":true,"in":"query","schema":{"type":"string"}},{"name":"to","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonSummaryResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/billing/checkout":{"post":{"operationId":"checkout","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UrlResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/billing/promo/validate":{"post":{"operationId":"validatePromo","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PromoValidateInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PromoValidateResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/billing/portal":{"post":{"operationId":"billingPortal","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UrlResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/export/cue":{"get":{"operationId":"exportCue","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"from","required":false,"in":"query","description":"YYYY-MM-DD","schema":{"type":"string"}},{"name":"to","required":false,"in":"query","description":"YYYY-MM-DD","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CueExportResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/export":{"get":{"operationId":"exportFarm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/weather":{"get":{"operationId":"weather","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WeatherResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/sellers/username-availability":{"get":{"operationId":"sellerUsernameAvailability","parameters":[{"name":"username","required":true,"in":"query","schema":{"type":"string"}},{"name":"profile","required":false,"in":"query","description":"Profile being renamed, so its handle stays available","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerUsernameAvailability"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers":{"get":{"operationId":"listSellerProfiles","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SellerProfileResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Store"]},"post":{"operationId":"createSellerProfile","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerProfileInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerProfileResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}":{"get":{"operationId":"getSellerProfile","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerProfileResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]},"patch":{"operationId":"updateSellerProfile","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerProfilePatch"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerProfileResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/farms":{"post":{"operationId":"linkSellerFarm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkSellerFarmInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerProfileResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/farms/{farmId}":{"delete":{"operationId":"unlinkSellerFarm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"farmId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SellerProfileResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/webhook-secret":{"post":{"operationId":"rotateSellerWebhook","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreWebhookSecretResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/availability":{"get":{"operationId":"sellerAvailability","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreAvailabilityResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/varieties":{"get":{"operationId":"listSellerVarieties","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"q","required":false,"in":"query","schema":{"type":"string"}},{"name":"crop","required":false,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/VarietyResponse"}}}}}},"security":[{"cookie":[]}],"summary":"Varieties of the profile owner, to map shop products to them","tags":["Store"]},"post":{"operationId":"resolveSellerVariety","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyResolved"}}}}},"security":[{"cookie":[]}],"summary":"Find a variety of the profile owner by name or create it","tags":["Store"]}},"/v1/sellers/{id}/catalog":{"get":{"operationId":"listSellerCatalog","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"source","required":false,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/StoreProductResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Store"]},"put":{"description":"Send `varietyId` (the crop comes with the variety) and optionally `gramsPerUnit`. Order lines can then send `productCode` and `quantity` only.","operationId":"upsertSellerProduct","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreProductInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreProductResponse"}}}}},"security":[{"cookie":[]}],"summary":"Map a shop product code to a variety","tags":["Store"]}},"/v1/sellers/{id}/orders":{"get":{"operationId":"listSellerOrders","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"source","required":false,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/StoreOrderResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/orders/{externalRef}":{"put":{"description":"Line `cents` are product amounts only. Shipping is not part of a sale: do not add it to any line.","operationId":"upsertSellerOrder","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"externalRef","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreOrderInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreOrderResponse"}}}}},"security":[{"cookie":[]}],"summary":"Create or update an order","tags":["Store"]}},"/v1/sellers/{id}/orders/{externalRef}/void":{"post":{"operationId":"voidSellerOrder","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"externalRef","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreVoidInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreOrderResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/sales":{"post":{"operationId":"registerSellerSale","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreSaleInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreOrderResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/sellers/{id}/webhook":{"post":{"operationId":"receiveSellerWebhook","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreOrderResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/farms/{id}/store-orders":{"get":{"operationId":"listFarmStoreOrders","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmStoreOrdersResponse"}}}}},"security":[{"cookie":[]}],"tags":["Store"]}},"/v1/farms/{id}/varieties":{"get":{"operationId":"listFarmVarieties","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"q","required":false,"in":"query","description":"Accent and case insensitive search","schema":{"type":"string"}},{"name":"crop","required":false,"in":"query","description":"Only this crop. Empty: no crop","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/VarietyResponse"}}}}}},"security":[{"cookie":[]}],"summary":"Varieties of the farm holder, shared by all their farms","tags":["Varieties"]},"post":{"description":"Names are compared without case, accents or extra spaces: 'hass', 'Hass' and ' HÁSS ' are one variety. `created` tells whether it is new. `catalogVarietyId` or `catalogCropId` (from `GET /v1/catalog/search`) link the variety to the AgroJefe catalogue; with `catalogVarietyId` the name may be omitted. Free text that is not in the catalogue still creates a variety of the holder.","operationId":"resolveFarmVariety","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyResolved"}}}}},"security":[{"cookie":[]}],"summary":"Find a variety by name or create it","tags":["Varieties"]}},"/v1/farms/{id}/varieties/{varietyId}":{"patch":{"operationId":"renameFarmVariety","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"varietyId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyPatch"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyResponse"}}}}},"security":[{"cookie":[]}],"summary":"Rename a variety, change its crop or its catalogue link. The id does not change","tags":["Varieties"]}},"/v1/farms/{id}/varieties/{varietyId}/merge":{"post":{"description":"Every record, order line and product of this variety moves to `intoId`.","operationId":"mergeFarmVariety","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"varietyId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyMergeInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VarietyResponse"}}}}},"security":[{"cookie":[]}],"summary":"Merge a duplicate into another variety","tags":["Varieties"]}},"/v1/catalog/search":{"get":{"description":"Matches names and aliases without case or accents, best match first. `name` is always the canonical name; `alias` is set when the text matched another name of the same crop or variety («palta» → Aguacate). Use `cropId` and `varietyId` as `catalogCropId` and `catalogVarietyId` when saving a sector or a variety.","operationId":"search","parameters":[{"name":"q","required":false,"in":"query","description":"Text typed so far. Empty lists all","schema":{"type":"string"}},{"name":"crop","required":false,"in":"query","description":"Only this crop: a catalogue id, a name or an alias. A crop that is not in the catalogue has no catalogue varieties","schema":{"type":"string"}},{"name":"kind","required":false,"in":"query","schema":{"enum":["crop","variety"],"type":"string"}},{"name":"limit","required":false,"in":"query","description":"1 to 50. Default 12","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CatalogItem"}}}}}},"security":[{"cookie":[]}],"summary":"Search crops and varieties of the AgroJefe catalogue","tags":["Catalog"]}},"/v1/catalog/targets/search":{"get":{"description":"The targets are the «agentes» of the MAPA register of plant protection products, named exactly as MAPA writes them («Áfidos, pulgones, Aphididae»). Matches any part of the name without case or accents, best match first, across pests, diseases and weeds alike: the catalogue does not classify them. `match` is the part that matched when the name does not start with the text; `exact` is true when the text names that target alone. Use `id` as `catalogTargetId` in `phytosanitary.targets.links` when saving a treatment.","operationId":"targets","parameters":[{"name":"q","required":false,"in":"query","description":"Text typed so far. Empty lists all","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"1 to 50. Default 12","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CatalogTargetItem"}}}}}},"security":[{"cookie":[]}],"summary":"Search treatment targets (pests, diseases and weeds) of the AgroJefe catalogue","tags":["Catalog"]}},"/v1/farms/{id}/phyto-registry/products":{"get":{"operationId":"searchPhytoRegistry","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"q","required":true,"in":"query","description":"Nº de registro o nombre comercial","schema":{"type":"string"}},{"name":"date","required":false,"in":"query","description":"Fecha del tratamiento, YYYY-MM-DD","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhytoRegistrySearchResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/phyto-registry/check":{"get":{"operationId":"checkPhytoRegistry","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"registrationNumber","required":false,"in":"query","schema":{"type":"string"}},{"name":"name","required":false,"in":"query","description":"Nombre comercial","schema":{"type":"string"}},{"name":"crop","required":false,"in":"query","description":"Cultivo escrito en el formulario","schema":{"type":"string"}},{"name":"targets","required":false,"in":"query","description":"Plagas, enfermedades o malas hierbas escritas, separadas por comas","schema":{"type":"string"}},{"name":"dose","required":false,"in":"query","description":"Dosis escrita","schema":{"type":"string"}},{"name":"doseUnit","required":false,"in":"query","description":"Unidad escrita","schema":{"type":"string"}},{"name":"date","required":false,"in":"query","description":"Fecha del tratamiento, YYYY-MM-DD: se usa la copia del registro vigente ese día","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhytoRegistryCheckResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/accesos":{"get":{"operationId":"listAccesos","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Items the person may see, without the secret","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoListResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]},"post":{"operationId":"createAcceso","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/farms/{id}/accesos/{accesoId}":{"patch":{"operationId":"updateAcceso","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"accesoId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoInput"}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]},"delete":{"operationId":"archiveAcceso","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"accesoId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Archives the item; nothing is deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/farms/{id}/accesos/{accesoId}/secret":{"get":{"operationId":"accesoSecret","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"accesoId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"The secret, only for who may see the item","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoSecretResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/farms/{id}/accesos/{accesoId}/photos":{"post":{"operationId":"createAccesoPhoto","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"accesoId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoPhotoInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoPhotoUploadResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/farms/{id}/accesos/{accesoId}/photos/{photoId}/confirm":{"post":{"operationId":"confirmAccesoPhoto","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"accesoId","required":true,"in":"path","schema":{"type":"string"}},{"name":"photoId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoPhoto"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/farms/{id}/accesos/{accesoId}/photos/{photoId}":{"get":{"operationId":"accesoPhoto","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"accesoId","required":true,"in":"path","schema":{"type":"string"}},{"name":"photoId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"The photo, only for who may see the item","content":{"image/*":{"schema":{"type":"string","format":"binary"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]},"delete":{"operationId":"removeAccesoPhoto","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"accesoId","required":true,"in":"path","schema":{"type":"string"}},{"name":"photoId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/farms/{id}/acceso-links":{"get":{"operationId":"listAccesoLinks","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AccesoLinkResponse"}}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]},"post":{"operationId":"createAccesoLink","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoLinkInput"}}}},"responses":{"201":{"description":"The URL is returned only here","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccesoLinkResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/farms/{id}/acceso-links/{linkId}":{"delete":{"operationId":"revokeAccesoLink","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"linkId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Accesos"]}},"/v1/acceso-links/{token}":{"get":{"operationId":"sharedAccesos","parameters":[{"name":"token","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SharedAccesosResponse"}}}}},"tags":["Accesos"]}},"/v1/acceso-links/{token}/photos/{photoId}":{"get":{"operationId":"sharedAccesoPhoto","parameters":[{"name":"token","required":true,"in":"path","schema":{"type":"string"}},{"name":"photoId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"image/*":{"schema":{"type":"string","format":"binary"}}}}},"tags":["Accesos"]}},"/v1/join/{token}":{"get":{"operationId":"info","parameters":[{"name":"token","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JoinInfoResponse"}}}}},"tags":["Farms"]},"post":{"operationId":"join","parameters":[{"name":"token","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JoinResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/entries/{entryId}/attachments":{"post":{"operationId":"create","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttachmentInput"}}}},"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttachmentUploadResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/entries/{entryId}/attachments/{attachmentId}/confirm":{"post":{"operationId":"confirm","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}},{"name":"attachmentId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttachmentResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/farms/{id}/entries/{entryId}/attachments/{attachmentId}":{"delete":{"operationId":"remove","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"entryId","required":true,"in":"path","schema":{"type":"string"}},{"name":"attachmentId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"security":[{"cookie":[]}],"tags":["Farms"]}},"/v1/storage/mock/{key}":{"post":{"operationId":"upload","parameters":[{"name":"key","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":""}},"tags":["System"]},"get":{"operationId":"download","parameters":[{"name":"key","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"tags":["System"]}},"/v1/billing/webhook":{"post":{"operationId":"webhook","parameters":[{"name":"stripe-signature","required":true,"in":"header","schema":{"type":"string"}}],"responses":{"201":{"description":""}},"tags":["Billing"]}},"/v1/platform/operations":{"get":{"operationId":"operations","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OperationsResponse"}}}}},"tags":["Platform"]}},"/v1/platform/farms/{id}/payments":{"get":{"operationId":"platformPayments","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PaymentResponse"}}}}}},"tags":["Platform"]}},"/v1/platform/attachments":{"get":{"operationId":"platformAttachments","parameters":[{"name":"offset","required":false,"in":"query","schema":{"type":"string"}},{"name":"q","required":false,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PlatformAttachment"}}}}}},"tags":["Platform"]}},"/v1/platform/storage":{"get":{"operationId":"platformStorage","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformStorageResponse"}}}}},"tags":["Platform"]}},"/v1/platform/attachments/{attachmentId}":{"delete":{"operationId":"removePlatformAttachment","parameters":[{"name":"attachmentId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}},"tags":["Platform"]}},"/v1/platform/crops":{"get":{"operationId":"platformCrops","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformCropStats"}}}}},"tags":["Platform"]}},"/v1/platform/crops/map":{"get":{"operationId":"platformCropsMap","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformCropMap"}}}}},"tags":["Platform"]}},"/v1/platform/signups":{"get":{"description":"Solo equipo de AgroJefe con sesión. Cuenta las cuentas de personas no eliminadas; las creadas desde el panel o antes de guardar el origen aparecen sin origen (los tres valores a null).","operationId":"platformSignups","parameters":[{"name":"from","required":false,"in":"query","description":"Primer día (yyyy-mm-dd, hora de Madrid). Sin él, desde la primera cuenta.","schema":{"type":"string"}},{"name":"to","required":false,"in":"query","description":"Último día, incluido (yyyy-mm-dd, hora de Madrid). Sin él, hasta hoy.","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformSignups"}}}}},"summary":"Altas por origen (utm_source, utm_medium, utm_campaign)","tags":["Platform"]}},"/v1/platform/targets":{"get":{"operationId":"platformTargets","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformTargetStats"}}}}},"tags":["Platform"]}},"/v1/platform/targets/map":{"get":{"operationId":"platformTargetsMap","parameters":[],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlatformTargetMap"}}}}},"tags":["Platform"]}},"/v1/platform/farms":{"get":{"description":"Equipo de AgroJefe con sesión, o una clave de API con el scope `platform:farms:read` cuyo dueño siga siendo equipo de AgroJefe. Los pagos de cada finca (`/farms/{id}/payments`) son solo de sesión.","operationId":"platformFarms","parameters":[{"name":"offset","required":false,"in":"query","schema":{"type":"string"}},{"name":"status","required":false,"in":"query","description":"Solo las fincas con este estado de suscripción (por ejemplo `trialing`, `active`, `past_due`, `canceled`), tal como lo devuelve `status`. Sin él, todas. 500 fincas por página: para contar por estado, pagina con `offset` hasta recibir menos de 500.","schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PlatformFarm"}}}}}},"summary":"Fincas de la plataforma con su suscripción y su dueño, de la más nueva a la más antigua","tags":["Platform"]}}},"info":{"title":"AgroJefe API","description":"Gestión de fincas: registros de trabajo, tareas, incidencias, cosechas, ventas, gastos, tratamientos fitosanitarios y fertilizaciones, con permisos por persona. GET /v1/farms/{id}/export/cue devuelve el cuaderno en JSON alineado con el Anexo V de SIEX (DT agrícola v3.11). No envía datos al IUWS. GET /v1/farms/{id}/phyto-registry/* consulta una copia fechada del Registro de Productos Fitosanitarios del MAPA: informa y avisa, no recomienda dosis. /v1/farms/{id}/accesos guarda los accesos de la finca (códigos, contraseñas, llaves) con permisos por elemento; solo con sesión, nunca con clave de API ni asistente. Las personas entran desde la app con una cookie de sesión. Los agentes y scripts usan una clave de API personal (`Authorization: Bearer agj_…`, creada en Mi cuenta → Claves de API) que actúa con los permisos de su dueño, acotados por scopes: farms:read, records:write, money:read, money:write, team:write, store:sync, farms:manage. farms:manage gestiona la estructura de la finca (sectores, ficha, máquinas, ficha de aplicador, tareas y archivar registros) y solo vale donde su dueño es titular o administración: 403 en las demás. Cuenta, pagos, creación y eliminación de fincas y rutas de plataforma son solo de sesión. Las únicas excepciones son GET /v1/platform/users y GET /v1/platform/farms, que admiten una clave con el scope platform:users:read o platform:farms:read creada por el equipo de AgroJefe en su panel. Las escrituras de registros llevan `Idempotency-Key`. Los importes van en céntimos. Más en https://agrojefe.com/desarrolladores.","version":"0.20.0","contact":{}},"tags":[],"servers":[{"url":"https://api.agrojefe.com"}],"components":{"securitySchemes":{"cookie":{"type":"apiKey","in":"cookie","name":"better-auth.session_token"},"apiKey":{"scheme":"bearer","bearerFormat":"JWT","type":"http","description":"Clave de API personal (agj_…)"}},"schemas":{"HealthResponse":{"type":"object","properties":{"status":{"type":"string"},"service":{"type":"string"},"version":{"type":"string"},"stage":{"type":"string"},"uptimeSeconds":{"type":"number"},"timestamp":{"type":"string"},"commit":{"type":"string"}},"required":["status","service","version","stage","uptimeSeconds","timestamp"]},"DatabaseStatus":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded","down","disabled"]},"detail":{"type":"string"},"latencyMs":{"type":"number"}},"required":["status"]},"MigrationsStatus":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded","down","disabled"]},"detail":{"type":"string"},"applied":{"type":"number"},"pending":{"type":"number"},"latest":{"type":"string"}},"required":["status","applied","pending"]},"MailStatus":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded","down","disabled"]},"detail":{"type":"string"},"provider":{"type":"string","enum":["resend","smtp"]},"pending":{"type":"number"},"failed":{"type":"number"}},"required":["status","provider","pending","failed"]},"BillingStatus":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded","down","disabled"]},"detail":{"type":"string"},"provider":{"type":"string","enum":["stripe","none"]}},"required":["status","provider"]},"VoiceStatus":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded","down","disabled"]},"detail":{"type":"string"},"provider":{"type":"string","enum":["openai","mock","none"]}},"required":["status","provider"]},"StatusResponse":{"type":"object","properties":{"status":{"type":"string"},"service":{"type":"string"},"version":{"type":"string"},"stage":{"type":"string"},"uptimeSeconds":{"type":"number"},"timestamp":{"type":"string"},"commit":{"type":"string"},"database":{"$ref":"#/components/schemas/DatabaseStatus"},"migrations":{"$ref":"#/components/schemas/MigrationsStatus"},"mail":{"$ref":"#/components/schemas/MailStatus"},"billing":{"$ref":"#/components/schemas/BillingStatus"},"voice":{"$ref":"#/components/schemas/VoiceStatus"},"storage":{"$ref":"#/components/schemas/VoiceStatus"}},"required":["status","service","version","stage","uptimeSeconds","timestamp","database","migrations","mail","billing","voice","storage"]},"CommentResponse":{"type":"object","properties":{"id":{"type":"string"},"body":{"type":"string"},"author":{"type":"string"},"authorId":{"type":"string"},"date":{"type":"string"}},"required":["id","body","author","authorId","date"]},"CommentInput":{"type":"object","properties":{"body":{"type":"string"}},"required":["body"]},"MessageResponse":{"type":"object","properties":{"message":{"type":"string"},"warning":{"type":"string","description":"Saved, but something deserves a look"}},"required":["message"]},"RecentCommentResponse":{"type":"object","properties":{"id":{"type":"string"},"body":{"type":"string"},"author":{"type":"string"},"authorId":{"type":"string"},"date":{"type":"string"},"entryId":{"type":"string"},"entryTitle":{"type":"string"}},"required":["id","body","author","authorId","date","entryId","entryTitle"]},"PlatformUser":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"username":{"type":"string"},"email":{"type":"string"},"freeFarms":{"type":"boolean"},"storeOrders":{"type":"boolean","description":"Shop orders turned on for this account by AgroJefe staff"},"platformAdmin":{"type":"boolean"},"createdAt":{"type":"string"},"farms":{"type":"number","description":"Farms where the person is a member"},"welcomedAt":{"type":"string","description":"Last welcome mail queued by the platform team"}},"required":["id","name","username","email","freeFarms","storeOrders","platformAdmin","createdAt","farms"]},"CreateUserInput":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string"},"welcome":{"type":"boolean","description":"Queue the welcome mail right after creating the account"}},"required":["email","name"]},"ImpersonationInput":{"type":"object","properties":{"userId":{"type":"string"},"reason":{"type":"string","minLength":3,"maxLength":500}},"required":["userId","reason"]},"ImpersonationTarget":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"username":{"type":"string"},"email":{"type":"string"}},"required":["id","name","username","email"]},"ImpersonationResponse":{"type":"object","properties":{"id":{"type":"string"},"token":{"type":"string","description":"Send as X-Impersonate on read requests; never stored server side"},"expiresAt":{"type":"string"},"target":{"$ref":"#/components/schemas/ImpersonationTarget"}},"required":["id","token","expiresAt","target"]},"GrantInput":{"type":"object","properties":{"enabled":{"type":"boolean"},"reason":{"type":"string"}},"required":["enabled","reason"]},"UsernameAvailability":{"type":"object","properties":{"username":{"type":"string"},"available":{"type":"boolean"}},"required":["username","available"]},"UsernameInput":{"type":"object","properties":{"username":{"type":"string","minLength":3,"maxLength":30,"pattern":"^[a-z0-9_]+$"}},"required":["username"]},"FeaturesResponse":{"type":"object","properties":{"voiceNotes":{"type":"boolean","description":"Voice notes are configured on this installation"},"impersonation":{"type":"boolean","description":"This person may view the app as someone else"},"attachments":{"type":"boolean","description":"Photo and video attachments available"}},"required":["voiceNotes","impersonation","attachments"]},"ImpersonationState":{"type":"object","properties":{"id":{"type":"string"},"actor":{"type":"string","description":"Name of the real signed-in person"},"expiresAt":{"type":"string"},"readOnly":{"type":"boolean","description":"False: the superadmin may act for the person, except account, billing and farm deletion"}},"required":["id","actor","expiresAt","readOnly"]},"MeResponse":{"type":"object","properties":{"username":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"emoji":{"type":"string"},"color":{"type":"string"},"features":{"$ref":"#/components/schemas/FeaturesResponse"},"impersonation":{"$ref":"#/components/schemas/ImpersonationState"}},"required":["username","id","name","email","features"]},"ProfileInput":{"type":"object","properties":{"name":{"type":"string"},"username":{"type":"string","description":"Omit to derive one from the name"}},"required":["name"]},"ProfileIdentityInput":{"type":"object","properties":{"emoji":{"type":"string","nullable":true},"color":{"type":"string","nullable":true}}},"DeleteAccountInput":{"type":"object","properties":{"code":{"type":"string","description":"One-time code sent to the account email"},"password":{"type":"string","description":"Only for accounts that sign in with a password"},"confirmation":{"type":"string","enum":["ELIMINAR"]}},"required":["confirmation"]},"ApiKeyResponse":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"start":{"type":"string","description":"First characters, to recognise the key"},"scopes":{"type":"array","items":{"type":"string"}},"farmIds":{"type":"array","items":{"type":"string"}},"profileIds":{"description":"Seller profiles this key may sync","type":"array","items":{"type":"string"}},"createdAt":{"type":"string"},"expiresAt":{"type":"string"},"lastUsedAt":{"type":"string"},"requests":{"type":"number"},"key":{"type":"string","description":"The full key, returned once at creation"}},"required":["id","name","start","scopes","farmIds","profileIds","createdAt","requests"]},"ApiKeyInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":32,"description":"Shown in lists and attributions"},"scopes":{"type":"array","description":"`farms:manage` gestiona la estructura de la finca (sectores, ficha, máquinas, ficha de aplicador, tareas y archivar registros) y solo funciona en las fincas donde la persona es titular o administración; nunca borra, cobra ni gestiona personas. `platform:users:read` y `platform:farms:read` solo los puede adjuntar el equipo de AgroJefe; cualquier otra cuenta recibe 403.","items":{"type":"string","enum":["farms:read","records:write","money:read","money:write","team:write","store:sync","farms:manage","platform:users:read","platform:farms:read"]}},"farmIds":{"description":"Restrict the key to these farms; empty or missing means all your farms","type":"array","items":{"type":"string"}},"sellerProfileIds":{"description":"Seller profiles a store:sync key may sync. Required when the key includes store:sync","type":"array","items":{"type":"string"}},"expiresInDays":{"type":"number","minimum":1,"maximum":365,"description":"Days until the key expires"}},"required":["name","scopes"]},"ConnectionResponse":{"type":"object","properties":{"id":{"type":"string","description":"Consent id"},"clientId":{"type":"string"},"name":{"type":"string","description":"Client name as it registered itself (Claude, ChatGPT…)"},"uri":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"farmIds":{"nullable":true,"description":"Farms chosen on the consent screen. Null means all the farms of the person, also the ones they join later; a list is fixed.","type":"array","items":{"type":"string"}},"createdAt":{"type":"string"},"lastUsedAt":{"type":"string","description":"Last time the client renewed its access"}},"required":["id","clientId","name","scopes","farmIds","createdAt"]},"OAuthConsentInput":{"type":"object","properties":{"oauthQuery":{"type":"string","description":"The signed authorization request the consent screen was opened with: `sig`, every `ba_param` and the parameters they name, as a query string"},"scope":{"type":"string","description":"Space-separated scopes the person accepts, among the requested ones. Required and never empty: a missing selection is refused, it is not read as all the requested scopes"},"farmIds":{"nullable":true,"description":"Farms the assistant may touch. Null means all your farms, also the ones you join later; a list (1 to 50 of your farms) is fixed.","type":"array","items":{"type":"string"}}},"required":["oauthQuery","scope","farmIds"]},"OAuthConsentResponse":{"type":"object","properties":{"url":{"type":"string","description":"Where to send the browser next: back to the assistant"}},"required":["url"]},"OAuthClientInfo":{"type":"object","properties":{"clientId":{"type":"string"},"name":{"type":"string"},"uri":{"type":"string"},"logo":{"type":"string"},"policy":{"type":"string"},"tos":{"type":"string"},"redirectHosts":{"description":"Hosts the client may be sent back to","type":"array","items":{"type":"string"}}},"required":["clientId","name","redirectHosts"]},"FarmAdvisor":{"type":"object","properties":{"id":{"type":"string","description":"Omit it on a new advisor: the server assigns it"},"name":{"type":"string"},"firstSurname":{"type":"string"},"secondSurname":{"type":"string"},"companyName":{"type":"string"},"nif":{"type":"string","description":"NIF, NIE or CIF. Managing roles only"},"ropo":{"type":"string","description":"ROPO inscription number. Managing roles only"}}},"FarmResponse":{"type":"object","properties":{"name":{"type":"string"},"latitude":{"type":"number"},"longitude":{"type":"number"},"location":{"type":"string"},"emoji":{"type":"string","description":"A single emoji that identifies the farm"},"color":{"type":"string","description":"Hex colour such as #214835"},"polygon":{"type":"array","nullable":true,"items":{"type":"array","items":{"type":"number"},"minItems":2,"maxItems":2},"description":"Farm outline as [lat, lng] vertices; null clears it"},"holderNif":{"type":"string","nullable":true,"description":"NIF/NIE/CIF of the exploitation holder. Null clears it; omitting it on edit keeps it"},"reaCode":{"type":"string","nullable":true,"description":"REA exploitation code. Null clears it; omitting it on edit keeps it"},"advisors":{"description":"Advisors of the farm for the official notebook, at most 10. Omitting it on edit keeps the list","type":"array","items":{"$ref":"#/components/schemas/FarmAdvisor"}},"complimentary":{"type":"boolean"},"id":{"type":"string"},"role":{"type":"string"},"writable":{"type":"boolean"},"subscriptionStatus":{"type":"string"},"trialEndsAt":{"type":"string"},"paidUntil":{"type":"string"},"billingAccount":{"type":"boolean","description":"True once the farm has a Stripe customer: portal and receipts are available"},"cancelAtPeriodEnd":{"type":"boolean","description":"The subscription ends at paidUntil instead of renewing"},"billingInterval":{"type":"string","enum":["month","year"]},"storeOrders":{"type":"boolean","description":"Shop orders are turned on for the account of the farm holder. Only AgroJefe staff change it. While false the app hides «Pedidos» and the order routes answer 403."}},"required":["name","id","role","writable","subscriptionStatus","trialEndsAt","storeOrders"]},"FarmInput":{"type":"object","properties":{"name":{"type":"string"},"latitude":{"type":"number"},"longitude":{"type":"number"},"location":{"type":"string"},"emoji":{"type":"string","description":"A single emoji that identifies the farm"},"color":{"type":"string","description":"Hex colour such as #214835"},"polygon":{"type":"array","nullable":true,"items":{"type":"array","items":{"type":"number"},"minItems":2,"maxItems":2},"description":"Farm outline as [lat, lng] vertices; null clears it"},"holderNif":{"type":"string","nullable":true,"description":"NIF/NIE/CIF of the exploitation holder. Null clears it; omitting it on edit keeps it"},"reaCode":{"type":"string","nullable":true,"description":"REA exploitation code. Null clears it; omitting it on edit keeps it"},"advisors":{"description":"Advisors of the farm for the official notebook, at most 10. Omitting it on edit keeps the list","type":"array","items":{"$ref":"#/components/schemas/FarmAdvisor"}}},"required":["name"]},"DeleteFarmInput":{"type":"object","properties":{"confirmation":{"type":"string"}},"required":["confirmation"]},"PlantingInput":{"type":"object","properties":{"crop":{"type":"string","maxLength":80,"description":"Cultivo, tal como se escribe: «Aguacate»"},"catalogCropId":{"type":"string","description":"Cultivo del catálogo de AgroJefe que representa `crop`"},"varietyId":{"type":"string","description":"Variedad del titular de la finca. Gana a `variety`. 404 si no es suya; 400 si es de otro cultivo"},"variety":{"type":"string","maxLength":80,"description":"Variedad por nombre: se busca entre las del titular dentro de ese cultivo y, si no existe, se crea. Solo escritura con este significado; en la respuesta es el nombre de la variedad"},"catalogVarietyId":{"type":"string","description":"Variedad del catálogo elegida en vez de escribir un nombre. Solo escritura"},"plants":{"type":"number","description":"Número de plantas, entero ≥ 0"},"hectares":{"type":"number","description":"Superficie de la línea en hectáreas"},"pollinizer":{"type":"boolean","description":"Está para polinizar a otra línea. Cuenta en el total de plantas del sector y no es la principal mientras haya otra que no lo sea. Por defecto, false"},"plantedYear":{"type":"number","description":"Año de plantación. No puede ser futuro"},"plantedOn":{"type":"string","description":"Fecha de plantación, siembra o trasplante (AAAA-MM-DD) si se sabe. No futura y del mismo año que `plantedYear`"},"notes":{"type":"string","maxLength":500}},"required":["crop"]},"MaterialLine":{"type":"object","properties":{"name":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string","description":"ud, sacos, l, kg…"},"unitCents":{"type":"number","description":"Price per unit in cents"}},"required":["name","quantity"]},"EquipmentUse":{"type":"object","properties":{"id":{"type":"string"},"hours":{"type":"number"},"fuelLiters":{"type":"number"}},"required":["id"]},"DgcInput":{"type":"object","properties":{"cadastralRef":{"type":"string","description":"Referencia catastral, 14 a 20 caracteres"},"province":{"type":"string","description":"Código de provincia, hasta 2 dígitos"},"municipality":{"type":"string","description":"Código de municipio, hasta 3 dígitos"},"aggregate":{"type":"string","description":"Código de agregado, hasta 3 dígitos"},"zone":{"type":"string","description":"Código de zona, hasta 2 dígitos"},"polygonCode":{"type":"string","description":"Código de polígono, hasta 3 dígitos"},"parcel":{"type":"string","description":"Código de parcela, hasta 5 dígitos"},"precinct":{"type":"string","description":"Código de recinto, hasta 5 dígitos"},"order":{"type":"number","description":"Número de orden por superficie de cultivo"},"hectares":{"type":"number","description":"Superficie DGC en hectáreas"},"startedOn":{"type":"string","description":"Fecha de alta DGC, YYYY-MM-DD"},"endedOn":{"type":"string","description":"Fecha de baja DGC, YYYY-MM-DD"}}},"PhytosanitaryTargetLink":{"type":"object","properties":{"catalogTargetId":{"type":"string","description":"Target of the AgroJefe catalogue (`id` of `GET /v1/catalog/targets/search`)"},"linkedBy":{"type":"string","description":"Read only. Who made the link: `user` (picked), `auto` (the text named it exactly when saved) or `auto-<migration>`. Ignored when sent"}},"required":["catalogTargetId"]},"PhytosanitaryTargetLinks":{"type":"object","properties":{"weeds":{"description":"Needs `weeds`","allOf":[{"$ref":"#/components/schemas/PhytosanitaryTargetLink"}]},"diseases":{"description":"Needs `diseases`","allOf":[{"$ref":"#/components/schemas/PhytosanitaryTargetLink"}]},"pests":{"description":"Needs `pests`","allOf":[{"$ref":"#/components/schemas/PhytosanitaryTargetLink"}]}}},"PhytosanitaryTargets":{"type":"object","properties":{"weeds":{"type":"string","description":"Malas hierbas (código de catálogo o descripción)"},"diseases":{"type":"string","description":"Enfermedades"},"pests":{"type":"string","description":"Artrópodos y gasterópodos"},"growthRegulators":{"type":"string","description":"Reguladores de crecimiento, rodenticidas y otros"},"justification":{"type":"string","description":"Justificación de la actuación"},"links":{"description":"Catalogue target each text stands for. Optional: the texts stay as written and are what the CUE export uses. A text with no link that names exactly one target is linked by the server","allOf":[{"$ref":"#/components/schemas/PhytosanitaryTargetLinks"}]}}},"PhytosanitaryProduct":{"type":"object","properties":{"type":{"type":"string","description":"Tipo de producto fitosanitario (catálogo)"},"tradeName":{"type":"string","description":"Nombre comercial"},"activeSubstance":{"type":"string","description":"Materia activa o formulado"},"farmProductId":{"type":"string","description":"Producto del catálogo de la finca (`GET /products`), de tipo fitosanitario y sin archivar. Al crear, el nombre, el nº de registro, la materia activa y la unidad que falten se copian de él; lo enviado manda. Nunca la dosis ni la cantidad. El tratamiento guarda la copia: editar o archivar el producto después no lo cambia"},"registrationNumber":{"type":"string","description":"Número de registro del producto (MAPA). Puede omitirse con `farmProductId`: se copia del catálogo"},"quantity":{"type":"number","description":"Cantidad. Excluyente con dose"},"dose":{"type":"number","description":"Dosis. Excluyente con quantity"},"unit":{"type":"string","description":"Unidad de medida. Puede omitirse con `farmProductId` si el producto tiene unidad habitual"}},"required":["registrationNumber","unit"]},"PhytosanitaryApplicator":{"type":"object","properties":{"personId":{"type":"string","description":"Persona de la finca. Su nombre, apellidos, razón social, NIF y ROPO se copian de su ficha si faltan. Sin ROPO se guarda igual: la exportación lo avisa"},"name":{"type":"string"},"firstSurname":{"type":"string"},"secondSurname":{"type":"string"},"companyName":{"type":"string"},"nif":{"type":"string","description":"NIF, NIE o CIF"},"ropo":{"type":"string","description":"Nº de inscripción ROPO"}}},"PhytosanitaryAdvisor":{"type":"object","properties":{"advisorId":{"type":"string","description":"Asesor de la ficha de la finca. Su identidad se copia al tratamiento si falta"},"date":{"type":"string","description":"Fecha de la prescripción o validación, YYYY-MM-DD"},"name":{"type":"string"},"firstSurname":{"type":"string"},"secondSurname":{"type":"string"},"companyName":{"type":"string"},"nif":{"type":"string"},"ropo":{"type":"string","description":"Nº de inscripción ROPO del asesor"},"validation":{"type":"string","enum":["favorable","unfavorable"]},"contract":{"type":"boolean","description":"Contrato de asesoramiento"}}},"PhytosanitaryInput":{"type":"object","properties":{"treatedHectares":{"type":"number","description":"Superficie tratada en hectáreas"},"hour":{"type":"string","description":"Hora de tratamiento, HH:MM"},"dryDate":{"type":"string","description":"Fecha seca, YYYY-MM-DD"},"phenologicalStage":{"type":"string","description":"Estado fenológico"},"targets":{"$ref":"#/components/schemas/PhytosanitaryTargets"},"product":{"$ref":"#/components/schemas/PhytosanitaryProduct"},"applicator":{"$ref":"#/components/schemas/PhytosanitaryApplicator"},"manual":{"type":"boolean","description":"Aplicación manual"},"roma":{"type":"string","description":"Nº de inscripción ROMA o REGANIP. Si falta, se copia de la máquina (equipmentId)"},"ownEquipment":{"type":"boolean","description":"El equipo es propio"},"unregisteredEquipment":{"type":"boolean","description":"Equipo no inscribible en ROMA/REGANIP"},"advisor":{"$ref":"#/components/schemas/PhytosanitaryAdvisor"},"efficacy":{"type":"string","description":"Eficacia del tratamiento. Se puede completar después"}},"required":["treatedHectares","targets","product","applicator"]},"FertilizerNutrients":{"type":"object","properties":{"nTotal":{"type":"number","description":"N total, %"},"nOrganic":{"type":"number","description":"N orgánico, %"},"nNitric":{"type":"number","description":"N nítrico, %"},"nAmmoniacal":{"type":"number","description":"N amoniacal, %"},"nUreic":{"type":"number","description":"N ureico, %"},"p2o5Total":{"type":"number","description":"P2O5 total, %"},"k2oTotal":{"type":"number","description":"K2O total, %"}}},"FertigationInput":{"type":"object","properties":{"waterDose":{"type":"number","description":"Dosis de agua"},"waterUnit":{"type":"string","description":"Unidad de la dosis de agua"},"nNitricMgPerL":{"type":"number","description":"N nítrico del agua, mg/l"},"p2o5MgPerL":{"type":"number","description":"P2O5 soluble en agua, mg/l"}},"required":["waterDose","waterUnit"]},"FertilizerInput":{"type":"object","properties":{"appliedHectares":{"type":"number","description":"Superficie de aplicación en hectáreas"},"farmProductId":{"type":"string","description":"Abono del catálogo de la finca (`GET /products`), sin archivar. Al crear, el material, la unidad y los N, P2O5 y K2O que falten se copian de él; lo enviado manda. Nunca la dosis. La fertilización guarda la copia"},"material":{"type":"string","description":"Material fertilizante. Puede omitirse con `farmProductId`"},"materialDetail":{"type":"string","description":"Detalle del material fertilizante"},"dose":{"type":"number"},"unit":{"type":"string"},"fertilizationType":{"type":"string","description":"Tipo de fertilización"},"applicationMethod":{"type":"string","description":"Método de aplicación"},"nutrients":{"$ref":"#/components/schemas/FertilizerNutrients"},"fertigation":{"$ref":"#/components/schemas/FertigationInput"}},"required":["appliedHectares","material","dose","unit","nutrients"]},"IrrigationInput":{"type":"object","properties":{"volume":{"type":"number","description":"Volumen de agua. Con él son obligatorios `waterUnit` y `volumeSource`"},"waterUnit":{"type":"string","enum":["m3/ha","l/ha","m3","l"],"description":"Unidad del volumen"},"volumeSource":{"type":"string","enum":["measured","estimated"],"description":"Si el volumen se midió (contador) o se estimó. No se supone nunca"},"durationMinutes":{"type":"number","description":"Duración de la operación de riego, en minutos. No son horas de trabajo de nadie ni horas de máquina"},"method":{"type":"string","description":"Método o sistema, texto libre de hasta 40 caracteres: goteo, aspersión…"}}},"AttachmentResponse":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["image","video","audio"]},"mime":{"type":"string"},"bytes":{"type":"number"},"width":{"type":"number"},"height":{"type":"number"},"durationSeconds":{"type":"number"},"url":{"type":"string","description":"Short-lived read URL"},"thumbUrl":{"type":"string","description":"Short-lived read URL of the preview"},"createdBy":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","kind","mime","bytes","url","createdBy","createdAt"]},"ViaResponse":{"type":"object","properties":{"kind":{"type":"string","enum":["api_key","oauth"]},"id":{"type":"string"},"name":{"type":"string","description":"Name of the key or client that acted for the author"}},"required":["kind","id","name"]},"StoreSaleLink":{"type":"object","properties":{"profileId":{"type":"string"},"source":{"type":"string"},"externalRef":{"type":"string"},"externalLineRef":{"type":"string"},"voided":{"type":"boolean","description":"True when the shop cancelled or refunded the order. The sale stays."},"voidReason":{"type":"string","enum":["cancelled","refunded"]},"voidedAt":{"type":"string"}},"required":["profileId","source","externalRef","externalLineRef","voided"]},"EntryResponse":{"type":"object","properties":{"kind":{"type":"string","enum":["sector","task","work","expense","income","harvest","sale","purchase","waste","incident","note","treatment","fertilization","irrigation"]},"title":{"type":"string"},"date":{"type":"string"},"endDate":{"type":"string"},"priority":{"type":"string","enum":["low","normal","high","urgent"]},"category":{"type":"string"},"sectorId":{"type":"string"},"notes":{"type":"string"},"crop":{"type":"string"},"variety":{"type":"string","description":"Variety name. Found or created among the varieties of the farm holder, ignoring case, accents and extra spaces. Responses carry the name of the entity"},"varietyId":{"type":"string","description":"Variety entity. Send this or `variety`; when both arrive the id wins"},"catalogCropId":{"type":"string","description":"Crop of the AgroJefe catalogue that `crop` stands for (`cropId` of `GET /v1/catalog/search`). Stored next to the text, which stays as written. Needs `crop`"},"catalogVarietyId":{"type":"string","description":"Variety of the AgroJefe catalogue picked instead of typing a name. Write only: the record gets the `varietyId` of the variety of the farm holder, created if needed and linked to the catalogue"},"hectares":{"type":"number"},"plantings":{"description":"Solo al crear un sector (`kind: sector`; al editar se rechaza, las líneas se cambian una a una): lo que hay plantado, línea a línea, en la misma transacción. El cultivo, la variedad, la fecha y el total de plantas del sector salen entonces de estas líneas; `crop`, si se envía, debe ser el de la principal. Sin `plantings`, el sector nace con una línea hecha de su `crop`, `variety`, `treeCount` y `plantedOn`","type":"array","items":{"$ref":"#/components/schemas/PlantingInput"}},"treeCount":{"type":"number","description":"En un sector: total de plantas, la suma de sus plantaciones activas (polinizadoras incluidas). Editarlo cambia las plantas de su única plantación; con varias se rechaza (400)"},"plantedOn":{"type":"string"},"rowSpacing":{"type":"number"},"treeSpacing":{"type":"number"},"orientation":{"type":"string"},"latitude":{"type":"number","description":"Sector position on the map"},"longitude":{"type":"number"},"polygon":{"type":"array","items":{"type":"array","items":{"type":"number"},"minItems":2,"maxItems":2},"description":"Sector outline as [lat, lng] vertices"},"minutes":{"type":"number"},"cents":{"type":"number"},"grams":{"type":"number"},"channel":{"type":"string"},"assignedTo":{"type":"string","description":"First assignee, kept for compatibility"},"assignees":{"description":"People responsible for this record","type":"array","items":{"type":"string"}},"status":{"type":"string"},"taskId":{"type":"string","description":"Pending task this new record completes. Only on a new work or irrigation. An irrigation completes only an irrigation task (its category or its title starts with «riego») of the same `sectorId`: otherwise 400 and nothing changes"},"workId":{"type":"string"},"repeatWeekly":{"type":"boolean"},"repeatEveryWeeks":{"type":"number"},"repeatUntil":{"type":"string"},"applyToSeries":{"type":"boolean"},"reviewed":{"type":"boolean"},"summary":{"type":"string","description":"Summary of a voice note"},"transcript":{"type":"string","description":"Full transcript of a voice note"},"source":{"type":"string","enum":["voice"]},"progress":{"type":"number","description":"Progress 0..100 of a job"},"estimatedCents":{"type":"number","description":"Budget in cents for a pending job or repair"},"related":{"description":"Linked record ids (kept symmetric)","type":"array","items":{"type":"string"}},"materials":{"description":"Materials used by a work","type":"array","items":{"$ref":"#/components/schemas/MaterialLine"}},"equipment":{"description":"Machinery used by a work","type":"array","items":{"$ref":"#/components/schemas/EquipmentUse"}},"equipmentId":{"type":"string","description":"Machine this expense or incident belongs to"},"auto":{"type":"string","enum":["materials"],"description":"Server-generated expense marker"},"dgc":{"nullable":true,"description":"SIGPAC/DGC codes. Sectors only. Null clears them; omitting them on edit keeps them","type":"object","allOf":[{"$ref":"#/components/schemas/DgcInput"}]},"phytosanitary":{"description":"Required when kind is treatment","allOf":[{"$ref":"#/components/schemas/PhytosanitaryInput"}]},"fertilizer":{"description":"Required when kind is fertilization","allOf":[{"$ref":"#/components/schemas/FertilizerInput"}]},"irrigation":{"description":"Required when kind is irrigation, together with `sectorId`. Rejected in any other kind. An irrigation takes only `title`, `date`, `sectorId`, `notes`, `irrigation`, `taskId`, `related` and `source`: any other field, even empty, is a 400 that names it","allOf":[{"$ref":"#/components/schemas/IrrigationInput"}]},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/AttachmentResponse"}},"via":{"description":"Set when an agent wrote the record","allOf":[{"$ref":"#/components/schemas/ViaResponse"}]},"storeSale":{"description":"Set when the sale was booked by a shop. Absent on sales typed in by the farm.","allOf":[{"$ref":"#/components/schemas/StoreSaleLink"}]},"seriesId":{"type":"string"},"id":{"type":"string"},"version":{"type":"number"},"createdBy":{"type":"string"},"author":{"type":"string"}},"required":["kind","title","date","id","version","createdBy","author"]},"MemberResponse":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string","description":"Empty until the person completes onboarding"},"email":{"type":"string","description":"Missing for people without an account"},"role":{"type":"string"},"nif":{"type":"string","description":"NIF/NIE/CIF recorded for this person on this farm"},"ropo":{"type":"string","description":"ROPO inscription recorded for this person on this farm"},"firstSurname":{"type":"string","description":"First surname for the official notebook"},"secondSurname":{"type":"string","description":"Second surname for the official notebook"},"companyName":{"type":"string","description":"Company name, when the applicator is a company"},"access":{"type":"boolean","description":"False for farm people who cannot sign in (peones)"},"emoji":{"type":"string"},"color":{"type":"string"},"pending":{"type":"boolean","description":"True while the person has never entered AgroJefe"},"lastSeenAt":{"type":"string","description":"Last time the person used the app"},"remindedAt":{"type":"string","description":"Last access reminder sent by the farm"}},"required":["id","name","role","access","pending"]},"EquipmentResponse":{"type":"object","properties":{"name":{"type":"string"},"category":{"type":"string"},"status":{"type":"string","enum":["ok","repair","broken","retired"]},"notes":{"type":"string"},"purchasedOn":{"type":"string","description":"YYYY-MM-DD"},"purchaseCents":{"type":"number","nullable":true,"description":"Purchase price in cents. On update, omitted keeps the stored price and null clears it. Setting, changing or clearing it needs `money:write`; it is only returned to who sees amounts (`money:read` and a financial role)"},"roma":{"type":"string","description":"Nº de inscripción ROMA o REGANIP. Se copia al tratamiento que usa esta máquina si no trae uno"},"id":{"type":"string"},"createdAt":{"type":"string"}},"required":["name","id","createdAt"]},"FarmProductNutrients":{"type":"object","properties":{"nTotal":{"type":"number","description":"N total, %"},"p2o5Total":{"type":"number","description":"P2O5 total, %"},"k2oTotal":{"type":"number","description":"K2O total, %"}}},"FarmProductResponse":{"type":"object","properties":{"kind":{"type":"string","enum":["phytosanitary","fertilizer"]},"name":{"type":"string","description":"Nombre comercial del fitosanitario o material del abono"},"defaultUnit":{"type":"string","description":"Unidad habitual, una de las del formulario de su tipo (kg/ha, l/ha…). No es una dosis"},"notes":{"type":"string"},"registrationNumber":{"type":"string","description":"Nº de registro MAPA. Obligatorio en un fitosanitario; un abono no lo lleva"},"activeSubstance":{"type":"string","description":"Materia activa. Solo fitosanitarios"},"nutrients":{"description":"N, P2O5 y K2O habituales, en porcentaje. Solo abonos","allOf":[{"$ref":"#/components/schemas/FarmProductNutrients"}]},"id":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["kind","name","id","createdAt","updatedAt"]},"PlantingResponse":{"type":"object","properties":{"id":{"type":"string"},"sectorId":{"type":"string","description":"El sector: un registro de tipo `sector`"},"crop":{"type":"string"},"catalogCropId":{"type":"string","nullable":true},"varietyId":{"type":"string","nullable":true},"variety":{"type":"string","nullable":true,"description":"Nombre de la variedad"},"plants":{"type":"number","nullable":true},"hectares":{"type":"number","nullable":true},"pollinizer":{"type":"boolean"},"plantedYear":{"type":"number","nullable":true},"plantedOn":{"type":"string","nullable":true},"main":{"type":"boolean","description":"Derivado, no se guarda: la línea activa que resume el sector. Es la no polinizadora con más plantas (a igualdad, más superficie y después la más antigua); si todas son polinizadoras, la de más plantas"},"share":{"type":"number","nullable":true,"description":"Derivado, no se guarda: parte de las plantas de su cultivo en el sector, de 0 a 1. Null si alguna línea activa de ese cultivo no indica plantas, y en las archivadas"},"notes":{"type":"string","nullable":true},"endedOn":{"type":"string","nullable":true},"endReason":{"type":"string","nullable":true,"enum":["removed","cycle_end","replaced","died","mistake"]},"archived":{"type":"boolean","description":"Arrancada o terminada. La fila se conserva"},"version":{"type":"number"},"createdAt":{"type":"string"},"warnings":{"description":"Solo al crear o editar: avisos que no impiden guardar (una polinizadora con más plantas que la principal)","type":"array","items":{"type":"string"}}},"required":["id","sectorId","crop","catalogCropId","varietyId","variety","plants","hectares","pollinizer","plantedYear","plantedOn","main","share","notes","endedOn","endReason","archived","version","createdAt"]},"VarietyResponse":{"type":"object","properties":{"id":{"type":"string"},"crop":{"type":"string","description":"Crop as written. Empty when the crop is not known yet"},"name":{"type":"string"},"catalogCropId":{"type":"string","nullable":true,"description":"Crop of the AgroJefe catalogue this variety belongs to. Null: not linked"},"catalogVarietyId":{"type":"string","nullable":true,"description":"Variety of the AgroJefe catalogue. Null: a variety only this holder names"}},"required":["id","crop","name","catalogCropId","catalogVarietyId"]},"FarmState":{"type":"object","properties":{"nextCursor":{"type":"string"},"farm":{"$ref":"#/components/schemas/FarmResponse"},"entries":{"type":"array","items":{"$ref":"#/components/schemas/EntryResponse"}},"members":{"type":"array","items":{"$ref":"#/components/schemas/MemberResponse"}},"equipment":{"type":"array","items":{"$ref":"#/components/schemas/EquipmentResponse"}},"products":{"description":"Products the farm uses often (phytosanitaries and fertilizers), not archived","type":"array","items":{"$ref":"#/components/schemas/FarmProductResponse"}},"plantings":{"description":"What is planted in each sector, line by line: every line of the farm, archived ones too","type":"array","items":{"$ref":"#/components/schemas/PlantingResponse"}},"varieties":{"description":"Varieties of the farm holder, shared by all their farms","type":"array","items":{"$ref":"#/components/schemas/VarietyResponse"}}},"required":["farm","entries","members","equipment","products","plantings","varieties"]},"EntryInput":{"type":"object","properties":{"kind":{"type":"string","enum":["sector","task","work","expense","income","harvest","sale","purchase","waste","incident","note","treatment","fertilization","irrigation"]},"title":{"type":"string"},"date":{"type":"string"},"endDate":{"type":"string"},"priority":{"type":"string","enum":["low","normal","high","urgent"]},"category":{"type":"string"},"sectorId":{"type":"string"},"notes":{"type":"string"},"crop":{"type":"string"},"variety":{"type":"string","description":"Variety name. Found or created among the varieties of the farm holder, ignoring case, accents and extra spaces. Responses carry the name of the entity"},"varietyId":{"type":"string","description":"Variety entity. Send this or `variety`; when both arrive the id wins"},"catalogCropId":{"type":"string","description":"Crop of the AgroJefe catalogue that `crop` stands for (`cropId` of `GET /v1/catalog/search`). Stored next to the text, which stays as written. Needs `crop`"},"catalogVarietyId":{"type":"string","description":"Variety of the AgroJefe catalogue picked instead of typing a name. Write only: the record gets the `varietyId` of the variety of the farm holder, created if needed and linked to the catalogue"},"hectares":{"type":"number"},"plantings":{"description":"Solo al crear un sector (`kind: sector`; al editar se rechaza, las líneas se cambian una a una): lo que hay plantado, línea a línea, en la misma transacción. El cultivo, la variedad, la fecha y el total de plantas del sector salen entonces de estas líneas; `crop`, si se envía, debe ser el de la principal. Sin `plantings`, el sector nace con una línea hecha de su `crop`, `variety`, `treeCount` y `plantedOn`","type":"array","items":{"$ref":"#/components/schemas/PlantingInput"}},"treeCount":{"type":"number","description":"En un sector: total de plantas, la suma de sus plantaciones activas (polinizadoras incluidas). Editarlo cambia las plantas de su única plantación; con varias se rechaza (400)"},"plantedOn":{"type":"string"},"rowSpacing":{"type":"number"},"treeSpacing":{"type":"number"},"orientation":{"type":"string"},"latitude":{"type":"number","description":"Sector position on the map"},"longitude":{"type":"number"},"polygon":{"type":"array","items":{"type":"array","items":{"type":"number"},"minItems":2,"maxItems":2},"description":"Sector outline as [lat, lng] vertices"},"minutes":{"type":"number"},"cents":{"type":"number"},"grams":{"type":"number"},"channel":{"type":"string"},"assignedTo":{"type":"string","description":"First assignee, kept for compatibility"},"assignees":{"description":"People responsible for this record","type":"array","items":{"type":"string"}},"status":{"type":"string"},"taskId":{"type":"string","description":"Pending task this new record completes. Only on a new work or irrigation. An irrigation completes only an irrigation task (its category or its title starts with «riego») of the same `sectorId`: otherwise 400 and nothing changes"},"workId":{"type":"string"},"repeatWeekly":{"type":"boolean"},"repeatEveryWeeks":{"type":"number"},"repeatUntil":{"type":"string"},"applyToSeries":{"type":"boolean"},"reviewed":{"type":"boolean"},"summary":{"type":"string","description":"Summary of a voice note"},"transcript":{"type":"string","description":"Full transcript of a voice note"},"source":{"type":"string","enum":["voice"]},"progress":{"type":"number","description":"Progress 0..100 of a job"},"estimatedCents":{"type":"number","description":"Budget in cents for a pending job or repair"},"related":{"description":"Linked record ids (kept symmetric)","type":"array","items":{"type":"string"}},"materials":{"description":"Materials used by a work","type":"array","items":{"$ref":"#/components/schemas/MaterialLine"}},"equipment":{"description":"Machinery used by a work","type":"array","items":{"$ref":"#/components/schemas/EquipmentUse"}},"equipmentId":{"type":"string","description":"Machine this expense or incident belongs to"},"auto":{"type":"string","enum":["materials"],"description":"Server-generated expense marker"},"dgc":{"nullable":true,"description":"SIGPAC/DGC codes. Sectors only. Null clears them; omitting them on edit keeps them","type":"object","allOf":[{"$ref":"#/components/schemas/DgcInput"}]},"phytosanitary":{"description":"Required when kind is treatment","allOf":[{"$ref":"#/components/schemas/PhytosanitaryInput"}]},"fertilizer":{"description":"Required when kind is fertilization","allOf":[{"$ref":"#/components/schemas/FertilizerInput"}]},"irrigation":{"description":"Required when kind is irrigation, together with `sectorId`. Rejected in any other kind. An irrigation takes only `title`, `date`, `sectorId`, `notes`, `irrigation`, `taskId`, `related` and `source`: any other field, even empty, is a 400 that names it","allOf":[{"$ref":"#/components/schemas/IrrigationInput"}]}},"required":["kind","title","date"]},"EntryUpdate":{"type":"object","properties":{"kind":{"type":"string","enum":["sector","task","work","expense","income","harvest","sale","purchase","waste","incident","note","treatment","fertilization","irrigation"]},"title":{"type":"string"},"date":{"type":"string"},"endDate":{"type":"string"},"priority":{"type":"string","enum":["low","normal","high","urgent"]},"category":{"type":"string"},"sectorId":{"type":"string"},"notes":{"type":"string"},"crop":{"type":"string"},"variety":{"type":"string","description":"Variety name. Found or created among the varieties of the farm holder, ignoring case, accents and extra spaces. Responses carry the name of the entity"},"varietyId":{"type":"string","description":"Variety entity. Send this or `variety`; when both arrive the id wins"},"catalogCropId":{"type":"string","description":"Crop of the AgroJefe catalogue that `crop` stands for (`cropId` of `GET /v1/catalog/search`). Stored next to the text, which stays as written. Needs `crop`"},"catalogVarietyId":{"type":"string","description":"Variety of the AgroJefe catalogue picked instead of typing a name. Write only: the record gets the `varietyId` of the variety of the farm holder, created if needed and linked to the catalogue"},"hectares":{"type":"number"},"plantings":{"description":"Solo al crear un sector (`kind: sector`; al editar se rechaza, las líneas se cambian una a una): lo que hay plantado, línea a línea, en la misma transacción. El cultivo, la variedad, la fecha y el total de plantas del sector salen entonces de estas líneas; `crop`, si se envía, debe ser el de la principal. Sin `plantings`, el sector nace con una línea hecha de su `crop`, `variety`, `treeCount` y `plantedOn`","type":"array","items":{"$ref":"#/components/schemas/PlantingInput"}},"treeCount":{"type":"number","description":"En un sector: total de plantas, la suma de sus plantaciones activas (polinizadoras incluidas). Editarlo cambia las plantas de su única plantación; con varias se rechaza (400)"},"plantedOn":{"type":"string"},"rowSpacing":{"type":"number"},"treeSpacing":{"type":"number"},"orientation":{"type":"string"},"latitude":{"type":"number","description":"Sector position on the map"},"longitude":{"type":"number"},"polygon":{"type":"array","items":{"type":"array","items":{"type":"number"},"minItems":2,"maxItems":2},"description":"Sector outline as [lat, lng] vertices"},"minutes":{"type":"number"},"cents":{"type":"number"},"grams":{"type":"number"},"channel":{"type":"string"},"assignedTo":{"type":"string","description":"First assignee, kept for compatibility"},"assignees":{"description":"People responsible for this record","type":"array","items":{"type":"string"}},"status":{"type":"string"},"taskId":{"type":"string","description":"Pending task this new record completes. Only on a new work or irrigation. An irrigation completes only an irrigation task (its category or its title starts with «riego») of the same `sectorId`: otherwise 400 and nothing changes"},"workId":{"type":"string"},"repeatWeekly":{"type":"boolean"},"repeatEveryWeeks":{"type":"number"},"repeatUntil":{"type":"string"},"applyToSeries":{"type":"boolean"},"reviewed":{"type":"boolean"},"summary":{"type":"string","description":"Summary of a voice note"},"transcript":{"type":"string","description":"Full transcript of a voice note"},"source":{"type":"string","enum":["voice"]},"progress":{"type":"number","description":"Progress 0..100 of a job"},"estimatedCents":{"type":"number","description":"Budget in cents for a pending job or repair"},"related":{"description":"Linked record ids (kept symmetric)","type":"array","items":{"type":"string"}},"materials":{"description":"Materials used by a work","type":"array","items":{"$ref":"#/components/schemas/MaterialLine"}},"equipment":{"description":"Machinery used by a work","type":"array","items":{"$ref":"#/components/schemas/EquipmentUse"}},"equipmentId":{"type":"string","description":"Machine this expense or incident belongs to"},"auto":{"type":"string","enum":["materials"],"description":"Server-generated expense marker"},"dgc":{"nullable":true,"description":"SIGPAC/DGC codes. Sectors only. Null clears them; omitting them on edit keeps them","type":"object","allOf":[{"$ref":"#/components/schemas/DgcInput"}]},"phytosanitary":{"description":"Required when kind is treatment","allOf":[{"$ref":"#/components/schemas/PhytosanitaryInput"}]},"fertilizer":{"description":"Required when kind is fertilization","allOf":[{"$ref":"#/components/schemas/FertilizerInput"}]},"irrigation":{"description":"Required when kind is irrigation, together with `sectorId`. Rejected in any other kind. An irrigation takes only `title`, `date`, `sectorId`, `notes`, `irrigation`, `taskId`, `related` and `source`: any other field, even empty, is a 400 that names it","allOf":[{"$ref":"#/components/schemas/IrrigationInput"}]},"version":{"type":"number"}},"required":["kind","title","date","version"]},"AuditResponse":{"type":"object","properties":{"id":{"type":"string"},"action":{"type":"string"},"date":{"type":"string"},"author":{"type":"string"},"title":{"type":"string"},"via":{"type":"string","description":"Name of the API key or client that acted for the author"}},"required":["id","action","date","author"]},"PaymentResponse":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"status":{"type":"string"},"cents":{"type":"number"},"currency":{"type":"string"},"date":{"type":"string"},"url":{"type":"string"}},"required":["id","number","status","cents","currency","date"]},"ContactFarm":{"type":"object","properties":{"name":{"type":"string"},"role":{"type":"string"}},"required":["name","role"]},"ContactResponse":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string","description":"Empty until the person completes onboarding"},"email":{"type":"string"},"farms":{"description":"Farms you share with this person","type":"array","items":{"$ref":"#/components/schemas/ContactFarm"}}},"required":["id","name","email","farms"]},"InviteLinkResponse":{"type":"object","properties":{"id":{"type":"string"},"role":{"type":"string"},"createdAt":{"type":"string"},"createdBy":{"type":"string"},"expiresAt":{"type":"string"},"uses":{"type":"number","description":"People who joined through this link"},"url":{"type":"string","description":"Only returned when the link is generated"}},"required":["id","role","createdAt","createdBy","uses"]},"InviteLinkInput":{"type":"object","properties":{"role":{"type":"string","enum":["admin","coordinator","worker"]},"expiresInDays":{"type":"number","nullable":true,"description":"Days until the link stops working; null or omitted means until revoked"}},"required":["role"]},"AddMemberInput":{"type":"object","properties":{"email":{"type":"string"},"role":{"type":"string","enum":["admin","coordinator","worker"]}},"required":["email","role"]},"VoiceMaterial":{"type":"object","properties":{"name":{"type":"string"},"quantity":{"type":"number"},"unit":{"type":"string","nullable":true},"unitCents":{"type":"number","nullable":true}},"required":["name","quantity"]},"VoiceEquipmentUse":{"type":"object","properties":{"equipmentId":{"type":"string"},"hours":{"type":"number","nullable":true},"fuelLiters":{"type":"number","nullable":true}},"required":["equipmentId"]},"VoiceWork":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string"},"sectorId":{"type":"string","nullable":true},"minutes":{"type":"number","nullable":true},"category":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"progress":{"type":"number","nullable":true,"description":"0..100"},"materials":{"type":"array","items":{"$ref":"#/components/schemas/VoiceMaterial"}},"equipment":{"type":"array","items":{"$ref":"#/components/schemas/VoiceEquipmentUse"}}},"required":["title","date"]},"VoiceIncident":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string"},"sectorId":{"type":"string","nullable":true},"priority":{"type":"string","nullable":true,"enum":["low","normal","high","urgent"]},"notes":{"type":"string","nullable":true},"estimatedCents":{"type":"number","nullable":true},"equipmentId":{"type":"string","nullable":true}},"required":["title","date"]},"VoiceTask":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string","nullable":true},"sectorId":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"assignees":{"description":"Member ids the note assigns this to","type":"array","items":{"type":"string"}},"estimatedCents":{"type":"number","nullable":true}},"required":["title","assignees"]},"VoiceHarvest":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string"},"assignees":{"description":"Member ids who harvested","type":"array","items":{"type":"string"}},"sectorId":{"type":"string","nullable":true},"variety":{"type":"string","nullable":true,"description":"Product or variety"},"grams":{"type":"number","nullable":true},"notes":{"type":"string","nullable":true}},"required":["title","date"]},"VoiceSale":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string"},"assignees":{"description":"Member ids who harvested","type":"array","items":{"type":"string"}},"sectorId":{"type":"string","nullable":true},"variety":{"type":"string","nullable":true,"description":"Product or variety"},"grams":{"type":"number","nullable":true},"notes":{"type":"string","nullable":true},"cents":{"type":"number","nullable":true},"channel":{"type":"string","nullable":true}},"required":["title","date"]},"VoiceExpense":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string"},"cents":{"type":"number","nullable":true},"category":{"type":"string","nullable":true},"sectorId":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"equipmentId":{"type":"string","nullable":true}},"required":["title","date"]},"VoicePurchase":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string"},"variety":{"type":"string","nullable":true},"grams":{"type":"number","nullable":true},"cents":{"type":"number","nullable":true},"notes":{"type":"string","nullable":true,"description":"Seller and details"}},"required":["title","date"]},"VoicePhytosanitaryTargetDraft":{"type":"object","properties":{"weeds":{"type":"string","nullable":true},"diseases":{"type":"string","nullable":true},"pests":{"type":"string","nullable":true},"growthRegulators":{"type":"string","nullable":true}}},"VoicePhytosanitaryProductDraft":{"type":"object","properties":{"tradeName":{"type":"string","nullable":true,"description":"Nombre comercial"},"registrationNumber":{"type":"string","nullable":true,"description":"Nº de registro MAPA. Null si no se dijo"},"dose":{"type":"number","nullable":true,"description":"Dosis. Excluyente con quantity"},"quantity":{"type":"number","nullable":true,"description":"Cantidad. Excluyente con dose"},"unit":{"type":"string","nullable":true,"description":"Null si no se dijo"}}},"VoiceApplicatorDraft":{"type":"object","properties":{"personId":{"type":"string","nullable":true,"description":"Persona de la finca nombrada como aplicador"},"name":{"type":"string","nullable":true},"ropo":{"type":"string","nullable":true,"description":"Nº ROPO dictado o, solo para titular, administración y coordinación, el de la ficha de la persona nombrada. Al resto del equipo llega null: la API lo copia de la ficha al guardar el tratamiento. Nunca se inventa"}}},"VoicePhytosanitaryDraft":{"type":"object","properties":{"treatedHectares":{"type":"number","nullable":true},"targets":{"$ref":"#/components/schemas/VoicePhytosanitaryTargetDraft"},"product":{"$ref":"#/components/schemas/VoicePhytosanitaryProductDraft"},"applicator":{"$ref":"#/components/schemas/VoiceApplicatorDraft"}},"required":["targets","product","applicator"]},"VoiceTreatment":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string","nullable":true,"description":"YYYY-MM-DD. Null si no se dijo"},"sectorId":{"type":"string","nullable":true},"crop":{"type":"string","nullable":true},"variety":{"type":"string","nullable":true,"description":"Variedad de la plantación del sector que nombra la nota («el Bacon del sector 2»), con su cultivo en `crop`. La lee el servidor de las palabras de la nota; nunca se supone"},"notes":{"type":"string","nullable":true},"pending":{"description":"Campos obligatorios que la nota no dijo y que no hay que inventar, y preguntas sobre la plantación nombrada («El sector 2 no tiene Bacon apuntado»)","type":"array","items":{"type":"string"}},"phytosanitary":{"$ref":"#/components/schemas/VoicePhytosanitaryDraft"}},"required":["title","pending","phytosanitary"]},"VoiceNutrientDraft":{"type":"object","properties":{"nTotal":{"type":"number","nullable":true,"description":"N total, %"},"p2o5Total":{"type":"number","nullable":true,"description":"P2O5 total, %"},"k2oTotal":{"type":"number","nullable":true,"description":"K2O total, %"}}},"VoiceFertilizerDraft":{"type":"object","properties":{"appliedHectares":{"type":"number","nullable":true},"material":{"type":"string","nullable":true},"dose":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"nutrients":{"$ref":"#/components/schemas/VoiceNutrientDraft"}},"required":["nutrients"]},"VoiceFertilization":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string","nullable":true,"description":"YYYY-MM-DD. Null si no se dijo"},"sectorId":{"type":"string","nullable":true},"crop":{"type":"string","nullable":true},"variety":{"type":"string","nullable":true,"description":"Variedad de la plantación del sector que nombra la nota («el Bacon del sector 2»), con su cultivo en `crop`. La lee el servidor de las palabras de la nota; nunca se supone"},"notes":{"type":"string","nullable":true},"pending":{"description":"Campos obligatorios que la nota no dijo y que no hay que inventar, y preguntas sobre la plantación nombrada («El sector 2 no tiene Bacon apuntado»)","type":"array","items":{"type":"string"}},"fertilizer":{"$ref":"#/components/schemas/VoiceFertilizerDraft"}},"required":["title","pending","fertilizer"]},"VoiceIrrigationDraft":{"type":"object","properties":{"volume":{"type":"number","nullable":true,"description":"La cifra que dice la nota. Si supera el máximo de un registro (1.000.000.000) llega tal cual y `pending` lo dice: se corrige, no se guarda así"},"waterUnit":{"type":"string","nullable":true,"enum":["m3/ha","l/ha","m3","l"]},"volumeSource":{"type":"string","nullable":true,"enum":["measured","estimated"],"description":"Solo si la nota lo afirma de ese volumen. Null si no lo dice, lo niega («no lo hemos medido», «el contador está averiado») o se contradice"},"durationMinutes":{"type":"number","nullable":true,"description":"Duración del riego, solo si la nota la afirma del riego, una sola vez y con una cifra legible. El tiempo de otra operación o de las personas no cuenta; dicha con duda, negada o varias veces llega a null y `pending` lo avisa"},"method":{"type":"string","nullable":true}}},"VoiceIrrigation":{"type":"object","properties":{"title":{"type":"string"},"date":{"type":"string","description":"YYYY-MM-DD. Hoy si la nota no dice otro día"},"sectorId":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"pending":{"description":"Lo que falta para guardarlo y que no hay que inventar","type":"array","items":{"type":"string"}},"irrigation":{"$ref":"#/components/schemas/VoiceIrrigationDraft"}},"required":["title","date","pending","irrigation"]},"VoiceDraftResponse":{"type":"object","properties":{"transcript":{"type":"string"},"summary":{"type":"string"},"provider":{"type":"string"},"works":{"type":"array","items":{"$ref":"#/components/schemas/VoiceWork"}},"incidents":{"type":"array","items":{"$ref":"#/components/schemas/VoiceIncident"}},"tasks":{"type":"array","items":{"$ref":"#/components/schemas/VoiceTask"}},"harvests":{"type":"array","items":{"$ref":"#/components/schemas/VoiceHarvest"}},"sales":{"type":"array","items":{"$ref":"#/components/schemas/VoiceSale"}},"expenses":{"type":"array","items":{"$ref":"#/components/schemas/VoiceExpense"}},"purchases":{"type":"array","items":{"$ref":"#/components/schemas/VoicePurchase"}},"treatments":{"description":"Tratamientos fitosanitarios ya hechos que dice la nota, para guardarlos como registro `treatment`. Lo que no se dijo llega a null y figura en `pending`","type":"array","items":{"$ref":"#/components/schemas/VoiceTreatment"}},"fertilizations":{"description":"Fertilizaciones ya hechas que dice la nota, para guardarlas como registro `fertilization`. Lo que no se dijo llega a null y figura en `pending`","type":"array","items":{"$ref":"#/components/schemas/VoiceFertilization"}},"irrigations":{"description":"Riegos ya hechos que la nota dice con su volumen o su duración, para guardarlos como registro `irrigation`. Los lee el servidor de las palabras de la nota: lo que no se dijo llega a null y, si hace falta para guardar, figura en `pending`. Un riego dicho sin volumen ni duración sigue saliendo en `works`, también cuando la misma nota trae otro riego con sus cifras","type":"array","items":{"$ref":"#/components/schemas/VoiceIrrigation"}}},"required":["transcript","summary","provider","works","incidents","tasks","harvests","sales","expenses","purchases","treatments","fertilizations","irrigations"]},"DiaryReportItem":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"title":{"type":"string"},"date":{"type":"string"},"meta":{"type":"string","description":"Sector · people · hours…"},"body":{"type":"string"},"lines":{"description":"Extra lines: materials, machinery","type":"array","items":{"type":"string"}},"cents":{"type":"number","description":"Amount in cents, money section only"},"progress":{"type":"number"}},"required":["id","kind","title","date","meta"]},"DiaryReportSection":{"type":"object","properties":{"key":{"type":"string"},"title":{"type":"string"},"items":{"type":"array","items":{"$ref":"#/components/schemas/DiaryReportItem"}},"totalCents":{"type":"number"}},"required":["key","title","items"]},"DiaryReportResponse":{"type":"object","properties":{"farm":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"},"sections":{"type":"array","items":{"$ref":"#/components/schemas/DiaryReportSection"}},"entries":{"type":"number"},"money":{"type":"boolean","description":"True when a money section is available to this person"}},"required":["farm","from","to","sections","entries","money"]},"EquipmentInput":{"type":"object","properties":{"name":{"type":"string"},"category":{"type":"string"},"status":{"type":"string","enum":["ok","repair","broken","retired"]},"notes":{"type":"string"},"purchasedOn":{"type":"string","description":"YYYY-MM-DD"},"purchaseCents":{"type":"number","nullable":true,"description":"Purchase price in cents. On update, omitted keeps the stored price and null clears it. Setting, changing or clearing it needs `money:write`; it is only returned to who sees amounts (`money:read` and a financial role)"},"roma":{"type":"string","description":"Nº de inscripción ROMA o REGANIP. Se copia al tratamiento que usa esta máquina si no trae uno"}},"required":["name"]},"EquipmentActivity":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"title":{"type":"string"},"date":{"type":"string"},"hours":{"type":"number"},"fuelLiters":{"type":"number"},"cents":{"type":"number"},"status":{"type":"string"}},"required":["id","kind","title","date"]},"EquipmentSummaryResponse":{"type":"object","properties":{"equipment":{"$ref":"#/components/schemas/EquipmentResponse"},"from":{"type":"string"},"to":{"type":"string"},"works":{"type":"number"},"hours":{"type":"number"},"fuelLiters":{"type":"number"},"expenseCents":{"type":"number","description":"Only for financial roles"},"incidentsOpen":{"type":"number"},"incidentsResolved":{"type":"number"},"activity":{"type":"array","items":{"$ref":"#/components/schemas/EquipmentActivity"}}},"required":["equipment","from","to","works","hours","fuelLiters","incidentsOpen","incidentsResolved","activity"]},"PlantingPatch":{"type":"object","properties":{"crop":{"type":"string","maxLength":80},"catalogCropId":{"type":"string","nullable":true},"varietyId":{"type":"string","nullable":true,"description":"Null quita la variedad"},"variety":{"type":"string","nullable":true,"description":"Un nombre sustituye la variedad; null la quita"},"catalogVarietyId":{"type":"string"},"plants":{"type":"number","nullable":true},"hectares":{"type":"number","nullable":true},"pollinizer":{"type":"boolean"},"plantedYear":{"type":"number","nullable":true},"plantedOn":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true,"maxLength":500},"version":{"type":"number","description":"La versión leída. 409 si la plantación cambió desde entonces"}},"required":["version"]},"PlantingArchiveInput":{"type":"object","properties":{"endedOn":{"type":"string","description":"Día en que se arrancó o terminó el ciclo (AAAA-MM-DD). Hoy si se omite. Ni futura ni anterior a la plantación"},"reason":{"type":"string","enum":["removed","cycle_end","replaced","died","mistake"],"description":"removed: arrancada. cycle_end: fin de ciclo. replaced: cambio de variedad. died: se perdió. mistake: se apuntó por error"},"version":{"type":"number"}},"required":["version"]},"FarmProductInput":{"type":"object","properties":{"kind":{"type":"string","enum":["phytosanitary","fertilizer"]},"name":{"type":"string","description":"Nombre comercial del fitosanitario o material del abono"},"defaultUnit":{"type":"string","description":"Unidad habitual, una de las del formulario de su tipo (kg/ha, l/ha…). No es una dosis"},"notes":{"type":"string"},"registrationNumber":{"type":"string","description":"Nº de registro MAPA. Obligatorio en un fitosanitario; un abono no lo lleva"},"activeSubstance":{"type":"string","description":"Materia activa. Solo fitosanitarios"},"nutrients":{"description":"N, P2O5 y K2O habituales, en porcentaje. Solo abonos","allOf":[{"$ref":"#/components/schemas/FarmProductNutrients"}]}},"required":["kind","name"]},"DiarySendInput":{"type":"object","properties":{"from":{"type":"string","description":"First day, YYYY-MM-DD"},"to":{"type":"string","description":"Last day, YYYY-MM-DD"},"intro":{"type":"string","description":"Introductory text placed before the entries"},"memberIds":{"description":"Farm members to send to","type":"array","items":{"type":"string"}},"emails":{"description":"Other email addresses","type":"array","items":{"type":"string"}},"includeMoney":{"type":"boolean","description":"Add the money section (financial roles only)"}},"required":["from","to"]},"DiarySendResponse":{"type":"object","properties":{"message":{"type":"string"},"recipients":{"type":"number"},"entries":{"type":"number"}},"required":["message","recipients","entries"]},"MemberUpdateInput":{"type":"object","properties":{"role":{"type":"string","enum":["admin","coordinator","worker"]},"name":{"type":"string","description":"People without access only"},"emoji":{"type":"string","nullable":true},"color":{"type":"string","nullable":true},"email":{"type":"string","description":"Gives a person without access an account: they sign in with a code from then on"},"nif":{"type":"string","nullable":true,"description":"Null clears the NIF"},"ropo":{"type":"string","nullable":true,"description":"Null clears the ROPO number"},"firstSurname":{"type":"string","nullable":true,"description":"Null clears it"},"secondSurname":{"type":"string","nullable":true,"description":"Null clears it"},"companyName":{"type":"string","nullable":true,"description":"Null clears it"}}},"PersonInput":{"type":"object","properties":{"name":{"type":"string"},"emoji":{"type":"string"},"color":{"type":"string"},"nif":{"type":"string","description":"NIF, NIE or CIF"},"ropo":{"type":"string","description":"ROPO inscription number"},"firstSurname":{"type":"string"},"secondSurname":{"type":"string"},"companyName":{"type":"string","description":"Company name, when the applicator is a company"}},"required":["name"]},"PersonVariety":{"type":"object","properties":{"variety":{"type":"string"},"grams":{"type":"number"}},"required":["variety","grams"]},"PersonActivity":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"title":{"type":"string"},"date":{"type":"string"},"sectorId":{"type":"string"},"variety":{"type":"string"},"grams":{"type":"number"},"minutes":{"type":"number"},"status":{"type":"string"},"people":{"type":"number","description":"How many people share this record"},"relation":{"type":"string","description":"created | assigned"}},"required":["id","kind","title","date","people","relation"]},"PersonSummaryResponse":{"type":"object","properties":{"person":{"$ref":"#/components/schemas/MemberResponse"},"from":{"type":"string"},"to":{"type":"string"},"works":{"type":"number"},"minutes":{"type":"number"},"tasksPending":{"type":"number"},"tasksDone":{"type":"number"},"harvestGrams":{"type":"number","description":"Grams attributed; shared harvests are split evenly"},"harvestShared":{"type":"number"},"harvestByVariety":{"type":"array","items":{"$ref":"#/components/schemas/PersonVariety"}},"wasteGrams":{"type":"number"},"incidentsReported":{"type":"number"},"incidentsOpen":{"type":"number"},"incidentsResolved":{"type":"number"},"comments":{"type":"number"},"activity":{"type":"array","items":{"$ref":"#/components/schemas/PersonActivity"}}},"required":["person","from","to","works","minutes","tasksPending","tasksDone","harvestGrams","harvestShared","harvestByVariety","wasteGrams","incidentsReported","incidentsOpen","incidentsResolved","comments","activity"]},"CheckoutInput":{"type":"object","properties":{"interval":{"type":"string","enum":["monthly","yearly"]},"promoCode":{"type":"string","description":"Promotional code (CUE2027), case-insensitive. Yearly plan only; refused with 400 and a machine `code` (invalid_code, expired, already_used, not_new_farm, plan_not_eligible) or 503 `unavailable`"}},"required":["interval"]},"UrlResponse":{"type":"object","properties":{"url":{"type":"string"}},"required":["url"]},"PromoValidateInput":{"type":"object","properties":{"code":{"type":"string"},"interval":{"type":"string","enum":["monthly","yearly"]}},"required":["code","interval"]},"PromoValidateResponse":{"type":"object","properties":{"valid":{"type":"boolean"},"code":{"type":"string","description":"The code as the server reads it: trimmed, upper case"},"message":{"type":"string","description":"Spanish text to show to the owner"},"reason":{"type":"string","description":"Why the code does not apply; absent when valid","enum":["invalid_code","expired","already_used","not_new_farm","plan_not_eligible","unavailable"]},"discountCents":{"type":"number","description":"Discount on the first payment, in cents; when valid"},"amountCents":{"type":"number","description":"First payment after the discount, in cents; when valid"},"currency":{"type":"string"}},"required":["valid","code","message"]},"CueExploitation":{"type":"object","properties":{"nombre":{"type":"string"},"nifTitular":{"type":"string","nullable":true},"codigoRea":{"type":"string","nullable":true}},"required":["nombre","nifTitular","codigoRea"]},"CueDelimitation":{"type":"object","properties":{"sectorId":{"type":"string"},"nombre":{"type":"string","description":"Nombre del sector en AgroJefe"},"cultivo":{"type":"string","nullable":true},"variedad":{"type":"string","nullable":true},"superficieHa":{"type":"number","nullable":true,"description":"Superficie de la ficha, ha"},"referenciaCatastral":{"type":"string","nullable":true},"codigoProvincia":{"type":"string","nullable":true},"codigoMunicipio":{"type":"string","nullable":true},"codigoAgregado":{"type":"string","nullable":true},"codigoZona":{"type":"string","nullable":true},"codigoPoligono":{"type":"string","nullable":true},"codigoParcela":{"type":"string","nullable":true},"codigoRecinto":{"type":"string","nullable":true},"numeroOrden":{"type":"number","nullable":true},"superficieDgcHa":{"type":"number","nullable":true},"fechaAltaDgc":{"type":"string","nullable":true},"fechaBajaDgc":{"type":"string","nullable":true}},"required":["sectorId","nombre","cultivo","variedad","superficieHa","referenciaCatastral","codigoProvincia","codigoMunicipio","codigoAgregado","codigoZona","codigoPoligono","codigoParcela","codigoRecinto","numeroOrden","superficieDgcHa","fechaAltaDgc","fechaBajaDgc"]},"CueProblem":{"type":"object","properties":{"malasHierbas":{"type":"string","nullable":true},"enfermedades":{"type":"string","nullable":true},"artropodosGasteropodos":{"type":"string","nullable":true},"reguladoresCrecimientoRodenticidasOtros":{"type":"string","nullable":true},"justificacionActuacion":{"type":"string","nullable":true}},"required":["malasHierbas","enfermedades","artropodosGasteropodos","reguladoresCrecimientoRodenticidasOtros","justificacionActuacion"]},"CueProduct":{"type":"object","properties":{"tipoProducto":{"type":"string","nullable":true},"nombreComercial":{"type":"string","nullable":true},"materiaActiva":{"type":"string","nullable":true},"numeroRegistro":{"type":"string","nullable":true},"cantidad":{"type":"number","nullable":true},"dosis":{"type":"number","nullable":true},"unidad":{"type":"string","nullable":true}},"required":["tipoProducto","nombreComercial","materiaActiva","numeroRegistro","cantidad","dosis","unidad"]},"CueApplicator":{"type":"object","properties":{"nombre":{"type":"string","nullable":true},"primerApellido":{"type":"string","nullable":true},"segundoApellido":{"type":"string","nullable":true},"razonSocial":{"type":"string","nullable":true},"nif":{"type":"string","nullable":true},"numeroInscripcionRopo":{"type":"string","nullable":true}},"required":["nombre","primerApellido","segundoApellido","razonSocial","nif","numeroInscripcionRopo"]},"CueAdvisor":{"type":"object","properties":{"fecha":{"type":"string","nullable":true},"nombre":{"type":"string","nullable":true},"primerApellido":{"type":"string","nullable":true},"segundoApellido":{"type":"string","nullable":true},"razonSocial":{"type":"string","nullable":true},"nif":{"type":"string","nullable":true},"numeroInscripcionRopo":{"type":"string","nullable":true},"validacion":{"type":"string","nullable":true,"enum":["Favorable","Desfavorable"]},"contratoAsesoramiento":{"type":"string","nullable":true,"enum":["S","N"]}},"required":["fecha","nombre","primerApellido","segundoApellido","razonSocial","nif","numeroInscripcionRopo","validacion","contratoAsesoramiento"]},"CueTreatment":{"type":"object","properties":{"id":{"type":"string"},"sectorId":{"type":"string","nullable":true},"fechaInicio":{"type":"string"},"fechaFin":{"type":"string","nullable":true},"horaTratamiento":{"type":"string","nullable":true},"fechaSeca":{"type":"string","nullable":true},"superficieTratadaHa":{"type":"number","nullable":true},"cultivo":{"type":"string","nullable":true},"estadoFenologico":{"type":"string","nullable":true},"problemaFitosanitario":{"$ref":"#/components/schemas/CueProblem"},"productoFitosanitario":{"$ref":"#/components/schemas/CueProduct"},"aplicador":{"$ref":"#/components/schemas/CueApplicator"},"aplicacionManual":{"type":"string","nullable":true,"enum":["S","N"]},"numeroInscripcionRoma":{"type":"string","nullable":true},"equipoPropio":{"type":"string","nullable":true,"enum":["S","N"]},"equipoNoInscribible":{"type":"string","nullable":true,"enum":["S","N"]},"equipoId":{"type":"string","nullable":true},"asesor":{"nullable":true,"type":"object","allOf":[{"$ref":"#/components/schemas/CueAdvisor"}]},"eficacia":{"type":"string","nullable":true},"observaciones":{"type":"string","nullable":true}},"required":["id","sectorId","fechaInicio","fechaFin","horaTratamiento","fechaSeca","superficieTratadaHa","cultivo","estadoFenologico","problemaFitosanitario","productoFitosanitario","aplicador","aplicacionManual","numeroInscripcionRoma","equipoPropio","equipoNoInscribible","equipoId","asesor","eficacia","observaciones"]},"CueNutrients":{"type":"object","properties":{"nTotal":{"type":"number","nullable":true},"nOrganico":{"type":"number","nullable":true},"nNitrico":{"type":"number","nullable":true},"nAmoniacal":{"type":"number","nullable":true},"nUreico":{"type":"number","nullable":true},"p2o5Total":{"type":"number","nullable":true},"k2oTotal":{"type":"number","nullable":true}},"required":["nTotal","nOrganico","nNitrico","nAmoniacal","nUreico","p2o5Total","k2oTotal"]},"CueFertigation":{"type":"object","properties":{"dosisAgua":{"type":"number","nullable":true},"unidadAgua":{"type":"string","nullable":true},"nNitricoAguaMgL":{"type":"number","nullable":true},"p2o5SolubleAguaMgL":{"type":"number","nullable":true}},"required":["dosisAgua","unidadAgua","nNitricoAguaMgL","p2o5SolubleAguaMgL"]},"CueFertilization":{"type":"object","properties":{"id":{"type":"string"},"sectorId":{"type":"string","nullable":true},"fechaInicio":{"type":"string"},"fechaFin":{"type":"string","nullable":true},"cultivo":{"type":"string","nullable":true},"superficieAplicacionHa":{"type":"number","nullable":true},"materialFertilizante":{"type":"string","nullable":true},"detalleMaterialFertilizante":{"type":"string","nullable":true},"macronutrientes":{"$ref":"#/components/schemas/CueNutrients"},"dosisFertilizante":{"type":"number","nullable":true},"unidad":{"type":"string","nullable":true},"tipoFertilizacion":{"type":"string","nullable":true},"metodoAplicacion":{"type":"string","nullable":true},"fertirrigacion":{"nullable":true,"type":"object","allOf":[{"$ref":"#/components/schemas/CueFertigation"}]},"observaciones":{"type":"string","nullable":true}},"required":["id","sectorId","fechaInicio","fechaFin","cultivo","superficieAplicacionHa","materialFertilizante","detalleMaterialFertilizante","macronutrientes","dosisFertilizante","unidad","tipoFertilizacion","metodoAplicacion","fertirrigacion","observaciones"]},"CueExportResponse":{"type":"object","properties":{"version":{"type":"string","example":"3.11"},"fuente":{"type":"string"},"generado":{"type":"string"},"explotacion":{"$ref":"#/components/schemas/CueExploitation"},"delimitacionesGraficas":{"type":"array","items":{"$ref":"#/components/schemas/CueDelimitation"}},"actuacionesFitosanitarias":{"type":"array","items":{"$ref":"#/components/schemas/CueTreatment"}},"fertilizacion":{"type":"array","items":{"$ref":"#/components/schemas/CueFertilization"}},"avisos":{"type":"array","items":{"type":"string"}}},"required":["version","fuente","generado","explotacion","delimitacionesGraficas","actuacionesFitosanitarias","fertilizacion","avisos"]},"WeatherDays":{"type":"object","properties":{"time":{"type":"array","items":{"type":"string"}},"temperature_2m_max":{"type":"array","items":{"type":"number"}},"temperature_2m_min":{"type":"array","items":{"type":"number"}},"precipitation_sum":{"type":"array","items":{"type":"number"}},"weather_code":{"description":"WMO weather codes","type":"array","items":{"type":"number"}},"wind_speed_10m_max":{"type":"array","items":{"type":"number"}},"precipitation_probability_max":{"type":"array","items":{"type":"number"}}},"required":["time","temperature_2m_max","temperature_2m_min","precipitation_sum"]},"WeatherCurrent":{"type":"object","properties":{"time":{"type":"string"},"temperature_2m":{"type":"number"},"weather_code":{"type":"number","description":"WMO weather code"},"wind_speed_10m":{"type":"number"},"is_day":{"type":"number","description":"1 by day, 0 by night"}}},"WeatherHours":{"type":"object","properties":{"time":{"type":"array","items":{"type":"string"}},"temperature_2m":{"type":"array","items":{"type":"number"}},"weather_code":{"type":"array","items":{"type":"number"}},"precipitation":{"type":"array","items":{"type":"number"}},"precipitation_probability":{"type":"array","items":{"type":"number"}},"wind_speed_10m":{"type":"array","items":{"type":"number"}}},"required":["time","temperature_2m"]},"WeatherResponse":{"type":"object","properties":{"daily":{"$ref":"#/components/schemas/WeatherDays"},"current":{"$ref":"#/components/schemas/WeatherCurrent"},"hourly":{"$ref":"#/components/schemas/WeatherHours"}},"required":["daily"]},"SellerUsernameAvailability":{"type":"object","properties":{"username":{"type":"string"},"available":{"type":"boolean"},"suggestion":{"type":"string"}},"required":["username","available"]},"SellerFarmResponse":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"]},"SellerProfileResponse":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"username":{"type":"string","description":"Public handle, unique, like a Stripe account name"},"webhookConfigured":{"type":"boolean"},"createdAt":{"type":"string"},"farms":{"type":"array","items":{"$ref":"#/components/schemas/SellerFarmResponse"}}},"required":["id","name","username","webhookConfigured","createdAt","farms"]},"SellerProfileInput":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"username":{"type":"string","description":"Handle. If omitted, one is suggested from the name"}},"required":["name"]},"SellerProfilePatch":{"type":"object","properties":{"name":{"type":"string"},"username":{"type":"string"}}},"LinkSellerFarmInput":{"type":"object","properties":{"farmId":{"type":"string"}},"required":["farmId"]},"StoreWebhookSecretResponse":{"type":"object","properties":{"secret":{"type":"string","description":"Shown once. Send it as the HMAC secret; it is not the API key."},"url":{"type":"string"}},"required":["secret","url"]},"StoreAvailabilityFarm":{"type":"object","properties":{"farmId":{"type":"string"},"name":{"type":"string"},"grams":{"type":"number","description":"Reviewed harvest minus live sales minus reviewed waste, in grams. Reservations are not included"},"harvestGrams":{"type":"number"},"soldGrams":{"type":"number"},"wasteGrams":{"type":"number"},"committedGrams":{"type":"number","description":"Grams promised on this farm by received or paid orders. Unassigned reservations are not included"},"freeGrams":{"type":"number","description":"grams minus committedGrams. Negative means this farm is overbooked"}},"required":["farmId","name","grams","harvestGrams","soldGrams","wasteGrams","committedGrams","freeGrams"]},"StoreAvailabilityItem":{"type":"object","properties":{"varietyId":{"type":"string","nullable":true,"description":"Variety entity. Null for produce recorded with a crop and no variety"},"crop":{"type":"string","description":"Crop of the variety"},"variety":{"type":"string","description":"Name of the variety"},"grams":{"type":"number","description":"Reviewed harvest minus live sales minus reviewed waste, in grams. Unchanged by reservations"},"harvestGrams":{"type":"number"},"soldGrams":{"type":"number"},"wasteGrams":{"type":"number"},"committedGrams":{"type":"number","description":"Grams promised by received or paid orders that have not become a sale yet"},"freeGrams":{"type":"number","description":"grams minus committedGrams. Negative means the harvest is still short of the reservations"},"farms":{"type":"array","items":{"$ref":"#/components/schemas/StoreAvailabilityFarm"}}},"required":["varietyId","crop","variety","grams","harvestGrams","soldGrams","wasteGrams","committedGrams","freeGrams","farms"]},"StoreAvailabilityResponse":{"type":"object","properties":{"channel":{"type":"string","example":"venta directa web"},"items":{"type":"array","items":{"$ref":"#/components/schemas/StoreAvailabilityItem"}}},"required":["channel","items"]},"VarietyInput":{"type":"object","properties":{"name":{"type":"string","maxLength":80,"description":"Required unless `catalogVarietyId` is sent, which names the variety"},"crop":{"type":"string","maxLength":80,"description":"Free text. Omitted: the catalogue crop when one is picked, else not known"},"catalogCropId":{"type":"string","description":"Links the variety to this crop of the catalogue"},"catalogVarietyId":{"type":"string","description":"Links the variety to this variety of the catalogue"}}},"VarietyResolved":{"type":"object","properties":{"id":{"type":"string"},"crop":{"type":"string","description":"Crop as written. Empty when the crop is not known yet"},"name":{"type":"string"},"catalogCropId":{"type":"string","nullable":true,"description":"Crop of the AgroJefe catalogue this variety belongs to. Null: not linked"},"catalogVarietyId":{"type":"string","nullable":true,"description":"Variety of the AgroJefe catalogue. Null: a variety only this holder names"},"created":{"type":"boolean","description":"False when a variety with that normalized name already existed"}},"required":["id","crop","name","catalogCropId","catalogVarietyId","created"]},"StoreProductResponse":{"type":"object","properties":{"source":{"type":"string"},"productCode":{"type":"string"},"varietyId":{"type":"string","nullable":true},"crop":{"type":"string"},"variety":{"type":"string"},"gramsPerUnit":{"type":"number","description":"Grams of one unit of this product"},"title":{"type":"string"}},"required":["source","productCode","varietyId","crop","variety"]},"StoreProductInput":{"type":"object","properties":{"source":{"type":"string","default":"amandi"},"productCode":{"type":"string"},"varietyId":{"type":"string","description":"Variety this product sells. The crop is the one of the variety"},"gramsPerUnit":{"type":"number","description":"Grams of one unit, so an order line can send productCode and quantity only"},"crop":{"type":"string","description":"Crop name. Still accepted instead of varietyId"},"variety":{"type":"string","description":"Variety name. Still accepted instead of varietyId: found or created"},"title":{"type":"string"}},"required":["productCode"]},"StoreOrderLineResponse":{"type":"object","properties":{"externalLineRef":{"type":"string"},"title":{"type":"string"},"productCode":{"type":"string"},"varietyId":{"type":"string","nullable":true},"crop":{"type":"string"},"variety":{"type":"string"},"quantity":{"type":"number","description":"Units sold, when the shop sent a quantity"},"sectorId":{"type":"string"},"farmId":{"type":"string","nullable":true},"farmName":{"type":"string"},"grams":{"type":"number"},"cents":{"type":"number","description":"Product amount in cents. Shipping is not included"},"saleId":{"type":"string","nullable":true},"voided":{"type":"boolean"},"voidReason":{"type":"string","enum":["cancelled","refunded"]}},"required":["externalLineRef","title","varietyId","crop","variety","farmId","grams","cents","saleId","voided"]},"StoreOrderResponse":{"type":"object","properties":{"id":{"type":"string"},"source":{"type":"string"},"externalRef":{"type":"string"},"status":{"type":"string","enum":["received","paid","shipped","delivered","cancelled","refunded"]},"occurredOn":{"type":"string"},"trackingNumber":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"currency":{"type":"string","enum":["EUR"]},"updatedAt":{"type":"string"},"idempotent":{"type":"boolean","description":"True when this call repeated a notification already applied"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/StoreOrderLineResponse"}}},"required":["id","source","externalRef","status","occurredOn","trackingNumber","notes","currency","updatedAt","lines"]},"StoreLineInput":{"type":"object","properties":{"externalLineRef":{"type":"string"},"title":{"type":"string"},"productCode":{"type":"string","description":"Product code of the shop. With a catalogue entry it gives the variety and, with `quantity`, the grams. A code with no catalogue entry and no variety on the line is rejected with 400"},"varietyId":{"type":"string","description":"Variety entity. Wins over the catalogue and the names"},"crop":{"type":"string","description":"Crop name. Still accepted; prefer productCode or varietyId"},"variety":{"type":"string","description":"Variety name. Still accepted: found or created among the varieties of the owner"},"sectorId":{"type":"string"},"farmId":{"type":"string","description":"Farm of the profile. Omitted: the one with the most grams"},"quantity":{"type":"number","description":"Units sold. Grams become quantity × gramsPerUnit of the catalogue entry of productCode. Needs productCode"},"grams":{"type":"number","description":"Weight in grams. Required unless `quantity` is sent. When both arrive grams wins"},"cents":{"type":"number","description":"Product amount of the line in cents. Shipping is NOT part of a sale amount: do not add it to any line"}},"required":["externalLineRef","title","cents"]},"StoreOrderInput":{"type":"object","properties":{"source":{"type":"string","default":"amandi"},"status":{"type":"string","enum":["received","paid","shipped","delivered","cancelled","refunded"]},"occurredOn":{"type":"string","description":"YYYY-MM-DD. Becomes the sale date when the order ships"},"trackingNumber":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"currency":{"type":"string","enum":["EUR"],"default":"EUR"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/StoreLineInput"}}},"required":["status","occurredOn","lines"]},"StoreVoidInput":{"type":"object","properties":{"source":{"type":"string","default":"amandi"},"reason":{"type":"string","enum":["cancelled","refunded"]}},"required":["reason"]},"StoreSaleInput":{"type":"object","properties":{"source":{"type":"string","default":"amandi"},"externalRef":{"type":"string"},"occurredOn":{"type":"string"},"trackingNumber":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"currency":{"type":"string","enum":["EUR"],"default":"EUR"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/StoreLineInput"}}},"required":["externalRef","occurredOn","lines"]},"SellerProfileSummary":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"username":{"type":"string"}},"required":["id","name","username"]},"FarmStoreOrdersResponse":{"type":"object","properties":{"profile":{"nullable":true,"type":"object","allOf":[{"$ref":"#/components/schemas/SellerProfileSummary"}]},"orders":{"type":"array","items":{"$ref":"#/components/schemas/StoreOrderResponse"}},"availability":{"description":"Harvested balance and pre-sale commitments of the seller profile","type":"array","items":{"$ref":"#/components/schemas/StoreAvailabilityItem"}}},"required":["profile","orders","availability"]},"VarietyPatch":{"type":"object","properties":{"name":{"type":"string","maxLength":80},"crop":{"type":"string","maxLength":80},"catalogCropId":{"type":"string","nullable":true,"description":"Catalogue crop. Null removes the link to the catalogue"},"catalogVarietyId":{"type":"string","nullable":true,"description":"Catalogue variety. Null keeps the crop link and removes the variety link"}}},"VarietyMergeInput":{"type":"object","properties":{"intoId":{"type":"string","description":"Variety that stays and receives every reference"}},"required":["intoId"]},"CatalogItem":{"type":"object","properties":{"kind":{"type":"string","enum":["crop","variety"]},"cropId":{"type":"string","description":"Stable id of the crop, such as `aguacate`"},"crop":{"type":"string","description":"Canonical name of the crop"},"varietyId":{"type":"string","description":"Stable id of the variety, such as `aguacate-hass`"},"name":{"type":"string","description":"Canonical name of the crop or of the variety"},"alias":{"type":"string","description":"Alias the text matched when the canonical name did not: «Palta» for Aguacate"}},"required":["kind","cropId","crop","name"]},"CatalogTargetItem":{"type":"object","properties":{"id":{"type":"string","description":"Stable id of the target, such as `mapa-6-2-2-3-3`"},"mapaCode":{"type":"string","description":"`CodigoAgente` of the MAPA register, such as `6.2.2.3.3`"},"name":{"type":"string","description":"Name exactly as MAPA writes it: «Áfidos, pulgones, Aphididae»"},"match":{"type":"string","description":"Part of the name the text matched, when the name does not start with it"},"exact":{"type":"boolean","description":"The text names this target and no other"}},"required":["id","mapaCode","name","exact"]},"PhytoRegistryVersion":{"type":"object","properties":{"sourceDate":{"type":"string","description":"Fecha de la copia del registro del MAPA, YYYY-MM-DD"},"importedAt":{"type":"string","description":"Cuándo se importó en AgroJefe (ISO)"},"basis":{"type":"string","enum":["current","as_of","oldest_available"],"description":"current: la última copia. as_of: la copia vigente en la fecha pedida. oldest_available: la fecha es anterior a todas las copias y se usa la más antigua."}},"required":["sourceDate","importedAt","basis"]},"PhytoRegistrySubstance":{"type":"object","properties":{"substance":{"type":"string"},"euName":{"type":"string","nullable":true},"concentration":{"type":"string","nullable":true}},"required":["substance","euName","concentration"]},"PhytoRegistryProduct":{"type":"object","properties":{"registrationNumber":{"type":"string","description":"Nº de registro tal como lo publica el MAPA"},"name":{"type":"string"},"otherNames":{"description":"Otros nombres comerciales del mismo registro","type":"array","items":{"type":"string"}},"holder":{"type":"string","nullable":true,"description":"Titular"},"formulation":{"type":"string","nullable":true,"description":"Formulado"},"status":{"type":"string","description":"`Estado` tal como lo publica el MAPA: Vigente o Cancelado"},"inForce":{"type":"boolean","description":"true solo si el estado es Vigente"},"expiresOn":{"type":"string","nullable":true,"description":"Fecha de caducidad, YYYY-MM-DD"},"cancelledOn":{"type":"string","nullable":true,"description":"Fecha de cancelación, YYYY-MM-DD"},"saleLimitOn":{"type":"string","nullable":true,"description":"Fecha límite de venta, YYYY-MM-DD"},"composition":{"type":"array","items":{"$ref":"#/components/schemas/PhytoRegistrySubstance"}}},"required":["registrationNumber","name","otherNames","holder","formulation","status","inForce","expiresOn","cancelledOn","saleLimitOn","composition"]},"PhytoRegistrySearchResponse":{"type":"object","properties":{"loaded":{"type":"boolean","description":"false si todavía no se ha importado ninguna copia del registro"},"version":{"$ref":"#/components/schemas/PhytoRegistryVersion"},"products":{"type":"array","items":{"$ref":"#/components/schemas/PhytoRegistryProduct"}}},"required":["loaded","products"]},"PhytoRegistryCropName":{"type":"object","properties":{"name":{"type":"string","description":"Cultivo tal como figura en el registro"},"via":{"type":"string","enum":["exact","plural","alias","narrower","broader"],"description":"exact, plural y alias son coincidencias. narrower: el cultivo del registro es más concreto que el escrito. broader: es más general."}},"required":["name","via"]},"PhytoRegistryCropMatch":{"type":"object","properties":{"status":{"type":"string","enum":["exact","partial","none","not_provided"]},"input":{"type":"string","description":"Cultivo escrito en el formulario"},"mapaCrops":{"type":"array","items":{"$ref":"#/components/schemas/PhytoRegistryCropName"}}},"required":["status","input","mapaCrops"]},"PhytoRegistryAgentName":{"type":"object","properties":{"name":{"type":"string","description":"Agente tal como figura en el registro"},"via":{"type":"string","enum":["exact","partial"]}},"required":["name","via"]},"PhytoRegistryAgentMatch":{"type":"object","properties":{"status":{"type":"string","enum":["exact","partial","none","not_provided"]},"input":{"type":"string","description":"Plaga, enfermedad o mala hierba escrita en el formulario"},"mapaAgents":{"type":"array","items":{"$ref":"#/components/schemas/PhytoRegistryAgentName"}}},"required":["status","input","mapaAgents"]},"PhytoRegistryUseDose":{"type":"object","properties":{"kind":{"type":"string","enum":["range","single","up_to","none","inconsistent"],"description":"range: mínimo y máximo. single: una sola cifra. up_to: solo máximo. none: el registro no da cifra (0–0; está en notas o condiciones). inconsistent: el mínimo publicado supera al máximo."},"min":{"type":"string","nullable":true,"description":"Decimal exacto como texto"},"max":{"type":"string","nullable":true,"description":"Decimal exacto como texto"},"unit":{"type":"string","nullable":true,"description":"Unidad tal como la publica el MAPA"},"unitKind":{"type":"string","enum":["amount","note","device","none"],"description":"amount: comparable (l/ha, Kg/ha, %, ml/Hl…). note: «(ver nota)», «(ver condic.)». device: trampas, difusores, tabletas. none: sin unidad."}},"required":["kind","min","max","unit","unitKind"]},"PhytoRegistryCroppingSystem":{"type":"object","properties":{"raw":{"type":"string","description":"Código publicado: F, G, I u «Otros (ver condic.)»"},"label":{"type":"string","description":"Aire libre, Invernadero, Interior…"}},"required":["raw","label"]},"PhytoRegistryUse":{"type":"object","properties":{"crop":{"type":"string"},"cropVia":{"type":"string","nullable":true,"enum":["exact","plural","alias","narrower","broader"]},"agent":{"type":"string"},"agentVia":{"type":"string","nullable":true,"enum":["exact","partial"]},"dose":{"$ref":"#/components/schemas/PhytoRegistryUseDose"},"safetyPeriod":{"type":"string","nullable":true,"description":"Plazo de seguridad, literal"},"safetyDays":{"type":"number","nullable":true,"description":"Días, solo cuando el plazo publicado es únicamente un número"},"conditions":{"type":"string","nullable":true,"description":"Condicionamiento específico"},"croppingSystem":{"nullable":true,"type":"object","allOf":[{"$ref":"#/components/schemas/PhytoRegistryCroppingSystem"}]},"applications":{"type":"string","nullable":true},"applicationInterval":{"type":"string","nullable":true},"sprayVolume":{"type":"string","nullable":true},"userType":{"type":"string","nullable":true},"scope":{"type":"string","nullable":true},"method":{"type":"string","nullable":true},"bbch":{"type":"string","nullable":true}},"required":["crop","cropVia","agent","agentVia","dose","safetyPeriod","safetyDays","conditions","croppingSystem","applications","applicationInterval","sprayVolume","userType","scope","method","bbch"]},"PhytoRegistryDoseDetail":{"type":"object","properties":{"use":{"type":"number","description":"Posición del uso en `uses`"},"status":{"type":"string","enum":["in_range","below","above","unit_mismatch","not_comparable"]},"reason":{"type":"string","enum":["unit_note","unit_device","unit_missing","no_figure","inconsistent","typed_unit_missing"]}},"required":["use","status"]},"PhytoRegistryDoseCheck":{"type":"object","properties":{"status":{"type":"string","enum":["in_range","below","above","mixed","unit_mismatch","not_comparable","no_dose","no_matching_use"],"description":"Comparación de la dosis escrita con los usos coincidentes. Nunca propone una dosis. mixed: encaja en unos usos y en otros no."},"typedDose":{"type":"string","nullable":true},"typedUnit":{"type":"string","nullable":true},"details":{"type":"array","items":{"$ref":"#/components/schemas/PhytoRegistryDoseDetail"}}},"required":["status","typedDose","typedUnit","details"]},"PhytoRegistryCropSummary":{"type":"object","properties":{"crop":{"type":"string"},"useCount":{"type":"number"},"agentCount":{"type":"number"},"agents":{"description":"Primeros agentes autorizados en ese cultivo","type":"array","items":{"type":"string"}}},"required":["crop","useCount","agentCount","agents"]},"PhytoRegistrySummary":{"type":"object","properties":{"cropCount":{"type":"number"},"useCount":{"type":"number"},"crops":{"type":"array","items":{"$ref":"#/components/schemas/PhytoRegistryCropSummary"}}},"required":["cropCount","useCount","crops"]},"PhytoRegistryCheckResponse":{"type":"object","properties":{"loaded":{"type":"boolean","description":"false si todavía no se ha importado ninguna copia del registro"},"version":{"$ref":"#/components/schemas/PhytoRegistryVersion"},"productStatus":{"type":"string","enum":["found","not_found","ambiguous","not_provided"]},"product":{"$ref":"#/components/schemas/PhytoRegistryProduct"},"nameMatches":{"type":"boolean","description":"Con producto y nombre escrito: si el nombre es el del registro o uno de sus otros nombres"},"candidates":{"description":"Productos posibles cuando no hay uno solo","type":"array","items":{"$ref":"#/components/schemas/PhytoRegistryProduct"}},"crop":{"$ref":"#/components/schemas/PhytoRegistryCropMatch"},"agent":{"$ref":"#/components/schemas/PhytoRegistryAgentMatch"},"uses":{"description":"Usos autorizados que coinciden","type":"array","items":{"$ref":"#/components/schemas/PhytoRegistryUse"}},"useCount":{"type":"number","description":"Usos coincidentes antes de limitar la lista"},"dose":{"$ref":"#/components/schemas/PhytoRegistryDoseCheck"},"summary":{"$ref":"#/components/schemas/PhytoRegistrySummary"},"cropAgents":{"description":"Agentes autorizados en el cultivo cuando el escrito no está","type":"array","items":{"type":"string"}}},"required":["loaded","productStatus","candidates","crop","agent","uses","useCount","dose","summary","cropAgents"]},"AccesoPhoto":{"type":"object","properties":{"id":{"type":"string"},"mime":{"type":"string"},"width":{"type":"number"},"height":{"type":"number"}},"required":["id","mime"]},"AccesoResponse":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"hasSecret":{"type":"boolean","description":"The secret itself is only returned by the reveal route"},"photos":{"description":"Bytes come from the photo route, which checks the audience again","type":"array","items":{"$ref":"#/components/schemas/AccesoPhoto"}},"updatedAt":{"type":"string"},"roles":{"type":"array","description":"Managers only","items":{"type":"string","enum":["coordinator","worker"]}},"memberIds":{"description":"Managers only","type":"array","items":{"type":"string"}},"links":{"type":"number","description":"Active share links that include this item. Managers only"}},"required":["id","title","description","hasSecret","photos","updatedAt"]},"AccesoListResponse":{"type":"object","properties":{"canManage":{"type":"boolean","description":"Owner or admin: may create, edit, archive and share"},"items":{"type":"array","items":{"$ref":"#/components/schemas/AccesoResponse"}}},"required":["canManage","items"]},"AccesoSecret":{"type":"object","properties":{"label":{"type":"string","description":"What it is: «Código», «Contraseña», «Dónde están las llaves»…"},"value":{"type":"string"}},"required":["label","value"]},"AccesoInput":{"type":"object","properties":{"title":{"type":"string"},"description":{"type":"string"},"secrets":{"description":"Omitted on an edit keeps the stored secrets","type":"array","items":{"$ref":"#/components/schemas/AccesoSecret"}},"roles":{"type":"array","description":"Whole roles that may see this item. Owner and admin always can","items":{"type":"string","enum":["coordinator","worker"]}},"memberIds":{"description":"Farm members with an app account (coordinator or worker) who may see this item","type":"array","items":{"type":"string"}}},"required":["title"]},"AccesoSecretResponse":{"type":"object","properties":{"secrets":{"type":"array","items":{"$ref":"#/components/schemas/AccesoSecret"}}},"required":["secrets"]},"AccesoPhotoInput":{"type":"object","properties":{"mime":{"type":"string"},"bytes":{"type":"number","description":"Size the browser is about to upload"},"width":{"type":"number"},"height":{"type":"number"}},"required":["mime","bytes"]},"UploadTicketResponse":{"type":"object","properties":{"url":{"type":"string","description":"POST a multipart form here"},"fields":{"type":"object","description":"Form fields to send before the file"},"expiresIn":{"type":"number"}},"required":["url","fields","expiresIn"]},"AccesoPhotoUploadResponse":{"type":"object","properties":{"id":{"type":"string"},"upload":{"$ref":"#/components/schemas/UploadTicketResponse"}},"required":["id","upload"]},"AccesoLinkItem":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"}},"required":["id","title"]},"AccesoLinkResponse":{"type":"object","properties":{"id":{"type":"string"},"items":{"description":"Archived items are left out","type":"array","items":{"$ref":"#/components/schemas/AccesoLinkItem"}},"createdAt":{"type":"string"},"createdBy":{"type":"string"},"expiresAt":{"type":"string"},"uses":{"type":"number","description":"Times the link has been opened"},"lastUsedAt":{"type":"string"},"url":{"type":"string","description":"Only returned when the link is generated"}},"required":["id","items","createdAt","createdBy","uses"]},"AccesoLinkInput":{"type":"object","properties":{"accesoIds":{"description":"Items the link shows","type":"array","items":{"type":"string"}},"expiresInDays":{"type":"number","nullable":true,"enum":[7,30,90],"description":"Days until the link stops working; null or omitted means until revoked"}},"required":["accesoIds"]},"SharedAcceso":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"secrets":{"type":"array","items":{"$ref":"#/components/schemas/AccesoSecret"}},"photos":{"type":"array","items":{"$ref":"#/components/schemas/AccesoPhoto"}}},"required":["id","title","description","secrets","photos"]},"SharedAccesosResponse":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/SharedAcceso"}},"expiresAt":{"type":"string"}},"required":["items"]},"JoinFarmInfo":{"type":"object","properties":{"name":{"type":"string"},"emoji":{"type":"string"},"color":{"type":"string"}},"required":["name"]},"JoinInfoResponse":{"type":"object","properties":{"farm":{"$ref":"#/components/schemas/JoinFarmInfo"},"role":{"type":"string"},"invitedBy":{"type":"string"},"expiresAt":{"type":"string"}},"required":["farm","role","invitedBy"]},"JoinResponse":{"type":"object","properties":{"farmId":{"type":"string"},"farmName":{"type":"string"},"role":{"type":"string"},"alreadyMember":{"type":"boolean","description":"True when the person already belonged to the farm"},"message":{"type":"string"}},"required":["farmId","farmName","role","alreadyMember","message"]},"AttachmentThumbInput":{"type":"object","properties":{"mime":{"type":"string"},"bytes":{"type":"number"}},"required":["mime","bytes"]},"AttachmentInput":{"type":"object","properties":{"kind":{"type":"string","enum":["image","video","audio"]},"mime":{"type":"string"},"bytes":{"type":"number","description":"Size the browser is about to upload"},"width":{"type":"number"},"height":{"type":"number"},"durationSeconds":{"type":"number"},"thumb":{"$ref":"#/components/schemas/AttachmentThumbInput"}},"required":["kind","mime","bytes"]},"AttachmentUploadResponse":{"type":"object","properties":{"id":{"type":"string"},"upload":{"$ref":"#/components/schemas/UploadTicketResponse"},"thumbUpload":{"$ref":"#/components/schemas/UploadTicketResponse"}},"required":["id","upload"]},"OperationsResponse":{"type":"object","properties":{"pendingMail":{"type":"number"},"failedMail":{"type":"number"},"stripeConfigured":{"type":"boolean"},"lastPaymentSync":{"type":"string"},"stripeDashboardUrl":{"type":"string","description":"Stripe Dashboard for the configured mode (test or live)"}},"required":["pendingMail","failedMail","stripeConfigured"]},"PlatformAttachment":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"mime":{"type":"string"},"bytes":{"type":"number"},"createdAt":{"type":"string"},"farmId":{"type":"string"},"farm":{"type":"string"},"entryId":{"type":"string"},"entryKind":{"type":"string"},"entryTitle":{"type":"string"},"uploader":{"type":"string"},"uploaderEmail":{"type":"string"},"url":{"type":"string"},"thumbUrl":{"type":"string"}},"required":["id","kind","mime","bytes","createdAt","farmId","farm","entryId","uploader","url"]},"PlatformStorageFarm":{"type":"object","properties":{"farmId":{"type":"string"},"farm":{"type":"string"},"files":{"type":"number"},"bytes":{"type":"number"}},"required":["farmId","farm","files","bytes"]},"PlatformStorageResponse":{"type":"object","properties":{"provider":{"type":"string","description":"s3, mock or none"},"files":{"type":"number"},"bytes":{"type":"number"},"farms":{"type":"array","items":{"$ref":"#/components/schemas/PlatformStorageFarm"}}},"required":["provider","files","bytes","farms"]},"PlatformCatalogSize":{"type":"object","properties":{"crops":{"type":"number"},"varieties":{"type":"number"},"aliases":{"type":"number"}},"required":["crops","varieties","aliases"]},"PlatformOwnerVarieties":{"type":"object","properties":{"total":{"type":"number"},"linked":{"type":"number","description":"Linked to a catalogue variety"},"cropOnly":{"type":"number","description":"Catalogue crop, variety only the holder names"},"custom":{"type":"number","description":"Not linked to the catalogue"}},"required":["total","linked","cropOnly","custom"]},"PlatformCropVariety":{"type":"object","properties":{"farms":{"type":"number","description":"Farms with a sector of it"},"sectors":{"type":"number"},"hectares":{"type":"number","description":"Sum of the surface written in those sectors"},"ownerVarieties":{"type":"number","description":"Varieties of holders linked to it"},"varietyId":{"type":"string"},"variety":{"type":"string"}},"required":["farms","sectors","hectares","ownerVarieties","varietyId","variety"]},"PlatformCrop":{"type":"object","properties":{"farms":{"type":"number","description":"Farms with a sector of it"},"sectors":{"type":"number"},"hectares":{"type":"number","description":"Sum of the surface written in those sectors"},"ownerVarieties":{"type":"number","description":"Varieties of holders linked to it"},"cropId":{"type":"string"},"crop":{"type":"string"},"varieties":{"type":"array","items":{"$ref":"#/components/schemas/PlatformCropVariety"}}},"required":["farms","sectors","hectares","ownerVarieties","cropId","crop","varieties"]},"PlatformCustomCrop":{"type":"object","properties":{"crop":{"type":"string","description":"Most used spelling"},"owners":{"type":"number","description":"Account holders who wrote it"},"sectors":{"type":"number"}},"required":["crop","owners","sectors"]},"PlatformCustomVariety":{"type":"object","properties":{"crop":{"type":"string"},"variety":{"type":"string"},"owners":{"type":"number"}},"required":["crop","variety","owners"]},"PlatformCropStats":{"type":"object","properties":{"catalog":{"$ref":"#/components/schemas/PlatformCatalogSize"},"farms":{"type":"number","description":"Farms that are not archived"},"sectors":{"type":"number"},"hectares":{"type":"number"},"linkedSectors":{"type":"number","description":"Sectors whose crop is a catalogue crop"},"ownerVarieties":{"$ref":"#/components/schemas/PlatformOwnerVarieties"},"crops":{"type":"array","items":{"$ref":"#/components/schemas/PlatformCrop"}},"customCrops":{"description":"Crop texts outside the catalogue","type":"array","items":{"$ref":"#/components/schemas/PlatformCustomCrop"}},"customVarieties":{"description":"Varieties outside the catalogue","type":"array","items":{"$ref":"#/components/schemas/PlatformCustomVariety"}}},"required":["catalog","farms","sectors","hectares","linkedSectors","ownerVarieties","crops","customCrops","customVarieties"]},"PlatformCropPoint":{"type":"object","properties":{"latitude":{"type":"number","description":"Rounded to `precision` degrees"},"longitude":{"type":"number","description":"Rounded to `precision` degrees"},"cropId":{"type":"string","nullable":true},"crop":{"type":"string","description":"Catalogue crop, «Otro cultivo» or «Sin sectores»"},"sectors":{"type":"number","description":"Sectors at this rounded position with this crop"}},"required":["latitude","longitude","cropId","crop","sectors"]},"PlatformCropMapCount":{"type":"object","properties":{"farms":{"type":"number"},"sectors":{"type":"number"}},"required":["farms","sectors"]},"PlatformCropMap":{"type":"object","properties":{"precision":{"type":"number","description":"Degrees the coordinates are rounded to"},"points":{"type":"array","items":{"$ref":"#/components/schemas/PlatformCropPoint"}},"located":{"$ref":"#/components/schemas/PlatformCropMapCount"},"unlocated":{"description":"Without stored coordinates: counted, never placed","allOf":[{"$ref":"#/components/schemas/PlatformCropMapCount"}]}},"required":["precision","points","located","unlocated"]},"PlatformSignupRow":{"type":"object","properties":{"utmSource":{"type":"string","nullable":true,"description":"`utm_source` del alta"},"utmMedium":{"type":"string","nullable":true,"description":"`utm_medium` del alta"},"utmCampaign":{"type":"string","nullable":true,"description":"`utm_campaign` del alta"},"count":{"type":"number","description":"Cuentas creadas con esta combinación"}},"required":["utmSource","utmMedium","utmCampaign","count"]},"PlatformSignups":{"type":"object","properties":{"total":{"type":"number","description":"Cuentas creadas en el periodo"},"withAttribution":{"type":"number","description":"De ellas, las que llegaron con `utm_source`, `utm_medium` o `utm_campaign`"},"rows":{"description":"Por origen, de más a menos altas, 200 filas como máximo. La fila con los tres valores a null son las altas sin origen.","type":"array","items":{"$ref":"#/components/schemas/PlatformSignupRow"}}},"required":["total","withAttribution","rows"]},"PlatformTargetCatalogSize":{"type":"object","properties":{"targets":{"type":"number"},"aliases":{"type":"number"}},"required":["targets","aliases"]},"PlatformTargetMentions":{"type":"object","properties":{"total":{"type":"number","description":"Weeds, diseases and pests written in treatments"},"linked":{"type":"number","description":"Picked from the catalogue, or a text that names one target"},"custom":{"type":"number","description":"Texts outside the catalogue"}},"required":["total","linked","custom"]},"PlatformTargetFields":{"type":"object","properties":{"weeds":{"type":"number","description":"Times written as a weed"},"diseases":{"type":"number","description":"Times written as a disease"},"pests":{"type":"number","description":"Times written as a pest"}},"required":["weeds","diseases","pests"]},"PlatformTarget":{"type":"object","properties":{"targetId":{"type":"string"},"mapaCode":{"type":"string","description":"`CodigoAgente` of the MAPA register"},"target":{"type":"string","description":"Name as MAPA writes it"},"farms":{"type":"number","description":"Farms with a treatment against it"},"owners":{"type":"number","description":"Account holders of those farms"},"treatments":{"type":"number"},"fields":{"$ref":"#/components/schemas/PlatformTargetFields"}},"required":["targetId","mapaCode","target","farms","owners","treatments","fields"]},"PlatformCustomTarget":{"type":"object","properties":{"text":{"type":"string","description":"Most used spelling"},"owners":{"type":"number","description":"Account holders who wrote it"},"farms":{"type":"number"},"treatments":{"type":"number"},"fields":{"$ref":"#/components/schemas/PlatformTargetFields"}},"required":["text","owners","farms","treatments","fields"]},"PlatformTargetStats":{"type":"object","properties":{"catalog":{"$ref":"#/components/schemas/PlatformTargetCatalogSize"},"farms":{"type":"number","description":"Farms that are not archived"},"treatingFarms":{"type":"number","description":"Farms with a treatment"},"treatments":{"type":"number","description":"Treatments that are not archived"},"mentions":{"$ref":"#/components/schemas/PlatformTargetMentions"},"targets":{"type":"array","items":{"$ref":"#/components/schemas/PlatformTarget"}},"customTargets":{"description":"Top texts outside the catalogue","type":"array","items":{"$ref":"#/components/schemas/PlatformCustomTarget"}}},"required":["catalog","farms","treatingFarms","treatments","mentions","targets","customTargets"]},"PlatformTargetPoint":{"type":"object","properties":{"latitude":{"type":"number","description":"Rounded to `precision` degrees"},"longitude":{"type":"number","description":"Rounded to `precision` degrees"},"targetId":{"type":"string","nullable":true},"target":{"type":"string","description":"Catalogue target, or «Otro agente» for any other text"},"treatments":{"type":"number","description":"Treatments at this rounded position against this target"}},"required":["latitude","longitude","targetId","target","treatments"]},"PlatformTargetMapCount":{"type":"object","properties":{"farms":{"type":"number"},"treatments":{"type":"number"}},"required":["farms","treatments"]},"PlatformTargetMap":{"type":"object","properties":{"precision":{"type":"number","description":"Degrees the coordinates are rounded to"},"points":{"type":"array","items":{"$ref":"#/components/schemas/PlatformTargetPoint"}},"located":{"$ref":"#/components/schemas/PlatformTargetMapCount"},"unlocated":{"description":"Without stored coordinates: counted, never placed","allOf":[{"$ref":"#/components/schemas/PlatformTargetMapCount"}]}},"required":["precision","points","located","unlocated"]},"PlatformFarm":{"type":"object","properties":{"trialEndsAt":{"type":"string"},"billingInterval":{"type":"string","nullable":true},"billingAmountCents":{"type":"number","nullable":true},"billingCurrency":{"type":"string","nullable":true},"billingSyncedAt":{"type":"string","nullable":true},"cancelAtPeriodEnd":{"type":"boolean"},"stripeCustomerId":{"type":"string","nullable":true},"complimentary":{"type":"boolean"},"ownerFreeFarms":{"type":"boolean"},"id":{"type":"string"},"name":{"type":"string"},"owner":{"type":"string"},"email":{"type":"string"},"status":{"type":"string"},"paidUntil":{"type":"string"},"members":{"type":"number"}},"required":["trialEndsAt","cancelAtPeriodEnd","complimentary","ownerFreeFarms","id","name","owner","email","status","members"]}}}}