---
title: "Archive or reactivate a workflow template"
method: PUT
path: "/v1/farm/{farm_id}/workflow-templates/{template_id}/state"
tags: ["workflow-templates"]
---

# Archive or reactivate a workflow template

`PUT /v1/farm/{farm_id}/workflow-templates/{template_id}/state`

## Request

- Base URL: `https://api.ranch.bot`
- URL: `https://api.ranch.bot/v1/farm/{farm_id}/workflow-templates/{template_id}/state`
- Auth: HTTP bearer

Owner-only farm configuration. External credential scope: write:farms. Publishing is optimistic on expected_current_version; state/default changes are optimistic on expected_metadata_revision. Conflicts return 409. Archiving the default template requires an active replacement_template_id in the same transaction.

## Path parameters

- `farm_id` string, uuid, required
- `template_id` string, uuid, required

## Request body

- object
  - `expected_metadata_revision` integer, required
  - `is_active` boolean, required
  - `replacement_template_id` string, uuid

## Response `200`

Success

- WorkflowTemplate
  - `id` string, uuid, required
  - `workflow` string, required
  - `name` string, required
  - `is_active` boolean, required
  - `is_default` boolean, required
  - `metadata_revision` integer, required
  - `current_version` WorkflowTemplateVersion
    - `id` string, uuid, required
    - `version` integer, required
    - `definition` WorkflowTemplateDefinition, required
      - `schema_version` 1, required
      - `workflow` 'record_birth', required
      - `name` string, required
      - `fields` WorkflowTemplateField[], required
        - `key` string, required
        - `scope` 'event' | 'offspring', required
        - `label` string, required
        - `required` boolean
        - `hidden` boolean
        - `default` object
        - `unit` 'kg' | 'lb'
        - `type` 'text' | 'number' | 'boolean' | 'date' | 'choice'
        - `choices` object[]
          - `key` string, required
          - `label` string, required
    - `created_at` string, date-time
  - `versions` object[]
  - `created_at` string, date-time
  - `updated_at` string, date-time

## Other responses

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

---

[API](https://skmtc.dev/ranch/apis/ranch-bot-http-api.md) · [All operations](https://skmtc.dev/ranch/apis/ranch-bot-http-api/llms.txt) · [OpenAPI document](https://skmtc.dev/ranch/apis/ranch-bot-http-api/revisions/24109d33fa02?raw)
