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

# Create/update invoice



## OpenAPI

````yaml /openapi/openapi.json post /sales/invoice
openapi: 3.1.0
info:
  title: OpenAPI
  version: '1.0'
  summary: OpenApi
  contact:
    name: Altera Support
    url: https://altera.co
    email: wsparcie@altera.co
  description: ''
  license:
    url: https://altera.co/regulamin
    name: Terms of services for Altera.app
servers:
  - url: https://api.altera.co
    description: Production endpoint (proxied)
security:
  - Authorization: []
tags:
  - name: Configuration
  - name: Data export
  - name: Expenses
  - name: Sales
paths:
  /sales/invoice:
    parameters: []
    post:
      tags:
        - Sales
      summary: Create/update invoice
      operationId: post-sales
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceDtoIn'
            examples:
              Example 1:
                value:
                  modelType: INVOICE
                  override: false
                  basicInformation:
                    invoiceId: 2069
                    invoiceType: SALES
                    invoiceFormat: '%N/%M/%Y'
                    saleDate: '2022-10-11T00:00:00.000Z'
                    issueDate: '2022-10-11T00:00:00.000Z'
                    isReceipt: false
                    relatedInvoicesIds: []
                    priceTypeId: NET
                  contractor:
                    contractorRegion: POLAND
                    country: PL
                    contractorType: COMPANY
                    contractorName: Test działania
                    street: Testowa
                    houseNumber: '10'
                    flatNumber: '10'
                    city: Bydgoszcz
                    postCode: 62-156
                    defaultCurrency: PLN
                    taxIdentificationNumber: '1589651654'
                    email: testing@attention.please
                    areaNumber: '+58'
                    phoneNumber: 518 961 516
                  invoicePosition:
                    - productPosition: 0
                      productName: A
                      positionType: PRODUCT
                      productCategory: Health
                      quantity: 10
                      unit: szt.
                      priceType: null
                      unitNetPrice: 150
                      unitGrossPrice: 184.5
                      vat: 23%
                      pkwiu: ''
                      discount: '0'
                      deductions: false
                      netPrice: '1500'
                      grossPrice: '1845'
                      invoiceProductId: 179
                  additionalDetails: ''
                  correctionReason: ''
                  payments:
                    isPaid: false
                    paymentMethod: TRANSFER
                    dueDate: '2022-10-25T00:00:00.000Z'
                    bankAccountNumber: 10 1010 1062 5565 1561 5615 1516
                    isSplitPayment: false
                  projects: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      data:
                        type: object
                        x-stoplight:
                          id: 81aw0gcdvcsye
                        properties:
                          invoiceId:
                            type: number
                            x-stoplight:
                              id: ng63zj0yg4qvv
                            example: 12413
                  - $ref: '#/components/schemas/SuccessResponse'
                    x-stoplight:
                      id: wfh8d9tigst1z
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    InvoiceDtoIn:
      type: object
      x-examples:
        Example 1:
          modelType: INVOICE
          override: false
          basicInformation:
            invoiceId: 2069
            invoiceType: SALES
            invoiceFormat: '%N/%M/%Y'
            saleDate: '2022-10-11T00:00:00.000Z'
            issueDate: '2022-10-11T00:00:00.000Z'
            isReceipt: false
            relatedInvoicesIds: []
            priceTypeId: NET
          contractor:
            contractorRegion: POLAND
            country: PL
            contractorType: COMPANY
            contractorName: Test działania
            street: Testowa
            houseNumber: '10'
            flatNumber: '10'
            city: Bydgoszcz
            postCode: 62-156
            defaultCurrency: PLN
            taxIdentificationNumber: '1589651654'
            email: testing@attention.please
            areaNumber: '+58'
            phoneNumber: 518 961 516
          invoicePosition:
            - productPosition: 0
              productName: A
              positionType: PRODUCT
              productCategory: Health
              quantity: 10
              unit: szt.
              priceType: null
              unitNetPrice: 150
              unitGrossPrice: 184.5
              vat: 23%
              pkwiu: ''
              discount: '0'
              deductions: false
              netPrice: '1500'
              grossPrice: '1845'
              invoiceProductId: 179
          additionalDetails: ''
          correctionReason: ''
          payments:
            isPaid: false
            paymentMethod: TRANSFER
            dueDate: '2022-10-25T00:00:00.000Z'
            bankAccountNumber: 10 1010 1062 5565 1561 5615 1516
            isSplitPayment: false
          projects: []
      examples:
        - modelType: INVOICE
          override: false
          basicInformation:
            invoiceType: SALES
            invoiceFormat: '%N/%M/%Y'
            saleDate: '2022-10-11T00:00:00.000Z'
            issueDate: '2022-10-11T00:00:00.000Z'
            isReceipt: false
            relatedInvoicesIds: []
            priceTypeId: NET
            statusId: DRAFT
          contractor:
            contractorRegion: POLAND
            country: PL
            contractorType: COMPANY
            contractorName: Test działania
            street: Testowa
            houseNumber: '10'
            flatNumber: '10'
            city: Bydgoszcz
            postCode: 62-156
            defaultCurrency: PLN
            taxIdentificationNumber: '1589651654'
            email: testing@attention.please
            areaNumber: '+58'
            phoneNumber: 518 961 516
          invoicePosition:
            - productPosition: 0
              productName: A
              positionType: PRODUCT
              productCategory: Health
              quantity: 10
              unit: szt.
              unitNetPrice: 150
              unitGrossPrice: 184.5
              vat: 23%
              pkwiu: ''
              discount: '0'
              deductions: false
              netPrice: '1500'
              grossPrice: '1845'
              invoiceProductId: 179
          additionalDetails: ''
          correctionReason: ''
          payments:
            isPaid: false
            paymentMethod: TRANSFER
            dueDate: '2022-10-25T00:00:00.000Z'
            bankAccountNumber: 10 1010 1062 5565 1561 5615 1516
            isSplitPayment: false
        - modelType: INVOICE
          override: false
          sendToKSEF: true
          basicInformation:
            invoiceId: 2069
            invoiceType: SALES
            invoiceFormat: '%N/%M/%Y'
            saleDate: '2022-10-11T00:00:00.000Z'
            issueDate: '2022-10-11T00:00:00.000Z'
            isReceipt: false
            relatedInvoicesIds: []
            priceTypeId: NET
            statusId: ISSUED
          contractor:
            contractorRegion: POLAND
            country: PL
            contractorType: COMPANY
            contractorName: Test działania
            street: Testowa
            houseNumber: '10'
            flatNumber: '10'
            city: Bydgoszcz
            postCode: 62-156
            defaultCurrency: PLN
            taxIdentificationNumber: '1589651654'
            email: testing@attention.please
            areaNumber: '+58'
            phoneNumber: 518 961 516
          invoicePosition:
            - productPosition: 0
              productName: A
              positionType: PRODUCT
              productCategory: Health
              quantity: 10
              unit: szt.
              unitNetPrice: 150
              unitGrossPrice: 184.5
              vat: 23%
              pkwiu: ''
              discount: '0'
              deductions: false
              netPrice: '1500'
              grossPrice: '1845'
              invoiceProductId: 179
          additionalDetails: ''
          correctionReason: ''
          payments:
            isPaid: false
            paymentMethod: TRANSFER
            dueDate: '2022-10-25T00:00:00.000Z'
            bankAccountNumber: 10 1010 1062 5565 1561 5615 1516
            isSplitPayment: false
      properties:
        override:
          type: boolean
          default: false
          description: >-
            Defines whether we wish to override split payments warning, in
            Machine-machine integrations should be set to `true`
        sendToKSEF:
          type: boolean
          description: Submit the invoice to KSeF during save.
          default: false
        basicInformation:
          type: object
          required:
            - invoiceType
            - invoiceFormat
            - saleDate
            - issueDate
            - priceTypeId
          properties:
            invoiceId:
              type: integer
              description: Invoice identificator, used for updating documents
            invoiceType:
              type: string
              enum:
                - SALES
                - PRO_FORMA
                - INTERIM
                - INTERIM_FINAL
                - CORRECTION
              example: SALES
              description: The type of invoice we wish to create
            invoiceFormat:
              type: string
              example: '%N/%M/%Y'
              description: >-
                Defines the Invoice numbering format that will be used; Altera
                providesa set of pre-defined formats right after company
                creation. They can be reviewed in the UI
            saleDate:
              type: string
            issueDate:
              type: string
            isReceipt:
              type: boolean
              description: >-
                Defines whether we are creating an invoice to an already issued
                receipt
            relatedInvoicesIds:
              type: array
              description: >-
                Optional array of invoiceIds that should be related to the
                document we are creating; Rule of thumb if you wish to work with
                relatedInvoices (CORRECTION, INTERIM_FINAL) it is best to start
                from th pre-populated object retrieved via GET /sales/invoice
                with parameter `related` in use
              items:
                type: object
            priceTypeId:
              type: string
              enum:
                - NET
                - GROSS
              default: NET
              example: NET
            statusId:
              x-stoplight:
                id: 94k63xf3cdiyb
              example: ISSUED
              enum:
                - DRAFT
                - ISSUED
              default: DRAFT
        contractor:
          type: object
          properties:
            contractorRegion:
              type: string
              enum:
                - EU
                - OUTSIDE_OF_EU
                - POLAND
              example: POLAND
            country:
              type: string
              maxLength: 2
              example: PL
              description: ISO 3166-1 alfa-2 two letter country code
            contractorType:
              type: string
              enum:
                - COMPANY
                - PRIVATE_PERSON
              example: COMPANY
            contractorName:
              type: string
            street:
              type: string
            houseNumber:
              type: string
            flatNumber:
              type: string
            city:
              type: string
            postCode:
              type: string
            defaultCurrency:
              type: string
            taxIdentificationNumber:
              type: string
              maxLength: 45
            email:
              type: string
              maxLength: 200
              description: Comma delimited list of contractor e-mails
            areaNumber:
              type: string
              maxLength: 5
            phoneNumber:
              type: string
              maxLength: 45
        invoicePosition:
          type: array
          items:
            type: object
            properties:
              productPosition:
                type: integer
                example: 0
                description: Zero based position number in invoice
              productName:
                type: string
                maxLength: 200
              positionType:
                type: string
                enum:
                  - PRODUCT
                  - SERVICE
                example: SERVICE
              productCategory:
                type: string
                description: Allows grouping of similar products
                example: Personalized
              quantity:
                type: number
                example: 14
              unit:
                type: string
                example: pcs.
              unitNetPrice:
                type: number
                description: Defines the net price per item
                example: 100
              unitGrossPrice:
                type: number
                description: 'Defines the gross price per item '
                example: 123
              vat:
                type: string
                enum:
                  - 23%
                  - 8%
                  - 5%
                  - 0%
                  - np
                  - zw
                example: 23%
                description: Defines the vat rate used for this product
              pkwiu:
                type: string
              discount:
                type: string
                example: 10%
                description: Defines % discount on given product
              invoiceProductId:
                type: integer
        additionalDetails:
          type: string
          description: Describes extra information that we wish to present on the invoice
        correctionReason:
          type: string
          description: >-
            Additional information regarding the reason behing correcting your
            invoice
        payments:
          type: object
          properties:
            isPaid:
              type: boolean
            paymentMethod:
              type: string
              enum:
                - TRANSFER
                - CASH
                - CARD
              example: TRANSFER
            dueDate:
              type: string
            bankAccountNumber:
              type: string
              description: Defines the bank account no. we wish to receive funds to
            isSplitPayment:
              type: boolean
      description: ''
    SuccessResponse:
      title: SuccessResponse
      x-stoplight:
        id: yqo2bqzd7zztg
      type: object
      properties:
        result:
          type: string
          x-stoplight:
            id: 22hlosab8poxg
          default: OK
          example: OK
          enum:
            - OK
        data:
          type: object
          x-stoplight:
            id: i58aambagr5xn
      examples:
        - result: OK
          data:
            invoiceId: 12413
      description: |-
        Regular format of success response in Altera API
        Retrieved information will always be stored in the 'data' node
    ErrorResponse:
      type: object
      x-examples:
        Example 1:
          result: Error
          errorMessage: >-
            This tag cannot be deleted, it has been used in at least one
            invoice. You can disable it so it won't appear on the suggestion
            lists.
          errorMessagePL: >-
            Ta kategoria nie może zostać usunięta ponieważ została użyta w
            przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała
            się na liście sugerowanych.
      examples:
        - result: Error
          errorMessage: >-
            This tag cannot be deleted, it has been used in at least one
            invoice. You can disable it so it won't appear on the suggestion
            lists.
          errorMessagePL: >-
            Ta kategoria nie może zostać usunięta ponieważ została użyta w
            przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała
            się na liście sugerowanych.
      properties:
        result:
          type: string
          enum:
            - Error
          default: Error
          example: Error
        errorMessage:
          type: string
        errorMessagePL:
          type: string
      description: >-
        Default error message format in Altera API

        Depending on particular reason, different HTTP Status codes will be
        employed
  securitySchemes:
    Authorization:
      name: Authorization
      type: apiKey
      in: header
      description: OpenApi Key created within Altera.app for a certain company

````