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

# Crear una nueva factura

> Crear una nueva factura con la posibilidad de crear un contacto nuevo o usar uno existente



## OpenAPI

````yaml post /invoice
openapi: 3.0.0
info:
  version: 1.0.0
  title: Fint API
  description: Fint API
servers:
  - url: https://api.fint.app/api/v1
    variables: {}
security: []
paths:
  /invoice:
    post:
      tags:
        - Facturas
      summary: Crear una nueva factura
      description: >-
        Crear una nueva factura con la posibilidad de crear un contacto nuevo o
        usar uno existente
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                contactId:
                  type: number
                description:
                  type: string
                date:
                  type: string
                totalAmount:
                  type: number
                  description: >-
                    Monto total de la factura, si se envia items el monto va a
                    ser ignorado
                expirationDate:
                  type: string
                externalReference:
                  type: string
                newContact:
                  type: object
                  properties:
                    externalReference:
                      type: string
                    name:
                      type: string
                    lastName:
                      type: string
                    documentType:
                      type: string
                      enum:
                        - DNI
                        - CUIT
                        - CUIL
                        - CDI
                        - LE
                        - LC
                        - CI Extranjera
                        - Pasaporte
                        - CI Policía Federal
                        - Certificado de Migración
                        - RUT
                        - Otro
                    documentNumber:
                      type: string
                    email:
                      type: string
                      format: email
                    phoneNumber:
                      type: string
                    address:
                      type: string
                    country:
                      type: string
                    metadata:
                      type: object
                      additionalProperties:
                        nullable: true
                      description: >-
                        Informacion adicional que luego se puede consumir y
                        llegara en los webhooks
                    payerContact:
                      type: object
                      properties:
                        name:
                          type: string
                        lastName:
                          type: string
                        documentType:
                          type: string
                          enum:
                            - DNI
                            - CUIT
                            - CUIL
                            - CDI
                            - LE
                            - LC
                            - CI Extranjera
                            - Pasaporte
                            - CI Policía Federal
                            - Certificado de Migración
                            - RUT
                            - Otro
                        documentNumber:
                          type: string
                        email:
                          type: string
                          format: email
                        phoneNumber:
                          type: string
                        address:
                          type: string
                        country:
                          type: string
                      required:
                        - name
                        - lastName
                        - documentType
                        - documentNumber
                        - email
                        - phoneNumber
                    tagGroup:
                      type: object
                      properties:
                        name:
                          type: string
                      required:
                        - name
                    tags:
                      type: array
                      items:
                        type: object
                        properties:
                          name:
                            type: string
                        required:
                          - name
                    sendPortalInvite:
                      type: boolean
                      default: true
                  required:
                    - name
                    - lastName
                sendEmail:
                  type: boolean
                  default: true
                  description: >-
                    Envía email a los pagadores del contacto con acceso al
                    portal para que page la factura.
                items:
                  type: array
                  nullable: true
                  items:
                    type: object
                    properties:
                      itemId:
                        type: number
                      quantity:
                        type: number
                        default: 1
                        description: Cantidad de items a asociar a la factura
                    required:
                      - itemId
                  description: >-
                    Items de tipo subscription (one_time) o settlement
                    (condition: none). Todos los items deben tener el mismo
                    useCase. Si items esta presente el totalAmount va a ser
                    autocalculado.
                itemGroups:
                  type: array
                  nullable: true
                  items:
                    type: object
                    properties:
                      itemGroupId:
                        type: number
                      selectedItems:
                        type: array
                        nullable: true
                        items:
                          type: object
                          properties:
                            itemId:
                              type: number
                            quantity:
                              type: number
                              default: 1
                              description: Cantidad de items a asociar a la factura
                          required:
                            - itemId
                    required:
                      - itemGroupId
                serviceCost:
                  type: object
                  properties:
                    cost:
                      type: number
                    percentage:
                      type: number
                  required:
                    - cost
                    - percentage
                customItems:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                      description:
                        type: string
                      amount:
                        type: number
                      type:
                        type: string
                        enum:
                          - credit
                          - debit
                      quantity:
                        type: number
                      details:
                        oneOf:
                          - type: object
                            properties:
                              source:
                                type: string
                                enum:
                                  - item
                              discountItemId:
                                type: number
                              amountType:
                                type: string
                              configuredAmount:
                                type: number
                              condition:
                                type: string
                              conditionItems:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: number
                                  required:
                                    - id
                              baseAmount:
                                type: number
                                nullable: true
                              appliedAmount:
                                type: number
                              maxDiscountAmount:
                                type: number
                                nullable: true
                              cartItems:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    itemId:
                                      type: number
                                    totalAmount:
                                      type: number
                                  required:
                                    - itemId
                                    - totalAmount
                              breakdown:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    itemId:
                                      type: number
                                    discountAmount:
                                      type: number
                                  required:
                                    - itemId
                                    - discountAmount
                            required:
                              - source
                              - discountItemId
                              - amountType
                              - configuredAmount
                              - condition
                              - conditionItems
                              - baseAmount
                              - appliedAmount
                              - maxDiscountAmount
                              - cartItems
                              - breakdown
                          - type: object
                            properties:
                              source:
                                type: string
                                enum:
                                  - manual
                              condition:
                                type: string
                              conditionItems:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: number
                                  required:
                                    - id
                              appliedAmount:
                                type: number
                              cartItems:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    itemId:
                                      type: number
                                    totalAmount:
                                      type: number
                                  required:
                                    - itemId
                                    - totalAmount
                              breakdown:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    itemId:
                                      type: number
                                    discountAmount:
                                      type: number
                                  required:
                                    - itemId
                                    - discountAmount
                            required:
                              - source
                    required:
                      - name
                      - amount
                      - type
                      - quantity
              required:
                - date
                - expirationDate
      responses:
        '201':
          description: Factura creada con éxito
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoiceId:
                    type: number
                  contactId:
                    type: number
                required:
                  - invoiceId
                  - contactId
        '400':
          description: Bad request, invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      Error message. Possible values:

                      - "Item in draft status cannot be added to an invoice"

                      - "Item of type settlement cannot be added to an invoice
                      manually yet"

                      - "Item of type recurring cannot be added to an invoice
                      manually yet"

                      - "Total amount does not match the sum of the items"
                required:
                  - message
        '404':
          description: Resources not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      Error message. Format:

                      - For items not found: "Items not found:
                      {itemId1},{itemId2},..."

                      - For single item: "Item not found"- For contact not
                      found: "Contact not found"
                required:
                  - message
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````