Xero: Updates or creates one or more credit notes
Xero accounting.updateOrCreateCreditNotes: arguments, response, policy and SDK examples.
← Accounting operations · Get started
Operation xero.updateorcreatecreditnotes
Provider route: POST /api.xro/2.0/CreditNotes. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/xero with npm, or alter-sdk-xero with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { XeroIntegration } from "@alter-ai/xero";
async function execute(input: Parameters<XeroIntegration["accounting"]["updateOrCreateCreditNotes"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new XeroIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.accounting.updateOrCreateCreditNotes(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_xero import XeroIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = XeroIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.accounting.update_or_create_credit_notes(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
query | object | Optional | Additional keys: not allowed |
query.summarizeErrors | boolean | Optional | Default: false |
query.unitdp | integer | Optional | |
headers | object | Required within parent | Additional keys: not allowed |
headers.xero-tenant-id | string | Required within parent | |
headers.Idempotency-Key | string | Optional | |
body | Model | Required within parent | Expand Creates a new credit note — request body — body |
Referenced models: Creates a new credit note — request body — body
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Creates a new credit note — response body |
Referenced models: Creates a new credit note — response body
Schemas
Section titled “Schemas”47 more schemas are linked from the tables above, on the schema pages.
Creates a new credit note — request body — body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
CreditNotes | array | Optional | |
CreditNotes[] | Model | Each item | Expand Creates a single payment for invoice or credit notes — request body — body Credit Note |
Warnings | array | Optional | Displays array of warning messages from the API |
Warnings[] | Model | Each item | Expand Retrieves journals — response body — Warnings item |
pagination | Model | Optional | Expand Creates a new credit note — request body — body pagination |
Referenced models: Creates a new credit note — request body — body pagination, Creates a single payment for invoice or credit notes — request body — body Credit Note, Retrieves journals — response body — Warnings item
Creates a new credit note — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
CreditNotes | array | Optional | |
CreditNotes[] | Model | Each item | Expand Deletes an Allocation from a Prepayment — response body — Credit Note |
Warnings | array | Optional | Displays array of warning messages from the API |
Warnings[] | Model | Each item | Expand Retrieves journals — response body — Warnings item |
pagination | Model | Optional | Expand Retrieves prepayments — response body — pagination |
Referenced models: Retrieves prepayments — response body — pagination, Deletes an Allocation from a Prepayment — response body — Credit Note, Retrieves journals — response body — Warnings item
Creates a new credit note — request body — body pagination
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
itemCount | integer | Optional | |
page | integer | Optional | |
pageCount | integer | Optional | |
pageSize | integer | Optional |
Creates a single payment for invoice or credit notes — request body — body Credit Note
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
Allocations | array | Optional | See Allocations |
Allocations[] | Model | Each item | Expand Creates allocation for a specific credit note — request body — body Allocations item |
AppliedAmount | number | Optional | The amount of applied to an invoice Format: double |
BrandingThemeID | string | Optional | See BrandingThemes Format: uuid |
CISDeduction | number | Optional | CIS deduction for UK contractors Format: double Read only: true |
CISRate | number | Optional | CIS Deduction rate for the organisation Format: double Read only: true |
Contact | Model | Optional | Expand Creates contacts to a specific contact group — request body — body Contacts item |
CreditNoteID | string | Optional | Xero generated unique identifier Format: uuid |
CreditNoteNumber | string | Optional | ACCRECCREDIT – Unique alpha numeric code identifying credit note (when missing will auto-generate from your Organisation Invoice Settings) |
CurrencyCode | Model | Optional | Expand Create a new currency for a Xero organisation — request body — body Code The specified currency code |
CurrencyRate | number | Optional | The currency rate for a multicurrency invoice. If no rate is specified, the XE.com day rate is used Format: double |
Date | string | Optional | The date the credit note is issued YYYY-MM-DD. If the Date element is not specified then it will default to the current date based on the timezone setting of the organisation |
DueDate | string | Optional | Date invoice is due – YYYY-MM-DD |
FullyPaidOnDate | string | Optional | Date when credit note was fully paid(UTC format) |
HasAttachments | boolean | Optional | boolean to indicate if a credit note has an attachment Default: false |
HasErrors | boolean | Optional | A boolean to indicate if a credit note has an validation errors Default: false |
InvoiceAddresses | array | Optional | An array of addresses used to auto calculate sales tax |
InvoiceAddresses[] | Model | Each item | Expand Creates a single payment for invoice or credit notes — request body — body Invoice Invoice Addresses item |
LineAmountTypes | string | Optional | Line amounts are exclusive of tax by default if you don’t specify this element. See Line Amount Types One of: Exclusive, Inclusive, NoTax |
LineItems | array | Optional | See Invoice Line Items |
LineItems[] | Model | Each item | Expand Creates a single payment for invoice or credit notes — request body — body Invoice Line Items item |
Payments | array | Optional | See Payments |
Payments[] | Model | Each item | Expand Creates a single payment for invoice or credit notes — request body — body |
Reference | string | Optional | ACCRECCREDIT only – additional reference number |
RemainingCredit | number | Optional | The remaining credit balance on the Credit Note Format: double |
SentToContact | boolean | Optional | Boolean to set whether the credit note in the Xero app should be marked as “sent”. This can be set only on credit notes that have been approved |
Status | string | Optional | See Credit Note Status Codes One of: DRAFT, SUBMITTED, DELETED, AUTHORISED, PAID, VOIDED |
StatusAttributeString | string | Optional | A string to indicate if a invoice status |
SubTotal | number | Optional | The subtotal of the credit note excluding taxes Format: double |
Total | number | Optional | The total of the Credit Note(subtotal + total tax) Format: double |
TotalTax | number | Optional | The total tax on the credit note Format: double |
Type | string | Optional | See Credit Note Types One of: ACCPAYCREDIT, ACCRECCREDIT |
UpdatedDateUTC | string | Optional | UTC timestamp of last update to the credit note Read only: true |
UpdatedDateUTCString | string | Optional | UTC ISO-8601 formatted timestamp of last update to the credit note Read only: true |
ValidationErrors | array | Optional | Displays array of validation error messages from the API |
ValidationErrors[] | Model | Each item | Expand Retrieves journals — response body — Warnings item |
Warnings | array | Optional | Displays array of warning messages from the API |
Warnings[] | Model | Each item | Expand Retrieves journals — response body — Warnings item |
Referenced models: Create a new currency for a Xero organisation — request body — body Code, Creates allocation for a specific credit note — request body — body Allocations item, Creates contacts to a specific contact group — request body — body Contacts item, Creates a single payment for invoice or credit notes — request body — body Invoice Invoice Addresses item, Creates a single payment for invoice or credit notes — request body — body Invoice Line Items item, Retrieves journals — response body — Warnings item, Creates a single payment for invoice or credit notes — request body — body
Retrieves journals — response body — Warnings item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
Message | string | Optional | Validation error message |
Retrieves prepayments — response body — pagination
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
itemCount | JSON | Optional | |
itemCount (anyOf 1) | integer | Alternative | |
itemCount (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
page | JSON | Optional | |
page (anyOf 1) | integer | Alternative | |
page (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
pageCount | JSON | Optional | |
pageCount (anyOf 1) | integer | Alternative | |
pageCount (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
pageSize | JSON | Optional | |
pageSize (anyOf 1) | integer | Alternative | |
pageSize (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
Creates contacts to a specific contact group — response body — Contacts item Contact Persons item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
EmailAddress | string | Optional | Email address of person |
FirstName | string | Optional | First name of person |
IncludeInEmails | boolean | Optional | boolean to indicate whether contact should be included on emails with invoices etc. |
LastName | string | Optional | Last name of person |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: xero.updateorcreatecreditnotes. Catalog operation: updateOrCreateCreditNotes. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.