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

# Sync invoices and payments

> Create or update invoices and their payments, including dedicated refunds, in one atomic request. Invoice balances are validated once, after all changes are applied.

Creates or updates invoices and their payments in one request. Layer applies the invoices first, then the payments and their dedicated refunds, and validates invoice balances once at the end.

The request is atomic. If any invoice, payment, or refund fails, nothing is saved.

## Request rules

* Send payments in the top-level `payments` list, not inside an invoice.
* If a payment pays several invoices, include all of those invoices in the same request.
* `external_id` values must be unique within `invoices` and within `payments`.
* Payments that you don't include are left unchanged.

## Example

```bash Request theme={null}
curl -X POST https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/sync \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "invoices": [
      {
        "external_id": "inv-1001",
        "customer_external_id": "customer-42",
        "sent_at": "2026-11-10T16:41:07Z",
        "line_items": [
          { "external_id": "inv-1001-line-1", "product": "Brake pads", "unit_price": 9000, "quantity": 1 }
        ]
      }
    ],
    "payments": [
      {
        "external_id": "pay-456",
        "paid_at": "2026-11-10T17:00:00Z",
        "method": "CREDIT_CARD",
        "amount": 10000,
        "invoice_payments": [{ "invoice_external_id": "inv-1001", "amount": 10000 }],
        "dedicated_refunds": [
          {
            "external_id": "ref-123",
            "completed_at": "2026-11-18T00:00:00Z",
            "method": "CREDIT_CARD",
            "line_items": [
              { "amount": 1000, "account_identifier": { "type": "StableName", "stable_name": "CUSTOMER_REFUNDS" } }
            ]
          }
        ]
      }
    ]
  }'
```

## Rate Limiting

This endpoint shares its rate limit with [Bulk create invoices](https://docs.layerfi.com/api-reference/v1/bulk-create-invoices.md) and [Batch create invoices](https://docs.layerfi.com/api-reference/v1/batch-create-invoices.md).

| Environment | Limit | Refill Period |
| - | - | - |
| Sandbox | 20 requests | 1 second |
| Production | 20 requests | 1 second |

For details on rate limit headers, see [Rate Limiting](https://docs.layerfi.com/api-details/rate-limiting.md).


## OpenAPI

````yaml post /v1/businesses/{businessId}/invoices/sync
openapi: 3.0.1
info:
  title: API
  version: latest
servers: []
security:
  - BearerAuth: []
tags: []
externalDocs:
  url: /
paths:
  /v1/businesses/{businessId}/invoices/sync:
    post:
      tags: []
      summary: Sync invoices and payments
      description: >-
        Create or update invoices and their payments, including dedicated
        refunds, in one atomic request. Invoice balances are validated once,
        after all changes are applied.
      operationId: business.invoices.sync.post
      parameters:
        - name: businessId
          in: path
          description: The UUID of the business to sync invoices for.
          required: true
          schema:
            type: string
            format: uuid
        - name: Content-Type
          in: header
          description: Content-Type must be set to application/json.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SyncInvoicesParams'
      responses:
        '200':
          description: >-
            Every invoice and payment was applied. Returns each invoice and
            payment in its final state.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/SyncInvoicesResponse'
                required:
                  - data
        '400':
          description: >-
            Invalid request, or the final state is invalid. Nothing is
            persisted. This can occur if:

            - An invoice includes `payments`

            - Duplicate `external_id` values are present within `invoices` or
            within `payments`

            - An invoice would end overpaid or have a negative outstanding
            balance

            - Any other validation error on an invoice, payment, or refund
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: >-
            Business not found, or a referenced invoice or ledger account does
            not exist. Nothing is persisted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      deprecated: false
components:
  schemas:
    SyncInvoicesParams:
      type: object
      description: Invoices and payments to apply in one atomic request.
      properties:
        invoices:
          type: array
          items:
            $ref: '#/components/schemas/NewInvoicePostParams'
          description: >-
            Invoices to create or update, matched by `external_id`. Each uses
            the same parameters as the create invoice endpoint, except that
            `payments` must be omitted. Send payments in the top-level
            `payments` list.
        payments:
          type: array
          items:
            $ref: '#/components/schemas/CreateStandaloneInvoicePayment'
          description: >-
            Payments to create or update, matched by `external_id`. Each uses
            the same parameters as the bulk create invoice payments endpoint,
            including `dedicated_refunds`. A payment may allocate to several
            invoices.
    SyncInvoicesResponse:
      type: object
      description: Final state of the invoices and payments in a sync request.
      properties:
        type:
          type: string
          description: Resource type. Value will be `SyncInvoicesResponse`.
          example: SyncInvoicesResponse
        invoices:
          type: array
          items:
            $ref: '#/components/schemas/ApiInvoice'
          description: The invoices from the request, in request order.
        payments:
          type: array
          items:
            $ref: '#/components/schemas/ApiInvoicePayment'
          description: >-
            The payments from the request, in request order, including their
            refund allocations.
    ApiError:
      type: object
      description: An error object returned in API error responses.
      properties:
        type:
          $ref: '#/components/schemas/ApiErrorType'
          description: >-
            A fixed category for the error, helpful for categorizing and
            processing errors.
        description:
          type: string
          description: A human-readable error description.
        error_enum:
          $ref: '#/components/schemas/ApiEnumErrorType'
          description: >-
            A stable, machine-readable identifier for programmatically handling
            specific error conditions. Only present for 4xx client errors—not
            included for 5xx server errors. Use this instead of parsing the
            description field, as enum values remain stable across API versions.
          nullable: true
        meta:
          type: object
          description: Optional additional information about the error.
          nullable: true
      required:
        - type
        - description
    NewInvoicePostParams:
      type: object
      properties:
        external_id:
          type: string
          description: >-
            External ID for the invoice within your platform. **Idempotency
            key**. If an invoice with this `external_id` exists and the request
            differs from it, Layer updates that invoice in place.
          example: '019234'
        sent_at:
          type: string
          description: >-
            When the invoice was sent by the business to the recipient. Accepts
            an ISO 8601 date (`YYYY-MM-DD`) or a full ISO 8601 timestamp. A
            date-only value is stored as midnight Eastern Time on that day.
          example: '2024-04-02'
        due_at:
          type: string
          description: >-
            When the invoice is due. Accepts an ISO 8601 date (`YYYY-MM-DD`) or
            a full ISO 8601 timestamp. A date-only value is stored as midnight
            Eastern Time on that day.
          example: '2024-05-02'
        voided_at:
          type: string
          format: date-time
          description: >-
            When the invoice was voided. Voiding excludes the invoice entirely
            from accounting.
        customer_id:
          type: string
          format: uuid
          description: >-
            ID of the customer to associate with the invoice. Either
            `customer_id` or `customer_external_id` must be provided.
        customer_external_id:
          type: string
          description: >-
            External ID of the customer to associate with the invoice. Either
            `customer_id` or `customer_external_id` must be provided. If the
            customer does not already exist, Layer will create it using this
            external ID.
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/NewInvoiceLineItem'
          description: Line items making up the invoice.
        additional_sales_taxes:
          type: array
          items:
            $ref: '#/components/schemas/CreateTaxLineItem'
          description: >-
            List of additional sales tax obligations on the invoice outside
            individual line items.
        additional_discount:
          type: integer
          description: >-
            Additional discount applied to the whole invoice in addition to
            individual line items.
        tips:
          type: integer
          description: Tips included by the buyer, in cents.
        tips_account:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            The Account Identifier for a tips account. If not specified, Layer
            uses the chart's default tips account, which is typically a
            liability account. Specify a different account if tips should be
            tracked as revenue.
        payments:
          type: array
          items:
            $ref: '#/components/schemas/CreateImmediatePaymentInput'
          nullable: true
          description: >-
            Payments that have been made towards the balance of the invoice.
            Include these to create an immediately paid or partially paid
            invoice in the same API call. When upserting an existing invoice:
            omitting this field (or passing `null`) preserves any existing
            dedicated payments; passing an empty array `[]` removes all
            dedicated payments. Non-dedicated payments (those independently
            recorded or included in a payout) are never removed by this field.
        dedicated_refunds:
          type: array
          items:
            $ref: '#/components/schemas/CreateDedicatedRefundParams'
          description: Dedicated refunds to associate with this invoice.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the invoice (for
            example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the invoice. Can be used to filter when listing invoices.
    CreateStandaloneInvoicePayment:
      type: object
      required:
        - paid_at
        - method
        - amount
        - invoice_payments
      properties:
        external_id:
          type: string
          nullable: true
          description: External identifier for the payment, used for idempotency.
        customer_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            Layer ID of the customer to associate with the payment. Lets you tag
            a payment with a customer even before it is allocated to any invoice
            (for example, a standalone deposit). When the payment has invoice
            allocations, the customer must match the customer on every allocated
            invoice, otherwise the request is rejected with a 400.
        customer_external_id:
          type: string
          nullable: true
          description: >-
            External ID of the customer to associate with the payment. Can be
            specified in place of `customer_id`.
        paid_at:
          type: string
          format: date-time
          description: The timestamp when the payment was made.
        method:
          $ref: '#/components/schemas/PaymentMethod'
          description: Payment method.
        fee:
          type: integer
          format: int64
          nullable: true
          description: Fee amount in cents.
        additional_fees:
          type: array
          items:
            $ref: '#/components/schemas/CreatePaymentFeeParams'
          description: Additional fees associated with the payment.
        amount:
          type: integer
          format: int64
          description: Payment amount in cents.
        processor:
          type: string
          nullable: true
          description: Payment processor name.
        payment_clearing_account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            The ledger account to use for the payment (overrides the default
            determined by the payment method).
        redemption_account:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            Account to use for credit balance redemptions. Only applicable when
            method is CREDIT_BALANCE.
        invoice_payments:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/CreateInvoicePaymentAllocation'
                description: Allocates a portion of the payment to a specific invoice.
                title: Invoice Payment Allocation
              - $ref: >-
                  #/components/schemas/CreateInvoicePaymentAllocationToLedgerAccount
                description: >-
                  Allocates a portion of the payment directly to a ledger
                  account, rather than to an invoice.
                title: Ledger Account Allocation
          description: >-
            Each element in this array is either an `InvoicePaymentAllocation`
            (allocating to an invoice) or an
            `InvoicePaymentAllocationToLedgerAccount` (allocating directly to a
            ledger account). The type is determined by the fields present: if
            `account` is provided, it is treated as a ledger account allocation;
            otherwise, it is treated as an invoice allocation.
        dedicated_refunds:
          type: array
          items:
            $ref: '#/components/schemas/CreateDedicatedRefundParams'
          description: Dedicated refunds to associate with this invoice payment.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
          description: Tags to apply to the payment.
        memo:
          type: string
          nullable: true
          description: Memo for any text you would like to associate with the payment.
        metadata:
          type: object
          nullable: true
          description: Arbitrary custom metadata in JSON format.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the payment.
    ApiInvoice:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the invoice.
        type:
          type: string
          description: Resource type. Value will be 'Invoice'.
          example: Invoice
        business_id:
          type: string
          format: uuid
          description: ID of the Business that generated the invoice.
        external_id:
          type: string
          description: Unique ID of the invoice in your system for linking purposes.
          example: '1'
        status:
          $ref: '#/components/schemas/InvoiceStatus'
          description: Status of the invoice.
        sent_at:
          type: string
          format: date-time
          description: When the invoice was sent by the business to the recipient.
        due_at:
          type: string
          format: date-time
          description: When the invoice is due.
        paid_at:
          type: string
          format: date-time
          description: When the invoice was paid.
        voided_at:
          type: string
          format: date-time
          description: >-
            When the invoice was voided. Voiding excludes the invoice from
            accounting.
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/ApiInvoiceLineItem'
          description: Line items making up the invoice.
        subtotal:
          type: integer
          description: Subtotal of all invoice line items in cents.
        additional_discount:
          type: integer
          description: >-
            Additional discount applied to the whole invoice in addition to
            individual line items.
        additional_sales_taxes_total:
          type: integer
          description: >-
            Sum of all taxes across the invoice line items and any additional
            taxes in cents.
        additional_sales_taxes:
          type: array
          items:
            $ref: '#/components/schemas/ApiInvoiceTaxLineItem'
          description: List of additional sales tax line items.
        tips:
          type: integer
          description: Tips included by the buyer, in cents.
        total_amount:
          type: integer
          description: Total amount of the invoice in cents.
        outstanding_balance:
          type: integer
          description: >-
            The remaining balance on the invoice after factoring in all previous
            invoice payments and write-offs.
        memo:
          type: string
          description: >-
            Memo for any text you would like to associate with the Invoice (for
            example, to display to end users).
        payment_allocations:
          type: array
          items:
            $ref: '#/components/schemas/ApiInvoicePaymentAllocation'
          description: >-
            Payments made by a customer are allocated toward one or many
            invoices. This list shows which payments have been been allocated
            towards this invoice. The most common case is that there is a 1:1
            relationship between a payment and an invoice, in which case the
            allocation’s `amount` will match the payment’s `amount`.
          example: []
        refund_allocations:
          type: array
          items:
            $ref: '#/components/schemas/ApiRefundAllocation'
          description: >-
            Refunds made by a customer are allocated toward one or many
            invoices. This list shows which refunds have been been allocated
            towards this invoice.
          example: []
        imported_at:
          type: string
          format: date-time
          description: >-
            Time when the invoice was first imported into Layer. **Eligible sort
            key**.
        updated_at:
          type: string
          format: date-time
          description: >-
            Time when the invoice was first updated in Layer. **Eligible sort
            key**.
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
          description: Tags on the transactions associated with the invoice.
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the invoice. Can be used to filter when listing invoices.
    ApiInvoicePayment:
      type: object
      properties:
        type:
          type: string
          description: Resource type. Value will be `Invoice_Payment`.
          example: Invoice_Payment
        id:
          type: string
          format: uuid
          description: Unique identifier for the payment.
        external_id:
          type: string
          nullable: true
          description: >-
            Unique ID of the invoice payment in an external system for linking
            and idempotency.
          example: payment-1
        customer:
          $ref: '#/components/schemas/ApiCustomerData'
          nullable: true
          description: >-
            The customer associated with this payment, if one has been set. May
            be present even when the payment is not allocated to any invoice.
        at:
          type: string
          format: date-time
          description: Timestamp when the payment was completed.
        method:
          $ref: '#/components/schemas/PaymentMethod'
          description: Payment method.
        fee:
          type: integer
          format: int64
          description: Fee paid by business for processing of payment in positive cents.
        prepayment_account:
          $ref: '#/components/schemas/AccountIdentifier'
          description: Identifier for the ledger account to use if this is a prepayment.
        payment_clearing_account:
          $ref: '#/components/schemas/SingleApiChartAccount'
          description: >-
            The the ledger account to use for the payment (overrides the default
            determined by the payment method), if specified.
        additional_fees:
          type: array
          items:
            $ref: '#/components/schemas/ApiInvoicePaymentFee'
          description: List of additional fees associated with this payment.
        amount:
          type: integer
          format: int64
          description: Customer payment amount, in cents.
        processor:
          type: string
          nullable: true
          description: >-
            Processor used to make the payment, if any. Any processor name can
            be provided and will be tracked. Allowed only when `method` is
            `CREDIT_CARD`, `ACH`, `CREDIT_BALANCE`, or `OTHER`.
          example: STRIPE
        imported_at:
          type: string
          format: date-time
          description: Timestamp when the payment was imported into Layer.
        allocations:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/ApiInvoicePaymentAllocation'
                description: Allocates a portion of the payment to a specific invoice.
                title: Invoice Payment Allocation
              - $ref: >-
                  #/components/schemas/ApiInvoicePaymentAllocationToLedgerAccount
                description: >-
                  Allocates a portion of the payment directly to a ledger
                  account, rather than to an invoice.
                title: Ledger Account Allocation
            discriminator:
              propertyName: type
          description: >-
            Allocations specify how a payment is distributed. A payment can
            include two types of allocations: `InvoicePaymentAllocation`
            (allocates to an invoice) and
            `InvoicePaymentAllocationToLedgerAccount` (allocates directly to a
            ledger account for overpayments or deposits). The sum of all
            allocation amounts must be less than or equal to the payment amount.
        refund_allocations:
          type: array
          items:
            $ref: '#/components/schemas/ApiRefundAllocation'
          description: Refund allocations associated with this invoice payment.
          example: []
        payouts:
          type: array
          items:
            $ref: '#/components/schemas/ApiPayoutWithoutTransactions'
          description: Payouts associated with this payment.
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
          description: List of tags associated with this transaction.
          example: []
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the invoice
            payment (for example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the invoice payment. Can be used to filter when listing invoice
            payments.
    ApiErrorType:
      type: string
      enum:
        - ResourceArchived
        - AuthFailure
        - Plaid
        - Stripe
        - InvalidState
        - ResourceNotFound
        - InvalidParameters
        - JsonSerialization
        - Unknown
        - BadRequest
        - PaginationCursor
        - Conflict
        - LedgerOperationFailed
      example: InvalidParameters
    ApiEnumErrorType:
      type: string
      description: >-
        Stable enum values for programmatic error handling. Only present in 4xx
        error responses.
      enum:
        - AccessCodeInvalid
        - BalanceSheetDoesNotBalance
        - BalanceSheetMissingAccount
        - BankStatementAccountDetectionError
        - BankStatementParsingError
        - BankStatementParserError
        - BankStatementValidationError
        - BillStateError
        - BulkCategorizeFailure
        - BulkMatchFailure
        - BusinessTaskAlreadyCompleted
        - BusinessTaskDeleted
        - CalendlyOAuthError
        - CallBookingError
        - CantUpdateTransactionInCustomerPayout
        - CantUpdateTransactionInVendorPayout
        - CheckPayrollConfigNotFound
        - CheckPayrollServiceNotFound
        - ClerkUserAlreadyExists
        - ConflictingQueryParams
        - CustomAccountAlreadyExists
        - CustomTransactionCsvParsingError
        - CustomTransactionUploadFailure
        - CustomerPayoutInputFormatError
        - DoesNotMatchExistingEntity
        - EmptyBatchRequest
        - ExpenseParserError
        - ExternalAccountBalanceReconciliationError
        - ExternalIdConflict
        - InvalidCategory
        - InvalidEffectiveDate
        - InvalidLedgerOperation
        - InvalidMonthlyAverageRange
        - InvalidMultiPartRequest
        - InvalidPaginationCursor
        - InvalidPayload
        - InvoiceDeleted
        - InvoiceNotFound
        - InvoiceReferenceMismatch
        - InvoiceStateError
        - ManualRateLimit
        - MultipleTagKeyFiltersUnsupported
        - NoCognitoUserFound
        - NoOpeningBalanceFound
        - NotYetReconciled
        - OnePasswordApiError
        - OnePasswordItemNotFound
        - OnePasswordVaultNotFound
        - OpenAICategorizationError
        - PaymentLinkInvalid
        - PayrollStateError
        - PeriodIsClosed
        - PeriodNotClosed
        - PhoneNumberAlreadyRegistered
        - PlaidApiError
        - PlaidConnectionBroken
        - PlaidCreateLinkTokenError
        - PlaidCredentialsNotConfigured
        - PlaidExchangePublicTokenError
        - PlaidGetInstitutionByIdError
        - PlaidGetItemError
        - PlaidInvalidEnvironment
        - PlaidItemAlreadyExists
        - PlaidItemNotFound
        - PlaidProcessorApiError
        - PlaidStatementsAccessNotEnabled
        - PlaidStatementsNotEnabled
        - PlaidStatementsNotSupported
        - PlaidUnlinkItemError
        - QueryParamFormat
        - QueryParamMissing
        - QuickbooksBrokenConnection
        - QuickbooksConnectionAlreadyExists
        - QuickbooksConnectionAlreadySyncing
        - QuickbooksConnectionMissing
        - QuickbooksConnectionNotActivated
        - QuickbooksInvalidRequest
        - QuickbooksInvalidState
        - QuickbooksNoMatchingAccount
        - QuickbooksNonPostingAccountType
        - QuickbooksNotConfigured
        - QuickbooksOAuthCallbackInvalid
        - QuickbooksOAuthError
        - QuickbooksTokenExpired
        - ReadOnlyBusiness
        - ResourceArchived
        - ScheduleCNotConfigured
        - SmsNotEnabled
        - SpecifiedBadRequest
        - SpecifiedIdNotFound
        - SplitTransactionError
        - StepEvaluationBadRequest
        - StripeConnectAccountIdNotFound
        - StripeCredentialsNotConfigured
        - StripeGetBalanceForConnectAccountFailure
        - StripeRedirectOrRefreshUrlNotConfigured
        - TagFilterNotFound
        - UnexpectedQueryParam
        - UnitAccountsInUse
        - WrongAnswerType
      example: InvalidPayload
    NewInvoiceLineItem:
      type: object
      properties:
        account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            Account identifier for the line item. If specified, the line item is
            attributed to that specific account. If omitted, Layer maps the
            product name to an account using the business or industry accounting
            configuration.
        prepayment_account_identifier:
          $ref: '#/components/schemas/SingleApiChartAccount'
          description: >-
            Ledger account for the line item used for accrual reporting. Should
            only be specified when this line item is a pre-payment.
        external_id:
          type: string
          nullable: true
          description: The external ID of the invoice line item in your system.
        description:
          type: string
          nullable: true
          description: Description for the new invoice line item.
          example: Line item description
        product:
          type: string
          description: Name of the product the line item is for.
          example: Widgets
        unit_price:
          type: integer
          format: int64
        quantity:
          type: number
          format: bigdecimal
          nullable: true
        discount_amount:
          type: integer
          format: int64
          nullable: true
        sales_taxes:
          type: array
          items:
            $ref: '#/components/schemas/CreateTaxLineItem'
          nullable: true
          description: Sales tax obligations for this line item.
        dedicated_refunds:
          type: array
          items:
            $ref: '#/components/schemas/CreateDedicatedRefundParams'
          description: Dedicated refunds to associate with this invoice line item.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
          description: List of tags to associate with the invoice line item.
        time_entry_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            UUID of a time entry to link to this invoice line item. The time
            entry is automatically unlinked when the line item is deleted or
            updated to remove it.
    CreateTaxLineItem:
      type: object
      required:
        - amount
      properties:
        tax_account:
          $ref: '#/components/schemas/TaxAccountIdentifier'
          description: >-
            Tax identifier for this line item. Use a `Tax_Name` object to have
            Layer create or reuse a tax account by name, or use an `AccountId`
            or `StableName` account identifier when you want to target a
            specific ledger account.
        amount:
          type: integer
          format: int64
          description: Amount, in cents, of tax owed.
    AccountIdentifier:
      oneOf:
        - $ref: '#/components/schemas/AccountId'
          description: ID of the account.
          title: Account ID
        - $ref: '#/components/schemas/AccountStableName'
          description: Stable name associated with the account.
          title: Account Stable Name
    CreateImmediatePaymentInput:
      type: object
      required:
        - method
        - amount
      properties:
        external_id:
          type: string
          nullable: true
          description: >-
            External ID for the payment within your platform. **Idempotency
            key**.
          example: '12345'
        paid_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            When the payment was made. If omitted, Layer uses the `sent_at` of
            the invoice.
        method:
          $ref: '#/components/schemas/PaymentMethod'
          description: Method used to make the payment.
        fee:
          type: integer
          format: int64
          nullable: true
          description: >-
            Fee associated with processing a payment, e.g. credit card
            processing fees, in cents.
        amount:
          type: integer
          format: int64
          description: Value of the payment, in cents.
        processor:
          type: string
          nullable: true
          description: >-
            Processor used to make the payment, if any. Any processor name can
            be provided and will be tracked.
          example: STRIPE
        payment_clearing_account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            The the ledger account to use for the payment (overrides the default
            determined by the payment method).
        dedicated_refunds:
          type: array
          items:
            $ref: '#/components/schemas/CreateDedicatedRefundParams'
          description: Dedicated refunds to associate with this invoice payment.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the invoice
            payment (for example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the invoice payment. Can be used to filter when listing invoice
            payments.
    CreateDedicatedRefundParams:
      type: object
      properties:
        external_id:
          type: string
          description: >-
            Unique ID of the refund in your system for linking purposes.
            **Idempotency key**.
          example: '31415926535'
        account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          nullable: true
          description: >-
            Optional account identifier to override what ledger account the
            dedicated refund comes out of.
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/CreateCustomerRefundAllocationLineItemParams'
          nullable: true
          description: >-
            Detailed line items for the refund allocation. Use this for itemized
            refunds where you need to specify the exact amounts and accounts.
        completed_at:
          type: string
          format: date-time
          description: When the dedicated refund was given and paid.
        refund_processing_fee:
          type: integer
          format: int64
          description: Fee charged to the business for processing the refund.
        method:
          $ref: '#/components/schemas/PaymentMethod'
        processor:
          type: string
          nullable: true
        refunded_payment_fees:
          type: array
          items:
            $ref: '#/components/schemas/RefundedPaymentFeeInput'
          description: >-
            List of fees associated with the payment for this dedicated refund.
            These are refunded from the payment processor rather than the
            business.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
          description: List of tags associated with this dedicated refund.
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the refund (for
            example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the refund. Can be used to filter when listing refunds.
        payment_clearing_account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          nullable: true
          description: >-
            Optional account identifier to specify the clearing account for
            inferred refund payments. Only used when the system automatically
            generates a payment for the dedicated refund.
    TagKeyValue:
      type: object
      description: >-
        A TagKeyValue holds key=value data related to a tag. This is used when
        creating or updating taggable entities (transactions, invoices, etc.).
      properties:
        key:
          type: string
          description: The tag dimension key (e.g., "department", "project", "location").
          example: department
        dimension_display_name:
          type: string
          nullable: true
          description: >-
            If the TagDimension doesn't exist, providing this value specifies
            the display name upon database insertion. Otherwise, it is left as
            null on the TagDimension.
          example: Department
        value:
          type: string
          description: The tag value (e.g., "sales", "marketing", "engineering").
          example: sales
        value_display_name:
          type: string
          nullable: true
          description: >-
            If the TagValueDefinition doesn't exist, providing this value
            specifies the display name upon database insertion. Otherwise, it is
            left as null on the TagValueDefinition.
          example: Sales Department
      required:
        - key
        - value
    PlatformDefinedJson:
      type: object
      description: Arbitrary JSON data defined by the caller, with a 1KB size constraint.
      additionalProperties: true
      example:
        custom_field: value
        any valid json: below 1kb
        nested:
          meaning of life: 42
          array: []
    PaymentMethod:
      type: string
      enum:
        - CASH
        - CHECK
        - CREDIT_CARD
        - ACH
        - CREDIT_BALANCE
        - OTHER
      example: ACH
    CreatePaymentFeeParams:
      description: >-
        Parameters for creating an additional fee on an invoice payment. The fee
        `type` is optional and defaults to `STANDARD`; use `LOAN_REPAYMENT` to
        record a loan repayment as part of the payment.
      oneOf:
        - $ref: '#/components/schemas/StandardPaymentFeeParams'
        - $ref: '#/components/schemas/LoanRepaymentFeeParams'
    CreateInvoicePaymentAllocation:
      type: object
      properties:
        invoice_id:
          type: string
          format: uuid
          description: >-
            Layer ID of the invoice to apply payment. Either the invoice_id or
            invoice_external_id must be provided.
        invoice_external_id:
          type: string
          format: uuid
          description: >-
            External ID of the invoice payment. Either the invoice_id or
            invoice_external_id must be provided.
        amount:
          type: integer
          format: int64
          description: Amount paid towards this invoice in cents.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
          description: Tags to apply to the allocation.
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the invoice
            payment allocation (for example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the invoice payment allocation.
    CreateInvoicePaymentAllocationToLedgerAccount:
      type: object
      description: >-
        Input for allocating a portion of a payment directly to a ledger
        account, rather than to an invoice. This is useful for recording
        payments not associated with a specific invoice, such as overpayments or
        deposits.
      required:
        - account
        - amount
      properties:
        account:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            The [Account Identifier](/api-reference/ledger/account-identifier)
            of the ledger account to allocate to. The presence of this field
            distinguishes a ledger account allocation from an invoice
            allocation.
        amount:
          type: integer
          format: int64
          description: Amount to allocate to this ledger account, in cents.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
          description: Tags to apply to the allocation.
        memo:
          type: string
          nullable: true
          description: Optional memo for the allocation.
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: User-visible identifier for the allocation.
    InvoiceStatus:
      type: string
      enum:
        - SENT
        - PARTIALLY_PAID
        - PAID
        - VOIDED
        - PARTIALLY_WRITTEN_OFF
        - WRITTEN_OFF
        - REFUNDED
      example: SENT
    ApiInvoiceLineItem:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ID of the invoice line item.
        external_id:
          type: string
          nullable: true
          description: The external ID of the invoice line item in your system.
        invoice_id:
          type: string
          format: uuid
          description: ID of the parent invoice.
        account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          description: Identifier for the account.
        ledger_account:
          $ref: '#/components/schemas/SingleApiChartAccount'
          description: Ledger account for the line item.
        prepayment_account:
          $ref: '#/components/schemas/SingleApiChartAccount'
          description: >-
            Ledger account for the line item used for accrual reporting. Should
            only be specified when this line item is a pre-payment.
        description:
          type: string
          nullable: true
          description: Description for the invoice line item.
          example: Widget sale
        product:
          type: string
          description: Name of the product the invoice line item is for.
          example: Widget
        unit_price:
          $ref: '#/components/schemas/SignedAmount'
          description: The amount in cents of each unit.
        quantity:
          type: number
          format: bigdecimal
          description: Number of units sold.
        subtotal:
          type: integer
          format: int64
          description: Subtotal for the invoice line item in cents.
        discount_amount:
          type: integer
          format: int64
          description: Total discount given to this line item, in cents.
        sales_taxes_total:
          type: integer
          format: int64
          description: Sum of amounts for all sales taxes for the line item.
        sales_taxes:
          type: array
          items:
            $ref: '#/components/schemas/ApiInvoiceTaxLineItem'
          description: List of sales taxes line items.
          nullable: true
        total_amount:
          type: integer
          format: int64
          description: Total amount on the line item.
        refund_allocations:
          type: array
          items:
            $ref: '#/components/schemas/ApiRefundAllocation'
          description: Refund allocations associated with this invoice line item.
          example: []
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
          description: >-
            List of tags on the transaction associated with the invoice line
            item.
    ApiInvoiceTaxLineItem:
      type: object
      properties:
        tax_account:
          $ref: '#/components/schemas/TaxAccountIdentifier'
          description: >-
            Tax account name or identifier. If not set, account defaults to top
            level sales tax payable liability account.
        tax_ledger_account:
          $ref: '#/components/schemas/SingleApiChartAccount'
          description: Ledger account for the tax line item.
          example:
            id: c4007474-f604-4d57-9690-b7f40f7a1cee
            name: 'Sales tax: CALIFORNIA'
            stable_name: SALES_TAXES_PAYABLE:CALIFORNIA
            normality: CREDIT
            account_type:
              value: LIABILITY
              display_name: Liabilities
            account_subtype:
              value: SALES_TAXES_PAYABLE
              display_name: Sales Taxes Payable
        amount:
          type: integer
          format: int64
          description: Amount, in cents, of tax owed.
    ApiInvoicePaymentAllocation:
      type: object
      properties:
        invoice_id:
          type: string
          format: uuid
          description: ID of the invoice.
        payment_id:
          type: string
          format: uuid
          description: ID of the payment.
        amount:
          type: integer
          format: int64
          description: >-
            Amount of the payment allocated towards this invoice. If this amount
            is the full payment amount, this payment was fully allocated towards
            this invoice. The amount cannot exceed the invoice total.
        amount_net_of_refunds:
          type: integer
          format: int64
          description: Amount allocated after applying any refunds, in cents.
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
          description: >-
            List of tags on the transaction associated with the payment
            allocation.
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the invoice
            payment allocation (for example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the invoice payment allocation.
    ApiRefundAllocation:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the refund allocation.
        refund_id:
          type: string
          format: uuid
          description: ID of the refund this allocation belongs to.
        refund_external_id:
          type: string
          nullable: true
          description: External ID of the refund this allocation belongs to.
        invoice_id:
          type: string
          format: uuid
          nullable: true
          description: ID of the invoice this allocation is associated with.
        amount:
          type: integer
          format: int64
          description: Amount of the allocation in cents.
        account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            Identifier of the ledger account for the refund allocation to apply
            to.
          nullable: true
        invoice_external_id:
          type: string
          nullable: true
          description: External ID of the invoice this allocation is associated with.
        invoice_line_item_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            ID of the invoice line item this allocation is associated with. If
            specified, must not refer to a different invoice `invoice_external`
            or `invoice_id`.
        invoice_line_item_external_id:
          type: string
          nullable: true
          description: >-
            The external ID of the invoice line item to refund. If specified
            alongside `invoice_line_item_id`, they must refer to the same
            invoice line item.
        invoice_payment_id:
          type: string
          format: uuid
          nullable: true
          description: ID of the invoice payment this allocation is associated with.
        invoice_payment_external_id:
          type: string
          nullable: true
          description: >-
            External ID of the invoice payment this allocation is associated
            with.
        customer:
          $ref: '#/components/schemas/ApiCustomerData'
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the refund
            allocation (for example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the refund allocation.
    ApiTag:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ID for the tag.
        key:
          type: string
          description: Key for the tag.
          example: ExampleTagKey
        dimension_display_name:
          type: string
          nullable: true
          description: Display name for the tag dimension.
        value:
          type: string
          description: Value for the tag.
          example: ExampleTagValue
        value_display_name:
          type: string
          nullable: true
          description: Display name for the tag value definition.
        dimension_id:
          type: string
          format: uuid
          description: ID of the tag dimension this tag belongs to.
        definition_id:
          type: string
          format: uuid
          description: ID of the tag value definition.
        archived_at:
          type: string
          format: date-time
          nullable: true
          description: When the tag was archived.
      required:
        - id
        - key
        - value
        - dimension_id
        - definition_id
    ApiCustomerData:
      type: object
      properties:
        type:
          type: string
          description: Resource type. Value will be `CustomerData`.
          example: CustomerData
        id:
          type: string
          format: uuid
          description: Unique identifier for the customer.
        external_id:
          type: string
          description: >-
            Unique ID of the customer in your system for linking purposes.
            **Idempotency key**.
          example: '31415926535'
        individual_name:
          type: string
          nullable: true
          description: >-
            Full name of the individual customer or contact at a corporate
            customer.
        company_name:
          type: string
          nullable: true
          description: Name of the company customer.
        email:
          type: string
          nullable: true
          description: Email address of the customer.
        mobile_phone:
          type: string
          nullable: true
          description: Mobile phone number of the customer.
        office_phone:
          type: string
          nullable: true
          description: Office phone number of the customer.
        address_string:
          type: string
          nullable: true
          description: Address of the customer.
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the customer (for
            example, to display to end users).
        status:
          type: string
          description: 'Status of the customer. Possible values: `ACTIVE`, `ARCHIVED`.'
          example: ACTIVE
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
    SingleApiChartAccount:
      type: object
      properties:
        type:
          type: string
          description: Resource type. Value will be `Single_Chart_Account`.
          example: Single_Chart_Account
        id:
          $ref: '#/components/schemas/AccountIdentifier'
        name:
          type: string
          description: Name of the account.
          example: Current Assets
        account_number:
          type: string
          nullable: true
          description: Account number if configured.
          example: '4000'
        stable_name:
          $ref: '#/components/schemas/AccountStableName'
        normality:
          $ref: '#/components/schemas/BankTransactionDirection'
        account_type:
          $ref: '#/components/schemas/ApiLedgerAccountType'
        account_subtype:
          $ref: '#/components/schemas/ApiLedgerAccountSubtype'
      description: A single ledger account without nested children.
    ApiInvoicePaymentFee:
      type: object
      properties:
        fee_amount:
          type: integer
          format: int64
          description: Amount of the fee in cents.
        description:
          type: string
          description: Description of the fee.
        account:
          $ref: '#/components/schemas/AccountIdentifier'
          description: Account to which the fee should be allocated.
        is_passed_to_customer:
          type: boolean
          description: >-
            Whether or not the fee is passed to the customer. It is paid by the
            business otherwise.
    ApiInvoicePaymentAllocationToLedgerAccount:
      type: object
      description: >-
        Represents a portion of a payment allocated directly to a ledger
        account, rather than to a specific invoice. This is useful for recording
        payments that are not associated with a specific invoice, such as
        overpayments or deposits.
      properties:
        account_id:
          type: string
          format: uuid
          description: ID of the ledger account to which this payment is allocated.
        payment_id:
          type: string
          format: uuid
          description: ID of the payment this allocation applies from.
        amount:
          type: integer
          format: int64
          description: Customer payment amount, in cents.
        amount_net_of_refunds:
          type: integer
          format: int64
          description: Amount allocated after applying any refunds, in cents.
        memo:
          type: string
          nullable: true
          description: Optional memo for the allocation.
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format.
        reference_number:
          type: string
          nullable: true
          description: User-visible identifier for the allocation.
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
          description: >-
            List of tags on the transaction associated with the payment
            allocation.
    ApiPayoutWithoutTransactions:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique ID for the Payout. **Idempotency key.**.
        external_id:
          type: string
          nullable: true
          description: Unique ID of the payout in your system for linking purposes.
          example: payout-1234
        business_id:
          type: string
          format: uuid
          description: ID of the Business that generated the payout.
        paid_out_amount:
          type: integer
          format: int64
          description: The amount of the payout, in cents.
        fee:
          type: integer
          format: int64
          description: The platform fee associated with the payout.
        processor:
          $ref: '#/components/schemas/PaymentProcessor'
          description: >-
            Processor used to make the payment, if any. Any processor name can
            be provided and will be tracked.
          example: STRIPE
        payment_clearing_account:
          $ref: '#/components/schemas/SingleApiChartAccount'
          nullable: true
          description: >-
            The ledger account where the payout deposits. If not specified
            during creation, this is `null` and the payout deposits to
            Undeposited Funds.
        imported_at:
          type: string
          format: date-time
          description: Timestamp of when the payout was imported.
        completed_at:
          type: string
          format: date-time
          description: Timestamp of when the payout was completed.
        match:
          $ref: '#/components/schemas/ApiMatch'
          description: The transaction match associated with the payout.
          example:
            id: 6b0a3734-f4ef-4fb0-9fc1-3f59b0c1cf99
            match_type: PAYOUT
            bank_transaction:
              type: Bank_Transaction_Data
              id: a703c8d6-cfe8-453d-a275-b92eacc6fc6e
              business_id: 738ec216-e8e5-48f2-b7f2-cdc89c96b3d4
              source: STRIPE
              source_transaction_id: trxn_1sdOeLQiFAKE2LQBkcvrJw95f
              source_account_id: 738ec216-e154-48f2-1111-cdc89c96b3d4
              imported_at: '2024-03-19T22:09:53.290591Z'
              date: '2024-03-06T06:06:40Z'
              direction: CREDIT
              amount: 87459
              counterparty_name: null
              description: Payout (po_1OqnTHISISFAKEiTVBkCiyAERwm).
              account_name: Layer Banking
              categorization_status: MATCHED
            details:
              type: Payout_Match
              id: d224508b-b05e-41da-89de-0fbd8a573507
              amount: 87459
              date: '2024-03-06T00:00:00Z'
              description: Payout from STRIPE.
              adjustment: null
        transaction_tags:
          type: array
          items:
            $ref: '#/components/schemas/ApiTag'
          description: A list of tags associated with the payout.
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the payout (for
            example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the payout. Can be used to filter when listing payouts.
    TaxAccountIdentifier:
      type: object
      oneOf:
        - $ref: '#/components/schemas/TaxName'
          title: Tax Name
        - $ref: '#/components/schemas/AccountId'
          title: Ledger Account ID
        - $ref: '#/components/schemas/AccountStableName'
          title: Ledger Account Stable Name
      discriminator:
        propertyName: type
        mapping:
          AccountId: '#/components/schemas/AccountId'
          StableName: '#/components/schemas/AccountStableName'
          Tax_Name: '#/components/schemas/TaxName'
    AccountId:
      type: object
      required:
        - type
        - id
      properties:
        type:
          type: string
          enum:
            - AccountId
          description: Resource type. Value will be `AccountId`.
          example: AccountId
        id:
          type: string
          format: uuid
          description: ID of the account.
    AccountStableName:
      type: object
      required:
        - type
        - stable_name
      properties:
        type:
          type: string
          enum:
            - StableName
          description: Resource type. Value will be `StableName`.
          example: StableName
        stable_name:
          type: string
          example: CURRENT_ASSETS
          description: Stable name of the account.
    CreateCustomerRefundAllocationLineItemParams:
      type: object
      properties:
        external_id:
          type: string
          nullable: true
          description: An external identifier for the line item.
        amount:
          type: integer
          format: int64
          description: The amount of this line item in cents.
        account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          nullable: true
          description: Identifier of the ledger account for this line item.
        prepayment_account_identifier:
          $ref: '#/components/schemas/AccountIdentifier'
          nullable: true
          description: Identifier of the prepayment ledger account for this line item.
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagKeyValue'
          description: Tags to associate with the line item.
        memo:
          type: string
          nullable: true
          description: Memo for any text you would like to associate with the line item.
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the refund allocation line item.
      required:
        - amount
      description: Parameters for creating a refund allocation line item.
    RefundedPaymentFeeInput:
      type: object
      properties:
        account:
          $ref: '#/components/schemas/AccountIdentifier'
          description: Account to which the fee should be allocated.
        description:
          type: string
          nullable: true
          description: Description of the fee.
        fee_amount:
          type: integer
          format: int64
          description: Amount of the fee in cents.
      required:
        - account
        - fee_amount
      description: Input parameters for a refunded payment fee.
    StandardPaymentFeeParams:
      type: object
      title: Standard fee
      description: A standard additional fee on an invoice payment.
      required:
        - account
        - fee_amount
      properties:
        type:
          type: string
          enum:
            - STANDARD
          default: STANDARD
          description: Discriminator for the fee type. Optional; defaults to `STANDARD`.
        description:
          type: string
          description: Optional description of the fee.
        account:
          $ref: '#/components/schemas/AccountIdentifier'
          description: >-
            The [Account Identifier](/api-reference/ledger/account-identifier)
            for the fee to be debited.
        fee_amount:
          type: integer
          format: int64
          description: Amount of the fee in cents.
        is_passed_to_customer:
          type: boolean
          description: >-
            Whether or not the fee is passed to the customer. It is paid by the
            business otherwise. When calculating the outstanding balance on the
            invoice, only the portion of each payment allocation that is applied
            to the invoice (excluding pass-through fees) is considered. This
            allows customers to pay the invoice amount plus any pass-through
            fees without the invoice being considered overpaid.
    LoanRepaymentFeeParams:
      type: object
      title: Loan repayment fee
      description: >-
        An additional fee on an invoice payment that records a repayment against
        a loan. Layer creates a linked [loan
        payment](/api-reference/loan/loan#loan-payment-object) from the embedded
        parameters.
      required:
        - type
        - loan_payment
      properties:
        type:
          type: string
          enum:
            - LOAN_REPAYMENT
          description: Discriminator for the fee type. Must be `LOAN_REPAYMENT`.
        loan_payment:
          allOf:
            - $ref: '#/components/schemas/CreateLoanPaymentParams'
          description: The loan payment to create and link to this invoice payment.
        description:
          type: string
          description: Optional description of the fee.
    SignedAmount:
      type: integer
      format: int64
    BankTransactionDirection:
      type: string
      enum:
        - CREDIT
        - DEBIT
      example: DEBIT
    ApiLedgerAccountType:
      type: object
      properties:
        value:
          $ref: '#/components/schemas/LedgerAccountType'
          description: Type of the account.
        display_name:
          type: string
          description: Display name of the account type.
          example: Asset
    ApiLedgerAccountSubtype:
      type: object
      properties:
        value:
          $ref: '#/components/schemas/LedgerAccountSubtype'
        display_name:
          type: string
          description: Display name of the account subtype.
          example: Current Assets
    PaymentProcessor:
      type: string
      enum:
        - STRIPE
        - PAYPAL
        - SHOPIFY
        - ADYEN
        - RAINFOREST
      example: STRIPE
    ApiMatch:
      type: object
      properties:
        type:
          type: string
          description: Resource type. Value will be `Match`.
          example: Match
        id:
          type: string
          format: uuid
          description: Layer's UUID for the match.
        match_type:
          $ref: '#/components/schemas/MatchType'
          description: Type of the object to match.
        bank_transaction:
          $ref: '#/components/schemas/ApiBankTransactionInterface'
        details:
          $ref: '#/components/schemas/ApiMatchDetails'
    TaxName:
      type: object
      properties:
        type:
          type: string
          description: Resource type. Value will be 'Tax_Name'.
          example: Tax_Name
        name:
          type: string
          description: Name of the ledger account.
          example: CALIFORNIA_VAT
      required:
        - name
    CreateLoanPaymentParams:
      type: object
      description: >-
        Parameters for recording a loan payment. Provide exactly one of
        `loan_id` or `loan_external_id` to identify the loan.
      required:
        - amount
        - date
      properties:
        loan_id:
          type: string
          format: uuid
          nullable: true
          description: ID of the loan being paid. Provide this or `loan_external_id`.
        loan_external_id:
          type: string
          nullable: true
          description: External ID of the loan being paid. Provide this or `loan_id`.
        external_id:
          type: string
          nullable: true
          description: Unique ID of the payment in your system for linking purposes.
        amount:
          type: integer
          format: int64
          description: >-
            Total payment amount, in cents. Must equal the sum of the splits.
            Use a negative amount to record a reversal of an earlier payment,
            for example when a lender returns a repayment it withheld. Record
            the reversal as its own payment; do not edit the payment it offsets.
        date:
          type: string
          format: date
          description: Date of the payment.
        splits:
          type: array
          items:
            $ref: '#/components/schemas/CreateLoanPaymentSplitParams'
          nullable: true
          description: >-
            Breakdown of the payment into principal, interest, and fee portions.
            Optional for MCA and flex loans: when omitted, Layer derives a
            `PRINCIPAL`/`FEE` split from the loan's `fee_percentage` (`principal
            = amount / (1 + fee_percentage / 100)`, fee = remainder). Required
            for all other loan types. Provide explicit splits to override the
            derived ones.
        defer_posting:
          type: boolean
          default: false
          description: >-
            If true, the payment is recorded but not posted to the ledger until
            it is paid out or its due date is reached.
        method:
          allOf:
            - $ref: '#/components/schemas/PaymentMethod'
          default: OTHER
          description: Payment method. Defaults to `OTHER`.
        processor:
          type: string
          nullable: true
          description: Payment processor, if any (e.g. `stripe`).
        payment_clearing_account_identifier:
          allOf:
            - $ref: '#/components/schemas/AccountIdentifier'
          nullable: true
          description: >-
            Override the clearing account used for the payment. Defaults based
            on `method`.
        memo:
          type: string
          nullable: true
          description: Internal note about the payment.
        metadata:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            Arbitrary JSON object you can attach for your own use. Layer stores
            and returns it unchanged.
        reference_number:
          type: string
          nullable: true
          description: Reference number for the payment.
    LedgerAccountType:
      type: string
      enum:
        - ASSET
        - LIABILITY
        - EQUITY
        - REVENUE
        - EXPENSE
      example: ASSET
    LedgerAccountSubtype:
      type: string
      enum:
        - BANK_ACCOUNTS
        - ACCOUNTS_RECEIVABLE
        - INVENTORY
        - PAYMENT_PROCESSOR_CLEARING_ACCOUNT
        - FIXED_ASSET
        - ACCUMULATED_DEPRECIATION
        - CASH
        - UNDEPOSITED_FUNDS
        - CURRENT_ASSET
        - NON_CURRENT_ASSET
        - PREPAID_EXPENSES
        - DEVELOPMENT_COSTS
        - LOANS_RECEIVABLE
        - INTANGIBLE_ASSET
        - ACCOUNTS_PAYABLE
        - CREDIT_CARD
        - TAXES_PAYABLE
        - INCOME_TAXES_PAYABLE
        - SALES_TAXES_PAYABLE
        - OTHER_TAXES_PAYABLE
        - PAYROLL_TAXES_PAYABLE
        - UNEARNED_REVENUE
        - PAYROLL_LIABILITY
        - PAYROLL_CLEARING
        - LINE_OF_CREDIT
        - TIPS
        - REFUND_LIABILITIES
        - UNDEPOSITED_OUTFLOWS
        - OUTGOING_PAYMENT_CLEARING_ACCOUNT
        - OTHER_CURRENT_LIABILITY
        - LOANS_PAYABLE
        - NOTES_PAYABLE
        - SHAREHOLDER_LOAN
        - NON_CURRENT_LIABILITY
        - CONTRIBUTIONS
        - DISTRIBUTIONS
        - COMMON_STOCK
        - PREFERRED_STOCK
        - ADDITIONAL_PAID_IN_CAPITAL
        - RETAINED_EARNINGS
        - ACCUMULATED_ADJUSTMENTS
        - OPENING_BALANCE_EQUITY
        - OTHER_EQUITY
        - SALES
        - UNCATEGORIZED_REVENUE
        - RETURNS_ALLOWANCES
        - DIVIDEND_INCOME
        - INTEREST_INCOME
        - OTHER_INCOME
        - COGS
        - OPERATING_EXPENSES
        - PAYROLL
        - TAXES_LICENSES
        - UNCATEGORIZED_EXPENSE
        - CHARITABLE_CONTRIBUTIONS
        - LOAN_EXPENSES
        - FINANCE_COSTS
        - INTEREST_EXPENSES
        - DEPRECIATION
        - AMORTIZATION
        - BAD_DEBT
        - OTHER_EXPENSES
      example: BANK_ACCOUNTS
    MatchType:
      type: string
      enum:
        - TRANSFER
        - INVOICE_PAYMENT
        - PAYOUT
      example: TRANSFER
    ApiBankTransactionInterface:
      type: object
      required:
        - id
        - amount
        - date
      properties:
        id:
          type: string
          format: uuid
          description: Layer's UUID for the bank transaction.
        business_id:
          type: string
          format: uuid
          description: UUID of the business the transaction is for.
        source:
          $ref: '#/components/schemas/TransactionSource'
          description: Source of the bank transaction.
        source_transaction_id:
          type: string
          description: >-
            External transaction ID from the source platform (e.g, Plaid
            transaction ID).
          example: g4DlKyjXqGH3Kp5XlaWMtwLRrE4Z9AiE8B4Ko
        source_account_id:
          type: string
          description: >-
            External account ID from the source platform (e.g, Plaid account
            ID).
          example: Aaoy8G7VXZHVeqNoL1GvcmkPdqpLRWi9NArdG
        external_account_id:
          type: string
          format: uuid
          description: >-
            Layer's internal UUID for the linked external account. This is
            distinct from source_account_id, which is the provider's identifier
            (e.g., Plaid or Stripe account ID).
        imported_at:
          type: string
          format: date-time
          description: Timestamp when the transaction was imported.
        date:
          type: string
          format: date-time
          description: Timestamp when the transaction was created.
        direction:
          $ref: '#/components/schemas/BankTransactionDirection'
          description: Direction of the transaction.
        amount:
          type: integer
          format: int64
          description: Amount of the transaction, in cents.
        counterparty_name:
          type: string
          nullable: true
          description: Name of the transaction counterparty.
          example: WeWork
        description:
          type: string
          nullable: true
          description: Description of the transaction.
          example: WeWork monthly rent payment
        account_name:
          type: string
          nullable: true
          description: Name of the bank account.
          example: Plaid Checking
        categorizationStatus:
          $ref: '#/components/schemas/CategorizationStatus'
          description: The status of the transaction’s categorization in Layer’s systems.
        memo:
          type: string
          nullable: true
          description: >-
            Memo for any text you would like to associate with the bank
            transaction (for example, to display to end users).
        metadata:
          $ref: '#/components/schemas/PlatformDefinedJson'
          nullable: true
          description: Arbitrary custom metadata in JSON format with a size limit of 1KB.
        reference_number:
          type: string
          nullable: true
          description: >-
            Any (typically user-visible) identifier you would like to associate
            with the bank transaction. Can be used to filter when listing bank
            transactions.
    ApiMatchDetails:
      type: object
      required:
        - id
        - amount
        - date
      properties:
        id:
          type: string
          format: uuid
          description: Layer's ID for the match.
        amount:
          type: integer
          format: int64
          description: Monetary amount of the matched transaction, in cents.
        date:
          type: string
          format: date-time
          description: Date that the matched transaction occurred.
        description:
          type: string
          nullable: true
          description: Description of the match.
          example: Transfer from SavingsAccount to CheckingAccount
    CreateLoanPaymentSplitParams:
      type: object
      description: >-
        How a portion of a loan payment is allocated. All splits on a payment
        must sum to the payment `amount` and share its sign.
      required:
        - split_type
        - amount
      properties:
        split_type:
          $ref: '#/components/schemas/LoanPaymentSplitType'
        amount:
          type: integer
          format: int64
          description: >-
            Split amount, in cents. Must share the sign of the payment `amount`,
            so splits on a reversal are negative.
        account_identifier:
          allOf:
            - $ref: '#/components/schemas/AccountIdentifier'
          nullable: true
          description: >-
            For `INTEREST` and `FEE` splits, the expense account to post to
            (defaults to `INTEREST_EXPENSE` and `OTHER_FEES` respectively).
            Ignored for `PRINCIPAL` splits.
        external_id:
          type: string
          nullable: true
          description: Unique ID of the split in your system for linking purposes.
    TransactionSource:
      type: string
      enum:
        - UNIT
        - PLAID
        - API
        - STRIPE
        - CUSTOM
      example: PLAID
    CategorizationStatus:
      type: string
      enum:
        - PENDING
        - READY_FOR_INPUT
        - CATEGORIZED
        - SPLIT
        - LAYER_REVIEW
        - JOURNALING
        - MATCHED
      example: CATEGORIZED
    LoanPaymentSplitType:
      type: string
      description: The portion of a loan payment a split applies to.
      enum:
        - PRINCIPAL
        - INTEREST
        - FEE
      example: PRINCIPAL
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.