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

# Apply payment to invoices

> Applies a payment that isn't on an invoice yet to one or more invoices of its customer, or of
the customer's group. A deposit's payment works the same way, though
[Apply deposit to invoice](/api-reference/deposit-links/apply-deposit-to-invoice) is simpler for a
deposit.

The amounts have to come to the whole payment, and none can be more than its invoice owes.
Each invoice has to be in the payment's currency and not voided.

**This is final.** The invoices' balances change at once, and the payment goes to QuickBooks,
NetSuite, Shopify, or HubSpot if you've connected them. It can't be undone from the API or the
Streamlined app.




## OpenAPI

````yaml /api-reference/openapi.yaml post /transactions/{id}/apply
openapi: 3.0.3
info:
  title: Streamlined API
  description: >
    Access customers, customer applications, customer groups, products, payouts,
    invoices, transactions, deposit links, and the reports behind your dashboard
    programmatically through this API, and receive webhooks when deposit links
    change. All requests must be authenticated with an API key, except [Create
    signup intent](/api-reference/signup/create-signup-intent), which an AI
    agent can call for a business that wants an account.
  version: 1.18.0
  license:
    name: Proprietary
    url: https://streamlinedpayments.com/terms
servers:
  - url: https://api.staging.streamlinedpayments.com/api/v1
    description: Sandbox
  - url: https://api.streamlinedpayments.com/api/v1
    description: Production
security:
  - AppIdAuth: []
    ApiKeyAuth: []
tags:
  - name: Customers
    description: Create, update and delete the businesses you sell to.
  - name: Customer applications
    description: >-
      List the applications your customers submit, and approve them. Approving
      can also set net terms and export the customer to Shopify. See [Approve
      customer applications](/guides/customer-applications).
  - name: Customer groups
    description: >-
      Organize customers into groups and manage who's in each one. A group can
      be linked to a Shopify B2B company.
  - name: Customer files
    description: Upload and manage files attached to a customer.
  - name: Customer addresses
    description: Manage a customer's addresses and choose their default billing address.
  - name: Orders
    description: Create orders, add and remove line items, and schedule them.
  - name: Invoices
    description: Create invoices from orders, then list, look up and update them.
  - name: Transactions
    description: >-
      Record payments you received elsewhere and credit or debit notes, apply
      payments to invoices, and look up where each one went. See [Record and
      apply payments](/guides/record-and-apply-payments).
  - name: Payouts
    description: List payouts, including pending ones, and look one up.
  - name: Products
    description: >-
      Create and update the products and services you sell, import them in bulk,
      and merge duplicates.
  - name: Deposit links
    description: Collect money from a customer before an invoice exists.
  - name: Webhooks
    description: >-
      Register HTTPS endpoints to receive events when something changes. See
      [Webhooks](/guides/webhooks) for signatures, retries and delivery
      guarantees.
  - name: Signup
    description: >-
      Get a signup link, or an email from our team, for a business you're
      helping start with Streamlined. For AI agents, with no API key. See [Sign
      up a business](/guides/sign-up-a-business).
  - name: Reports
    description: >-
      Read the aging, sales, collections, and customer figures your dashboard
      and customer pages show. Amounts are in cents, in the currency each
      response names. See [Reports](/guides/reports) for how each figure is
      worked out.
paths:
  /transactions/{id}/apply:
    post:
      tags:
        - Transactions
      summary: Apply payment to invoices
      description: >
        Applies a payment that isn't on an invoice yet to one or more invoices
        of its customer, or of

        the customer's group. A deposit's payment works the same way, though

        [Apply deposit to
        invoice](/api-reference/deposit-links/apply-deposit-to-invoice) is
        simpler for a

        deposit.


        The amounts have to come to the whole payment, and none can be more than
        its invoice owes.

        Each invoice has to be in the payment's currency and not voided.


        **This is final.** The invoices' balances change at once, and the
        payment goes to QuickBooks,

        NetSuite, Shopify, or HubSpot if you've connected them. It can't be
        undone from the API or the

        Streamlined app.
      operationId: applyPayment
      parameters:
        - name: id
          in: path
          description: The UUID of the payment
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - invoices
              properties:
                invoices:
                  $ref: '#/components/schemas/TransactionInvoiceLines'
            example:
              invoices:
                - invoice_uuid: 8d2c4a17-6b3e-4f95-a1d0-7e9c5b2f4a63
                  amount: 300000
                - invoice_uuid: 2b7e9d41-0c5a-4f3e-8a6b-1d9c7e5f3a20
                  amount: 180000
      responses:
        '200':
          description: >-
            Applied. Returns the payment, with `allocations` for each invoice
            and `unapplied_amount` of 0.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionDetail'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: >-
            The payment or an invoice isn't on your account. `code` is
            `transaction_not_found` or `invoice_not_found`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodedError'
              example:
                error: Transaction not found
                code: transaction_not_found
        '409':
          description: >-
            The payment is being applied in the Streamlined app right now. Retry
            shortly; if that apply went through, the retry gets
            `already_applied`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodedError'
              example:
                error: This payment is being applied already. Try again shortly.
                code: allocation_in_progress
        '422':
          description: >-
            Refused, and nothing was applied. `code` is `apply_refused`,
            `already_applied`, `invalid_invoices`, or `invalid_amount`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodedError'
              example:
                error: >-
                  W51846 owes $1,800.00, so no more than that can be applied to
                  it
                code: apply_refused
components:
  schemas:
    TransactionInvoiceLines:
      type: array
      minItems: 1
      maxItems: 50
      description: >-
        The invoices and how much of the payment goes on each, in cents.
        Together they have to come to the whole payment, and none can be more
        than its invoice owes.
      items:
        type: object
        required:
          - invoice_uuid
          - amount
        properties:
          invoice_uuid:
            type: string
            format: uuid
          amount:
            type: integer
            minimum: 1
            description: In cents.
    TransactionDetail:
      description: >
        Returned by GET /transactions/:id, Record transaction, and Apply payment
        to invoices. Note:

        this returns the transaction object directly, not wrapped in a
        `transaction` key. This

        differs from /orders, /invoices, /customers etc, which wrap their
        resource. Kept this way

        for v1 backwards compatibility.
      allOf:
        - $ref: '#/components/schemas/Transaction'
        - type: object
          properties:
            allocations:
              type: array
              description: >
                Where the transaction's money went, one entry per invoice, the
                invoice it's recorded on

                first. Empty while a payment is unapplied. A payment bigger than
                its invoice shows the

                whole amount on that invoice; the rest is credit there.
              items:
                type: object
                properties:
                  invoice_uuid:
                    type: string
                    format: uuid
                  invoice_identifier:
                    type: string
                    nullable: true
                    description: The invoice number, such as `W51846`.
                  amount:
                    type: integer
                    description: In cents, in the transaction's currency.
            unapplied_amount:
              type: integer
              description: >-
                How much of the transaction isn't on an invoice yet, in cents.
                The whole amount while a payment is unapplied, else 0.
    CodedError:
      type: object
      description: >-
        An error with a sentence to show people and a stable `code` to branch
        on.
      properties:
        error:
          type: string
          description: >-
            What went wrong, as a sentence to show people. Don't parse it. The
            wording can change.
        code:
          type: string
          description: A stable value to branch on. The endpoint's guide lists each one.
    Transaction:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
        created_at:
          type: string
          format: date-time
        currency:
          $ref: '#/components/schemas/Currency'
        amount:
          type: integer
          description: >-
            The amount, in cents. For a payment applied to invoices in another
            currency, this is what it paid in the invoices' currency, and
            `received` holds what arrived.
        fee:
          type: integer
          nullable: true
          description: >-
            The processing fee, in cents. Null when there's none, as for a
            payment you recorded.
        payment_source:
          type: string
        memo:
          type: string
          nullable: true
        payout_date:
          type: string
          format: date
          nullable: true
          description: Null if the transaction has not been paid out yet.
        net_amount:
          type: integer
        self_recorded:
          type: boolean
        display_type:
          type: string
        txn_files:
          type: array
          items:
            $ref: '#/components/schemas/TransactionFile'
        invoice:
          type: object
          nullable: true
          description: >-
            The invoice the transaction is recorded on, the first of
            `allocations`. Null if it isn't on an invoice, such as a payment
            that hasn't been applied.
          properties:
            invoice_token:
              type: string
              description: >-
                The token in the invoice's payment link. It isn't the invoice's
                `uuid`: to match this invoice to `allocations`, use the first
                entry's `invoice_uuid`.
            amount:
              type: integer
              description: The invoice's total, in cents.
            currency:
              $ref: '#/components/schemas/Currency'
            due_date:
              type: string
              format: date-time
              nullable: true
              description: >-
                When the invoice is due, as an ISO 8601 timestamp in UTC. The
                due day is its UTC date part (`2027-01-20T12:00:00.000Z` is due
                January 20). Invoices issued before v1.16.0, and due dates
                picked in the Streamlined app, can carry a time whose UTC date
                is a day off. Read those in your account's time zone.
        recipient:
          $ref: '#/components/schemas/InvoiceRecipient'
        received:
          allOf:
            - $ref: '#/components/schemas/ReceivedAmount'
          nullable: true
          description: >-
            What arrived, when a payment was applied to invoices in another
            currency in the Streamlined app. The transaction's `amount`,
            `currency`, and `fee` are then what it paid in the invoices'
            currency, and payouts use the `received` figures. Null for every
            other transaction.
        conversion:
          allOf:
            - $ref: '#/components/schemas/CurrencyConversion'
          nullable: true
          description: >-
            The rate a payment was applied at, when it was applied to invoices
            in another currency. Null for every other transaction.
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    Currency:
      type: string
      description: >-
        ISO currency code. Most resources support these. Products are limited to
        USD, CAD, EUR, GBP, AUD.
      enum:
        - USD
        - CAD
        - GBP
        - EUR
        - AUD
        - JPY
        - INR
    TransactionFile:
      type: object
      properties:
        id:
          type: integer
        filename:
          type: string
        thumbnail_url:
          type: string
        url:
          type: string
    InvoiceRecipient:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
        company_name:
          type: string
          nullable: true
        display_name:
          type: string
          nullable: true
          description: >-
            Company name if present, otherwise first/last name. Null if neither
            is set.
    ReceivedAmount:
      type: object
      description: What arrived for a payment applied to invoices in another currency.
      properties:
        amount:
          type: integer
          description: The amount that arrived, in cents.
        currency:
          $ref: '#/components/schemas/Currency'
        fee:
          type: integer
          nullable: true
          description: >-
            The processing fee on what arrived, in cents. Null when there's
            none, as for a payment you recorded.
      example:
        amount: 72000
        currency: USD
        fee: 217
    CurrencyConversion:
      type: object
      description: >-
        The rate a payment was applied at, when it was applied to invoices in
        another currency.
      properties:
        rate:
          type: string
          description: >-
            Units of the currency that arrived per one unit of the invoices'
            currency, as a decimal string. 72,000 cents in USD paying 100,000
            cents in CAD is `0.72`.
          example: '0.72'
        market_rate:
          type: string
          nullable: true
          description: >-
            The market rate for the same pair when the payment arrived, for
            comparison. Null when there was no rate for that pair.
          example: '0.731'
        market_rate_as_of:
          type: string
          format: date
          nullable: true
          description: The date of that market rate.
          example: '2026-11-18'
  responses:
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            AuthenticationRequired:
              value:
                error: Authentication required
                message: >-
                  API endpoint requires authentication. Please provide valid
                  X-App-Id and X-Api-Key headers.
            InvalidCredentials:
              value:
                error: Invalid credentials
                message: >-
                  The provided API credentials are invalid. Please check your
                  X-App-Id and X-Api-Key values.
  securitySchemes:
    AppIdAuth:
      type: apiKey
      in: header
      name: X-App-Id
      description: App ID for authentication
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: API Key for authentication

````

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