Skip to content

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.

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 os
from alter_sdk import App
from 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()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
queryobjectOptionalAdditional keys: not allowed
query.summarizeErrorsbooleanOptionalDefault: false
query.unitdpintegerOptional
headersobjectRequired within parentAdditional keys: not allowed
headers.xero-tenant-idstringRequired within parent
headers.Idempotency-KeystringOptional
bodyModelRequired within parentExpand Creates a new credit note — request body — body

Referenced models: Creates a new credit note — request body — body

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Creates a new credit note — response body

Referenced models: Creates a new credit note — response body

47 more schemas are linked from the tables above, on the schema pages.

Creates a new credit note — request body — body
FieldTypePresenceDescription and constraints
$objectRoot
CreditNotesarrayOptional
CreditNotes[]ModelEach itemExpand Creates a single payment for invoice or credit notes — request body — body Credit Note
WarningsarrayOptionalDisplays array of warning messages from the API
Warnings[]ModelEach itemExpand Retrieves journals — response body — Warnings item
paginationModelOptionalExpand 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
FieldTypePresenceDescription and constraints
$objectRoot
CreditNotesarrayOptional
CreditNotes[]ModelEach itemExpand Deletes an Allocation from a Prepayment — response body — Credit Note
WarningsarrayOptionalDisplays array of warning messages from the API
Warnings[]ModelEach itemExpand Retrieves journals — response body — Warnings item
paginationModelOptionalExpand 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
FieldTypePresenceDescription and constraints
$objectRoot
itemCountintegerOptional
pageintegerOptional
pageCountintegerOptional
pageSizeintegerOptional
Creates a single payment for invoice or credit notes — request body — body Credit Note
FieldTypePresenceDescription and constraints
$objectRoot
AllocationsarrayOptionalSee Allocations
Allocations[]ModelEach itemExpand Creates allocation for a specific credit note — request body — body Allocations item
AppliedAmountnumberOptionalThe amount of applied to an invoice
Format: double
BrandingThemeIDstringOptionalSee BrandingThemes
Format: uuid
CISDeductionnumberOptionalCIS deduction for UK contractors
Format: double
Read only: true
CISRatenumberOptionalCIS Deduction rate for the organisation
Format: double
Read only: true
ContactModelOptionalExpand Creates contacts to a specific contact group — request body — body Contacts item
CreditNoteIDstringOptionalXero generated unique identifier
Format: uuid
CreditNoteNumberstringOptionalACCRECCREDIT – Unique alpha numeric code identifying credit note (when missing will auto-generate from your Organisation Invoice Settings)
CurrencyCodeModelOptionalExpand Create a new currency for a Xero organisation — request body — body Code
The specified currency code
CurrencyRatenumberOptionalThe currency rate for a multicurrency invoice. If no rate is specified, the XE.com day rate is used
Format: double
DatestringOptionalThe 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
DueDatestringOptionalDate invoice is due – YYYY-MM-DD
FullyPaidOnDatestringOptionalDate when credit note was fully paid(UTC format)
HasAttachmentsbooleanOptionalboolean to indicate if a credit note has an attachment
Default: false
HasErrorsbooleanOptionalA boolean to indicate if a credit note has an validation errors
Default: false
InvoiceAddressesarrayOptionalAn array of addresses used to auto calculate sales tax
InvoiceAddresses[]ModelEach itemExpand Creates a single payment for invoice or credit notes — request body — body Invoice Invoice Addresses item
LineAmountTypesstringOptionalLine amounts are exclusive of tax by default if you don’t specify this element. See Line Amount Types
One of: Exclusive, Inclusive, NoTax
LineItemsarrayOptionalSee Invoice Line Items
LineItems[]ModelEach itemExpand Creates a single payment for invoice or credit notes — request body — body Invoice Line Items item
PaymentsarrayOptionalSee Payments
Payments[]ModelEach itemExpand Creates a single payment for invoice or credit notes — request body — body
ReferencestringOptionalACCRECCREDIT only – additional reference number
RemainingCreditnumberOptionalThe remaining credit balance on the Credit Note
Format: double
SentToContactbooleanOptionalBoolean 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
StatusstringOptionalSee Credit Note Status Codes
One of: DRAFT, SUBMITTED, DELETED, AUTHORISED, PAID, VOIDED
StatusAttributeStringstringOptionalA string to indicate if a invoice status
SubTotalnumberOptionalThe subtotal of the credit note excluding taxes
Format: double
TotalnumberOptionalThe total of the Credit Note(subtotal + total tax)
Format: double
TotalTaxnumberOptionalThe total tax on the credit note
Format: double
TypestringOptionalSee Credit Note Types
One of: ACCPAYCREDIT, ACCRECCREDIT
UpdatedDateUTCstringOptionalUTC timestamp of last update to the credit note
Read only: true
UpdatedDateUTCStringstringOptionalUTC ISO-8601 formatted timestamp of last update to the credit note
Read only: true
ValidationErrorsarrayOptionalDisplays array of validation error messages from the API
ValidationErrors[]ModelEach itemExpand Retrieves journals — response body — Warnings item
WarningsarrayOptionalDisplays array of warning messages from the API
Warnings[]ModelEach itemExpand 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
FieldTypePresenceDescription and constraints
$objectRoot
MessagestringOptionalValidation error message
Retrieves prepayments — response body — pagination
FieldTypePresenceDescription and constraints
$objectRoot
itemCountJSONOptional
itemCount (anyOf 1)integerAlternative
itemCount (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
pageJSONOptional
page (anyOf 1)integerAlternative
page (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
pageCountJSONOptional
pageCount (anyOf 1)integerAlternative
pageCount (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
pageSizeJSONOptional
pageSize (anyOf 1)integerAlternative
pageSize (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
Creates contacts to a specific contact group — response body — Contacts item Contact Persons item
FieldTypePresenceDescription and constraints
$objectRoot
EmailAddressstringOptionalEmail address of person
FirstNamestringOptionalFirst name of person
IncludeInEmailsbooleanOptionalboolean to indicate whether contact should be included on emails with invoices etc.
LastNamestringOptionalLast name of person

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.

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.