Skip to content

Xero: Updates or creates one or more items

Xero accounting.updateOrCreateItems: arguments, response, policy and SDK examples.

← Accounting operations · Get started

Operation xero.updateorcreateitems

Provider route: POST /api.xro/2.0/Items. 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"]["updateOrCreateItems"]>[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.updateOrCreateItems(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_items(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 Updates a specific item — request body — body

Referenced models: Updates a specific item — 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 Retrieves items — response body

Referenced models: Retrieves items — response body

Updates a specific item — request body — body
FieldTypePresenceDescription and constraints
$objectRoot
ItemsarrayOptional
Items[]ModelEach itemExpand Updates a specific item — request body — body Items item

Referenced models: Updates a specific item — request body — body Items item

Retrieves items — response body
FieldTypePresenceDescription and constraints
$objectRoot
ItemsarrayOptional
Items[]ModelEach itemExpand Retrieves items — response body — Items item

Referenced models: Retrieves items — response body — Items item

Updates a specific item — request body — body Items item
FieldTypePresenceDescription and constraints
$objectRoot
CodestringRequired within parentUser defined item code (max length = 30)
Maximum length: 30
DescriptionstringOptionalThe sales description of the item (max length = 4000)
Maximum length: 4000
InventoryAssetAccountCodestringOptionalThe inventory asset account for the item. The account must be of type INVENTORY. The COGSAccountCode in PurchaseDetails is also required to create a tracked item
IsPurchasedbooleanOptionalBoolean value, defaults to true. When IsPurchased is true the item is available for purchase transactions in the Xero UI. If IsPurchased is updated to false then PurchaseDescription and PurchaseDetails values will be nulled.
IsSoldbooleanOptionalBoolean value, defaults to true. When IsSold is true the item will be available on sales transactions in the Xero UI. If IsSold is updated to false then Description and SalesDetails values will be nulled.
IsTrackedAsInventorybooleanOptionalTrue for items that are tracked as inventory. An item will be tracked as inventory if the InventoryAssetAccountCode and COGSAccountCode are set.
ItemIDstringOptionalThe Xero identifier for an Item
Format: uuid
NamestringOptionalThe name of the item (max length = 50)
Maximum length: 50
PurchaseDescriptionstringOptionalThe purchase description of the item (max length = 4000)
Maximum length: 4000
PurchaseDetailsModelOptionalExpand Updates a specific item — request body — body Items item Sales Details
QuantityAvailablenumberOptionalThe quantity of the item available. This is equal to `QuantityOnHand` - `QuantityOnBackOrder`. This value will be negative if `QuantityOnBackOrder` is greater than 0.
Format: double
Read only: true
QuantityOnBackOrdernumberOptionalThe quantity of the item on backorder. This will be 0 if `QuantityOnHand` is greater than 0.
Format: double
Read only: true
QuantityOnHandnumberOptionalThe quantity of the item on hand. This will be 0 if `QuantityOnBackOrder` is greater than 0.
Format: double
SalesDetailsModelOptionalExpand Updates a specific item — request body — body Items item Sales Details
StatusAttributeStringstringOptionalStatus of object
TotalCostPoolnumberOptionalThe value of the item on hand. Calculated using average cost accounting.
Format: double
UpdatedDateUTCstringOptionalLast modified date in UTC format
Read only: true
ValidationErrorsarrayOptionalDisplays array of validation error messages from the API
ValidationErrors[]ModelEach itemExpand Retrieves journals — response body — Warnings item

Referenced models: Retrieves journals — response body — Warnings item, Updates a specific item — request body — body Items item Sales Details

Retrieves items — response body — Items item
FieldTypePresenceDescription and constraints
$objectRoot
CodestringRequired within parentUser defined item code (max length = 30)
Maximum length: 30
DescriptionstringOptionalThe sales description of the item (max length = 4000)
Maximum length: 4000
InventoryAssetAccountCodestringOptionalThe inventory asset account for the item. The account must be of type INVENTORY. The COGSAccountCode in PurchaseDetails is also required to create a tracked item
IsPurchasedbooleanOptionalBoolean value, defaults to true. When IsPurchased is true the item is available for purchase transactions in the Xero UI. If IsPurchased is updated to false then PurchaseDescription and PurchaseDetails values will be nulled.
IsSoldbooleanOptionalBoolean value, defaults to true. When IsSold is true the item will be available on sales transactions in the Xero UI. If IsSold is updated to false then Description and SalesDetails values will be nulled.
IsTrackedAsInventorybooleanOptionalTrue for items that are tracked as inventory. An item will be tracked as inventory if the InventoryAssetAccountCode and COGSAccountCode are set.
ItemIDstringOptionalThe Xero identifier for an Item
Format: uuid
NamestringOptionalThe name of the item (max length = 50)
Maximum length: 50
PurchaseDescriptionstringOptionalThe purchase description of the item (max length = 4000)
Maximum length: 4000
PurchaseDetailsModelOptionalExpand Retrieves items — response body — Items item Sales Details
QuantityAvailableJSONOptional
QuantityAvailable (anyOf 1)numberAlternativeThe quantity of the item available. This is equal to `QuantityOnHand` - `QuantityOnBackOrder`. This value will be negative if `QuantityOnBackOrder` is greater than 0.
Format: double
Read only: true
QuantityAvailable (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
QuantityOnBackOrderJSONOptional
QuantityOnBackOrder (anyOf 1)numberAlternativeThe quantity of the item on backorder. This will be 0 if `QuantityOnHand` is greater than 0.
Format: double
Read only: true
QuantityOnBackOrder (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
QuantityOnHandJSONOptional
QuantityOnHand (anyOf 1)numberAlternativeThe quantity of the item on hand. This will be 0 if `QuantityOnBackOrder` is greater than 0.
Format: double
QuantityOnHand (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
SalesDetailsModelOptionalExpand Retrieves items — response body — Items item Sales Details
StatusAttributeStringstringOptionalStatus of object
TotalCostPoolJSONOptional
TotalCostPool (anyOf 1)numberAlternativeThe value of the item on hand. Calculated using average cost accounting.
Format: double
TotalCostPool (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
UpdatedDateUTCstringOptionalLast modified date in UTC format
Read only: true
ValidationErrorsarrayOptionalDisplays array of validation error messages from the API
ValidationErrors[]ModelEach itemExpand Retrieves journals — response body — Warnings item

Referenced models: Retrieves items — response body — Items item Sales Details, Retrieves journals — response body — Warnings item

Retrieves journals — response body — Warnings item
FieldTypePresenceDescription and constraints
$objectRoot
MessagestringOptionalValidation error message
Updates a specific item — request body — body Items item Sales Details
FieldTypePresenceDescription and constraints
$objectRoot
AccountCodestringOptionalDefault account code to be used for purchased/sale. Not applicable to the purchase details of tracked items
COGSAccountCodestringOptionalCost of goods sold account. Only applicable to the purchase details of tracked items.
TaxTypestringOptionalThe tax type from TaxRates
UnitPricenumberOptionalUnit Price of the item. By default UnitPrice is rounded to two decimal places. You can use 4 decimal places by adding the unitdp=4 querystring parameter to your request.
Format: double
Retrieves items — response body — Items item Sales Details
FieldTypePresenceDescription and constraints
$objectRoot
AccountCodestringOptionalDefault account code to be used for purchased/sale. Not applicable to the purchase details of tracked items
COGSAccountCodestringOptionalCost of goods sold account. Only applicable to the purchase details of tracked items.
TaxTypestringOptionalThe tax type from TaxRates
UnitPriceJSONOptional
UnitPrice (anyOf 1)numberAlternativeUnit Price of the item. By default UnitPrice is rounded to two decimal places. You can use 4 decimal places by adding the unitdp=4 querystring parameter to your request.
Format: double
UnitPrice (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$

SDK function policy ID: xero.updateorcreateitems. Catalog operation: updateOrCreateItems. 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.