Creating Refunds
There are two ways to create refunds:Simple Refunds
Use simple refunds when you want to fully refund a single target (invoice, invoice line item, or invoice payment) and the refund is fully paid. Layer automatically:- Calculates the refund amount based on what can be refunded from the target
- Creates one allocation that perfectly cancels out the target
- Creates one refund payment that pays the refund in full
Itemized Refunds
Use itemized refunds for more complex scenarios including:- Refunding multiple targets in a single refund
- Partial refunds that don’t fully cancel out the target
- Unpaid refunds (refunds owed but not yet disbursed)
- Custom allocation amounts or payment structures
Refund Object
Attributes
Unique identifier for the refund.
Unique ID of the refund in your system for linking purposes. Idempotency key.
Amount refunded to the customer in cents.
Status of the refund.
Time when the refund was completed.
Whether this refund is dedicated or not. Dedicated refunds can only have one allocation and one payment, and their allocation target cannot be changed.
Allocations associated with this refund. See Refund Allocation Object for details.
Payments associated with this refund. See Refund Payment Object for details.
Payouts associated with this refund.
Tags associated with the refund.
Memo for any text you would like to associate with the refund.
Arbitrary metadata you can include with the refund.
Any (typically user-visible) identifier you would like to associate with the refund. Can be used to filter when listing refunds.
Refund Allocation Object
A Refund Allocation represents one of the targets of a refund. It can reference a specific invoice, invoice line item, invoice payment, or customer. For example, a refund can apply to two separate invoices if the invoices have the same customer. The total of the amounts of the refund allocations must add up to the refund amount.Unique identifier for the refund allocation.
ID of the invoice this allocation is associated with.
Amount of the allocation in cents.
Line items that make up this allocation. See Refund Allocation Line Item Object for details.
External ID of the invoice this allocation is associated with.
ID of the invoice line item this allocation is associated with. If specified, must not refer to a different invoice than
invoice_id
or invoice_external_id
.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.ID of the invoice payment this allocation is associated with.
External ID of the invoice payment this allocation is associated with.
Tags associated with the refund allocation.
Memo for any text you would like to associate with the refund allocation.
Arbitrary metadata you can include with the refund allocation.
Any (typically user-visible) identifier you would like to associate with the refund allocation.
Refund Allocation Line Item Object
A Refund Allocation Line Item represents a specific line within a refund allocation, allowing for detailed breakdowns of how the allocation amount is distributed across different ledger accounts.External identifier for the line item.
Amount of the line item in cents.
The ledger account associated with this line item.
The prepayment ledger account associated with this line item, if applicable.
Tags associated with the line item.
Memo for any text you would like to associate with the line item.
Arbitrary metadata you can include with the line item.
Any (typically user-visible) identifier you would like to associate with the refund pyment. Can be used to filter when listing refund payments.
Refund Payment Object
A Refund Payment represents a money movement by which the refund was disbursed to the customer. A refund with zero payments represents a refund that is owed to a customer but has not yet been sent. A refund can have many payments so long as the total of theirrefunded_amount
s does not exceed the total amount of the refund.
Refund payments are matchable to bank transactions and are therefore the means by which refunds are reconciled with bank accounts.
Unique identifier for the payment.
Unique ID of the payment in your system for linking purposes. Idempotency key.
Amount refunded to the customer in cents.
Fee paid by the business to make the refund payment (typically a payment processing fee).
Time when the payment was completed.
Method of the payment (e.g.,
CREDIT_CARD
, ACH
, etc.).Processor used for the payment (e.g.,
STRIPE
, SHOPIFY
, etc.).Refunded payment fees associated with the refund payment. See Refunded Payment Fee Object for details.
Tags associated with the refund payment.
Memo for any text you would like to associate with the refund payment.
Arbitrary metadata you can include with the refund payment.
Refunded Payment Fee Object
A Refunded Payment Fee represents a fee that was refunded as part of a refund payment. This differs from the ‘refund_processing_fee’ field on the refund payment, since that is paid by the business (typically to a payment processor), whereas this is refunded from the payment processor back to the business.Identifier of the ledger account for the refunded payment fee.
Description of the fee that the refunded payment fee refunds.
Amount of the fee refund in cents.
Simple Refund Creation Parameters
Use these parameters to create a simple refund that fully refunds a single target (invoice, invoice line item, or invoice payment) and is fully paid.Unique ID of the refund in your system for linking purposes. Idempotency key.
When the refund was completed and paid.
The ID of the invoice to refund. Cannot be used with other target identifiers.
The external ID of the invoice to refund. Cannot be used with other target identifiers.
The ID of the invoice line item to refund. Cannot be used with other target identifiers.
The external ID of the invoice line item to refund. Cannot be used with other target identifiers.
The ID of the invoice payment to refund. Cannot be used with other target identifiers.
The external ID of the invoice payment to refund. Cannot be used with other target identifiers.
Fee charged to the business for processing the refund in cents. Defaults to 0.
Method of the payment (e.g.,
CREDIT_CARD
, ACH
, etc.).Processor used for the payment (e.g.,
STRIPE
, SHOPIFY
, etc.).List of tags associated with this refund.
Memo for any text you would like to associate with the refund.
Arbitrary metadata you can include with the refund.
Itemized Refund Creation Parameters
Use these parameters to create an itemized refund with full control over allocations and payments.Unique ID of the refund in your system for linking purposes. Idempotency key.
The total amount of the refund in cents. Must equal the sum of all allocation amounts.
When the refund was completed.
The targets of the refund. Each allocation specifies how much of the refund should be applied to a specific invoice, line item, payment, or customer.
The payment methods and amounts used to process the refund.
List of tags associated with this refund.
Memo for any text you would like to associate with the refund.
Arbitrary metadata you can include with the refund.
Dedicated Refunds
Dedicated refunds are a refunds that are created alongside invoices, invoice line items, and invoice payments. They provide a streamlined way to create refunds during the invoice creation or payment recording process. They are intended for when you know at the time of importing an invoice, invoice line item, or payment that it will be refunded, and want to create everything in one API call. Each dedicated refund has exactly one allocation and one payment. Once created, the allocation target cannot be changed Dedicated refunds can be included when creating: Invoices: Adddedicated_refunds
array to the invoice body
Invoice Line Items: Add dedicated_refunds
array to any line item
Invoice Payments: Add dedicated_refunds
array to any payment within an invoice
Simple vs Itemized Dedicated Refunds
When creating dedicated refunds, Layer will automatically determine whether to create them as simple or itemized refunds based on the parameters you provide: Simple Dedicated Refunds (see Simple Refunds):- Created when you don’t specify the
line_items
parameter - Layer automatically calculates the refund amount and creates a single allocation
- Ideal for straightforward refunds where you want to refund the full amount of a target
- Created when you provide the
line_items
parameter with detailed allocation breakdowns - You have full control over how the refund amount is distributed across different ledger accounts
- Required for complex refunds involving multiple accounts or partial amounts
Create Dedicated Refund Parameters Object
External ID for the refund within your platform. Idempotency key.
The Account Identifier for the refund allocation. If not specified, will use the appropriate account based on the target.
Detailed line items for the refund allocation. Use this for itemized refunds where you need to specify the exact amounts and accounts.
When the refund was completed.
Processing fee for the refund, in cents. Defaults to 0.
Method used to make the refund.
Values can be:
CASH
, CHECK
, CREDIT_CARD
, ACH
, CREDIT_BALANCE
, OTHER
Processor used to make the refund, if any.
List of payment fees that were refunded as part of this refund.
List of tags associated with this refund.
Any text you would like to associate with the refund.
Arbitrary metadata you can include with the refund.
Any (typically user-visible) identifier you would like to associate with the refund.