How to Refund a Customer Deposit using NetSuite SuiteTalk

When refunding a NetSuite CustomerRefund or CashSale you'll add it to apply_list:

refund.apply_list = { apply: [
  {
    doc: 123,    # internalId of the CustomerRefund
    apply: true
  }
] }

Refunding a CustomerDeposit works a bit differently. If you inspect the SuiteTalk XML response for a CustomerRefund created for a CustomerDeposit it will appear under the apply_list XML tag. If you use that XML tag when creating the CustomerRefund you'll get the following error:

Unable to find a matching line for sublist apply with key

Instead, you need to use the deposit_list tag:

refund.deposit_list = { customer_refund_deposit: [
  {
    doc: 123,    # internalId of CustomerDeposit
    apply: true
  }
] }