> ## 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.

# Append a segment

> Upload one segment of a chunked upload. Idempotent per `segment_index` — re-send an index to overwrite it (that is how you resume). Every segment except the last must be exactly `segment_size` bytes.




## OpenAPI

````yaml /openapi.yaml post /v1/files/{id}/append
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/files/{id}/append:
    post:
      tags:
        - Files
      summary: Append a segment
      description: >
        Upload one segment of a chunked upload. Idempotent per `segment_index` —
        re-send an index to overwrite it (that is how you resume). Every segment
        except the last must be exactly `segment_size` bytes.
      operationId: appendSegment
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - segment_index
                - chunk
              properties:
                segment_index:
                  type: integer
                  description: Zero-based segment index.
                chunk:
                  type: string
                  format: binary
      responses:
        '200':
          description: Segment stored. Returns the upload's current state.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvelopeFile'
        '409':
          description: The upload is already finalized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Segment index out of range or wrong size.
          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
  schemas:
    EnvelopeFile:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          const: success
        data:
          $ref: '#/components/schemas/File'
    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.
    File:
      type: object
      required:
        - id
        - state
        - created_at
      description: >
        A stored file. `sha256` and `size` are present once `state` is `ready`.
        While `state` is `uploading`, `segment_size` and `received_segments`
        describe the resumable session.
      properties:
        id:
          type: string
          description: File handle (`file_…`).
        state:
          type: string
          enum:
            - uploading
            - ready
            - referenced
            - expired
        media_type:
          type: string
        filename:
          type: string
        size:
          type: integer
          description: Byte size, once ready.
        sha256:
          type: string
          description: Whole-file SHA-256, once ready.
        segment_size:
          type: integer
          description: Bytes per segment for a chunked upload (uploading only).
        received_segments:
          type: array
          items:
            type: integer
          description: >-
            Segment indices received so far (uploading only). Resume by sending
            the missing ones.
        expires_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
  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.