Create (from invoice lines)

Creates a new credit memo and returns its full payload.

Body

FieldTypeDefaultDescription
creditmemo_dataobject—Required. The credit memo, see below
commentstring—Optional comment stored on the memo
notify_customerboolfalseEmail the customer. For a refund handling this sends the refund receipt instead of the credit memo email
include_commentboolfalsePut comment in the email body. Has no effect on visibility
is_visible_on_frontboolfalseShow comment to the customer in their account

creditmemo_data

FieldDescription
customer_id / company_idThe account the credit belongs to. At least one is required, unless a linked invoice supplies the owner. A guest (ownerless) memo is allowed only together with a refund handling
store_idDefaults to the store of the source invoice, or the default store
creditmemo_type1 Items (default) or 2 Amount. An Amount memo may not include items or a fee_amount
memo_amountCredit amount for an Amount memo
shipping_amount, tax_amount, discount_amount, payment_surcharge_amount, fee_amountHeader amounts. fee_amount is for Items memos only
adjustment_amountAdjustment applied to the total. A memo whose grand total nets to 0 is created already Applied
created_atOptional credit memo date. It may not be later than today in the store's timezone
items[]Credit lines, see below
source_entity_links[]Optional { "linked_entity_type": 2, "linked_entity_id": <bill_id> } rows. If omitted they are derived from items[]
credit_handlingcredit (default), refund_offline or refund_online. An unknown value is rejected; it never falls back to credit
refund{ "method_code", "method_code_comment" }. Only allowed with refund_offline, where method_code must be an offline payment method

items[]

Each line must be one of these two kinds:

  • Invoice line: either unique_item_id as "2_<bill_id>_<bill_item_id>", or all three of linked_entity_type: 2, linked_entity_id and linked_entity_item_id. A partial reference is rejected, so an invoice line can't quietly turn into a standalone credit. Leaving out qty credits the line's full remaining creditable quantity.
  • Standalone line: product_id with no invoice reference. The price comes from the product's final price.

Optional on either kind: qty (always units, never packages), back_to_stock (return the quantity to inventory), location_id (inventory location) and ignore_packaging (bool, deliberately break a sold package).

Ignored fields

The server always creates a new memo. creditmemo_id, entity_id, increment_id, state, key and qty_entered_in_packages are ignored on the header, and so are item_id, entity_id and parent_id on items.

Response

{ success, creditmemo, notify_customer }, plus a refund object when a refund handling was used:

FieldDescription
refund.increment_idRefund transaction increment id
refund.capture_caseonline / offline
refund.method_code, refund.method_code_commentHow the refund was paid
refund.total, refund.base_totalRefunded amount
refund.payment_increment_idThe payment refunded. null for a ledger-only refund, e.g. when the source invoice was paid by credit

A refund failure, including a gateway decline, saves nothing. If the memo is saved but building the full response fails, the response is still success: true with only the increment ids, so the client must not retry in that case.

Variant: Create (standalone product)

Standalone Items memo: credits a product that isn't tied to an invoice line. The owner (customer_id and/or company_id) is required and the price comes from the product's final price.

See Create (from invoice lines) for the full field reference.

Variant: Create (flat amount)

Amount memo (creditmemo_type: 2): a flat credit of memo_amount with no line items. items and fee_amount are rejected on this type.

See Create (from invoice lines) for the full field reference.

Variant: Create + offline refund

Creates the memo and immediately pays all of its credit out as an offline refund in the same step. refund.method_code must be an offline payment method. notify_customer sends the refund receipt.

For a gateway refund use credit_handling: refund_online and leave out refund (sending it is rejected).

See Create (from invoice lines) for the full field reference.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Body Params
creditmemo_data
object
string
boolean
boolean
boolean
Responses

Language
Credentials
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json