Create and Apply Credit Memo (POST)

Create a credit memo and apply it to an invoice. The credit memo can fully or partially credit the invoice.

Use this API to adjust an outstanding invoice balance or rectify errors in an invoice. In the API request, pass a list of invoice lines to credit. Keep these considerations in mind when you use this API.

  • The request must contain at least one invoice line. Each invoice line must have the invoice line’s ID, the amount to credit, and any optional tax details. The invoice lines must be a part of the invoice passed in the resource.
  • The amount to credit must not exceed the charge or adjustment amount of an individual invoice line.
  • The request body’s credit amount inclusive of taxes must not exceed the target invoice line’s amount inclusive of taxes, except for taxes calculated through an external tax service.
  • The request body’s total credit amount inclusive of taxes calculated through an external tax service must not exceed the outstanding invoice balance, which is also inclusive of taxes.

This API creates and posts a credit memo. The credit memo has one credit memo line for each invoice line passed in the API request. The invoice balance reduces by a value equal to the credit memo’s balance. This API modifies the balance of a posted invoice or invoice line based on the specified credit application level for your org. See Apply Credits to Posted Invoices or Invoice Lines.

Special Access Rules 

You need the Credit Memo Operations User permission set to use this API.

Resource 

1/commerce/invoicing/invoices/{invoiceId}/actions/credit

Resource Example 

1https://{yourInstance}.salesforce.com/services/data/v68.0/commerce/invoicing/invoices/{3ttR000000008NEIAY}/actions/credit

Available Version 

62.0

HTTP Methods 

POST

Path Parameter for POST 

NameTypeDescriptionRequired or OptionalAvailable Version
invoice​IdStringID of the invoice to be credited partially or fully. The status of the invoice must be Posted.Required62.0

Request Body for POST 

JSON Example

This example shows a sample request with the Calculate tax strategy.

1{
2  "type": "POSTED",
3  "taxStrategy": "Calculate",
4  "taxEffectiveDate": "2024-07-20",
5  "effectiveDate": "2024-07-20",
6  "description": "Credit Invoice",
7  "invoiceLines": [
8    {
9      "invoiceLineId": "5TVR00000004SiqOBE",
10      "amountToCredit": 5
11    }
12  ]
13}

This example shows a sample request with the CopyFromInvoiceLine tax strategy.

1{
2  "type": "POSTED",
3  "taxStrategy": "CopyFromInvoiceLine",
4  "effectiveDate": "2020-05-22",
5  "description": "Credit Invoice",
6  "invoiceLines": [
7    {
8      "invoiceLineId": "5TVR00000004SiqOBE",
9      "amountToCredit": "5",
10      "taxStrategy": "CopyFromInvoiceLine"
11    }
12  ]
13}

This example shows a sample request with the ManualOverride and CopyFromInvoiceLine tax strategies.

1{
2  "type": "POSTED",
3  "taxStrategy": "ManualOverride",
4  "taxEffectiveDate": "2021-08-01",
5  "effectiveDate": "2021-08-01",
6  "description": "Credit issued because product was malfunctioning.",
7  "invoiceLines": [
8    {
9      "invoiceLineId": "5TVR00000004SiqOBE",
10      "amountToCredit": 100,
11      "taxStrategy": "ManualOverride",
12      "taxEffectiveDate": "2021-08-01T21:22:41.000Z",
13      "taxes": [
14        {
15          "taxAmount": 15,
16          "taxName": "abc",
17          "taxCode": "taxCode",
18          "taxRate": 7
19        }
20      ],
21      "addresses": {
22        "billingAddress": {
23          "street": "1 Market St #300",
24          "city": "San Francisco",
25          "state": "CA",
26          "country": "US",
27          "postalCode": "94105",
28          "latitude": "37.789901",
29          "longitude": "-122.396923"
30        },
31        "shippingAddress": {
32          "street": "415 Mission St",
33          "city": "San Francisco",
34          "state": "CA",
35          "country": "US",
36          "postalCode": "94105",
37          "latitude": "37.789901",
38          "longitude": "-122.396923"
39        }
40      }
41    },
42    {
43      "invoiceLineId": "5TVR00000004SiqOAE",
44      "amountToCredit": 200,
45      "taxStrategy": "CopyFromInvoiceLine"
46    }
47  ]
48}

Properties

NameTypeDescriptionRequired or OptionalAvailable Version
descriptionStringDescription for the credit memo to be created.Optional62.0
effective​DateStringDate when the credit memo takes effect.Optional62.0
invoice​LinesCredit Invoice Line Input[]List of the invoice lines to be credited. The invoice line IDs must be related to the invoice ID specified in the API request. If invoice lines aren’t specified, the API request results in an error.Required62.0
taxEffective​DateStringDate when the tax takes effect to recalculate the taxes.Optional62.0
tax​StrategyString Required62.0
typeString Optional62.0

Supported values:

  • Ignore—Specifies that the creation of tax lines must be ignored.
  • ManualOverride—Specifies that the provided tax values must be considered for taxes.
  • CopyFromInvoiceLine—Specifies that tax values must be copied from the invoice line.
  • Calculate—Specifies that tax must be calculated by using the API.

Response Body for POST 

Revenue Async Line Level