---
title: "PUT /projects/{projectId}/agents/{agentId}/factory-policy"
method: PUT
path: "/projects/{projectId}/agents/{agentId}/factory-policy"
---

# PUT /projects/{projectId}/agents/{agentId}/factory-policy

`PUT /projects/{projectId}/agents/{agentId}/factory-policy`

## Request

- Base URL: `https://api.caveman.so/api/v1`
- URL: `https://api.caveman.so/api/v1/projects/{projectId}/agents/{agentId}/factory-policy`
- Auth: one of:
  - OAuth 2
    - Authorization code: `/api/v1/oauth/authorize`
    - Token URL: `/api/v1/oauth/token` scopes: `autopilot:manage`
  - HTTP bearer
  - API key in cookie `cave_access`
  - API key in cookie `__Secure-cave_identity.session_token`

PUT /api/v1/projects/{projectId}/agents/{agentId}/factory-policy on the Caveman Cloud control plane. Requires the autopilot:manage scope. Not exposed to autonomous agents: Native user authority over factory case admission, bounded policy, binding approval and cancellation. An agent session must never read a case, resolve a setup blocker, approve an execution binding, admit paid improvement work or cancel a fence.

## Request body

- FactoryPolicyConfiguration
  - `expected_revision` integer, required
  - `goal` string, required
  - `change_class` 'application-source', required
  - `case_budget_micros` string, required: Per-case cap. Initial approval also sets the shared allowance. Later edits retain its original amount; new_attempt explicitly approves an additional allowance.
  - `publication_policy` 'evaluated-draft-only' | 'none', required
  - `test_connections` string[]
  - `model_connection_ref` string, nullable
  - `paused` boolean: Stops new case admissions. Already-admitted cases retain their original authority until cancelled or otherwise fenced.
  - `new_attempt` boolean: Explicitly approves a new additional allowance. Identical retries using the original expected_revision return the same new approval; changed content conflicts. Ordinary edits reuse the existing allowance.

## Response `200`

Current policy and exact shared allowance. Legacy policies have no shared allowance.

- FactoryPolicyResponse
  - `policy` FactoryPolicy, required
    - `revision` integer, required
    - `goal` string, required
    - `change_class` 'application-source', required
    - `case_budget_micros` string, required: Per-case cap. Initial approval also sets the shared allowance. Later edits retain its original amount; new_attempt explicitly approves an additional allowance.
    - `publication_policy` 'evaluated-draft-only' | 'none', required
    - `test_connections` string[], required
    - `model_connection_ref` string, nullable, required
    - `paused` boolean, required: Stops new case admissions. Already-admitted cases retain their original authority until cancelled or otherwise fenced.
    - `approved_by` string, uuid, required
    - `approved_at` string, date-time, required
    - `scope_digest` string, required
    - `allowance` FactoryAllowance, required
      - `id` string, uuid, required
      - `policy_revision` integer, required
      - `limit_micros` string, required: Exact integer micro amount.
      - `spent_micros` string, required: Exact integer micro amount.
      - `reserved_micros` string, required: Exact integer micro amount.
      - `held_micros` string, required: Unknown paid outcomes included in reserved_micros, never added twice.
      - `remaining_micros` string, required: Shared allowance remaining after spend and reservations; organization, project, repository and case ceilings still apply independently.
      - `approved_by` string, uuid, required
      - `approved_at` string, date-time, required
      - `basis` 'attempt_budget_rows_and_gateway_case_keys' | 'attempt_budget_rows', required: attempt_budget_rows_and_gateway_case_keys: the attempt budget row plus the gateway's spend on the factory keys of every case of the attempt. attempt_budget_rows: the row alone, when the gateway could not be read.
  - `latest_revision` integer, required

## Other responses

- `400`: Invalid policy.
- `403`: Native user authority required.
- `409`: Stale revision or changed fresh-approval retry.
- `4XX`: Structured failure. `error.code` is stable; `error.request_id` is echoed in the x-cave-request-id header.
- `5XX`: Structured failure. `error.code` is stable; `error.request_id` is echoed in the x-cave-request-id header.

---

[API](https://skmtc.dev/caveman/apis/caveman-cloud-api.md) - [All operations](https://skmtc.dev/caveman/apis/caveman-cloud-api/llms.txt) - [OpenAPI document](https://skmtc.dev/caveman/apis/caveman-cloud-api/revisions/508312d01cfc?raw)
