Apply Payments and Credits by Rules Action

Apply payments and credits to posted invoices by adhering to the specified rules.

This action uses predefined logic to allocate payments and credits, reducing any manual intervention and errors.

This action is available in API version 66.0 and later.

Supported REST HTTP Methods 

URI: /services/data/v68.0/actions/standard/applyPaymentsAndCreditsByRules

Formats: JSON, XML

HTTP Methods: POST

Authentication: Authorization: Bearer TOKEN

Where TOKEN is a placeholder for your OAuth access token.

Inputs 

InputTypeDescription
accountIdreferenceRequired. The ID of the account to perform the settlement of payments and credits against invoices in adherence with the applied rules.
targetDatedateOptional. The date used to select invoices and invoice lines with a posted date equal to or later than the target date to apply payments and credits.

Outputs 

OutputTypeDescription
rulesApplicationResponseApex-definedThe Apex RulesApplicationResponse record that contains the results of rules application including the list of applied rules, application details, and any errors.

Example 

POST

Here’s a sample request for the Apply Payments and Credits by Rules action.

1{
2  "inputs": [
3    {
4      "accountId": "001AAC0001NmajhYBB",
5      "targetDate": "2025-08-27"
6    }
7  ]
8}

Here’s a sample success response for the Apply Payments and Credits by Rules action.

1[
2  {
3    "actionName": "applyPaymentsAndCreditsByRules",
4    "errors": null,
5    "invocationId": null,
6    "isSuccess": true,
7    "outcome": null,
8    "outputValues": {
9      "rulesApplicationResponse": {
10        "rulesApplicationSummary": {
11          "totalPaymentApplications": 1,
12          "totalCreditMemoApplications": 1,
13          "fetchedPaymentsCount": 1,
14          "fetchedCreditMemosCount": 1,
15          "areAllInvoicesConsidered": true
16        },
17        "isSuccess": true,
18        "errors": null,
19        "appliedRules": [
20          "Match Balance",
21          "Prioritize Highest Balance Invoices"
22        ]
23      }
24    },
25    "sortOrder": -1,
26    "version": 1
27  }
28]

Here’s a sample error response for the Apply Payments and Credits by Rules action.

1[
2  {
3    "actionName": "applyPaymentsAndCreditsByRules",
4    "errors": null,
5    "invocationId": null,
6    "isSuccess": true,
7    "outcome": null,
8    "outputValues": {
9      "rulesApplicationResponse": {
10        "rulesApplicationSummary": null,
11        "isSuccess": false,
12        "errors": [
13          {
14            "message": "We couldn't find eligible invoices to apply rules-based credits and payments. ",
15            "errorCode": null
16          }
17        ],
18        "appliedRules": null
19      }
20    },
21    "sortOrder": -1,
22    "version": 1
23  }
24]