Ranch.Bot
Skip to reference

Traceability API

HTTP reference for traceability. Read authentication and access before using these operations. All examples use made-up data and placeholder credentials.

GET /v1/farm/{farm_id}/traceability-events

List Traceability Events

List typed events; voided events are excluded unless include_void is true. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
skipqueryNo{"type":"integer"}
takequeryNo{"type":"integer"}
kindqueryNo{"type":"string","enum":["MOVEMENT","PURCHASE","SALE","IMPORT","EXPORT","DEATH","SLAUGHTER","DISPOSAL","IDENTIFICATION"]} Filter by typed event kind.
movementqueryNo{"type":"boolean"}
include_voidqueryNo{"type":"boolean"}

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
totalnumberRequired
eventsarrayRequired
events[]objectRequired
events[].idstringRequired
events[].farm_idstringRequired
events[].record_idstringRequired
events[].kindstringRequiredenum: ["MOVEMENT","PURCHASE","SALE","IMPORT","EXPORT","DEATH","SLAUGHTER","DISPOSAL","IDENTIFICATION"]
events[].statusstringRequiredenum: ["ACTIVE","VOID"]
events[].current_revisionintegerRequired
events[].recordobjectOptional
events[].revisionsarrayOptional
events[].revisions[]objectRequired
events[].inventory_effectsarrayOptional
events[].inventory_effects[]objectRequired
events[].identifier_observationsarrayOptional
events[].identifier_observations[]objectRequired
events[].links_fromarrayOptional
events[].links_from[]objectRequired
events[].links_toarrayOptional
events[].links_to[]objectRequired

POST /v1/farm/{farm_id}/traceability-events

Create Traceability Event

Create one typed event atomically with an idempotent request key. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}

Request body (application/json)

FieldTypePresenceConstraints
request_keystringRequiredminLength: 1; maxLength: 200
source (variant 1)nullOptional
source (variant 2)stringOptional
payloadobjectRequired
json example
{
  "request_key": "00000000-0000-4000-8000-000000000001",
  "payload": {
    "schema_version": 1,
    "kind": "SALE",
    "event_date": "2026-04-10",
    "populations": [
      {
        "line_id": "l1",
        "subject_type": "LIVE_ANIMALS",
        "declared_count": {
          "state": "RECORDED",
          "value": 35
        }
      }
    ],
    "movement": {
      "purpose": {
        "state": "RECORDED",
        "value": "SALE"
      },
      "sent": [
        {
          "line_id": "l1",
          "count": {
            "state": "RECORDED",
            "value": 35
          }
        }
      ]
    },
    "inventory_effects": [
      {
        "line_id": "l1",
        "effect": "REMOVE",
        "quantity": 35,
        "reason": "SALE"
      }
    ]
  }
}

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"request_key":"00000000-0000-4000-8000-000000000001","payload":{"schema_version":1,"kind":"SALE","event_date":"2026-04-10","populations":[{"line_id":"l1","subject_type":"LIVE_ANIMALS","declared_count":{"state":"RECORDED","value":35}}],"movement":{"purpose":{"state":"RECORDED","value":"SALE"},"sent":[{"line_id":"l1","count":{"state":"RECORDED","value":35}}]},"inventory_effects":[{"line_id":"l1","effect":"REMOVE","quantity":35,"reason":"SALE"}]}}'

Responses

StatusMeaningContent type
201Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

201 response schema (application/json)

FieldTypePresenceConstraints
eventobjectRequired
event.idstringRequired
event.farm_idstringRequired
event.record_idstringRequired
event.kindstringRequiredenum: ["MOVEMENT","PURCHASE","SALE","IMPORT","EXPORT","DEATH","SLAUGHTER","DISPOSAL","IDENTIFICATION"]
event.statusstringRequiredenum: ["ACTIVE","VOID"]
event.current_revisionintegerRequired
event.recordobjectOptional
event.revisionsarrayOptional
event.revisions[]objectRequired
event.inventory_effectsarrayOptional
event.inventory_effects[]objectRequired
event.identifier_observationsarrayOptional
event.identifier_observations[]objectRequired
event.links_fromarrayOptional
event.links_from[]objectRequired
event.links_toarrayOptional
event.links_to[]objectRequired

GET /v1/farm/{farm_id}/traceability-events/history

Identifier History

Look up typed identifier observations by value across revisions. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
valuequeryYes{"type":"string","minLength":1,"maxLength":128} Identifier string value to search (1-128 characters after trimming).
typequeryNo{"type":"string","maxLength":50} Optional free-form identifier type filter (50 characters or fewer after trimming).
include_historicalqueryNo{"type":"boolean"}

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events/history?value=PLACEHOLDER_VALUE' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
matchesarrayRequired
matches[]objectRequired
untypedbooleanRequired

GET /v1/farm/{farm_id}/traceability-events/transport-suggestions

Transport Suggestions

Bounded recent transporter/vehicle suggestions from current nonvoid revisions. The strict take limit is 1-100 and defaults to 20; offset pagination (skip) is not supported. Event, history, and suggestion reads use read:records; writes use write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
takequeryNo{"type":"integer","minimum":1,"maximum":100,"default":20} Maximum number of suggestions to return (1-100; defaults to 20).

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events/transport-suggestions' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
suggestionsarrayRequired
suggestions[]objectRequired

GET /v1/farm/{farm_id}/traceability-events/status/{request_key}

Write Status Reconciliation

Read-only reconciliation of a previously attempted event write. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
request_keypathYes{"type":"string","minLength":1,"maxLength":200}

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events/status/<request_key>' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
request_keystringRequired
event_id (variant 1)nullRequired
event_id (variant 2)stringRequired
revision (variant 1)nullRequired
revision (variant 2)integerRequired
status (variant 1)nullRequired
status (variant 2)stringRequired

GET /v1/farm/{farm_id}/traceability-events/{event_id}

Get Traceability Event

Get one typed event with its current revision and projections. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
event_idpathYes{"type":"string","format":"uuid"}

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events/<event_id>' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
eventobjectRequired
event.idstringRequired
event.farm_idstringRequired
event.record_idstringRequired
event.kindstringRequiredenum: ["MOVEMENT","PURCHASE","SALE","IMPORT","EXPORT","DEATH","SLAUGHTER","DISPOSAL","IDENTIFICATION"]
event.statusstringRequiredenum: ["ACTIVE","VOID"]
event.current_revisionintegerRequired
event.recordobjectOptional
event.revisionsarrayOptional
event.revisions[]objectRequired
event.inventory_effectsarrayOptional
event.inventory_effects[]objectRequired
event.identifier_observationsarrayOptional
event.identifier_observations[]objectRequired
event.links_fromarrayOptional
event.links_from[]objectRequired
event.links_toarrayOptional
event.links_to[]objectRequired

GET /v1/farm/{farm_id}/traceability-events/{event_id}/revisions

Traceability Event Revisions

List every stored revision, including superseded and voided facts. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
event_idpathYes{"type":"string","format":"uuid"}

Request example

bash example
curl --fail-with-body -X GET \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events/<event_id>/revisions' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
event_idstringRequired
current_revisionintegerRequired
statusstringRequired
revisionsarrayRequired
revisions[]objectRequired

POST /v1/farm/{farm_id}/traceability-events/{event_id}/correct

Correct Traceability Event

Append a full replacement revision, rebuilding projections atomically. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
event_idpathYes{"type":"string","format":"uuid"}

Request body (application/json)

FieldTypePresenceConstraints
request_keystringRequiredminLength: 1; maxLength: 200
expected_revisionintegerRequired
reasonstringRequired
source (variant 1)nullOptional
source (variant 2)stringOptional
payloadobjectRequired
json example
{
  "request_key": "00000000-0000-4000-8000-000000000002",
  "expected_revision": 1,
  "reason": "Corrected the destination",
  "payload": {
    "schema_version": 1,
    "kind": "MOVEMENT",
    "event_date": "2026-04-10",
    "populations": [
      {
        "line_id": "l1",
        "subject_type": "LIVE_ANIMALS",
        "declared_count": {
          "state": "RECORDED",
          "value": 5
        }
      }
    ]
  }
}

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events/<event_id>/correct' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"request_key":"00000000-0000-4000-8000-000000000002","expected_revision":1,"reason":"Corrected the destination","payload":{"schema_version":1,"kind":"MOVEMENT","event_date":"2026-04-10","populations":[{"line_id":"l1","subject_type":"LIVE_ANIMALS","declared_count":{"state":"RECORDED","value":5}}]}}'

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
eventobjectRequired
event.idstringRequired
event.farm_idstringRequired
event.record_idstringRequired
event.kindstringRequiredenum: ["MOVEMENT","PURCHASE","SALE","IMPORT","EXPORT","DEATH","SLAUGHTER","DISPOSAL","IDENTIFICATION"]
event.statusstringRequiredenum: ["ACTIVE","VOID"]
event.current_revisionintegerRequired
event.recordobjectOptional
event.revisionsarrayOptional
event.revisions[]objectRequired
event.inventory_effectsarrayOptional
event.inventory_effects[]objectRequired
event.identifier_observationsarrayOptional
event.identifier_observations[]objectRequired
event.links_fromarrayOptional
event.links_from[]objectRequired
event.links_toarrayOptional
event.links_to[]objectRequired

POST /v1/farm/{farm_id}/traceability-events/{event_id}/void

Void Traceability Event

Void a typed event with a reason; history keeps every revision. Event/history/suggestion scopes use read:records/write:records; a payload that updates current animal identifiers or status additionally requires write:animals.

ParameterInRequiredSchema
farm_idpathYes{"type":"string","format":"uuid"}
event_idpathYes{"type":"string","format":"uuid"}

Request body (application/json)

FieldTypePresenceConstraints
request_keystringRequiredminLength: 1; maxLength: 200
expected_revisionintegerRequired
reasonstringRequired
json example
{
  "request_key": "00000000-0000-4000-8000-000000000003",
  "expected_revision": 1,
  "reason": "Duplicate entry"
}

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/farm/<farm_id>/traceability-events/<event_id>/void' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"request_key":"00000000-0000-4000-8000-000000000003","expected_revision":1,"reason":"Duplicate entry"}'

Responses

StatusMeaningContent type
200Successapplication/json
400Validation failed.No body
401Missing/invalid authentication or role.No body
403Missing required credential scope.No body
404Not found.No body
409Conflict (stale version, reused key, or returned/void event).No body

200 response schema (application/json)

FieldTypePresenceConstraints
eventobjectRequired
event.idstringRequired
event.farm_idstringRequired
event.record_idstringRequired
event.kindstringRequiredenum: ["MOVEMENT","PURCHASE","SALE","IMPORT","EXPORT","DEATH","SLAUGHTER","DISPOSAL","IDENTIFICATION"]
event.statusstringRequiredenum: ["ACTIVE","VOID"]
event.current_revisionintegerRequired
event.recordobjectOptional
event.revisionsarrayOptional
event.revisions[]objectRequired
event.inventory_effectsarrayOptional
event.inventory_effects[]objectRequired
event.identifier_observationsarrayOptional
event.identifier_observations[]objectRequired
event.links_fromarrayOptional
event.links_from[]objectRequired
event.links_toarrayOptional
event.links_to[]objectRequired

Error body

Validation and authentication errors generally use this envelope. Rate-limit errors omit data; OAuth polling also has protocol-specific errors shown in its reference.

json example
{
  "success": false,
  "errors": [
    {
      "code": 400,
      "name": "ValidationError",
      "message": "Example validation failure"
    }
  ]
}