> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usepatchwork.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Approve or reject a held write

> Resolve a write held at an approval gate. On `approve` Patchwork performs the write server-side and resumes the run; on `reject` the model is told it was declined and the run resumes so the agent can respond. Find the `tool_call_id` in `pending_confirmation` on GET /v1/loom/threads, or in the `write.confirmation_requested` realtime event.




## OpenAPI

````yaml /openapi.yaml post /v1/loom/runs/{run_id}/confirm
openapi: 3.1.0
info:
  title: Patchwork API
  version: 1.0.0
  description: >
    Public data-plane API. Two products today: Identify (bare account
    resolution) and Loom (threads, runs, and outcomes). Every response is a JSON
    envelope — `status: success` with `data`, or `status: error` with `error`.
  contact:
    url: https://usepatchwork.co
servers:
  - url: https://api.usepatchwork.co
security:
  - bearerAuth: []
tags:
  - name: Identify
    description: Resolve an account or wallet to the institution and rails behind it.
  - name: Extract
    description: >-
      Turn a document into structured data, and manage the schema types that
      shape it.
  - name: Loom
    description: Threads, messages, runs, and outcomes for an embedded agent.
  - name: Files
    description: Upload bytes once, get a durable handle, reference it from any product.
  - name: Voice
    description: Transcribe an utterance, speak a reply, list the available voices.
  - name: MCP
    description: >-
      The grants your users hold when they reach an agent from their own AI
      client.
paths:
  /v1/loom/runs/{run_id}/confirm:
    post:
      tags:
        - Loom
      summary: Approve or reject a held write
      description: >
        Resolve a write held at an approval gate. On `approve` Patchwork
        performs the write server-side and resumes the run; on `reject` the
        model is told it was declined and the run resumes so the agent can
        respond. Find the `tool_call_id` in `pending_confirmation` on GET
        /v1/loom/threads, or in the `write.confirmation_requested` realtime
        event.
      operationId: confirmWrite
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - name: run_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: '#/components/parameters/PatchworkSubject'
        - $ref: '#/components/parameters/PatchworkConnection'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tool_call_id
                - decision
              properties:
                tool_call_id:
                  type: string
                  format: uuid
                decision:
                  type: string
                  enum:
                    - approve
                    - reject
                detail:
                  type: object
                  description: >
                    Optional structured detail recorded on the tool call and
                    passed to the model. On a rejection, a short reason produces
                    a better next turn.
            example:
              tool_call_id: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
              decision: approve
      responses:
        '202':
          description: Decision accepted; run resumed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvelopeOutcome'
        '401':
          description: Missing or invalid credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >
            Unknown run, or no pending gated call with that tool_call_id
            (`unknown_confirmation`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >
            The run is not paused at a gate (`not_awaiting_confirmation`), or
            `decision` was not approve or reject (`invalid_decision`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >
        Makes this POST safe to retry. The first call does the work and its
        response is stored; a retry with the same key returns that stored
        response with `Idempotency-Replayed: true`, without charging again. Same
        key with a different body is rejected. Keys expire after 24 hours.
      schema:
        type: string
        maxLength: 255
    PatchworkSubject:
      name: Patchwork-Subject
      in: header
      required: false
      description: >
        Relay only. Opaque subject id, chosen by you and never resolved by
        Patchwork. Partitions threads and memory within your workspace. Direct
        tokens carry `sub` instead — do not send this header on a session token.

        **Required** on every subject-scoped resource: threads, messages, runs,
        outcomes, confirmations and realtime. Omitting it is `subject_required`,
        never a wider result. The value is used exactly as given — never trimmed
        or normalised — so a stray space creates a second partition and is
        refused as `invalid_subject`.
      schema:
        type: string
    PatchworkConnection:
      name: Patchwork-Connection
      in: header
      required: false
      description: >
        Connection id or name the agent may call. Required in relay when the
        agent has unpinned customer tools. Direct tokens may carry `conn`
        instead.
      schema:
        type: string
  schemas:
    EnvelopeOutcome:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          const: success
        data:
          $ref: '#/components/schemas/OutcomeAccepted'
    Error:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          required:
            - message
            - code
          properties:
            message:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable machine-readable code.
            details:
              description: Optional extra context.
    OutcomeAccepted:
      type: object
      properties:
        run_id:
          type: string
          format: uuid
        state:
          $ref: '#/components/schemas/RunState'
    RunState:
      type: string
      enum:
        - running
        - awaiting_input
        - awaiting_outcome
        - closed
        - failed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Identify accepts a workspace API key (`sk_…`). Loom accepts either a
        short-lived session token (direct) or a workspace API key (relay).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.