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

# Create supplier invoice

> Creates a draft invoice, optionally with items. The supplier is picked as `supplier_id` (its name copied once, contact fields not sent filled from the company); without it the supplier is copied from the PO of the first PO-linked item.



## OpenAPI

````yaml /openapi.yaml post /supplier_invoices
openapi: 3.0.1
info:
  title: GetSpecs REST API
  description: REST API documentation for GetSpecs.
  version: 1.0.0
servers:
  - url: /v1
  - url: https://demo-api.getspecs.io/v1
security: []
paths:
  /supplier_invoices:
    post:
      tags:
        - SupplierInvoice
      summary: Create supplier invoice
      description: >-
        Creates a draft invoice, optionally with items. The supplier is picked
        as `supplier_id` (its name copied once, contact fields not sent filled
        from the company); without it the supplier is copied from the PO of the
        first PO-linked item.
      operationId: supplier_invoices#create
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/requestBodySupplierInvoiceCreate'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/supplier_invoice'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      security:
        - apiKey: []
          workspaceId: []
components:
  schemas:
    requestBodySupplierInvoiceCreate:
      type: object
      description: >-
        The supplier is picked as `supplier_id`; its name is copied once (never
        changes afterwards) and the contact fields not sent are filled from the
        company. Without it the supplier (company and all supplier fields) is
        copied from the PO of the first PO-linked item.
      properties:
        invoice_number:
          type: string
          nullable: true
          description: >-
            Optional; when blank the next number of the workspace's generated
            `INV-0001` series is used. Unique per workspace and supplier.
        invoice_date:
          type: string
          format: date
        due_date:
          type: string
          format: date
          nullable: true
          description: >-
            Overrides the computed due date; null / blank goes back to computing
            it from the payment terms.
        currency:
          type: string
          nullable: true
          description: >-
            Blank = no currency. When not sent, defaults to the first linked
            PO's currency (even none), else the supplier's, else the workspace's
            (possibly none).
          example: PLN
        supplier_id:
          type: integer
          nullable: true
          description: >-
            A Contacts company of the workspace; PO-linked items must belong to
            orders of the same company.
        supplier_contact_name:
          type: string
          nullable: true
        supplier_contact_email:
          type: string
          nullable: true
        supplier_contact_phone:
          type: string
          nullable: true
        supplier_address:
          type: string
          nullable: true
        items:
          type: array
          items:
            $ref: '#/components/schemas/requestBodySupplierInvoiceItem'
      required:
        - invoice_date
    supplier_invoice:
      type: object
      properties:
        id:
          type: integer
        project_ids:
          type: array
          description: >-
            The projects of the invoice's items (PO item lines and extra
            charges), ascending. An invoice belongs to the workspace and may
            bill several projects.
          items:
            type: integer
        invoice_number:
          type: string
          description: >-
            The supplier's own invoice number, unique per workspace and
            supplier. Generated numbers continue the workspace's `INV-0001`
            series.
        invoice_date:
          type: string
          format: date
        due_date:
          type: string
          format: date
          nullable: true
          description: >-
            When the invoice should be paid. Computed as invoice_date + due_days
            of a payment line (see payment_terms_basis) unless typed in by hand
            (due_date_overridden); null without terms.
        due_date_overridden:
          type: boolean
          description: The due date was typed in by hand and is no longer computed.
        payment_terms_basis:
          type: object
          nullable: true
          description: >-
            The payment line the computed due date came from; null when typed in
            by hand or without terms.
          properties:
            source:
              type: string
              enum:
                - purchase_order
                - supplier
                - workspace_default
              description: >-
                `purchase_order`: a line of the order of the first PO-linked
                invoice line (the line this invoice starts billing, after the
                order's earlier invoices); `supplier` / `workspace_default`: the
                company's own terms or the workspace defaults (the first
                invoice-triggered one, else the first).
            purchase_order_id:
              type: integer
            payment_term_id:
              type: integer
              nullable: true
            label:
              type: string
            trigger:
              type: string
              enum:
                - order
                - delivery
                - invoice
            due_days:
              type: integer
        overdue:
          type: boolean
          description: Not fully paid and due before today; never for a cancelled invoice.
        currency:
          type: string
          nullable: true
          example: PLN
        net_amount:
          type: string
          description: Σ item quantity × unit price (extra charges included), 2 decimals.
        paid_amount:
          type: string
          description: Σ payments, 2 decimals.
        outstanding_amount:
          type: string
          description: net_amount − paid_amount.
        payment_status:
          type: string
          enum:
            - unpaid
            - partially_paid
            - paid
        purchase_orders:
          type: array
          description: >-
            The purchase orders this invoice bills, with this invoice's amounts
            per PO (summed over the PO's projects).
          items:
            type: object
            properties:
              id:
                type: integer
              label:
                type: string
              project_ids:
                type: array
                description: The projects this invoice bills the PO on, ascending.
                items:
                  type: integer
              items_amount:
                type: string
                description: Σ of the invoice items billing this PO.
              invoiced_amount:
                type: string
                description: >-
                  This PO's share of the invoice net amount — its items amount
                  plus a proportional share of the unlinked extra charges of the
                  same project.
              paid_amount:
                type: string
                description: Σ of this invoice's payment allocations to this PO.
        status:
          type: string
          enum:
            - draft
            - matched
            - on_hold
            - approved
            - cancelled
        matched_at:
          type: string
          format: date-time
          nullable: true
        exceptions_accepted_at:
          type: string
          format: date-time
          nullable: true
        exceptions_accepted_by_id:
          type: integer
          nullable: true
        exceptions_acceptance_note:
          type: string
          nullable: true
        position:
          type: integer
        supplier_id:
          type: integer
          description: >-
            The supplier, a Contacts company of the workspace (may no longer
            exist).
        supplier_company_name:
          type: string
          description: >-
            The company's name when the invoice got its supplier (copied from
            the PO, or picked); never changes afterwards.
        supplier_contact_name:
          type: string
          nullable: true
        supplier_contact_email:
          type: string
          nullable: true
        supplier_contact_phone:
          type: string
          nullable: true
        supplier_address:
          type: string
          nullable: true
        created_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        items:
          type: array
          description: Not on the list endpoint. Ordered by position descending.
          items:
            $ref: '#/components/schemas/supplier_invoice_item'
        attachments:
          type: array
          description: Not on the list endpoint. Newest first.
          items:
            $ref: '#/components/schemas/attachment'
        payments:
          type: array
          description: Not on the list endpoint. Newest payment first.
          items:
            $ref: '#/components/schemas/supplier_invoice_payment'
      required:
        - id
        - project_ids
        - invoice_number
        - invoice_date
        - currency
        - net_amount
        - paid_amount
        - outstanding_amount
        - payment_status
        - status
        - supplier_id
        - supplier_company_name
    error:
      type: object
      properties:
        error:
          type: string
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                nullable: true
              code:
                type: string
                nullable: true
              message:
                type: string
            required:
              - message
    requestBodySupplierInvoiceItem:
      type: object
      description: >-
        With `purchase_order_item_id` the item bills that PO item (same supplier
        and currency, PO open or closed); without it it is an extra charge and
        `description` is required.
      properties:
        purchase_order_item_id:
          type: integer
          nullable: true
        charge_purchase_order_id:
          type: integer
          nullable: true
          description: >-
            Extra charges only — the PO the charge belongs to (same checks as a
            PO item line); its whole amount goes to that PO. Unlinked charges
            are spread across the invoice's POs; an invoice with nothing linked
            is a non-PO cost. Setting `purchase_order_item_id` without this key
            clears it.
        project_id:
          type: integer
          nullable: true
          description: >-
            Extra charges only (PO item lines take their PO item's project) —
            any project of the workspace. Defaults to the only candidate — a
            linked charge's PO's projects; an unlinked charge's projects billed
            on POs by the invoice's other items, else those items' projects —
            and is required when there are several or none. A linked charge's
            project must be one of its PO's; when the invoice bills POs, an
            unlinked charge's project must be one of the billed projects.
            Defaults to the project of `package_section_id` /
            `package_baseline_item_id` when sent.
        package_section_id:
          type: integer
          nullable: true
          description: >-
            Extra charges only (PO item lines copy their PO item's dimensions,
            values sent are ignored) — required; a section of a baselined
            package of the charge's project, counted there by the budget
            analysis. Defaults to the only candidate — a linked charge's PO's
            item sections in its project, else the sections of the invoice's
            other items in its project.
        package_id:
          type: integer
          nullable: true
          description: >-
            Extra charges only — optional; must be the package of
            `package_section_id`.
        category_id:
          type: integer
          nullable: true
          description: Extra charges only — optional workspace category; blank clears it.
        package_baseline_item_id:
          type: integer
          nullable: true
          description: >-
            Extra charges only — optional baseline row of the charge's project
            (baselined package); the package, section and category are copied
            from it (an `package_section_id` sent along must match).
        description:
          type: string
          nullable: true
        quantity:
          type: string
          example: '400'
        unit_price:
          type: string
          example: '10.00'
    supplier_invoice_item:
      type: object
      properties:
        id:
          type: integer
        supplier_invoice_id:
          type: integer
        project_id:
          type: integer
          description: A PO item line's PO item project; an extra charge's own project.
        purchase_order_item:
          type: object
          nullable: true
          description: >-
            The billed PO item; null for an extra charge (freight, packaging,
            ...), which is never matched. Carries the PO item's current budget
            dimensions; the line's own are a snapshot taken when it was saved,
            so they differ once the PO item is moved (section, category,
            baseline row) after billing.
          properties:
            id:
              type: integer
            purchase_order_id:
              type: integer
            label:
              type: string
            description:
              type: string
              nullable: true
            package_section_id:
              type: integer
            category_id:
              type: integer
              nullable: true
            package_baseline_item_id:
              type: integer
              nullable: true
        charge_purchase_order:
          type: object
          nullable: true
          description: >-
            Extra charges only — the PO the charge belongs to; null for PO item
            lines and unlinked charges.
          properties:
            id:
              type: integer
            label:
              type: string
        package_id:
          type: integer
          description: >-
            Budget dimensions — a PO item line's copied from its PO item, an
            extra charge's own.
        package_section_id:
          type: integer
        category_id:
          type: integer
          nullable: true
        category:
          type: string
          nullable: true
          description: The category text (named like a manual PO item's).
        package_baseline_item_id:
          type: integer
          nullable: true
        description:
          type: string
          nullable: true
        quantity:
          type: string
          example: '400.00'
        unit_price:
          type: string
          example: '10.00'
        amount:
          type: string
          description: quantity × unit price, 2 decimals.
        position:
          type: integer
        matches:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              goods_receipt_item_id:
                type: integer
                nullable: true
              inspection_id:
                type: integer
                nullable: true
              matched_quantity:
                type: string
              result:
                type: string
                enum:
                  - matched
                  - exception
              exception_reason:
                type: string
                nullable: true
                enum:
                  - price_variance
                  - quantity_exceeds_order
                  - quantity_not_received
                  - quantity_rejected
                  - quantity_not_inspected
                  - null
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - project_id
        - quantity
        - unit_price
        - amount
        - package_id
        - package_section_id
        - matches
    attachment:
      type: object
      description: >-
        A file attached to a procurement document (purchase order, supplier
        invoice, goods receipt or inspection), a project or a baseline row.
      properties:
        id:
          type: integer
        filename:
          type: string
          description: The name the file was uploaded with.
        content_type:
          type: string
          example: application/pdf
        byte_size:
          type: integer
        url:
          type: string
          description: >-
            Download URL. On private storage a signed URL that serves the file
            inline under its filename.
        created_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        deleted_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            When it was removed from its document. Documents list only files
            that are not removed; a purchase order revision lists the files it
            had, removed ones included (their `url` still works).
      required:
        - id
        - filename
        - content_type
        - byte_size
        - url
        - created_at
    supplier_invoice_payment:
      type: object
      properties:
        id:
          type: integer
        amount:
          type: string
          example: '2500.00'
        paid_on:
          type: string
          format: date
        reference:
          type: string
          nullable: true
          description: Bank / transfer reference.
        notes:
          type: string
          nullable: true
        allocations:
          type: array
          description: >-
            How the payment is split across the invoice's purchase orders (adds
            up to `amount`). One entry per PO, whichever projects the invoice
            bills it on.
          items:
            type: object
            properties:
              purchase_order:
                type: object
                properties:
                  id:
                    type: integer
                  label:
                    type: string
              amount:
                type: string
        created_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
      required:
        - id
        - amount
        - paid_on
  securitySchemes:
    apiKey:
      type: apiKey
      name: authorization
      in: header
    workspaceId:
      type: apiKey
      name: X-Workspace-ID
      in: header

````

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