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

# Add invoice lines

> Appends one or more line items to a draft invoice and recalculates the invoice total. The invoice must be in `draft` status and every line item must use the invoice currency. If any line item is invalid, the whole request fails and no line item is added.



## OpenAPI

````yaml reference/main-api.json POST /v2/invoices/{id}/add_lines
openapi: 3.1.0
info:
  title: fintoc-api
  version: v2026-02-01
servers:
  - url: https://api.fintoc.com
security: []
paths:
  /v2/invoices/{id}/add_lines:
    post:
      tags:
        - Invoices
      summary: Add invoice lines
      description: >-
        Appends one or more line items to a draft invoice and recalculates the
        invoice total. The invoice must be in `draft` status and every line item
        must use the invoice currency. If any line item is invalid, the whole
        request fails and no line item is added.
      operationId: v2.invoices-add-lines
      parameters:
        - name: id
          in: path
          description: The `id` of the invoice to add line items to.
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                lines:
                  type: array
                  minItems: 1
                  description: >-
                    Line items to append to the invoice. Must contain at least
                    one line item.
                  items:
                    type: object
                    properties:
                      amount:
                        type: integer
                        example: 30000
                        description: >-
                          Amount of the line item, in the smallest unit of
                          `currency` (for example, `30000` for $30000 CLP, since
                          CLP has no minor unit, or `3000` for $30.00 MXN). Must
                          be greater than 0.
                      currency:
                        type: string
                        enum:
                          - CLP
                          - MXN
                        example: CLP
                        description: >-
                          Currency of the line item, as an ISO 4217 code. Must
                          match the invoice currency.
                      period_end:
                        type: string
                        format: date-time
                        example: '2026-06-01T00:00:00Z'
                        description: >-
                          ISO 8601 datetime in UTC marking the end of the
                          billing period covered by the line item. Optional, but
                          must be provided together with `period_start` and be
                          after it. Omit both for invoices not tied to a
                          subscription.
                      period_start:
                        type: string
                        format: date-time
                        example: '2026-05-01T00:00:00Z'
                        description: >-
                          ISO 8601 datetime in UTC marking the start of the
                          billing period covered by the line item. Optional, but
                          must be provided together with `period_end`. Omit both
                          for invoices not tied to a subscription.
                      quantity:
                        type: integer
                        example: 1
                        description: >-
                          Number of units billed by the line item. Must be
                          greater than 0.
                      name:
                        type: string
                        description: Display name for the line item shown on the invoice.
                        example: Premium Plan
                      description:
                        type: string
                        maxLength: 200
                        example: A premium plan
                        description: >-
                          Additional details about the line item shown on the
                          invoice. Up to 200 characters.
                    required:
                      - amount
                      - currency
                      - quantity
                      - name
              required:
                - lines
            examples:
              add_lines:
                summary: Add a line item
                value:
                  lines:
                    - amount: 30000
                      currency: CLP
                      period_end: '2026-06-01T00:00:00Z'
                      period_start: '2026-05-01T00:00:00Z'
                      quantity: 1
                      name: Premium Plan
                      description: A premium plan
      responses:
        '200':
          description: >-
            The updated invoice, including the new line items and the
            recalculated total.
          content:
            application/json:
              examples:
                invoice_with_new_lines:
                  value:
                    id: inv_2bVdWxLpzXq8RkNcM3JtUv9AhTe
                    object: invoice
                    collection_method: charge_automatically
                    hosted_invoice_url: null
                    created_at: '2026-05-01T12:00:00Z'
                    currency: CLP
                    customer: cus_2bVdWyTnGq4PfLs7DkXjRm0CwIo
                    lines:
                      - id: il_2bVdX0PqJs6RhNu9FmZlTo2EyKq
                        object: line_item
                        name: Premium Plan
                        description: A premium plan
                        amount: 30000
                        currency: CLP
                        period_end: '2026-06-01T00:00:00Z'
                        period_start: '2026-05-01T00:00:00Z'
                        quantity: 1
                      - id: il_2bVdX1QrKt7SiOvAGnAmUp3FzLr
                        object: line_item
                        name: Premium Plan
                        description: A premium plan
                        amount: 20000
                        currency: CLP
                        period_end: '2026-06-01T00:00:00Z'
                        period_start: '2026-05-01T00:00:00Z'
                        quantity: 2
                    metadata: null
                    mode: live
                    payments: []
                    status: draft
                    subscription: sub_2bVdWzKfHr5QgMt8ElYkSn1DxJp
                    total: 50000
              schema:
                $ref: '#/components/schemas/invoice_v2'
        '400':
          description: >-
            Invalid request. The request has one of these issues: missing
            `lines`, invalid `amount` or `quantity`, a currency mismatch, a
            malformed date, or a `description` longer than 200 characters. It
            can also return when exactly one of `period_start` and `period_end`
            is provided, or when `period_end` is not after `period_start`.
          content:
            application/json:
              examples:
                invalid_currency:
                  value:
                    error:
                      type: invalid_request_error
                      code: invalid_currency
                      message: 'Invalid currency: XYZ'
                invalid_period:
                  value:
                    error:
                      type: invalid_request_error
                      code: invalid_period
                      message: period_end must be greater than period_start
              schema:
                $ref: '#/components/schemas/error_object'
        '401':
          description: Invalid or missing API key.
          content:
            application/json:
              examples:
                invalid_api_key:
                  value:
                    error:
                      type: authentication_error
                      code: invalid_api_key
                      message: 'Invalid API Key: invalid-*oken'
              schema:
                $ref: '#/components/schemas/error_object'
        '404':
          description: >-
            The invoice does not exist, belongs to another organization, or
            belongs to a different mode than the API key.
          content:
            application/json:
              examples:
                invoice_not_found:
                  value:
                    error:
                      type: invalid_request_error
                      code: missing_resource
                      param: id
                      message: 'No such invoicing/invoice: inv_fake'
                      doc_url: https://docs.fintoc.com/reference/errors
              schema:
                $ref: '#/components/schemas/error_object'
        '409':
          description: >-
            The invoice is not editable: line items can only be added while the
            invoice is in `draft` status.
          content:
            application/json:
              examples:
                invoice_not_editable:
                  value:
                    error:
                      type: invalid_request_error
                      code: invoice_not_editable
                      message: Invoice may only be edited when in draft status
              schema:
                $ref: '#/components/schemas/error_object'
      security:
        - api_key: []
components:
  schemas:
    invoice_v2:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          description: >-
            Unique identifier of the invoice. `null` on the preview invoice
            carried by an `invoice.upcoming` event, since Fintoc has not created
            that invoice yet.
          example: inv_2bVdWxLpzXq8RkNcM3JtUv9AhTe
        object:
          const: invoice
          description: Type of the object. Always `invoice`.
        attempt_count:
          type: integer
          description: >-
            Number of automatic charge attempts Fintoc has made on the invoice.
            `0` until the invoice is finalized and charged for the first time.
          example: 1
        collection_method:
          type: string
          enum:
            - charge_automatically
            - send_invoice
          description: >-
            The way Fintoc collects the invoice. `charge_automatically` means
            Fintoc charges `default_payment_method` once the invoice is
            finalized. `send_invoice` means Fintoc leaves the invoice open for
            you to collect, through `hosted_invoice_url` or outside Fintoc.
            Subscription invoices inherit the collection method when issued and
            keep that collection method even if the subscription changes later.
          example: send_invoice
        created_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            ISO 8601 timestamp of when the invoice was created. `null` on the
            preview invoice carried by an `invoice.upcoming` event, since that
            invoice does not exist yet.
          example: '2026-05-01T12:00:00Z'
        currency:
          type: string
          enum:
            - CLP
            - MXN
          description: >-
            Currency of the invoice, as an ISO 4217 code. Every line item uses
            this currency.
          example: CLP
        customer:
          type: string
          description: '`id` of the customer the invoice bills.'
          example: cus_2bVdWyTnGq4PfLs7DkXjRm0CwIo
        default_payment_method:
          type:
            - string
            - 'null'
          description: >-
            `id` of the payment method Fintoc charges when the invoice is
            finalized. `null` for invoices without one, such as subscription
            invoices.
          example: pm_2c4mDhAbCdEfGhIjKlMnOpQrStu
        external_payment:
          type: boolean
          description: >-
            Whether the invoice was settled with a payment collected outside
            Fintoc. `false` for invoices Fintoc collected, and for invoices that
            are not yet paid.
          example: false
        hosted_invoice_url:
          type:
            - string
            - 'null'
          description: >-
            URL of the hosted invoice page, where your customer can view and pay
            the invoice. `null` for invoices that are not `open`. In `test`
            mode, the URL points to the test mode portal.
          example: >-
            https://acme.billing.fintoc.com/invoices/inv_2bVdWxLpzXq8RkNcM3JtUv9AhTe
        lines:
          type: array
          description: Line items that make up the invoice total.
          items:
            $ref: '#/components/schemas/invoice_line_item'
        metadata:
          type: object
          description: >-
            Set of key-value pairs attached to the invoice. `{}` when the
            invoice has no metadata.
        mode:
          type: string
          enum:
            - live
            - test
          description: >-
            Mode of the invoice. `live` invoices use real data; `test` invoices
            use fake data for integration testing. An API key only sees invoices
            that share its mode.
          example: live
        next_payment_attempt_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            ISO 8601 timestamp of the next scheduled automatic charge attempt.
            `null` when no further attempt is scheduled. Also `null` on the
            preview invoice carried by an `invoice.upcoming` event, where
            `lines[].period_start` marks the charge date.
          example: '2026-05-02T12:00:00Z'
        payments:
          type: array
          description: >-
            Payment attempts to collect the invoice. If a Mexican direct debit
            charge fails validation before reaching the bank, Fintoc adds no
            payment. Examples include an amount out of range, an exceeded limit,
            or an inactive mandate. Fintoc doesn't retry the charge or send
            `invoice.payment_failed`.
          items:
            type: object
            properties:
              amount:
                type: integer
                description: >-
                  Amount of the payment, in the smallest unit of `currency` (for
                  example, `30000` for $30000 CLP, since CLP has no minor unit,
                  or `3000` for $30.00 MXN).
                example: 30000
              currency:
                type: string
                enum:
                  - CLP
                  - MXN
                description: >-
                  Currency of the payment, as an ISO 4217 code. Always matches
                  the invoice currency.
                example: CLP
              payment_intent:
                type: string
                description: '`id` of the payment intent created to collect the invoice.'
                example: pi_2bVdX2RsLu8TjPwBHoBnVq4G0Ms
              status:
                type: string
                enum:
                  - pending
                  - succeeded
                  - failed
                description: Status of the payment attempt.
                example: succeeded
            required:
              - amount
              - currency
              - payment_intent
              - status
        reason:
          type:
            - string
            - 'null'
          enum:
            - split_amount_mismatch
            - null
          description: >-
            Reason the invoice reports `inconsistent`. `split_amount_mismatch`
            means the `flat` split amounts do not add up to `total`, or a
            `percentage` split leaves an entity with no amount, so Fintoc cannot
            finalize the invoice. For every other status, the value is `null`.
          example: null
        split:
          type:
            - array
            - 'null'
          description: >-
            Rules for dividing the payment between entities. The rules come from
            the subscription when the invoice is issued, or from the invoice
            creation request. `null` when the invoice has no split.
          items:
            type: object
            properties:
              amount:
                type: integer
                description: >-
                  Portion of the payment the entity receives. For `flat` splits,
                  an amount in the smallest unit of `currency`. For `percentage`
                  splits, basis points, where `10000` means 100%, so `2550`
                  means 25.50%.
                example: 8500
              charge_processing_fee:
                type: boolean
                description: >-
                  If `true`, the entity pays part of the Fintoc processing fee,
                  based on the entry's share of the total `amount` among entries
                  that set `charge_processing_fee` to `true`. The fee is
                  deducted at disbursement and does not change the split
                  amounts.
                example: true
              entity_id:
                type: string
                description: >-
                  Unique identifier of the entity that receives this portion of
                  the payment.
                example: ent_xK9mPq2RkV3WnDQG
              inherited:
                type: boolean
                description: >-
                  If `true`, the split rule comes from the invoice's
                  subscription. If `false`, you declared the split rule on the
                  invoice, replacing the subscription's rule for this cycle
                  only.
                example: true
              metadata:
                type: object
                description: Set of key-value pairs you attached to the split entry.
              type:
                type: string
                enum:
                  - flat
                  - percentage
                description: >-
                  How `amount` is expressed. `flat` for a fixed amount in the
                  smallest unit of `currency`, or `percentage` for basis points.
                example: percentage
            required:
              - amount
              - charge_processing_fee
              - entity_id
              - inherited
              - metadata
              - type
        split_applied:
          type:
            - array
            - 'null'
          description: >-
            Portion of the latest payment attempt assigned to each entity. A
            redirected portion is credited to `redirected_to_entity_id` instead.
            `null` when the invoice has no split or has not been charged yet.
          items:
            type: object
            properties:
              calculated_amount:
                type: integer
                description: >-
                  Amount of this portion, in the smallest unit of `currency`.
                  Fintoc credits the portion to `entity_id`, or to
                  `redirected_to_entity_id` when `redirected` is `true`. For
                  `percentage` splits, the amount is calculated from the split's
                  basis points, and any rounding remainder goes to the first
                  entity with `charge_processing_fee` set to `true`.
                example: 25500
              charge_processing_fee:
                type: boolean
                description: >-
                  If `true`, the entity credited with this portion pays part of
                  the Fintoc processing fee, based on the entry's share of the
                  total `calculated_amount` among entries that set
                  `charge_processing_fee` to `true`. The fee is deducted at
                  disbursement and is not deducted from `calculated_amount`.
                example: true
              entity_id:
                type: string
                description: >-
                  Unique identifier of the entity you assigned this portion to.
                  When `redirected` is `true`, Fintoc credited the portion to
                  `redirected_to_entity_id` instead.
                example: ent_xK9mPq2RkV3WnDQG
              redirected:
                type: boolean
                description: >-
                  If `true`, Fintoc credited this portion to your organization's
                  root entity instead of `entity_id`. See `redirection_reason`
                  for why Fintoc redirected the portion. The amount does not
                  change.
                example: false
              redirected_to_entity_id:
                type:
                  - string
                  - 'null'
                description: >-
                  Unique identifier of the entity that received the portion
                  instead of `entity_id`. `null` unless `redirected` is `true`.
              redirection_reason:
                type:
                  - string
                  - 'null'
                enum:
                  - not_operational
                  - not_found
                  - null
                description: >-
                  Reason Fintoc redirected the portion. `not_operational` when
                  the entity has not completed its splits onboarding or is
                  paused, and `not_found` when the entity no longer exists.
                  `null` unless `redirected` is `true`.
            required:
              - calculated_amount
              - charge_processing_fee
              - entity_id
              - redirected
              - redirected_to_entity_id
              - redirection_reason
        status:
          type: string
          enum:
            - draft
            - open
            - paid
            - void
            - uncollectible
            - inconsistent
          description: >-
            Status of the invoice. Invoices start as `draft`, become `open` when
            finalized, and end as `paid`, `void`, or `uncollectible`. An
            `uncollectible` invoice is no longer expected to be paid. A draft
            whose `split` can no longer be applied to `total` reports
            `inconsistent` until you update `split` or `lines`. The `reason`
            field explains why. The preview invoice carried by an
            `invoice.upcoming` event reports `draft` and never appears when you
            list invoices.
          example: draft
        subscription:
          type:
            - string
            - 'null'
          description: >-
            `id` of the subscription the invoice belongs to. `null` for invoices
            not tied to a subscription.
          example: sub_2bVdWzKfHr5QgMt8ElYkSn1DxJp
        total:
          type: integer
          description: >-
            Total amount of the invoice, in the smallest unit of `currency` (for
            example, `30000` for $30000 CLP, since CLP has no minor unit, or
            `3000` for $30.00 MXN). Equals the sum of the line item amounts.
          example: 30000
      required:
        - id
        - hosted_invoice_url
        - object
        - attempt_count
        - collection_method
        - created_at
        - currency
        - customer
        - default_payment_method
        - external_payment
        - lines
        - metadata
        - mode
        - next_payment_attempt_at
        - payments
        - split
        - split_applied
        - status
        - reason
        - subscription
        - total
    error_object:
      type: object
      properties:
        error:
          type: object
          description: Details of the error that caused the request to fail.
          properties:
            code:
              type: string
              description: >-
                Machine-readable code identifying the specific error, for
                example `invalid_api_key`. Not returned by every error.
              example: invalid_api_key
            doc_url:
              type: string
              description: >-
                URL of a documentation page with more details about the error.
                Not returned by every error.
              example: https://docs.fintoc.com/reference/errors
            message:
              type: string
              description: Human-readable message describing the error.
              example: 'Invalid API Key: invalid-*oken'
            param:
              type:
                - string
                - 'null'
              description: >-
                Name of the request parameter that caused the error. `null` when
                the error cannot be tied to a single parameter, and not returned
                by every error.
              example: amount
            type:
              type: string
              description: >-
                Category of the error, for example `invalid_request_error`,
                `authentication_error`, or `api_error`.
              example: invalid_request_error
          required:
            - type
            - message
    invoice_line_item:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          description: >-
            Unique identifier of the line item. `null` on line items carried by
            an `invoice.upcoming` event, since the invoice they belong to does
            not exist yet.
          example: il_2bVdX0PqJs6RhNu9FmZlTo2EyKq
        object:
          const: line_item
          description: Type of the object. Always `line_item`.
        amount:
          type: integer
          description: >-
            Amount of the line item, in the smallest unit of `currency` (for
            example, `30000` for $30000 CLP, since CLP has no minor unit, or
            `3000` for $30.00 MXN).
          example: 30000
        currency:
          type: string
          enum:
            - CLP
            - MXN
          description: >-
            Currency of the line item, as an ISO 4217 code. Always matches the
            invoice currency.
          example: CLP
        description:
          type:
            - string
            - 'null'
          maxLength: 200
          description: >-
            Additional details about the line item shown on the invoice. Up to
            200 characters. `null` when the line item has no description.
          example: A premium plan
        name:
          type: string
          description: Display name for the line item shown on the invoice.
          example: Premium Plan
        period_end:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            ISO 8601 datetime in UTC marking the end of the billing period
            covered by the line item. `null` for line items on invoices not tied
            to a subscription.
          example: '2026-06-01T00:00:00Z'
        period_start:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            ISO 8601 datetime in UTC marking the start of the billing period
            covered by the line item. `null` for line items on invoices not tied
            to a subscription.
          example: '2026-05-01T00:00:00Z'
        quantity:
          type: integer
          description: Number of units billed by the line item.
          example: 1
      required:
        - id
        - object
        - name
        - description
        - amount
        - currency
        - period_end
        - period_start
        - quantity
  securitySchemes:
    api_key:
      type: apiKey
      name: Authorization
      in: header

````