> ## 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.

# Record and apply payments

> Record payments you received outside Streamlined, apply payments to invoices, and add credit or debit notes, from your own system.

When a customer pays you outside Streamlined, such as by check, bank transfer, or cash, record the payment so their invoices show it. When a payment arrives without saying which invoices it's for, apply it to the right ones. Credit and debit notes change what an invoice owes without any money moving.

You need an API key. Every request below goes to Sandbox (`https://api.staging.streamlinedpayments.com/api/v1`) with your `X-App-Id` and `X-Api-Key` headers. Amounts are in cents.

> [!WARNING]
>
> Everything on this page is final. A recorded transaction or an applied payment changes the invoices' balances at once, and goes to QuickBooks, NetSuite, Shopify, or HubSpot if you've connected them. It can't be undone from the API or the Streamlined app. To fix a mistake, email [help@streamlinedpayments.com](mailto:help@streamlinedpayments.com).

## The rules

These hold for payments you record and for payments you apply:

| Rule | What happens otherwise |
| - | - |
| The invoice amounts come to the whole payment. | `422`, nothing saved. |
| No invoice gets more than it owes. | `422`, nothing saved. |
| Every invoice is the customer's, or another member's of the customer's group. | `422`, nothing saved. |
| Every invoice is in the currency you send, and the payment's. | `422`, nothing saved. |
| No invoice is voided. | `422`, nothing saved. |
| Every invoice and the customer are yours. | `404`. |

Record transaction and Apply payment to invoices can't apply more than the invoices owe. For a deposit larger than the invoice, use [Apply deposit to invoice](https://docs.streamlinedpayments.com/api-reference/deposit-links/apply-deposit-to-invoice.md), which keeps the rest as credit. For any other overpayment, record or apply it in the Streamlined app.

## Record a payment received elsewhere

[Record transaction](https://docs.streamlinedpayments.com/api-reference/transactions/record-transaction.md) with `type: payment` records the payment and applies it to the invoices you list, in one request. `payment_source` is how it was paid: `ach_credit` (a bank transfer), `check`, `cash`, or `card` (a card taken outside Streamlined). `invoices` is required: a payment without it is refused with `invalid_invoices`, and nothing is recorded. It's dated now.

```bash theme={null}
curl https://api.staging.streamlinedpayments.com/api/v1/transactions \
  -X POST \
  -H "X-App-Id: $STREAMLINED_APP_ID" \
  -H "X-Api-Key: $STREAMLINED_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: check-1042" \
  -d '{
    "type": "payment",
    "customer_uuid": "c1f0a92b-4d63-4e88-b0a7-2f9e4c6d1b35",
    "amount": 480000,
    "currency": "USD",
    "payment_source": "check",
    "memo": "Check 1042",
    "invoices": [
      { "invoice_uuid": "8d2c4a17-6b3e-4f95-a1d0-7e9c5b2f4a63", "amount": 300000 },
      { "invoice_uuid": "2b7e9d41-0c5a-4f3e-8a6b-1d9c7e5f3a20", "amount": 180000 }
    ]
  }'
```

You get `201` with the payment:

```json theme={null}
{
  "uuid": "6e1d4b92-3f7a-4c08-9b25-a8d3e7f1c540",
  "created_at": "2026-11-29T18:04:11.000Z",
  "currency": "USD",
  "amount": 480000,
  "fee": null,
  "payment_source": "check",
  "memo": "Check 1042",
  "payout_date": null,
  "net_amount": 480000,
  "self_recorded": true,
  "display_type": "Check",
  "invoice": {
    "invoice_token": "a47c1e09-5d3b-4f82-9e6a-0c8b2d7f5e13",
    "amount": 180000,
    "currency": "USD",
    "due_date": "2026-12-15T12:00:00.000Z"
  },
  "recipient": {
    "uuid": "c1f0a92b-4d63-4e88-b0a7-2f9e4c6d1b35",
    "company_name": "Northwind Traders",
    "display_name": "Northwind Traders"
  },
  "txn_files": [],
  "allocations": [
    { "invoice_uuid": "2b7e9d41-0c5a-4f3e-8a6b-1d9c7e5f3a20", "invoice_identifier": "W51851", "amount": 180000 },
    { "invoice_uuid": "8d2c4a17-6b3e-4f95-a1d0-7e9c5b2f4a63", "invoice_identifier": "W51846", "amount": 300000 }
  ],
  "unapplied_amount": 0
}
```

`invoice` is the one invoice the payment is recorded on, the one with the smallest amount. `allocations` is where all of it went, that invoice first. `invoice.invoice_token` is the token in that invoice's payment link, not its `uuid`, so it doesn't match an `invoice_uuid`. To find the invoice in `allocations`, take the first entry.

If the amounts break a rule, nothing is recorded: fix the request and send it again with the same `Idempotency-Key`.

The customer isn't emailed. Send `notify_customer: true` to email them that their balance changed.

## Apply a payment to invoices

A payment that came in through Streamlined without naming its invoices, such as a bank transfer, shows in [List transactions](https://docs.streamlinedpayments.com/api-reference/transactions/list-transactions.md) with a null `invoice`, and [Get transaction details](https://docs.streamlinedpayments.com/api-reference/transactions/get-transaction-details.md) gives its `unapplied_amount`. [Apply payment to invoices](https://docs.streamlinedpayments.com/api-reference/transactions/apply-payment-to-invoices.md) puts it on them:

```bash theme={null}
curl https://api.staging.streamlinedpayments.com/api/v1/transactions/6e1d4b92-3f7a-4c08-9b25-a8d3e7f1c540/apply \
  -X POST \
  -H "X-App-Id: $STREAMLINED_APP_ID" \
  -H "X-Api-Key: $STREAMLINED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "invoices": [
      { "invoice_uuid": "8d2c4a17-6b3e-4f95-a1d0-7e9c5b2f4a63", "amount": 300000 },
      { "invoice_uuid": "2b7e9d41-0c5a-4f3e-8a6b-1d9c7e5f3a20", "amount": 180000 }
    ]
  }'
```

You get `200` with the payment, in the same shape as above, with `allocations` filled in and `unapplied_amount` of `0`. Applying again gets `already_applied`, so a retry can't apply it twice.

For a deposit, [Apply deposit to invoice](https://docs.streamlinedpayments.com/api-reference/deposit-links/apply-deposit-to-invoice.md) is simpler: it takes the deposit link's `uuid`, and can queue a deposit that's still processing. See [Deposits](https://docs.streamlinedpayments.com/guides/deposits.md).

## Add a credit or debit note

A credit note lowers what an invoice owes, for a discount, a return, or damaged goods. A debit note raises it, for a late fee or a missed charge. Each is on one invoice, for that invoice's customer.

```bash theme={null}
curl https://api.staging.streamlinedpayments.com/api/v1/transactions \
  -X POST \
  -H "X-App-Id: $STREAMLINED_APP_ID" \
  -H "X-Api-Key: $STREAMLINED_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: credit-W51846-damaged" \
  -d '{
    "type": "credit_note",
    "invoice_uuid": "8d2c4a17-6b3e-4f95-a1d0-7e9c5b2f4a63",
    "amount": 12500,
    "currency": "USD",
    "memo": "One case arrived damaged"
  }'
```

A credit note can't be more than the invoice owes. A debit note has no limit. The customer can see the memo, so keep internal notes out of it.

## Retries

Send an `Idempotency-Key` with every [Record transaction](https://docs.streamlinedpayments.com/api-reference/transactions/record-transaction.md), such as your own payment's ID. Keys are kept for 24 hours.

| You send | You get |
| - | - |
| A new key | The transaction is recorded: `201`. |
| The same key again, after it was recorded with `201` | The first transaction, and nothing new: `200`. |
| The same key while the first request is still running | `409` with `request_in_flight`. Retry shortly with the same key. |
| The same key after a request that was refused | It's recorded this time, if the request is now right. A refused request frees its key. |
| The same key after a `409` with `payment_not_applied` | `409` with `payment_not_applied` again. The payment is recorded, and the key stays with it for 24 hours, so a retry within 24 hours can't record it twice. Don't retry it. Apply it in the Streamlined app. |
| The same key after a `409` with `allocation_in_progress` | It's recorded this time, if the payment can be applied now. Nothing was recorded the first time, so the key is free. Retry shortly. |

[Apply payment to invoices](https://docs.streamlinedpayments.com/api-reference/transactions/apply-payment-to-invoices.md) needs no key: applying a payment that's already applied is refused with `already_applied`.

## Audit log

Each payment, credit note, or debit note you record, and each payment you apply, shows in your account's audit log under your primary contact, marked "via API". A retry that returns the first transaction adds no row. A payment recorded with a `409` and `payment_not_applied` adds no row either, and neither do its retries. See [Authentication](https://docs.streamlinedpayments.com/authentication.md#changes-in-your-audit-log).

## Error codes

Every error has an `error` sentence to show people and a `code` to branch on.

| `code` | Status | What it means and what to do |
| - | - | - |
| `invalid_type` | 422 | `type` isn't `payment`, `credit_note`, or `debit_note`. |
| `invalid_amount` | 422 | An amount isn't a whole number of cents over 0. |
| `currency_required` | 422 | Send `currency`. |
| `currency_mismatch` | 422 | An invoice is in another currency. Send the invoice's currency, or record it in the app. |
| `invalid_payment_source` | 422 | `payment_source` isn't `ach_credit`, `check`, `cash`, or `card`. |
| `invalid_invoices` | 422 | `invoices` needs 1 to 50 items, each with `invoice_uuid` and `amount`. |
| `invoice_voided` | 422 | The note's invoice is voided. |
| `order_deleted` | 422 | The note's invoice has no order any more, so it can't be changed. |
| `entry_refused` | 422 | Record transaction broke a rule, such as amounts that don't add up or a credit note over what's owed. `error` says which. Nothing was recorded. |
| `apply_refused` | 422 | Apply payment to invoices broke a rule. `error` says which. Nothing was applied. |
| `already_applied` | 422 | The payment is already on an invoice. `error` names it. |
| `invalid_idempotency_key` | 422 | The `Idempotency-Key` is over 255 characters. |
| `customer_not_found` | 404 | The customer isn't yours. A `422` with this code means the note's invoice has no customer any more. |
| `invoice_not_found` | 404 | An invoice isn't yours. |
| `transaction_not_found` | 404 | The payment isn't yours, or isn't a payment. |
| `request_in_flight` | 409 | A request with this `Idempotency-Key` is still running. Retry shortly with the same key. |
| `allocation_in_progress` | 409 | The payment is being applied right now. Retry shortly. From Record transaction, nothing was recorded, so retry with the same key. |
| `payment_not_applied` | 409 | The payment was recorded but couldn't be applied, and is waiting in the Streamlined app to be applied there. Don't record it again. A retry with the same `Idempotency-Key` within 24 hours gets this code again. Apply it in the Streamlined app. |


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