Ranch.Bot
Skip to reference

Workflows API

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

POST /v1/farm/{farm_id}/workflows/preview

Preview a workflow run

External credential scope: read:records. Minimum farm role: EDITOR. Resolves literal and today defaults once, returns a non-committable preview with structured issues for field/domain problems, and creates no livestock records.

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

Request body (application/json)

FieldTypePresenceConstraints
request_idstringRequiredformat: "uuid"
template_idstringRequiredformat: "uuid"
template_versionintegerOptionalminimum: 1
inputsobjectRequired
inputs.eventobjectOptional
inputs.offspringarrayOptional
inputs.offspring[]objectRequired
timezonestringOptionalmaxLength: 100
replaces_preview_idstringOptionalformat: "uuid"

Create request.json with a JSON body matching the request schema above before running this example.

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/farm/<farm_id>/workflows/preview' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
409Concurrent change, archived template, expired preview, or conflicting approval.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
preview_idstringRequiredformat: "uuid"
template_idstringRequiredformat: "uuid"
template_versionintegerRequired
resolved_valuesobjectOptional
default_sourcesobjectOptional
proposed_changesobjectOptional
proposed_changes.template_versionintegerOptional
proposed_changes.bundleobjectOptional
reviewobject or nullOptional
validation_issuesarrayOptional
validation_issues[]objectRequired
validation_issues[].pathstringRequired
validation_issues[].codestringRequired
validation_issues[].severitystringRequiredenum: ["error","warning"]
validation_issues[].messagestringRequired
preview_hashstringRequired
expires_atstringOptionalformat: "date-time"
statusstringRequiredenum: ["pending","invalid","replaced","committed","discarded"]
committed_atstringOptionalformat: "date-time"
saved_entity_idsobjectOptional
outcomeobjectOptional

GET /v1/farm/{farm_id}/workflows/previews/{preview_id}

Read a workflow preview

External credential scope: read:records. Minimum farm role: EDITOR. Returns the pinned review and, when committed, the saved outcome. Committed receipts survive preview expiry and template archival.

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

Request example

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

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
409Concurrent change, archived template, expired preview, or conflicting approval.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
preview_idstringRequiredformat: "uuid"
template_idstringRequiredformat: "uuid"
template_versionintegerRequired
resolved_valuesobjectOptional
default_sourcesobjectOptional
proposed_changesobjectOptional
proposed_changes.template_versionintegerOptional
proposed_changes.bundleobjectOptional
reviewobject or nullOptional
validation_issuesarrayOptional
validation_issues[]objectRequired
validation_issues[].pathstringRequired
validation_issues[].codestringRequired
validation_issues[].severitystringRequiredenum: ["error","warning"]
validation_issues[].messagestringRequired
preview_hashstringRequired
expires_atstringOptionalformat: "date-time"
statusstringRequiredenum: ["pending","invalid","replaced","committed","discarded"]
committed_atstringOptionalformat: "date-time"
saved_entity_idsobjectOptional
outcomeobjectOptional

POST /v1/farm/{farm_id}/workflows/previews/{preview_id}/commit

Commit an approved workflow preview

External credential scopes: write:records, write:animals and write:groups. Minimum farm role: EDITOR. Requires an explicit approval of the exact preview_hash. Rechecks access, template activity, expiry, relevant state and reuses the single atomic birth writer.

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

Request body (application/json)

FieldTypePresenceConstraints
approvalobjectRequired
approval.confirmedbooleanRequiredconst: true
approval.preview_hashstringRequired

Create request.json with a JSON body matching the request schema above before running this example.

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/farm/<farm_id>/workflows/previews/<preview_id>/commit' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
409Concurrent change, archived template, expired preview, or conflicting approval.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
preview_idstringRequiredformat: "uuid"
statusstringRequiredconst: "committed"
saved_entity_idsobjectRequired
outcomeobjectOptional

POST /v1/farm/{farm_id}/workflows/previews/{preview_id}/discard

Discard an uncommitted workflow preview

External credential scope: read:records. Minimum farm role: EDITOR. Invalidates an uncommitted preview without livestock writes.

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

Request example

bash example
curl --fail-with-body -X POST \
  'https://api.ranch.bot/v1/farm/<farm_id>/workflows/previews/<preview_id>/discard' \
  -H "Authorization: Bearer $RANCHBOT_TOKEN"

Responses

StatusMeaningContent type
200Successapplication/json
400Request validation failed.application/json
401Missing/invalid authentication or insufficient farm role.application/json
403Missing required scope or credential type is disallowed.application/json
404Resource or active farm membership not found.application/json
409Concurrent change, archived template, expired preview, or conflicting approval.application/json

200 response schema (application/json)

FieldTypePresenceConstraints
preview_idstringRequiredformat: "uuid"
statusstringRequired
discarded_atstringOptionalformat: "date-time"

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"
    }
  ]
}