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

# Create a new invoice

> Creates a new invoice with line items. Returns the invoice with calculated totals.



## OpenAPI

````yaml /openapi.json post /invoices
openapi: 3.1.1
info:
  title: Heffl Public API (Legacy v1)
  version: 1.0.0
  description: >-
    Legacy Heffl REST API v1. Maintained for existing integrations. For new
    projects, use API v2 at https://docs.heffl.com/api-v2/introduction.
  contact:
    name: Heffl Support
    url: https://heffl.com/support
    email: support@heffl.com
servers:
  - url: https://api.heffl.com/api/v1
    description: Production API Server
security:
  - ApiKeyAuth: []
paths:
  /invoices:
    post:
      tags:
        - Invoices
      summary: Create a new invoice
      description: >-
        Creates a new invoice with line items. Returns the invoice with
        calculated totals.
      operationId: invoices.create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                clientId:
                  type: string
                  description: Client public ID (required)
                date:
                  type: string
                  format: date-time
                  x-native-type: date
                  description: Invoice date
                dueDate:
                  type: string
                  format: date-time
                  x-native-type: date
                  description: Due date
                lineItems:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                        description: Line item name
                      productId:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: Product public ID (optional)
                      quantity:
                        type: number
                        minimum: 0
                        default: 0
                        description: Quantity
                      price:
                        type: number
                        minimum: 0
                        default: 0
                        description: Unit price
                      description:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: Line item description
                      taxRateId:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: Tax rate public ID
                      discount:
                        type: number
                        minimum: 0
                        default: 0
                        description: Discount value
                      discountType:
                        enum:
                          - fixed
                          - percent
                        default: fixed
                        description: 'Discount type: fixed amount or percent'
                      buyPrice:
                        type: number
                        minimum: 0
                        default: 0
                        description: Cost/buy price
                    required:
                      - name
                  description: Invoice line items
                isInclusiveTax:
                  type: boolean
                  default: false
                  description: Whether prices include tax
                status:
                  enum:
                    - DRAFT
                    - SENT
                  default: DRAFT
                  description: Invoice status (DRAFT or SENT)
                contactId:
                  anyOf:
                    - type: string
                    - type: 'null'
                  description: Contact public ID
                subject:
                  anyOf:
                    - type: string
                    - type: 'null'
                  description: Invoice subject
                notes:
                  anyOf:
                    - type: string
                    - type: 'null'
                  description: Invoice notes
                salesPersonId:
                  anyOf:
                    - type: string
                    - type: 'null'
                  description: Sales person user public ID
                templateId:
                  anyOf:
                    - type: string
                    - type: 'null'
                  description: >-
                    Document template public ID. If not provided, uses the
                    team's default invoice template.
                tags:
                  type: array
                  items:
                    type: number
                  default: []
                  description: Tag IDs to associate with the invoice
              required:
                - clientId
                - date
                - dueDate
                - lineItems
              additionalProperties: {}
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Invoice public ID
                  number:
                    type: string
                    description: Auto-generated invoice number
                  date:
                    type: string
                    format: date-time
                    x-native-type: date
                    description: Invoice date
                  dueDate:
                    type: string
                    format: date-time
                    x-native-type: date
                    description: Invoice due date
                  status:
                    type: string
                    description: Invoice status
                  clientId:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Client public ID
                  contactId:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Contact public ID
                  currency:
                    type: string
                    description: Currency code
                  isInclusiveTax:
                    type: boolean
                    description: Whether prices include tax
                  subject:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Invoice subject
                  notes:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Invoice notes
                  salesPersonId:
                    anyOf:
                      - type: number
                      - type: 'null'
                    description: Sales person user ID
                  subTotal:
                    type: number
                    description: Subtotal before tax
                  taxTotal:
                    type: number
                    description: Total tax amount
                  discountTotal:
                    type: number
                    description: Total discount amount
                  total:
                    type: number
                    description: Grand total
                  pendingTotal:
                    type: number
                    description: Amount pending
                  paidTotal:
                    type: number
                    description: Total amount paid
                  lineItems:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          description: Line item name
                        description:
                          anyOf:
                            - type: string
                            - type: 'null'
                          description: Line item description
                        productId:
                          anyOf:
                            - type: number
                            - type: 'null'
                          description: Product ID
                        quantity:
                          type: number
                          description: Quantity
                        price:
                          type: number
                          description: Unit price
                        tax:
                          type: number
                          description: Tax percentage
                        discount:
                          type: number
                          description: Discount value
                        discountType:
                          enum:
                            - fixed
                            - percent
                          description: Discount type
                        buyPrice:
                          type: number
                          description: Cost/buy price
                        viewType:
                          enum:
                            - LINE_ITEM
                            - HEADING
                          description: Line item type
                        amount:
                          type: number
                          description: Line total after discount and tax
                        taxAmount:
                          type: number
                          description: Tax amount for this line
                        discountAmount:
                          type: number
                          description: Discount amount for this line
                      required:
                        - name
                        - quantity
                        - price
                        - tax
                        - discount
                        - discountType
                        - buyPrice
                        - viewType
                        - amount
                        - taxAmount
                        - discountAmount
                    description: Invoice line items
                  createdAt:
                    type: string
                    format: date-time
                    x-native-type: date
                    description: When the invoice was created
                  customFields:
                    anyOf:
                      - type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      - type: 'null'
                    description: Custom field values
                required:
                  - id
                  - number
                  - date
                  - dueDate
                  - status
                  - currency
                  - isInclusiveTax
                  - subTotal
                  - taxTotal
                  - discountTotal
                  - total
                  - pendingTotal
                  - paidTotal
                  - lineItems
                  - createdAt
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Get yours at
        app.heffl.com/settings/developers

````