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

# Create a print file record from an uploaded file

> Pairs with `/files/upload-url` + `/files/upload/{token}`. **Side effect:** triggers synchronous 3MF/GCODE metadata extraction + thumbnail upload, then queues a backup extraction job onto FILE_PROCESSING.



## OpenAPI

````yaml /api-reference/openapi.json post /files
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:
  /files:
    post:
      tags:
        - Files
      summary: Create a print file record from an uploaded file
      description: >-
        Pairs with `/files/upload-url` + `/files/upload/{token}`. **Side
        effect:** triggers synchronous 3MF/GCODE metadata extraction + thumbnail
        upload, then queues a backup extraction job onto FILE_PROCESSING.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    Print filename; must match the filename segment of
                    `storage_key` and use a supported extension.
                storage_key:
                  type: string
                  minLength: 1
                  description: >-
                    Storage key for the uploaded file, taken verbatim from the
                    `storage_key` field returned by `POST /files/upload-url`.
                product_id:
                  type: string
                  description: Optional product to associate the file with.
                number_of_units:
                  type: integer
                  minimum: 1
                  default: 1
                  description: >-
                    How many physical units this print produces per run (e.g. a
                    4-up plate = 4).
              required:
                - name
                - storage_key
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      name:
                        type: string
                      product_id:
                        type:
                          - string
                          - 'null'
                      file_size_bytes:
                        type:
                          - number
                          - 'null'
                      number_of_units:
                        type:
                          - number
                          - 'null'
                      print_time_seconds:
                        type:
                          - number
                          - 'null'
                      filament_weight_grams:
                        type:
                          - number
                          - 'null'
                      filament_length_meters:
                        type:
                          - number
                          - 'null'
                      filament_type:
                        type:
                          - string
                          - 'null'
                      printer_model_id:
                        type:
                          - string
                          - 'null'
                      nozzle_diameter:
                        type:
                          - number
                          - 'null'
                      layer_count:
                        type:
                          - number
                          - 'null'
                      curr_bed_type:
                        type:
                          - string
                          - 'null'
                      default_print_profile:
                        type:
                          - string
                          - 'null'
                      object_count:
                        type:
                          - number
                          - 'null'
                        description: >-
                          Raw count of objects on the plate, as detected by the
                          slicer parser. NOT a yield: two halves of one model
                          are 2 objects but 1 sellable unit. Only use this as a
                          fallback when `units_per_plate` is null.
                      unique_object_count:
                        type:
                          - number
                          - 'null'
                        description: Distinct geometries on the plate (display hint).
                      units_per_plate:
                        type:
                          - number
                          - 'null'
                        description: >-
                          Authoritative sellable units produced by one print of
                          this plate. Seeded from the parser and editable by the
                          operator. Null only for files parsed before this field
                          existed.
                      has_thumbnail:
                        type: boolean
                      created_at:
                        type:
                          - string
                          - 'null'
                      updated_at:
                        type:
                          - string
                          - 'null'
                    required:
                      - id
                      - name
                      - product_id
                      - file_size_bytes
                      - number_of_units
                      - print_time_seconds
                      - filament_weight_grams
                      - filament_length_meters
                      - filament_type
                      - printer_model_id
                      - nozzle_diameter
                      - layer_count
                      - curr_bed_type
                      - default_print_profile
                      - object_count
                      - unique_object_count
                      - units_per_plate
                      - has_thumbnail
                      - created_at
                      - updated_at
                required:
                  - success
                  - data
        '400':
          description: Validation or business-rule error
          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: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Duplicate name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: File exceeds maximum allowed size
          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:
    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.

````