openapi: 3.1.0 info: title: Agriculture Masterdata Sync API version: 0.1.0-alpha1 description: > HTTP surface for the Agriculture Masterdata Sync protocol (AgmaSync). It lets a connected application send, archive, request, and read the master-data entities (parties, farms, fields, field boundaries) that agrirouter synchronizes across an n:m network of systems, and configure per-entity opt-in for an endpoint. Each entity type has its own set of paths and its own concrete schema; there is no generic entity resource. The union type `Entity` survives only where a single channel genuinely carries all types — the event stream. agrirouter holds the Single Source of Truth (SSOT): the canonical copy of every entity plus a mapping to each application's own identifier. A write answers with the resulting canonical object, and that response is a delivery rather than an acknowledgement: it is the only place the writing endpoint sees the revision it just produced, since agrirouter does not echo a change back to its source. Clients MUST apply it as they apply an event from the stream, and MUST NOT apply any object whose `revision` is lower than the one they already hold. See "Applying what agrirouter returns" in specification.md. Attributes whose value set is expected to grow follow the Zalando RESTful API Guidelines convention for open-ended value lists (https://opensource.zalando.com/restful-api-guidelines/#112): instead of a closed `enum`, the currently known values are given as `examples` and the description carries the `[Extensible enum]` prefix. Values may be added to such an attribute without breaking deployed clients, so clients MUST accept unknown values, relay them unchanged, and fall back to their unknown-value handling. `enum` is reserved for sets this API fully controls and considers complete. See "Extensible enumerations" in specification.md. contact: name: DKE-Data Masterdata Sync Working Group security: - bearerAuth: [] tags: - name: Parties description: Sending, archiving, requesting, and reading parties. - name: Farms description: Sending, archiving, requesting, and reading farms. - name: Fields description: Sending, archiving, requesting, and reading fields. - name: FieldBoundaries description: Sending, archiving, requesting, and reading field boundaries. - name: Configuration description: Per-endpoint, per-entity opt-in for master-data exchange. - name: InitialLoad description: Per-endpoint initial-load state machine. - name: Events description: Receiving master-data changes as Server-Sent Events. paths: # ------------------------------------------------------------------- parties /masterdata/parties/{local_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' put: tags: [Parties] summary: Send (create or update) a party description: > Submits a party from the calling endpoint. If the (endpoint, local_id) pair is already mapped to a canonical object, that object is updated; otherwise a new canonical object is created in the endpoint's tenant and an `agrirouter_id` is assigned. The mapping is keyed by the external ID of the endpoint named in `x-agrirouter-endpoint-id`: a `local_id` names a record only in that endpoint's namespace, and the same string sent by a sibling endpoint of the same application is a different record. An update carries the revision it was edited from in `x-agrirouter-base-revision`; agrirouter rejects an update from a stale base with `412`, and an update without a base with `428`. No-op updates (leaving the current canonical revision as it is) do not create a new revision and are not forwarded. `content` is applied as a JSON Merge Patch (RFC 7396): an attribute with a value replaces the current one, `null` removes it, and an attribute left out is unchanged. Nested objects merge the same way; arrays and references are replaced whole. Required attributes are required on every write and are never `null`. The response is always the whole resulting object. `archived` is required. On a create it sets the initial state: `true` creates the object archived in one write, which is how a record held as archived is sent. On an update it must equal the object's current state, or the write is rejected with `409` and `current_archived`: a write never changes the state, which only archiving and unarchiving do. A missing `archived` is a `400`. Edits to an archived object are accepted and keep it archived. `_agmasync_details` carries its `partyTypeCode` on every write that includes it. It merges like any nested object while that `partyTypeCode` is unchanged; a write that changes it replaces `_agmasync_details` whole, so no attribute of the other party type survives. An application that does not record whether a party is a person or an organization leaves `_agmasync_details` out, which keeps what another application stated. operationId: putParty requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/Party' responses: '200': description: Party accepted; the resulting canonical object is returned. content: application/json: schema: $ref: '#/components/schemas/Party' '201': description: A new canonical object was created. content: application/json: schema: $ref: '#/components/schemas/Party' '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/PutConflict' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/parties/{local_id}/id-mapping/{agrirouter_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/IdMappingAgrirouterId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' put: tags: [Parties] summary: Bind a local identifier to an existing party description: > Declares that the canonical party in the path is the one this endpoint knows as `local_id` — used when the endpoint recognises a delivered object as one it already holds. Binding is not a data write: it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. Afterwards the ordinary PUT under that `local_id` resolves to this object and updates it. An endpoint MUST bind before sending an object it received: an unbound send does not resolve and creates a duplicate. Within its own endpoint a local identifier denotes exactly one canonical object, so this is a singleton: binding a second one is the `409`. The request has no body, both ends of the mapping being in the path, and is idempotent. operationId: bindPartyMapping responses: '204': description: The mapping is recorded. '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/parties/id-mapping-corrections: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [Parties] summary: Correct this endpoint's bindings of parties description: > Replaces bindings the endpoint's user found wrong. Each listed `local_id` ends mapped to the given party, or to none where `agrirouter_id` is `null`. Uniqueness is checked on the result, so a swap is one call, applied whole or not at all. A party bound to a `local_id` the request does not list is not taken from it: that is the `409`. Like binding it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. It corrects identity, not content: revisions written through the wrong binding stand. It is not a declaration that the endpoint deleted or discarded a record — for a deletion, use the archiving operation. operationId: correctPartyMappings requestBody: $ref: '#/components/requestBodies/IdMappingCorrection' responses: '204': description: The listed mappings are as requested. Repeating the request changes nothing. '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/parties/{local_id}/archiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [Parties] summary: Archive a party description: > Signals that the party was archived, deleted or similar in the source system. The canonical object is marked archived but retained. The operation is idempotent: archiving an already-archived entity succeeds without creating a new revision or notification. The first archiving is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is already archived the header is ignored. operationId: archiveParty responses: '200': description: Party is archived (either newly archived or already archived). content: application/json: schema: $ref: '#/components/schemas/Party' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/parties/{local_id}/unarchiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [Parties] summary: Unarchive a party description: > Signals that the party is no longer archived in the source system. The canonical object is no longer marked archived; its content is unchanged. A new party never needs this: the write that creates it sets its state. The operation is idempotent: unarchiving a party that is not archived succeeds without creating a new revision or notification. The first unarchiving of an archived object is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is not archived the header is ignored. operationId: unarchiveParty responses: '200': description: Party is not archived (either newly unarchived or already not archived). content: application/json: schema: $ref: '#/components/schemas/Party' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/parties/requests: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [Parties] summary: Request a party (lazy loading) description: > Refetches a party the caller is entitled to but does not currently hold — an object lost locally, or one referenced by an object that arrived on the live stream before the initial-load stream delivered its target. Opt-in remains the only filter on delivery, so a request never returns anything the stream would not also deliver. The object arrives asynchronously as a master-data change event (see `/masterdata/events`). It is delivered even when the requesting endpoint was the object's last writer: origin suppression does not apply to a requested object, since refetching something it wrote itself is exactly what an endpoint that lost the object needs. The frame is addressed to the requesting endpoint and carries that endpoint's own identifiers. operationId: requestParty requestBody: $ref: '#/components/requestBodies/EntityRequest' responses: '202': $ref: '#/components/responses/RequestAccepted' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # --------------------------------------------------------------------- farms /masterdata/farms/{local_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' put: tags: [Farms] summary: Send (create or update) a farm description: > Submits a farm from the calling endpoint. If the (endpoint, local_id) pair is already mapped to a canonical object, that object is updated; otherwise a new canonical object is created in the endpoint's tenant and an `agrirouter_id` is assigned. The mapping is keyed by the external ID of the endpoint named in `x-agrirouter-endpoint-id`: a `local_id` names a record only in that endpoint's namespace, and the same string sent by a sibling endpoint of the same application is a different record. An update carries the revision it was edited from in `x-agrirouter-base-revision`; agrirouter rejects an update from a stale base with `412`, and an update without a base with `428`. No-op updates (leaving the current canonical revision as it is) do not create a new revision and are not forwarded. `content` is applied as a JSON Merge Patch (RFC 7396): an attribute with a value replaces the current one, `null` removes it, and an attribute left out is unchanged. Nested objects merge the same way; arrays and references are replaced whole. Required attributes are required on every write and are never `null`. The response is always the whole resulting object. `archived` is required. On a create it sets the initial state: `true` creates the object archived in one write, which is how a record held as archived is sent. On an update it must equal the object's current state, or the write is rejected with `409` and `current_archived`: a write never changes the state, which only archiving and unarchiving do. A missing `archived` is a `400`. Edits to an archived object are accepted and keep it archived. operationId: putFarm requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/Farm' responses: '200': description: Farm accepted; the resulting canonical object is returned. content: application/json: schema: $ref: '#/components/schemas/Farm' '201': description: A new canonical object was created. content: application/json: schema: $ref: '#/components/schemas/Farm' '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/PutConflict' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/farms/{local_id}/id-mapping/{agrirouter_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/IdMappingAgrirouterId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' put: tags: [Farms] summary: Bind a local identifier to an existing farm description: > Declares that the canonical farm in the path is the one this endpoint knows as `local_id` — used when the endpoint recognises a delivered object as one it already holds. Binding is not a data write: it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. Afterwards the ordinary PUT under that `local_id` resolves to this object and updates it. An endpoint MUST bind before sending an object it received: an unbound send does not resolve and creates a duplicate. Within its own endpoint a local identifier denotes exactly one canonical object, so this is a singleton: binding a second one is the `409`. The request has no body, both ends of the mapping being in the path, and is idempotent. operationId: bindFarmMapping responses: '204': description: The mapping is recorded. '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/farms/id-mapping-corrections: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [Farms] summary: Correct this endpoint's bindings of farms description: > Replaces bindings the endpoint's user found wrong. Each listed `local_id` ends mapped to the given farm, or to none where `agrirouter_id` is `null`. Uniqueness is checked on the result, so a swap is one call, applied whole or not at all. A farm bound to a `local_id` the request does not list is not taken from it: that is the `409`. Like binding it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. It corrects identity, not content: revisions written through the wrong binding stand. It is not a declaration that the endpoint deleted or discarded a record — for a deletion, use the archiving operation. operationId: correctFarmMappings requestBody: $ref: '#/components/requestBodies/IdMappingCorrection' responses: '204': description: The listed mappings are as requested. Repeating the request changes nothing. '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/farms/{local_id}/archiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [Farms] summary: Archive a farm description: > Signals that the farm was archived, deleted or similar in the source system. The canonical object is marked archived but retained. The operation is idempotent: archiving an already-archived entity succeeds without creating a new revision or notification. The first archiving is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is already archived the header is ignored. operationId: archiveFarm responses: '200': description: Farm is archived (either newly archived or already archived). content: application/json: schema: $ref: '#/components/schemas/Farm' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/farms/{local_id}/unarchiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [Farms] summary: Unarchive a farm description: > Signals that the farm is no longer archived in the source system. The canonical object is no longer marked archived; its content is unchanged. A new farm never needs this: the write that creates it sets its state. The operation is idempotent: unarchiving a farm that is not archived succeeds without creating a new revision or notification. The first unarchiving of an archived object is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is not archived the header is ignored. operationId: unarchiveFarm responses: '200': description: Farm is not archived (either newly unarchived or already not archived). content: application/json: schema: $ref: '#/components/schemas/Farm' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/farms/requests: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [Farms] summary: Request a farm (lazy loading) description: > Refetches a farm the caller is entitled to but does not currently hold — an object lost locally, or one referenced by an object that arrived on the live stream before the initial-load stream delivered its target. Opt-in remains the only filter on delivery, so a request never returns anything the stream would not also deliver. The object arrives asynchronously as a master-data change event (see `/masterdata/events`). It is delivered even when the requesting endpoint was the object's last writer: origin suppression does not apply to a requested object, since refetching something it wrote itself is exactly what an endpoint that lost the object needs. The frame is addressed to the requesting endpoint and carries that endpoint's own identifiers. operationId: requestFarm requestBody: $ref: '#/components/requestBodies/EntityRequest' responses: '202': $ref: '#/components/responses/RequestAccepted' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # -------------------------------------------------------------------- fields /masterdata/fields/{local_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' put: tags: [Fields] summary: Send (create or update) a field description: > Submits a field from the calling endpoint. If the (endpoint, local_id) pair is already mapped to a canonical object, that object is updated; otherwise a new canonical object is created in the endpoint's tenant and an `agrirouter_id` is assigned. The mapping is keyed by the external ID of the endpoint named in `x-agrirouter-endpoint-id`: a `local_id` names a record only in that endpoint's namespace, and the same string sent by a sibling endpoint of the same application is a different record. An update carries the revision it was edited from in `x-agrirouter-base-revision`; agrirouter rejects an update from a stale base with `412`, and an update without a base with `428`. No-op updates (leaving the current canonical revision as it is) do not create a new revision and are not forwarded. `content` is applied as a JSON Merge Patch (RFC 7396): an attribute with a value replaces the current one, `null` removes it, and an attribute left out is unchanged. Nested objects merge the same way; arrays and references are replaced whole. Required attributes are required on every write and are never `null`. The response is always the whole resulting object. `archived` is required. On a create it sets the initial state: `true` creates the object archived in one write, which is how a record held as archived is sent. On an update it must equal the object's current state, or the write is rejected with `409` and `current_archived`: a write never changes the state, which only archiving and unarchiving do. A missing `archived` is a `400`. Edits to an archived object are accepted and keep it archived. operationId: putField requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/Field' responses: '200': description: Field accepted; the resulting canonical object is returned. content: application/json: schema: $ref: '#/components/schemas/Field' '201': description: A new canonical object was created. content: application/json: schema: $ref: '#/components/schemas/Field' '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/PutConflict' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/fields/{local_id}/id-mapping/{agrirouter_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/IdMappingAgrirouterId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' put: tags: [Fields] summary: Bind a local identifier to an existing field description: > Declares that the canonical field in the path is the one this endpoint knows as `local_id` — used when the endpoint recognises a delivered object as one it already holds. Binding is not a data write: it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. Afterwards the ordinary PUT under that `local_id` resolves to this object and updates it. An endpoint MUST bind before sending an object it received: an unbound send does not resolve and creates a duplicate. Within its own endpoint a local identifier denotes exactly one canonical object, so this is a singleton: binding a second one is the `409`. The request has no body, both ends of the mapping being in the path, and is idempotent. operationId: bindFieldMapping responses: '204': description: The mapping is recorded. '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/fields/id-mapping-corrections: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [Fields] summary: Correct this endpoint's bindings of fields description: > Replaces bindings the endpoint's user found wrong. Each listed `local_id` ends mapped to the given field, or to none where `agrirouter_id` is `null`. Uniqueness is checked on the result, so a swap is one call, applied whole or not at all. A field bound to a `local_id` the request does not list is not taken from it: that is the `409`. Like binding it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. It corrects identity, not content: revisions written through the wrong binding stand. It is not a declaration that the endpoint deleted or discarded a record — for a deletion, use the archiving operation. operationId: correctFieldMappings requestBody: $ref: '#/components/requestBodies/IdMappingCorrection' responses: '204': description: The listed mappings are as requested. Repeating the request changes nothing. '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/fields/{local_id}/archiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [Fields] summary: Archive a field description: > Signals that the field was archived, deleted or similar in the source system. The canonical object is marked archived but retained. The operation is idempotent: archiving an already-archived entity succeeds without creating a new revision or notification. The first archiving is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is already archived the header is ignored. operationId: archiveField responses: '200': description: Field is archived (either newly archived or already archived). content: application/json: schema: $ref: '#/components/schemas/Field' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/fields/{local_id}/unarchiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [Fields] summary: Unarchive a field description: > Signals that the field is no longer archived in the source system. The canonical object is no longer marked archived; its content is unchanged. A new field never needs this: the write that creates it sets its state. The operation is idempotent: unarchiving a field that is not archived succeeds without creating a new revision or notification. The first unarchiving of an archived object is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is not archived the header is ignored. operationId: unarchiveField responses: '200': description: Field is not archived (either newly unarchived or already not archived). content: application/json: schema: $ref: '#/components/schemas/Field' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/fields/requests: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [Fields] summary: Request a field (lazy loading) description: > Refetches a field the caller is entitled to but does not currently hold — an object lost locally, or one referenced by an object that arrived on the live stream before the initial-load stream delivered its target. Opt-in remains the only filter on delivery, so a request never returns anything the stream would not also deliver. The object arrives asynchronously as a master-data change event (see `/masterdata/events`). It is delivered even when the requesting endpoint was the object's last writer: origin suppression does not apply to a requested object, since refetching something it wrote itself is exactly what an endpoint that lost the object needs. The frame is addressed to the requesting endpoint and carries that endpoint's own identifiers. operationId: requestField requestBody: $ref: '#/components/requestBodies/EntityRequest' responses: '202': $ref: '#/components/responses/RequestAccepted' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # ---------------------------------------------------------- field-boundaries /masterdata/field-boundaries/{local_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' put: tags: [FieldBoundaries] summary: Send (create or update) a field boundary description: > Submits a field boundary from the calling endpoint. If the (endpoint, local_id) pair is already mapped to a canonical object, that object is updated; otherwise a new canonical object is created in the endpoint's tenant and an `agrirouter_id` is assigned. The mapping is keyed by the external ID of the endpoint named in `x-agrirouter-endpoint-id`: a `local_id` names a record only in that endpoint's namespace, and the same string sent by a sibling endpoint of the same application is a different record. An update carries the revision it was edited from in `x-agrirouter-base-revision`; agrirouter rejects an update from a stale base with `412`, and an update without a base with `428`. No-op updates (leaving the current canonical revision as it is) do not create a new revision and are not forwarded. `content` is applied as a JSON Merge Patch (RFC 7396): an attribute with a value replaces the current one, `null` removes it, and an attribute left out is unchanged. Nested objects merge the same way; arrays and references are replaced whole. A write whose `boundary.geometry` differs from the current geometry replaces `boundary` whole: what the write leaves out of it, such as the creation method, the GNSS fields and `gNSSDataQualityMetrics`, is removed, because it described the previous geometry. Required attributes are required on every write and are never `null`. The response is always the whole resulting object. `archived` is required. On a create it sets the initial state: `true` creates the object archived in one write, which is how a record held as archived is sent. On an update it must equal the object's current state, or the write is rejected with `409` and `current_archived`: a write never changes the state, which only archiving and unarchiving do. A missing `archived` is a `400`. Edits to an archived object are accepted and keep it archived. operationId: putFieldBoundary requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/FieldBoundary' responses: '200': description: Field boundary accepted; the resulting canonical object is returned. content: application/json: schema: $ref: '#/components/schemas/FieldBoundary' '201': description: A new canonical object was created. content: application/json: schema: $ref: '#/components/schemas/FieldBoundary' '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/PutConflict' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/field-boundaries/{local_id}/id-mapping/{agrirouter_id}: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/IdMappingAgrirouterId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' put: tags: [FieldBoundaries] summary: Bind a local identifier to an existing field boundary description: > Declares that the canonical field boundary in the path is the one this endpoint knows as `local_id` — used when the endpoint recognises a delivered object as one it already holds. Binding is not a data write: it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. Afterwards the ordinary PUT under that `local_id` resolves to this object and updates it. An endpoint MUST bind before sending an object it received: an unbound send does not resolve and creates a duplicate. Within its own endpoint a local identifier denotes exactly one canonical object, so this is a singleton: binding a second one is the `409`. The request has no body, both ends of the mapping being in the path, and is idempotent. operationId: bindFieldBoundaryMapping responses: '204': description: The mapping is recorded. '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/field-boundaries/id-mapping-corrections: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [FieldBoundaries] summary: Correct this endpoint's bindings of field boundaries description: > Replaces bindings the endpoint's user found wrong. Each listed `local_id` ends mapped to the given field boundary, or to none where `agrirouter_id` is `null`. Uniqueness is checked on the result, so a swap is one call, applied whole or not at all. A field boundary bound to a `local_id` the request does not list is not taken from it: that is the `409`. Like binding it creates no revision, does not change `source_endpoint_id`, and is delivered to nobody. It corrects identity, not content: revisions written through the wrong binding stand. It is not a declaration that the endpoint deleted or discarded a record — for a deletion, use the archiving operation. operationId: correctFieldBoundaryMappings requestBody: $ref: '#/components/requestBodies/IdMappingCorrection' responses: '204': description: The listed mappings are as requested. Repeating the request changes nothing. '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/MappingConflict' /masterdata/field-boundaries/{local_id}/archiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [FieldBoundaries] summary: Archive a field boundary description: > Signals that the field boundary was archived, deleted or similar in the source system. The canonical object is marked archived but retained. The operation is idempotent: archiving an already-archived entity succeeds without creating a new revision or notification. The first archiving is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is already archived the header is ignored. operationId: archiveFieldBoundary responses: '200': description: Field boundary is archived (either newly archived or already archived). content: application/json: schema: $ref: '#/components/schemas/FieldBoundary' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/field-boundaries/{local_id}/unarchiving: parameters: - $ref: '#/components/parameters/LocalId' - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/BaseRevision' post: tags: [FieldBoundaries] summary: Unarchive a field boundary description: > Signals that the field boundary is no longer archived in the source system. The canonical object is no longer marked archived; its content is unchanged. A new field boundary never needs this: the write that creates it sets its state. The operation is idempotent: unarchiving a field boundary that is not archived succeeds without creating a new revision or notification. The first unarchiving of an archived object is a write like any other and carries the revision it was made from in `x-agrirouter-base-revision`; a concurrent edit to the object is a conflict, and only one of the two succeeds. On an object that is not archived the header is ignored. operationId: unarchiveFieldBoundary responses: '200': description: Field boundary is not archived (either newly unarchived or already not archived). content: application/json: schema: $ref: '#/components/schemas/FieldBoundary' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '412': $ref: '#/components/responses/RevisionConflict' '428': $ref: '#/components/responses/BaseRevisionRequired' /masterdata/field-boundaries/requests: parameters: - $ref: '#/components/parameters/AgrirouterEndpointId' - $ref: '#/components/parameters/AgrirouterTenantId' post: tags: [FieldBoundaries] summary: Request a field boundary (lazy loading) description: > Refetches a field boundary the caller is entitled to but does not currently hold — an object lost locally, or one referenced by an object that arrived on the live stream before the initial-load stream delivered its target. Opt-in remains the only filter on delivery, so a request never returns anything the stream would not also deliver. The object arrives asynchronously as a master-data change event (see `/masterdata/events`). It is delivered even when the requesting endpoint was the object's last writer: origin suppression does not apply to a requested object, since refetching something it wrote itself is exactly what an endpoint that lost the object needs. The frame is addressed to the requesting endpoint and carries that endpoint's own identifiers. operationId: requestFieldBoundary requestBody: $ref: '#/components/requestBodies/EntityRequest' responses: '202': $ref: '#/components/responses/RequestAccepted' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' # ------------------------------------------------------------------- events /masterdata/events: get: tags: [Events] summary: Receive master-data changes (Server-Sent Events) description: > A persistent SSE stream of master-data changes for the calling application, carrying every tenant it is routed to and every entity type it is opted into. agrirouter never echoes a change back to the endpoint it originated from; a change made by one endpoint is still delivered to the application's other endpoints. Each event's `data` is an `Entity` — a `Party`, `Farm`, `Field`, or `FieldBoundary` discriminated by its `type` property. A frame is addressed to one endpoint, named in `recipient_endpoint_id`, and carries that endpoint's own identifier in `content.id.referenceId` when agrirouter holds one, and no `referenceId` at all when it does not. The mapping is scoped to the endpoint, so an object entitled to two of the application's endpoints arrives twice, rendered for each. This stream carries steady-state synchronization only. Initial load is delivered separately, per endpoint, by `/endpoints/{external_id}/masterdata-initial-load/events`; the two are independent and are not deduplicated against each other, so an object may arrive on both while an endpoint is loading. An application reconnecting after an absence is served catch-up before live changes: everything it is entitled to that changed since its position, ordered so that a referenced object precedes the objects that reference it, ending with a `CAUGHT_UP` event. That is the only property of the order an application may rely on. The order itself is agrirouter's and may change in a later version of this API, so an application MUST NOT depend on the position of one entity type relative to another, or read the completeness of an entity type out of it. `Last-Event-ID` is the only position the application keeps, and positions do not expire. The stream also carries `ROUTE_CHANGED`, which states which entity types the user has selected for one of the application's endpoints. It is issued every time that selection changes — the endpoint routed to master-data, a type selected, a type deselected, the last one deselected. It also carries `RESET_MASTERDATA_SYNC` when the user has wiped a tenant's master data: every canonical object, identifier mapping, masterdata route and initial-load state of the tenant is gone, and the application MUST discard its bindings there, and every correspondence table it retained for a removed endpoint there. It reaches every application that has had an endpoint in the tenant take part at some point, whether or not that endpoint still exists, so it may concern a tenant the application is no longer routed to or has no endpoint left in. It precedes any later event of that tenant, catch-up included. The application MUST durably store a position at or past it before taking part in that tenant's initial load again. operationId: streamMasterdataEvents parameters: - $ref: '#/components/parameters/LastEventId' responses: '200': description: An event stream. content: text/event-stream: schema: description: > SSE stream as defined in https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events SSE event would carry three parts: "id:", "event:" and "data:". The `data:` is a payload of each SSE frame. Frames carry an `event:` of `MASTERDATA_CHANGED`, `CAUGHT_UP`, `ROUTE_CHANGED` or `RESET_MASTERDATA_SYNC`. `MASTERDATA_CHANGED` carries an `Entity`: the canonical state of the object at that revision, archived or not as its `archived` says, which is the only signal of its lifecycle state. `CAUGHT_UP` has no data, and `ROUTE_CHANGED` and `RESET_MASTERDATA_SYNC` carry an event payload. Every frame also carries an `id:`, which is the delivery position as of that frame — what the application persists once it has durably applied the frame, and returns as `Last-Event-ID` on reconnect. `id` may repeat across some events and application should not expect it would always advance or attempt to parse, compare, or construct it in any way: `id` must be treated as an opaque string whose structure may change. Whatever `id` a frame carries is safe to resume from once that frame and every frame before it have been applied. oneOf: - $ref: '#/components/schemas/Entity' - $ref: '#/components/schemas/RouteChangedEventData' - $ref: '#/components/schemas/MasterdataResetEventData' # ------------------------------------------------------------ configuration /endpoints/{external_id}: put: tags: [Configuration] operationId: putEndpoint summary: Create or update endpoint description: > This resource can be used to create new endpoint or reconfigure existing one. Masterdata: Declare what masterdata entity types the endpoint can exchange. Masterdata routes must be separately created by a user, selecting a subset of these entity types. There is no default routing for masterdata. The configuration MUST be dependency-closed: enabling field boundaries requires the fields they reference to be enabled as well, and enabling parties and fields requires farms, the only link between them. A configuration that is not dependency-closed is rejected with `400` naming the missing entity type. Any other combination of entity types is valid, for example farms and fields without parties, or fields alone. security: - agrirouterOauthQA: ["endpoints:manage"] - agrirouterOauthPROD: ["endpoints:manage"] parameters: - $ref: "#/components/parameters/AgrirouterTenantId" - $ref: "#/components/parameters/external_id" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PutEndpointRequest" responses: '200': description: Endpoint was successfully updated content: application/json: schema: $ref: "#/components/schemas/Endpoint" '201': description: Endpoint was successfully created content: application/json: schema: $ref: "#/components/schemas/Endpoint" '400': description: Request is invalid content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" '401': description: Authentication failed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" '403': description: Authorization failed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" '413': description: Content too large content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" '502': description: Bad Gateway, upstream service has returned an error '503': description: Service Unavailable at the moment '504': description: Gateway Timeout, request took too long to process '500': description: Server Side Error # ----------------------------------------------------------------- initial load /endpoints/{external_id}/masterdata-initial-load/events: parameters: - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/external_id' get: tags: [InitialLoad] summary: Receive the endpoint's canonical set (Server-Sent Events) description: > Delivers the canonical set this endpoint is owed: every object of every entity type it is opted into that it is entitled to, while the endpoint is in `LOADING_FROM_AGRIROUTER`. One stream per endpoint, matching the granularity of the initial-load state and the shape of its status resource. The set is complete: objects that are archived are part of it and arrive with `archived: true`, and so are objects whose current revision the requesting application itself last wrote — origin suppression does not apply here, since withholding them would have a returning endpoint push them back as new and duplicate them. A delivered object carries this endpoint's own identifier in `content.id.referenceId` where agrirouter holds one, and names the endpoint in `recipient_endpoint_id`. agrirouter moves the endpoint to `RECONCILING` once it has sent the whole set and closes the HTTP response after it, in that order: the state is what tells an orderly finish from a dropped connection, so closing first would leave a window in which an endpoint reads `LOADING_FROM_AGRIROUTER` for a set that did arrive and takes the whole set again for nothing. The set is fixed when the load starts: an entity type opted in while the set is streaming restarts the load, so the endpoint re-enters `LOADING_FROM_AGRIROUTER` and the set is sent again including the new type. Order is agrirouter's, not the endpoint's. The set is delivered so that a referenced object precedes the objects that reference it, as catch-up on `/masterdata/events` is, and opt-in is dependency-closed, so the target of every reference is in the set and an endpoint can apply each object as it arrives. That is the only property of the order an endpoint may rely on: the order itself may change in a later version of this API, so an endpoint MUST NOT depend on the position of one entity type relative to another, or read the completeness of an entity type out of it. An object referenced from the live stream that this stream has not delivered yet is requested (`POST /masterdata//requests`). The stream carries **no delivery position**: it delivers a set rather than a sequence of changes, so it takes no `Last-Event-ID`, its frames carry no `id:`, and a connection that drops before the set is complete is recovered by requesting it again from the beginning. An endpoint MUST NOT treat the response ending as proof that the set arrived — a dropped connection ends it the same way. Whether the set was sent is recorded in the endpoint's state on the Initial Load resource, which agrirouter advances only after sending everything, and before closing this response. That read is therefore conclusive as soon as the response ends: an endpoint that finds `LOADING_FROM_AGRIROUTER` there has been cut short and reconnects at once, without waiting before the read or polling for a state change. This stream is independent of the application's steady-state stream `/masterdata/events`, which keeps running throughout and is not deduplicated against this one. operationId: streamInitialLoadEvents responses: '200': description: > The canonical set, as an event stream. The response closing is what marks the set complete. content: text/event-stream: schema: description: > SSE stream as defined in https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events SSE event would carry three parts: "id:", "event:" and "data:". Every frame carries an `event:` of `MASTERDATA_CHANGED` and an `Entity` type in the `data:` payload. $ref: '#/components/schemas/Entity' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' /endpoints/{external_id}/masterdata-initial-load/status: parameters: - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/external_id' get: tags: [InitialLoad] summary: Get the endpoint's initial load status description: > Returns the endpoint's initial load state. There is one state per endpoint, covering every entity type it is opted into; an endpoint opted into no entity type has no initial-load state and is `404`. The state machine is: `LOADING_FROM_AGRIROUTER` → `RECONCILING` → `LOADING_TO_AGRIROUTER` → `COMPLETED`. Entering `LOADING_FROM_AGRIROUTER` is agrirouter's alone and follows from the user's opt-in and from nothing else: the user selecting the endpoint's first entity type, when giving it a masterdata route, starts it there, and selecting a further entity type returns it there. An application cannot enter it, from any state including from itself, and there is no operation for asking that the set be sent again. agrirouter itself advances it to `RECONCILING` once the whole canonical set has been sent; the endpoint drives the remaining two transitions by sending a PUT request to this resource. Initial load is one state and one stream per endpoint, not per entity type, which is why selecting a further type restarts it from whatever state the endpoint is in: the set is fixed when a load starts, and agrirouter cannot enumerate what the endpoint missed while the type was not selected, so the whole set — every selected type — is sent again. Deselecting a type stops its delivery and leaves this state as it is; deselecting the last one discards it, and the endpoint is then `404`. Neither the canonical objects nor the endpoint's identifier mapping are discarded by a deselection, so a repeat load arrives matched, and `previous_load_completed_at` below marks it as a repeat. operationId: getInitialLoadStatus responses: '200': description: The endpoint's initial load status. content: application/json: schema: $ref: '#/components/schemas/InitialLoadStatus' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' put: tags: [InitialLoad] summary: Set the endpoint's initial load state description: > Sets the endpoint's initial-load `state`. The states advance in order and agrirouter rejects any other transition with `409`. The two transitions available here are the endpoint's own: the confirmation and the completion. Set `LOADING_TO_AGRIROUTER` to confirm the endpoint has *reconciled* the canonical set, not merely received it. Receipt is already recorded: agrirouter moved the endpoint to `RECONCILING` when it finished sending, so this operation asserts only that the conflicts reconciling surfaced have been resolved in the endpoint's own software. That is human-paced and unbounded, so an endpoint may sit in `RECONCILING` for a long time without anything being wrong. Carry the bindings reconciliation produced in `id_mappings`, so the objects the endpoint matched resolve to the canonical objects they were matched to. From that point the endpoint sends the objects it knows about via the ordinary PUT operations. Set `COMPLETED` once the endpoint has sent everything, after which steady-state (day-2) synchronization applies. Setting `LOADING_TO_AGRIROUTER` while the endpoint is still `LOADING_FROM_AGRIROUTER` is rejected with `409`: the endpoint cannot have reconciled a set it has not finished receiving. An endpoint enters `LOADING_FROM_AGRIROUTER` when it is opted in, when an entity type is added, or when a user asks agrirouter to load it again, and leaves it when agrirouter has sent the set — none of which happens through this operation. Setting `LOADING_FROM_AGRIROUTER` is a `409` from every state, including from itself. Repeating an endpoint-driven transition is not a conflict. Setting the state the endpoint is already in returns `200` with the current status; if the request carries `id_mappings`, each pair is applied again — binding is idempotent per pair — and `rejected_id_mappings` is recomputed against the mapping as it now stands. That is how an endpoint recovers from a lost response: it cannot read its mapping back, so repeating the confirmation is its only way to learn which bindings were recorded. Only out-of-order transitions are `409`. operationId: setInitialLoadState requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/InitialLoadStateUpdate' responses: '200': description: Updated initial load status for this endpoint. content: application/json: schema: $ref: '#/components/schemas/InitialLoadStatus' '400': $ref: '#/components/responses/ValidationError' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/InitialLoadConflict' /endpoints/{external_id}/masterdata-initial-load/user-attention: parameters: - $ref: '#/components/parameters/AgrirouterTenantId' - $ref: '#/components/parameters/external_id' put: tags: [InitialLoad] summary: Report that the endpoint's initial load is waiting on a user description: > Raises `awaiting_user` on the endpoint's initial-load status, so that agrirouter shows "waiting for you in " — linking to the master-data resolution URI supplied for this endpoint — in place of its own "this application is working through your data". It is a resource of its own because reporting a user is not a transition. Conflicts surface object by object, so an endpoint has to be able to say this from any state before `COMPLETED`, including while the canonical set is still arriving; naming a state in order to say it would mean naming one the endpoint does not own and cannot set. This names none, so it never races the transitions agrirouter drives and is never out of order. It carries no body and raises the flag; there is nothing to lower it with, because lowering it is not the endpoint's to do. agrirouter clears it on the two endpoint-driven transitions — advancing to `LOADING_TO_AGRIROUTER` or to `COMPLETED` — and the step to `RECONCILING` does not, that being agrirouter reporting it has finished sending rather than the user having finished deciding. Repeating it while it is already raised is a `200`. agrirouter learns *that* a person is needed and never what for: it is one bit per endpoint, not a conflict list. Nothing in the protocol branches on it, so an endpoint that never calls this costs precision rather than correctness. operationId: reportUserAttention responses: '200': description: The endpoint's initial load status, with the flag raised. content: application/json: schema: $ref: '#/components/schemas/InitialLoadStatus' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': description: > The endpoint's initial load is `COMPLETED`, and a completed load is waiting on nobody. An endpoint opted into no entity type has no initial-load state at all and is `404`. content: application/json: schema: $ref: '#/components/schemas/Error' components: securitySchemes: bearerAuth: type: oauth2 description: OAuth 2.0 bearer tokens obtained via the Client Credentials flow. flows: clientCredentials: tokenUrl: https://api.prod.agrirouter.farm/oauth/token scopes: manage_endpoints: Configure endpoints and their master-data opt-in. masterdata: Send, request, and read synchronized master data. parameters: AgrirouterTenantId: name: x-agrirouter-tenant-id in: header required: true schema: type: string format: uuid description: The farmer's tenant ID in relation to which communication is done. external_id: name: external_id in: path required: true schema: type: string minLength: 3 maxLength: 255 pattern: '^([uU][rR][nN]:)?[a-zA-Z0-9][a-zA-Z0-9-]{0,31}:[a-zA-Z0-9()+,\-.:=@;$_!*%/?#]+$' description: | Application-defined external ID of the endpoint. SHOULD be formatted as a URN as defined by RFC 8141 (e.g. `urn:my-app:endpoint:42`). The `urn:` prefix itself is optional for backwards compatibility, but the value must always contain a namespace identifier and a namespace-specific string separated by a colon. The URN namespace identifier and namespace-specific string allow applications to scope their endpoint IDs in a stable, globally unique way. example: urn:my-app:endpoint:42 LocalId: name: local_id in: path required: true description: > The calling endpoint's own identifier for the entity. Unique within that endpoint per entity type and meaningless outside it: the mapping is keyed by the endpoint, so the same string from a sibling endpoint of the same application names a different record. A local identifier already mapped to a different canonical object for this endpoint is rejected (see the specification, "Identifier mapping"). schema: type: string AgrirouterEndpointId: name: x-agrirouter-endpoint-id in: header required: true description: > The endpoint acting — the sender of an entity, the caller of a request, the holder of a binding. The token authorizes an *application*, which holds many endpoints across many tenants, so the acting one is named per request rather than derived. It decides entitlement and the tenant, and it becomes the `source_endpoint_id` of any revision produced. It scopes `local_id`: the identifier resolves in this endpoint's own namespace, never in a sibling endpoint's. This is the agrirouter endpoint ID — the `id` of the endpoint, not the `external_id` the application chose for it. An application already holds it: it is returned when the endpoint is created or updated, listed with the tenant's endpoints, and carried on the endpoint events. The same header identifies the sending endpoint on every master-data write. schema: type: string format: uuid BaseRevision: name: x-agrirouter-base-revision in: header required: false description: > The `revision` the client edited from — the base of this write. It is a precondition on the request, not part of the entity, which is why it travels as a header: `revision` in the body stays server-assigned and is ignored on send, and a client-supplied revision is compared, never assigned. Required on a write to an object that already exists; absent there is `428`, since omitting it would opt the client out of concurrency control. Absent on a create is normal, there being no base. Present on a request that does not resolve to an existing object it is `412`: the client believes it is updating something agrirouter does not know under that `local_id`. A base behind the current revision is `412` with the current revision, even where the client's change and the intervening ones touch different attributes: agrirouter does not merge them. The client rebases on the current object and writes again. A write whose payload equals the current canonical value succeeds as a no-op whatever the base. See "Concurrency control" in specification.md. schema: type: integer minimum: 1 IdMappingAgrirouterId: name: agrirouter_id in: path required: true description: > The canonical object the local identifier in the path denotes. The endpoint at the other end of the mapping is scoped exactly as the entity path it hangs off, so it is not a segment here. schema: type: string format: uuid LastEventId: name: Last-Event-ID in: header required: false description: > The event id the application saved last from `/masterdata/events` stream, as agrirouter issued it in the `id:` field of an SSE frame. The application MUST send it back exactly as issued, treat it as an opaque string and MUST NOT interpret, compare, construct, or modify it in any way. Its structure is not defined by this API and may change; the example below illustrates its size and shape only. It does not always advance on every frame: the same value may repeat on some frames, and an application MUST NOT read anything into that beyond its own position for `Last-Event-ID` being unchanged. The application MUST save it from what it has **durably applied** rather than from whatever its stream client last read; delivery is at-least-once, so everything after it is sent again on reconnect. Where applies complete out of order, store the id of the earliest frame, in the order the stream delivered them, that is not yet applied: ids are not comparable by the application, so this is a matter of remembering delivery order. It does not expire, and agrirouter stores no copy of it. Omitted, or present and one agrirouter cannot validate, is served as a first connection on this stream: everything the application is entitled to, ending with a `CAUGHT_UP` frame. That costs the application its place in the stream and not its entitlement, and is how it asks for every entity to be delivered again. This parameter applies to `/masterdata/events` only. The initial-load stream carries no position and does not accept it. schema: type: string example: 'v1.f8yQ_KL5hHBS.TBQjL_8GeXSs6TIxFzsdQQ' requestBodies: IdMappingCorrection: required: true content: application/json: schema: $ref: '#/components/schemas/IdMappingCorrection' EntityRequest: required: true content: application/json: schema: $ref: '#/components/schemas/EntityRequest' responses: RequestAccepted: description: > Request accepted; the entity will be delivered via the event stream if the caller is entitled to it. ValidationError: description: > The payload failed hard validation against the master-data subset and was rejected without being applied or forwarded. content: application/json: schema: $ref: '#/components/schemas/Error' Forbidden: description: > The caller is not the owner of the endpoint, or is not opted in / not permitted to write the entity type. content: application/json: schema: $ref: '#/components/schemas/Error' NotFound: description: No such entity, or the caller is not entitled to it. content: application/json: schema: $ref: '#/components/schemas/Error' RevisionConflict: description: > The write could not be applied against its `x-agrirouter-base-revision`: the base is behind the current revision (agrirouter does not merge concurrent edits); or the base is one agrirouter never issued for this object; or a base was given for a `local_id` that does not resolve to an existing object. The body carries the current revision. The client refetches the object — through the stream or `POST /masterdata//requests` — rebases its change, and writes again. content: application/json: schema: $ref: '#/components/schemas/RevisionConflictError' BaseRevisionRequired: description: > The object exists and the request carried no `x-agrirouter-base-revision`. Concurrency control is not optional on an update. The body carries the current revision so the client can obtain the object and write again with a base. content: application/json: schema: $ref: '#/components/schemas/RevisionConflictError' MappingConflict: description: > The supplied local identifier is already mapped to a different canonical object, or — when binding — the canonical object is already bound to a different local identifier of this endpoint. Both are checked for the calling endpoint only: a sibling endpoint's mappings, of the same application or in another tenant, never conflict. Either way an asymmetric / n:1 mapping the caller must resolve. The body names which of the two identifiers is taken, and the mapping that holds it, since that is what the resolving side has to show its user. When correcting, the canonical object is bound to a local identifier of this endpoint that the correction does not list. content: application/json: schema: $ref: '#/components/schemas/MappingConflictError' PutConflict: description: > The write conflicts with what agrirouter holds. Either the supplied local identifier is already mapped to a different canonical object (`MappingConflictError`, as described for `MappingConflict`), or the write's `archived` differs from the object's current state (`LifecycleConflictError`). The two are told apart by their required field: `rejection` or `current_archived`. content: application/json: schema: $ref: '#/components/schemas/PutConflictError' InitialLoadConflict: description: > The requested transition is not valid from the endpoint's current initial load state (e.g. confirming before the set has been sent, or completing before confirming). content: application/json: schema: $ref: '#/components/schemas/Error' schemas: Error: type: object properties: message: type: string required: [message] RevisionConflictError: description: > The `412` or `428` of a write: an `Error` carrying the revision the object is currently at, so that the client has the answer a rejected write would otherwise have to fetch separately. allOf: - $ref: '#/components/schemas/Error' - type: object properties: current_revision: type: integer description: The canonical object's current `revision`. required: [current_revision] MappingConflictError: description: > The `409` of a binding: an `Error` carrying the rejection that caused it. The same shape the bulk path returns per pair, so an endpoint resolves a conflict identically whichever path raised it. As there, the outcome is carried by `rejection.reason`; the `message` of the `Error` is diagnostic and MUST NOT be branched on. allOf: - $ref: '#/components/schemas/Error' - type: object properties: rejection: $ref: '#/components/schemas/IdMappingRejection' required: [rejection] PutConflictError: description: > The `409` of a PUT: a `MappingConflictError` or a `LifecycleConflictError`, told apart by their required field, `rejection` or `current_archived`. oneOf: - $ref: '#/components/schemas/MappingConflictError' - $ref: '#/components/schemas/LifecycleConflictError' LifecycleConflictError: description: > The `409` of a write whose `archived` differs from the object's current state: an `Error` carrying that state. The state changes only through archiving and unarchiving; the client decides which, if either, it means, and writes again. The `message` of the `Error` is diagnostic and MUST NOT be branched on. allOf: - $ref: '#/components/schemas/Error' - type: object properties: current_archived: type: boolean description: The canonical object's current `archived`. required: [current_archived] IdMappingRejectionReason: type: string description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). Why a binding could not be recorded. `LOCAL_ID_ALREADY_BOUND` — this endpoint already knows a different canonical object by that `local_id`. `existing_mapping` names it. `AGRIROUTER_ID_ALREADY_BOUND` — this endpoint already knows that canonical object by a different `local_id`. `existing_mapping` names it. `UNKNOWN_OBJECT` — no such canonical object, or the endpoint is not entitled to it. On the per-entity operation this is the `404` instead. `DUPLICATE_IN_REQUEST` — the same `local_id` or the same `agrirouter_id` appears in more than one pair of this request, which would make the outcome depend on the order pairs were applied in. Every pair involved is rejected and none is applied. Bulk path only. examples: - LOCAL_ID_ALREADY_BOUND - AGRIROUTER_ID_ALREADY_BOUND - UNKNOWN_OBJECT - DUPLICATE_IN_REQUEST IdMappingRejection: description: > A binding that could not be recorded: the pair as submitted, why, and the mapping standing in its way. allOf: - $ref: '#/components/schemas/IdMappingBinding' - type: object properties: reason: $ref: '#/components/schemas/IdMappingRejectionReason' existing_mapping: $ref: '#/components/schemas/IdMappingBinding' description: > The mapping that already holds the taken identifier. Both of its ends belong to the rejected endpoint itself, so naming it discloses nothing the endpoint does not already hold, and it is what the endpoint shows the user resolving the conflict. Present for `LOCAL_ID_ALREADY_BOUND` and `AGRIROUTER_ID_ALREADY_BOUND`, absent for the other reasons, where no mapping is in the way. required: [reason] EntityRequest: type: object description: A lazy-loading request for a single canonical object. properties: agrirouter_id: type: string format: uuid description: The canonical identifier of the wanted entity. required: [agrirouter_id] IdMappingBinding: type: object description: > One binding of a local identifier to a canonical object, as carried in bulk on the initial-load confirmation. Both ends belong to the calling endpoint's own store: the object it matched, and what it calls that object. A mapping only ever travels from an endpoint to agrirouter. An endpoint onboarded again under an `external_id` its application kept a correspondence table for re-declares that table here, agrirouter having discarded the mapping with the removed endpoint. properties: agrirouter_id: type: string format: uuid local_id: type: string required: [agrirouter_id, local_id] IdMappingCorrection: type: object description: > The correct pairs for a set of the calling endpoint's local identifiers. A `local_id` and a non-null `agrirouter_id` each appear at most once. properties: id_mappings: type: array minItems: 1 items: $ref: '#/components/schemas/IdMappingCorrectionEntry' required: [id_mappings] IdMappingCorrectionEntry: type: object properties: local_id: type: string agrirouter_id: type: [string, 'null'] format: uuid description: The object `local_id` denotes, or `null` for none. required: [local_id, agrirouter_id] Id: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: > Identity of an object, based on the ADAPT `Id`. Used for the object's own `id` and inside every `Ref`. Both identifiers it can carry are those of the near end of the transfer: on send the sending endpoint's, on delivery the receiving endpoint's. It never carries another endpoint's identifier, a sibling endpoint's of the same application included. On delivery `referenceId` is the receiving endpoint's local identifier, present exactly when it has bound the object. `uniqueIds` holds the agrirouter entry, the canonical identifier, and then, only when the endpoint's latest write of the object sent one, the local entry it sent: `idText` equal to `referenceId`, with that write's `idTypeCode` and `idSource`. An endpoint that never sends a local entry receives none. On send the local identifier is `referenceId`, and the local entry is the entry whose `idText` equals it. `uniqueIds` holds at most the local entry and the agrirouter entry, the one with `idSource` `https://agrirouter.com`, one of each: any other entry is a `400`. As an object's own `id`, on send `referenceId` must equal the `{local_id}` in the path, and an agrirouter entry, if any, must be the object that `local_id` is bound to. On delivery `referenceId` and the local entry are absent when the receiving endpoint has not bound the object, or has unbound it. An absent `referenceId` means "you do not hold this object": create it locally and bind the identifier you issue. properties: referenceId: type: string description: > The near end's local identifier. Absent when it has none, which ADAPT does not allow. uniqueIds: type: array description: > Always present on delivery. May be absent on send, where `referenceId` alone identifies the object. items: $ref: '#/components/schemas/UniqueId' UniqueId: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: > One identifier of an object, based on the ADAPT `UniqueId`. properties: idSource: type: string description: > `https://agrirouter.com` for the canonical identifier, assigned by agrirouter. For a local entry, whatever the endpoint sent, relayed back to that endpoint only, or absent if it sent none. `https://agrirouter.com` is reserved and is never a local entry's. examples: ['https://agrirouter.com', 'https://fmis.example.com'] idText: type: string idTypeCode: type: string description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). From the ADAPT IdType list. examples: [UUID, STRING, LONGINT, URI, GLN] required: [idText, idTypeCode] Ref: type: object additionalProperties: false description: > A reference to another entity, in place of ADAPT's `Id` strings. A property `_agmasync_Ref`, or `Ref` inside a prefixed value. On send either identifier suffices: without an agrirouter entry, `referenceId` is resolved against the calling endpoint's own mapping, and is rejected if the target has not been sent or bound through that endpoint yet. On delivery the agrirouter entry is always present, `referenceId` carries the receiving endpoint's own identifier for the target, or is absent when it has none, and the local entry is there only as in the target's own `id`: as the endpoint's latest write of the target sent it. A sent reference with neither an agrirouter entry nor a `referenceId` is rejected with `400`. A reference is replaced whole on write. properties: id: $ref: '#/components/schemas/Id' required: [id] WeakRef: type: object additionalProperties: false description: > A weak reference: shaped like a `Ref`, but outside the dependency order. A property `_agmasync_Ref` typed `WeakRef`. On send it resolves as a `Ref` does: its target must have been sent or bound through the calling endpoint first. On delivery its target may arrive after the object referencing it. A receiver applies the referencing object without waiting and links the target when it arrives. A reference is replaced whole on write. properties: id: $ref: '#/components/schemas/Id' required: [id] Envelope: type: object description: > Sync state common to every master-data entity. The master data itself, identity included, is in `content`. The concrete entity type is determined by the path; each entity schema pins the `type` discriminator so that objects remain self-describing on the event stream. agrirouter assigns `revision`, `modified_at`, `tenant_id`, `source_endpoint_id`, `recipient_endpoint_id`, and `type`. An object may be sent back as it was delivered, these included: `revision`, `modified_at`, `source_endpoint_id`, and `recipient_endpoint_id` are read-only, ignored on send and always present on delivery; `tenant_id` and `type` are optional on send and must match the object written, or the write is a 400. `archived` is required on send: it sets the state of a new object and must equal the state of an existing one (see `archived`). `content` is based on the corresponding ADAPT 2.0.2 type. Properties ADAPT has no slot for are prefixed `_agmasync_`, and unknown properties are rejected. See "Relation to ADAPT" in specification.md for every deviation from ADAPT. An optional attribute declared nullable accepts `null` on a write, where it removes the attribute. agrirouter never delivers `null`: an attribute absent from a delivered object is unset. properties: archived: type: boolean description: > Whether the object is archived. Required on send. On a create it sets the initial state; on an update it must equal the current state, or the write is rejected with `409` and a `LifecycleConflictError`. The state of an existing object changes only through archiving and unarchiving. Always present on delivery, where it is the only signal of the object's lifecycle state. revision: type: integer readOnly: true description: > Monotonic per-object counter maintained by agrirouter. Never taken from the body: the revision a write was made from travels in the `x-agrirouter-base-revision` header, where it is compared and discarded. Ignored on send. modified_at: type: string readOnly: true format: date-time description: Assigned by agrirouter. Ignored on send. tenant_id: type: string format: uuid description: > The tenant the object belongs to. Assigned by agrirouter. On send the tenant follows from the endpoint named in `x-agrirouter-endpoint-id`; a `tenant_id` sent must be that tenant. One application stream carries every tenant the application is routed to, so on delivery this is the field that says which of them an object belongs to. A receiver holding data for several tenants partitions on it rather than on the connection. source_endpoint_id: type: string readOnly: true format: uuid description: > The agrirouter identifier of the endpoint whose change produced this revision. It always belongs to `tenant_id`. Ignored on send. recipient_endpoint_id: type: string readOnly: true format: uuid description: > The agrirouter identifier of the endpoint this copy is for: the endpoint whose local identifiers `content.id` and every reference carry. It always belongs to `tenant_id`. The mapping is scoped to the endpoint, so an object entitled to several of an application's endpoints is delivered once for each. On a write response it is the calling endpoint. Ignored on send. required: [archived] AddressContactMethod: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: > An address of a party or a farm, based on the ADAPT `AddressContactMethod`. Replaced whole on write. properties: addressLines: type: array items: type: string city: type: string postalCode: type: string countrySubdivision: type: string country: type: string countryCode: type: string pattern: '^[A-Z]{2}$' addressContactTypeCode: type: string description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). From the ADAPT AddressContactType list. Plus `BILLING` for a billing address. examples: [PHYSICAL, POSTAL, LEGAL, BILLING] required: [addressContactTypeCode] TelecommunicationContactMethod: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: > A phone number or e-mail address of a party, based on the ADAPT `TelecommunicationContactMethod`. properties: valueText: type: string telecommunicationContactTypeCode: type: string description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). From the ADAPT TelecommunicationContactType list. examples: [FIXED_PHONE, MOBILE_PHONE, FAX, EMAIL] required: [valueText, telecommunicationContactTypeCode] ContactInfo: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: > Contact data of a party, based on the ADAPT `ContactInfo`. Each list holds at most one entry per type code, and is replaced whole on write. properties: addressContactMethods: type: [array, 'null'] items: $ref: '#/components/schemas/AddressContactMethod' telecommunicationContactMethods: type: [array, 'null'] items: $ref: '#/components/schemas/TelecommunicationContactMethod' HarvestPeriod: type: object additionalProperties: false description: > Canonical harvest period as an interval. A discrete year is mapped to an interval on send; `label` may round-trip the native presentation. properties: validFrom: type: string format: date validTo: type: [string, 'null'] format: date description: Absent means open / current. label: type: [string, 'null'] description: 'Human-facing designation, e.g. "2026" or "2025/2026".' required: [validFrom] Party: description: > A legal or natural actor: a person, an organization, or a party whose party type its sender does not record. It plays no fixed role: whether it acts as a contractor or as a client follows from the relations it stands in, not from an attribute. allOf: - $ref: '#/components/schemas/Envelope' - type: object properties: type: const: party description: > Discriminator, set by agrirouter. Implied by the path on send. If sent, it must match the path. Always present on delivery. content: $ref: '#/components/schemas/PartyContent' required: [content] PartyContent: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: > Based on the ADAPT `Party`. The party type is the `partyTypeCode` of `_agmasync_details`, not a `partyTypeCode` on the party itself. properties: id: $ref: '#/components/schemas/Id' name: type: string description: > The name the party is known by: an organization's name, a person's full name. description: type: [string, 'null'] contactInfo: oneOf: - $ref: '#/components/schemas/ContactInfo' - type: 'null' _agmasync_details: oneOf: - $ref: '#/components/schemas/PartyDetails' - type: 'null' description: > Whether the party is a person or an organization, with the attributes specific to that party type. Absent means the party type is unknown. Whatever a write sends here is stated to every application. _agmasync_taxNumber: type: [string, 'null'] description: Identifier assigned by tax authorities. _agmasync_taxId: type: [string, 'null'] description: Numerical identifier assigned by tax authorities. _agmasync_tradeId: type: [string, 'null'] description: Numerical identifier assigned by public authorities. required: [id, name] PartyDetails: description: > The type of a party. `partyTypeCode` is a closed set, since it selects the schema of the remaining attributes, and each type admits only its own attributes. oneOf: - $ref: '#/components/schemas/PersonDetails' - $ref: '#/components/schemas/OrganizationDetails' discriminator: propertyName: partyTypeCode mapping: PERSON: '#/components/schemas/PersonDetails' ORGANIZATION: '#/components/schemas/OrganizationDetails' PersonDetails: type: object additionalProperties: false description: > A natural person. A person may belong to an organization, such as its employer, through `parentOrganizationRef`. properties: partyTypeCode: const: PERSON title: type: [string, 'null'] firstName: type: [string, 'null'] lastName: type: [string, 'null'] parentOrganizationRef: oneOf: - $ref: '#/components/schemas/Ref' - type: 'null' description: > The organization this person belongs to, such as its employer: a party whose `_agmasync_details` is an organization. A write naming any other party is a `400`, and so is a change or removal of party type on an organization that persons still name. required: [partyTypeCode] OrganizationDetails: type: object additionalProperties: false description: A legal entity to which persons may belong. properties: partyTypeCode: const: ORGANIZATION commercialRegistryNumber: type: [string, 'null'] description: Identifier from the commercial register. required: [partyTypeCode] Farm: description: > A grouping of fields that the farmer considers part of the same management group. allOf: - $ref: '#/components/schemas/Envelope' - type: object properties: type: const: farm description: > Discriminator, set by agrirouter. Implied by the path on send. If sent, it must match the path. Always present on delivery. content: $ref: '#/components/schemas/FarmContent' required: [content] FarmContent: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: Based on the ADAPT `Farm`. properties: id: $ref: '#/components/schemas/Id' name: type: string description: type: [string, 'null'] _agmasync_growerRef: oneOf: - $ref: '#/components/schemas/Ref' - type: 'null' description: > The party that holds the farm, in place of ADAPT's Grower. Absent where the farm's system does not record parties. _agmasync_specialisedUsageType: type: [string, 'null'] description: > Production orientation of the farm (e.g. arable farming, dairy, vineyard, orchard). Free-form, drawn from AGROVOC where a matching concept exists. _agmasync_address: oneOf: - $ref: '#/components/schemas/AddressContactMethod' - type: 'null' _agmasync_geoReference: oneOf: - $ref: '#/components/schemas/WktPoint' - type: 'null' description: The point locating the farm. required: [id, name] SoilInfo: type: object additionalProperties: false description: Soil characteristics of a field. properties: type: type: [string, 'null'] description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). The soil classification. examples: - SAND - LOAMY_SAND - HEAVY_LOAMY_SAND - SANDY_TO_SILTY_LOAM - CLAYEY_LOAM - CLAY ratingPoints: type: [integer, 'null'] minimum: 0 maximum: 100 description: > Soil rating points (Bodenzahl / Ackerzahl). Germany only, as defined by the [Bodenschätzungsgesetz](https://www.bundesfinanzministerium.de/Content/DE/Standardartikel/Themen/Steuern/Weitere_Steuerthemen/2014-07-21-bodenschaetzung-anlage-VRBodSchaetzG.pdf?__blob=publicationFile&v=1). Area: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: An area, based on the ADAPT measurement type. Always in hectares. properties: numericValue: type: number minimum: 0 unitOfMeasureCode: type: string enum: [ha] required: [numericValue, unitOfMeasureCode] Field: description: > A named physical space where production agriculture takes place, used to partition and identify data. allOf: - $ref: '#/components/schemas/Envelope' - type: object properties: type: const: field description: > Discriminator, set by agrirouter. Implied by the path on send. If sent, it must match the path. Always present on delivery. content: $ref: '#/components/schemas/FieldContent' required: [content] FieldContent: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: Based on the ADAPT `Field`. properties: id: $ref: '#/components/schemas/Id' name: type: string description: type: [string, 'null'] arableArea: oneOf: - $ref: '#/components/schemas/Area' - type: 'null' description: Nominal area of the field. timeZone: type: [string, 'null'] description: IANA time zone of the field, e.g. Europe/Berlin. _agmasync_farmRef: oneOf: - $ref: '#/components/schemas/Ref' - type: 'null' description: > The farm this field belongs to. The field's grower is its farm's `_agmasync_growerRef`. _agmasync_activeBoundaryRef: oneOf: - $ref: '#/components/schemas/WeakRef' - type: 'null' description: > The field's active boundary, in place of ADAPT's `activeBoundaryId`. A weak reference: the boundary may arrive after the field. A receiver treats an archived boundary, or one naming another field, as no active boundary. _agmasync_soil: oneOf: - $ref: '#/components/schemas/SoilInfo' - type: 'null' _agmasync_topography: type: [number, 'null'] description: Slope / gradient, e.g. 7 (degrees). _agmasync_harvestPeriod: oneOf: - $ref: '#/components/schemas/HarvestPeriod' - type: 'null' _agmasync_metadata: type: [object, 'null'] description: > Additional key/value metadata. An application leaves the keys it does not understand out of its writes, which keeps them. additionalProperties: true required: [id, name] GNSSDataQualityMetric: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: > A metric documenting the quality of the GNSS data a boundary was recorded with, the ADAPT `GNSSDataQualityMetric` unchanged. Its `definitionCode` is a Data Type Definition of the ADAPT `GNSS_DATA_QUALITY_METRICS` scope, which also defines how to read `valueText`. properties: definitionCode: type: string valueText: type: string required: [definitionCode, valueText] Boundary: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: The geometry of a field boundary, based on the ADAPT `Boundary`. properties: geometry: $ref: '#/components/schemas/WktArea' boundaryCreationMethodCode: type: [string, 'null'] description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). From the ADAPT BoundaryCreationMethod list. examples: - UNKNOWN - MANUAL - DRIVEN - SURVEYED - AUTO_OPERATION - AUTO_IMAGERY - ADMINISTRATIVE gNSSBaseStationTypeCode: type: [string, 'null'] description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). From the ADAPT GNSSBaseStationType list. examples: [PHYSICAL, VIRTUAL] gNSSBaseSurveyTypeCode: type: [string, 'null'] description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). From the ADAPT GNSSBaseSurveyType list. examples: [MOBILE_BASE, PROFESSIONAL, VIRTUAL] gNSSCorrectionNetworkName: type: [string, 'null'] gNSSCorrectionNetworkBrand: type: [string, 'null'] gNSSDataQualityMetrics: type: [array, 'null'] items: $ref: '#/components/schemas/GNSSDataQualityMetric' required: [geometry] FieldBoundary: description: > A geometry identifying the geo-spatial coordinates of a field, including its outer boundary and the holes of areas left out. A field may have several boundaries that differ in geometry by intended use. allOf: - $ref: '#/components/schemas/Envelope' - type: object properties: type: const: fieldBoundary description: > Discriminator, set by agrirouter. Implied by the path on send. If sent, it must match the path. Always present on delivery. content: $ref: '#/components/schemas/FieldBoundaryContent' required: [content] FieldBoundaryContent: # Generated by tools/adapt from adapt/deviations.yaml. Do not edit. type: object additionalProperties: false description: Based on the ADAPT `FieldBoundary`. properties: id: $ref: '#/components/schemas/Id' name: type: [string, 'null'] description: type: [string, 'null'] boundary: $ref: '#/components/schemas/Boundary' _agmasync_fieldRef: $ref: '#/components/schemas/Ref' description: > The field this boundary describes. A field's boundaries are the boundaries that name it. _agmasync_boundaryType: type: [string, 'null'] description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). The boundary classification. examples: - CONCEPTUAL - OPERATIONAL - ECONOMIC_DEFINED - ADMINISTRATIVE_RECEIVED _agmasync_harvestPeriod: oneOf: - $ref: '#/components/schemas/HarvestPeriod' - type: 'null' _agmasync_regulatoryRequirements: type: [string, 'null'] description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). A regulatory constraint applying to the boundary. examples: [RED_ZONE_NITROGEN, WATER_PROTECTION_AREA] _agmasync_metadata: type: [object, 'null'] description: > Additional key/value metadata. An application leaves the keys it does not understand out of its writes, which keeps them. additionalProperties: true required: [id, boundary, _agmasync_fieldRef] Entity: description: > Any master-data entity. Used only on the event stream, which carries every opted-in entity type over a single connection; the typed resources use the concrete schemas directly. oneOf: - $ref: '#/components/schemas/Party' - $ref: '#/components/schemas/Farm' - $ref: '#/components/schemas/Field' - $ref: '#/components/schemas/FieldBoundary' discriminator: propertyName: type mapping: party: '#/components/schemas/Party' farm: '#/components/schemas/Farm' field: '#/components/schemas/Field' fieldBoundary: '#/components/schemas/FieldBoundary' WktPoint: type: string description: > A POINT as Well-Known Text in WGS84. Any valid WKT is accepted and delivered in the canonical form of "Encoding" in specification.md. examples: ['POINT (9.5531 52.2089)'] WktArea: type: string description: > A POLYGON or MULTIPOLYGON as Well-Known Text in WGS84. A polygon's first ring is its exterior, every further ring a hole, and it must be valid as in OGC Simple Features. Any valid WKT is accepted and delivered in the canonical form of "Encoding" in specification.md, which is always a MULTIPOLYGON: a POLYGON is delivered as the MULTIPOLYGON of that one polygon. examples: ['MULTIPOLYGON (((9.5605 52.2085, 9.56 52.205, 9.566 52.205, 9.5665 52.208, 9.5605 52.2085), (9.5646 52.2072, 9.5646 52.2068, 9.564 52.2068, 9.564 52.2072, 9.5646 52.2072)))'] EntityTypeToggle: type: object properties: entity_type: type: string description: > [Extensible enum](https://github.com/DKE-Data/masterdata-sync-working-group/blob/main/specification.md#extensible-enumerations). The entity type this toggle applies to. examples: [party, farm, field, fieldBoundary] required: [entity_type] PutEndpointRequest: type: object required: - application_id - software_version_id - capabilities - subscriptions - endpoint_type properties: name: type: string minLength: 1 maxLength: 200 pattern: '^[\p{L}\p{N} _.,:@\-]+$' description: | Optional name of the endpoint, for easier identification in agrirouter web interface. Does not have to be unique. If not specified, the name would be generated automatically. When provided, must be 1-200 characters long and may contain letters from any script, digits, spaces, and the following special characters: `-`, `_`, `.`, `,`, `:`, `@`. Names consisting only of whitespace are not allowed as well, which is not expressed in the regex pattern. It is not guaranteed that this "application-set" name would be used, because user may override it with "user-set" name in agrirouter web interface. Name send via this API cannot override "user-set" name, but it can update "application-set" name at any time and user can choose to switch name back to "application-set". example: my-endpoint application_id: type: string format: uuid description: The ID of the application that owns the endpoint software_version_id: type: string format: uuid description: The ID of the software version that owns the endpoint capabilities: type: array items: $ref: "#/components/schemas/EndpointCapability" description: The effective capabilities of the endpoint, must be subset of the capabilities of software version. subscriptions: type: array items: $ref: "#/components/schemas/EndpointSubscription" endpoint_type: $ref: "#/components/schemas/EndpointTypeToCreate" allow_delete_by_user: type: boolean default: false description: > Flag indicating whether the user is allowed to delete this endpoint. Note that even when this flag is not set, the user can still force deletion of the endpoint. Applications must handle the ENDPOINT_DELETED event on a best-effort basis. It is also possible that an endpoint is deleted immediately after creation due to a race with the user disconnecting the entire application, so applications should not rely on this flag to prevent endpoint deletion entirely. connections_uri: type: string format: uri description: > URI pointing to where the user can manage the entity connected to this endpoint, e.g. to disconnect or delete equipment from an equipment vendor. When provided, this URI will be shown when the user attempts to delete the endpoint, instead of the usual deletion dialog, directing them to the vendor's management page. owner_endpoint_external_id: type: string description: > Optional external ID of the endpoint that should own (be the parent of) this endpoint. The referenced owner endpoint must belong to the same tenant and the same application as this endpoint, otherwise the request is rejected. When the owner endpoint is deleted, the endpoints it owns are deleted as well. Note that the owner endpoint must already be processed internally. Since endpoint state is propagated asynchronously, an owner endpoint that was just created may not yet be resolvable masterdata: $ref: '#/components/schemas/MasterdataConfig' Endpoint: type: object required: - id - external_id - endpoint_type - tenant_id - application_id - software_version_id - capabilities properties: id: type: string format: uuid external_id: type: string application_id: type: string format: uuid software_version_id: type: string format: uuid endpoint_type: $ref: "#/components/schemas/EndpointType" tenant_id: type: string description: The tenant ID of the endpoint capabilities: type: array items: $ref: "#/components/schemas/EndpointCapability" allow_delete_by_user: type: boolean default: false description: Flag indicating whether the user is allowed to delete this endpoint. readOnly: true connections_uri: type: string format: uri description: > URI pointing to where the user can manage the entity connected to this endpoint, e.g. to disconnect or delete equipment from an equipment vendor. readOnly: true owner_endpoint_external_id: type: string description: > External ID of the endpoint that owns (is the parent of) this endpoint, if any. readOnly: true masterdata: $ref: '#/components/schemas/MasterdataConfig' EndpointSubscription: type: object required: - message_type properties: message_type: type: string example: "iso:11783:-10:taskdata:zip" description: | The message type that the endpoint is subscribed to. See available types here: https://docs.agrirouter.com/agrirouter-interface-documentation/latest/tmt/overview.html EndpointCapability: type: object required: - message_type - direction properties: message_type: type: string example: "iso:11783:-10:taskdata:zip" description: | The message type that the endpoint can send or receive. See available types here: https://docs.agrirouter.com/agrirouter-interface-documentation/latest/tmt/overview.html direction: type: string enum: - "SEND" - "RECEIVE" - "SEND_RECEIVE" ErrorResponse: type: object required: - message properties: message: type: string description: A human-readable error message describing what went wrong. EndpointType: type: string description: | Type of an endpoint that can be observed in the system. This includes types that can be created via this G4 API as well as legacy types that can only be created via the G2/G3 APIs. For values accepted when creating an endpoint, see `EndpointTypeToCreate`. enum: - cloud_software - virtual_communication_unit - communication_unit - telemetry_platform EndpointTypeToCreate: type: string description: | Type of an endpoint that can be created via this G4 API. Legacy types such as `communication_unit` and `telemetry_platform` cannot be created here; see `EndpointType` for the full set that may be observed. `farming_software` is accepted as a deprecated alias for `cloud_software` and will be removed in a future revision. enum: - cloud_software - virtual_communication_unit - farming_software MasterdataConfig: type: object description: > Per-endpoint, per-entity opt-in for master-data exchange. Absence of a toggle for an entity type means the endpoint is not opted in for it. properties: endpoint_id: type: string format: uuid readOnly: true description: > The agrirouter identifier of the endpoint this resource belongs to. The path addresses it by the application's own `external_id`. capabilities: type: array items: $ref: '#/components/schemas/EntityTypeToggle' resolution_url: type: string format: uri description: > Where the user resolves initial-load conflicts in the endpoint's own software. Optional, opaque to agrirouter, and not per conflict: it is rendered as a link while the endpoint has `awaiting_user` set. examples: ['https://app.example.com/tenants/42/agrirouter/masterdata'] required: [capabilities] RouteChangedEventData: type: object description: > Data structure for `ROUTE_CHANGED` events on `/masterdata/events`. It states which entity types the user has selected for one of the application's endpoints. One event covers every way the selection changes: the endpoint given a masterdata route for the first time, a further entity type selected on one already routed, a type deselected, and the last one deselected or the route removed. The event may arrive more than once for one move and MUST be handled idempotently. required: [event_type, tenant_id, endpoint_id, external_id, entity_types, changed_at] properties: event_type: type: string const: ROUTE_CHANGED description: Discriminator; matches the `event:` line. tenant_id: type: string format: uuid description: The tenant of the endpoint. endpoint_id: type: string format: uuid description: The agrirouter identifier of the endpoint whose selection changed. external_id: type: string description: The application's own identifier for the same endpoint. entity_types: type: array items: $ref: '#/components/schemas/EntityTypeToggle' description: > The endpoint's selection as it stands after the change, stated in full rather than as a delta. An empty array is a statement and not an omission: it says the endpoint exchanges nothing, because the user deselected the last entity type or the route was removed. examples: - [{entity_type: party}, {entity_type: farm}] changed_at: type: string format: date-time description: > When the selection reached this state. Not a delivery timestamp: it is unchanged when the same event is delivered again, and a repeat carrying an older value than one already applied for this endpoint can be discarded. examples: ['2026-07-14T09:20:00Z'] MasterdataResetEventData: type: object description: > Data structure for `RESET_MASTERDATA_SYNC` events on `/masterdata/events`. It states that the user wiped the tenant's master data in agrirouter: every canonical object, every identifier mapping, every masterdata route and every initial-load state of the tenant is discarded. Only a user can do this; no operation of this API does. Sent to every application that has had an endpoint in the tenant take part at some point, whether or not that endpoint still exists. The application MUST discard every binding and stored revision it holds in the tenant, and every correspondence table it retained for a removed endpoint there, and treat the listed endpoints as opted into nothing. It MUST NOT delete or archive its local records. No `ROUTE_CHANGED` is issued for the listed endpoints. agrirouter delivers it before any later event of the tenant. The application MUST durably store a position at or past it before taking part in that tenant's initial load again, so that a repeat can only arrive while nothing is bound and handling it again changes nothing. required: [event_type, tenant_id, endpoints] properties: event_type: type: string const: RESET_MASTERDATA_SYNC description: Discriminator; matches the `event:` line. tenant_id: type: string format: uuid description: The tenant whose master data was wiped. endpoints: type: array description: > The application's endpoints in the tenant, each now opted into nothing. Empty where the application has no endpoint left there and is told only because one of its endpoints took part before it was removed. items: type: object required: [endpoint_id, external_id] properties: endpoint_id: type: string format: uuid description: The agrirouter identifier of the endpoint. external_id: type: string description: The application's own identifier for the same endpoint. InitialLoadState: type: string description: > Per-endpoint initial-load state, covering every entity type the endpoint is opted into. `LOADING_FROM_AGRIROUTER` — agrirouter is still sending the canonical set. Entered when the user selects the endpoint's first entity type, and again whenever a further entity type is selected. Both are a user's opt-in decision carried out by agrirouter, and the application is told of them by `ROUTE_CHANGED` on `/masterdata/events`. An application cannot enter this state directly — neither by adding a type to its declaration, which enables nothing, nor by setting it on the `status` resource, which is a `409`. `RECONCILING` — the whole canonical set has been delivered, and agrirouter moves the endpoint here before closing the initial-load stream. agrirouter moves it here itself, and only this one, because it is the side that knows it has finished sending, which is also why this state is the authoritative answer to whether the set arrived: an endpoint cannot tell an orderly close from a dropped connection. Moving first is what makes reading it once, as the response ends, enough. The endpoint is now working through whatever conflicts reconciling surfaced, which may take as long as a user takes. `LOADING_TO_AGRIROUTER` — the endpoint has confirmed it reconciled, and is sending the objects it holds that the canonical set did not contain. `COMPLETED` — steady-state synchronization applies. The endpoint drives two of these transitions, both through the `status` resource: `RECONCILING` → `LOADING_TO_AGRIROUTER` and `LOADING_TO_AGRIROUTER` → `COMPLETED`. enum: - LOADING_FROM_AGRIROUTER - RECONCILING - LOADING_TO_AGRIROUTER - COMPLETED InitialLoadStatus: type: object description: > The endpoint's initial-load state. One per endpoint, covering every entity type it is opted into; an endpoint opted into no entity type has no initial-load state. properties: endpoint_id: type: string format: uuid readOnly: true description: > The agrirouter identifier of the endpoint this resource belongs to. The path addresses it by the application's own `external_id`. state: $ref: '#/components/schemas/InitialLoadState' awaiting_user: type: boolean readOnly: true description: > Whether the endpoint's own software is needing user action — a conflict, a missing required attribute, a granularity mismatch. Raised by the endpoint through the `user-attention` resource and cleared by agrirouter, on the two endpoint-driven transitions only: advancing to `LOADING_TO_AGRIROUTER` clears it, and so does advancing to `COMPLETED`. The step to `RECONCILING` does not, since that is agrirouter reporting it has finished sending and says nothing about whether the user has finished deciding. agrirouter renders the flag as "waiting for you in ", linking to the master-data resolution URI supplied for this endpoint. previous_load_completed_at: type: string format: date-time readOnly: true description: > When this endpoint last reached `COMPLETED`, present only if it has. Its presence means the canonical set now arriving is a repeat load — the endpoint took part before and has returned, having been deselected, had its masterdata route removed, or had a further entity type selected on it. Each of those is the user's act: an application cannot ask for the set again. The identifier mapping survived all of them, so the objects arrive carrying the endpoint's own `referenceId` and match rather than reconcile. An endpoint MUST NOT take the arrival of a canonical set as evidence of a first connection: without this check it creates local duplicates of data it already holds. rejected_id_mappings: type: array readOnly: true description: > Bindings supplied on this request that could not be recorded, each with its `reason` and, where one exists, the mapping that stands in its way. They do not fail the transition: one unresolvable pair should not block the load of a set. The endpoint resolves them as it resolves a `409` on the per-entity operation, and rebinds through that operation once it has. Recomputed on every request that carries `id_mappings`, including a repeat of the transition, so a retry after a lost response reports the current outcome rather than the first. items: $ref: '#/components/schemas/IdMappingRejection' updated_at: type: string format: date-time readOnly: true required: [state] InitialLoadStateUpdate: type: object description: > The target initial-load `state` for the endpoint. The states are accepted in order, and repeating the one the endpoint is already in is accepted too. `LOADING_FROM_AGRIROUTER` is never a transition an endpoint may make, from any state including from itself. properties: state: $ref: '#/components/schemas/InitialLoadState' id_mappings: type: array description: > The bindings reconciliation produced: one entry per canonical object the endpoint matched to something it already held. Carried here because matching happens over a whole set, and the semantics are those of the per-entity `id-mapping` operation applied to each pair. Meaningful only on the transition to `LOADING_TO_AGRIROUTER`, which is where reconciliation is asserted to be done, and on a repeat of that transition, where the pairs are applied again and the rejections recomputed. Pairs are applied independently: any that cannot be recorded — because an identifier is already bound, because the canonical object is unknown to the endpoint, or because the request names the same identifier twice — come back in `rejected_id_mappings` rather than failing the transition. items: $ref: '#/components/schemas/IdMappingBinding' required: [state]