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

# Create an invoice from a sale (draft or sent)



## OpenAPI

````yaml https://dev.flextell.ai/docs/api.json post /v1/invoices
openapi: 3.1.0
info:
  title: Flextell API
  version: 0.0.1
  description: '## Flextell API'
servers:
  - url: https://dev.flextell.ai/api
security:
  - oauth2: []
  - bearer: []
paths:
  /v1/invoices:
    post:
      tags:
        - Invoice
      summary: Create an invoice from a sale (draft or sent)
      operationId: invoice.store
      parameters:
        - name: X-Tenant
          in: header
          required: true
          description: >-
            Tenant identifier. Send the Tenant ID in the `X-Tenant` header to
            scope API requests to a specific tenant.
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceStoreRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '422':
          $ref: '#/components/responses/ValidationException'
components:
  schemas:
    InvoiceStoreRequest:
      type: object
      properties:
        sale_id:
          type: integer
          description: The sale ID.
          minimum: 1
        invoice_account_id:
          type: integer
          description: The invoice account ID.
          minimum: 1
        mode:
          type: string
          description: The mode of operation.
          enum:
            - draft
            - send
        series_name:
          type: string
          description: The invoice series name.
          maxLength: 50
        issue_date:
          type: string
          format: date-time
          description: The invoice issue date (YYYY-MM-DD).
        global_withholding_rate:
          type:
            - number
            - 'null'
          description: Global withholding tax rate as a percentage.
          minimum: 0
          maximum: 1
        use_passport_number:
          type:
            - boolean
            - 'null'
          description: Whether to use the passport number on the invoice.
        notes:
          type:
            - string
            - 'null'
          description: Internal notes.
          maxLength: 2000
        custom_line_items:
          type:
            - array
            - 'null'
          description: Custom invoice line items.
          items:
            type: object
            properties:
              name:
                type: string
                description: The custom line items.*.name.
                maxLength: 255
              quantity:
                type: number
                description: The custom line items.*.quantity.
                minimum: 0.01
              unit_price:
                type: number
                description: The custom line items.*.unit price.
                minimum: 0
              tax_rate:
                type: number
                description: The custom line items.*.tax rate.
                enum:
                  - '0'
                  - '1'
                  - '10'
                  - '20'
              vat_rate_percent:
                type: string
                description: The custom line items.*.vat rate percent.
      required:
        - sale_id
        - invoice_account_id
        - mode
        - series_name
        - issue_date
      title: InvoiceStoreRequest
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://dev.flextell.ai/oauth/authorize
          tokenUrl: https://dev.flextell.ai/oauth/token
          scopes:
            '*': all
    bearer:
      type: http
      scheme: bearer

````