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

# Fulfill all items in an order

> **Side effect:** deducts `finished_goods.ready_stock` for every unfulfilled line item and recalculates each finished_good's status. Composite (kit) items fail with KIT_NOT_PRODUCED or KIT_NOT_ASSEMBLED when their parent stock is insufficient — call `POST /orders/{id}/produce` first. Order transitions to `shipped` or `fulfilled` based on item state; `shipped_at` is set when entering those states.



## OpenAPI

````yaml /api-reference/openapi.json post /orders/{id}/fulfill
openapi: 3.1.0
info:
  title: AutoPrintFarm Public API
  version: 1.0.0
  description: >-
    Public API for AutoPrintFarm — read + write surface for printers, jobs,
    inventory, orders, SKUs, files, worklist, and assembly. Authorization uses
    three scopes: `read` (any list/get), `write` (data mutations — create,
    update, delete, uploads, fulfillment), and `control` (physical printer
    actions: start, pause, resume, stop, heaters, light, filament). Authenticate
    with an API key minted from Settings → API Keys in the AutoPrintFarm
    dashboard.
  contact:
    name: AutoPrintFarm
    url: https://autoprintfarm.com
servers:
  - url: https://api.autoprintfarm.com/public/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Printers
    description: Printer fleet status
  - name: Jobs
    description: Print job queue and history
  - name: Inventory
    description: Finished-goods stock levels
  - name: Orders
    description: Customer orders and line items
  - name: Wiki
    description: Internal documentation articles
  - name: Worklist
    description: Operational task queue
  - name: Products
    description: Product catalog, SKUs, components, and color presets
  - name: Files
    description: Print file metadata and versions
  - name: Hubs
    description: Hub fleet and connection status
  - name: Assembly
    description: Post-print assembly tasks with bundled wiki
  - name: Materials
    description: Filament, components, packaging, and printer parts inventory
  - name: Analytics
    description: >-
      Dashboard rollups and reporting (overview, production, printers, failures,
      inventory, revenue)
paths:
  /orders/{id}/fulfill:
    post:
      tags:
        - Orders
      summary: Fulfill all items in an order
      description: >-
        **Side effect:** deducts `finished_goods.ready_stock` for every
        unfulfilled line item and recalculates each finished_good's status.
        Composite (kit) items fail with KIT_NOT_PRODUCED or KIT_NOT_ASSEMBLED
        when their parent stock is insufficient — call `POST
        /orders/{id}/produce` first. Order transitions to `shipped` or
        `fulfilled` based on item state; `shipped_at` is set when entering those
        states.
      parameters:
        - schema:
            type: string
          required: true
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                tracking_number:
                  type: string
                tracking_url:
                  type: string
                  format: uri
                notify_customer:
                  type: boolean
                  default: false
                  description: >-
                    Reserved. Accepted but not yet wired — customer email
                    notifications are not sent by the public API.
      responses:
        '200':
          description: Order fulfilled
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    allOf:
                      - $ref: '#/components/schemas/OrderDetail'
                      - type: object
                        properties:
                          fulfillment_errors:
                            type: array
                            items:
                              type: string
                required:
                  - success
                  - data
        '400':
          description: Order already fulfilled / cancelled / fulfilment failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing, invalid, revoked, or expired API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: API key lacks the required scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Order not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (120 req/min/key)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth:
            - write
components:
  schemas:
    OrderDetail:
      type: object
      properties:
        id:
          type: string
        order_number:
          type: string
        platform:
          type: string
        customer_name:
          type: string
        customer_email:
          type:
            - string
            - 'null'
        customer_phone:
          type:
            - string
            - 'null'
        order_date:
          type: string
        status:
          type:
            - string
            - 'null'
        total_revenue:
          type: number
        shipping_cost:
          type:
            - number
            - 'null'
        tax_amount:
          type:
            - number
            - 'null'
        discount_amount:
          type:
            - number
            - 'null'
        shipping_street:
          type:
            - string
            - 'null'
        shipping_city:
          type:
            - string
            - 'null'
        shipping_state:
          type:
            - string
            - 'null'
        shipping_zip:
          type:
            - string
            - 'null'
        shipping_country:
          type:
            - string
            - 'null'
        tracking_number:
          type:
            - string
            - 'null'
        tracking_url:
          type:
            - string
            - 'null'
        shipped_at:
          type:
            - string
            - 'null'
        external_id:
          type:
            - string
            - 'null'
        notes:
          type:
            - string
            - 'null'
        created_at:
          type:
            - string
            - 'null'
        updated_at:
          type:
            - string
            - 'null'
        items:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              product_sku_id:
                type:
                  - string
                  - 'null'
              sku:
                type: string
              product_name:
                type: string
              quantity:
                type: number
              unit_price:
                type: number
              total_price:
                type: number
              quantity_fulfilled:
                type:
                  - number
                  - 'null'
              fulfillment_status:
                type:
                  - string
                  - 'null'
              notes:
                type:
                  - string
                  - 'null'
              created_at:
                type:
                  - string
                  - 'null'
            required:
              - id
              - product_sku_id
              - sku
              - product_name
              - quantity
              - unit_price
              - total_price
              - quantity_fulfilled
              - fulfillment_status
              - notes
              - created_at
      required:
        - id
        - order_number
        - platform
        - customer_name
        - customer_email
        - customer_phone
        - order_date
        - status
        - total_revenue
        - shipping_cost
        - tax_amount
        - discount_amount
        - shipping_street
        - shipping_city
        - shipping_state
        - shipping_zip
        - shipping_country
        - tracking_number
        - tracking_url
        - shipped_at
        - external_id
        - notes
        - created_at
        - updated_at
        - items
    Error:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                Machine-readable error code (e.g. NOT_FOUND, VALIDATION_ERROR,
                FORBIDDEN, HUB_OFFLINE). Stable across releases — use this for
                branching.
              example: NOT_FOUND
            message:
              type: string
              description: >-
                Human-readable error message. May vary across releases — do not
                branch on this.
              example: Resource not found
            details:
              description: >-
                Optional structured detail. For VALIDATION_ERROR this is `{
                field: [messages] }`.
          required:
            - code
            - message
          description: Error detail object
      required:
        - success
        - error
      description: Standard error response envelope
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: apf_live_<64 hex>
      description: >-
        API keys are minted in the AutoPrintFarm web app under Settings → API
        Keys. Send as `Authorization: Bearer apf_live_...`. Keys are shown
        exactly once at creation and can be revoked at any time.

````