Xero: Creates linked transactions (billable expenses)
Xero accounting.createLinkedTransaction: arguments, response, policy and SDK examples.
← Accounting operations · Get started
Operation xero.createlinkedtransaction
Provider route: PUT /api.xro/2.0/LinkedTransactions. 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"]["createLinkedTransaction"]>[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.createLinkedTransaction(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.create_linked_transaction(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
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 linked transactions (billable expenses) — request body — body |
Referenced models: Creates linked transactions (billable expenses) — 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 linked transactions (billable expenses) — response body |
Referenced models: Creates linked transactions (billable expenses) — response body
Schemas
Section titled “Schemas”Creates linked transactions (billable expenses) — request body — body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
ContactID | string | Optional | Filter by the combination of ContactID and Status. Get all the linked transactions that have been assigned to a particular customer and have a particular status e.g. GET /LinkedTransactions?ContactID=4bb34b03-3378-4bb2-a0ed-6345abf3224e&Status=APPROVED. Format: uuid |
LinkedTransactionID | string | Optional | The Xero identifier for an Linked Transaction e.g./LinkedTransactions/297c2dc5-cc47-4afd-8ec8-74990b8761e9 Format: uuid |
SourceLineItemID | string | Optional | The line item identifier from the source transaction. Format: uuid |
SourceTransactionID | string | Optional | Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY invoice Format: uuid |
SourceTransactionTypeCode | string | Optional | The Type of the source tranasction. This will be ACCPAY if the linked transaction was created from an invoice and SPEND if it was created from a bank transaction. One of: ACCPAY, SPEND |
Status | string | Optional | Filter by the combination of ContactID and Status. Get all the linked transactions that have been assigned to a particular customer and have a particular status e.g. GET /LinkedTransactions?ContactID=4bb34b03-3378-4bb2-a0ed-6345abf3224e&Status=APPROVED. One of: APPROVED, DRAFT, ONDRAFT, BILLED, VOIDED |
TargetLineItemID | string | Optional | The line item identifier from the target transaction. It is possible to link multiple billable expenses to the same TargetLineItemID. Format: uuid |
TargetTransactionID | string | Optional | Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice Format: uuid |
Type | string | Optional | This will always be BILLABLEEXPENSE. More types may be added in future. One of: BILLABLEEXPENSE |
UpdatedDateUTC | string | Optional | The last modified date in UTC format 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 |
Referenced models: Retrieves journals — response body — Warnings item
Creates linked transactions (billable expenses) — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
LinkedTransactions | array | Optional | |
LinkedTransactions[] | Model | Each item | Expand Creates linked transactions (billable expenses) — response body — Linked Transactions item |
Referenced models: Creates linked transactions (billable expenses) — response body — Linked Transactions item
Retrieves journals — response body — Warnings item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
Message | string | Optional | Validation error message |
Creates linked transactions (billable expenses) — response body — Linked Transactions item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
ContactID | string | Optional | Filter by the combination of ContactID and Status. Get all the linked transactions that have been assigned to a particular customer and have a particular status e.g. GET /LinkedTransactions?ContactID=4bb34b03-3378-4bb2-a0ed-6345abf3224e&Status=APPROVED. Format: uuid |
LinkedTransactionID | string | Optional | The Xero identifier for an Linked Transaction e.g./LinkedTransactions/297c2dc5-cc47-4afd-8ec8-74990b8761e9 Format: uuid |
SourceLineItemID | string | Optional | The line item identifier from the source transaction. Format: uuid |
SourceTransactionID | string | Optional | Filter by the SourceTransactionID. Get all the linked transactions created from a particular ACCPAY invoice Format: uuid |
SourceTransactionTypeCode | string | Optional | The Type of the source tranasction. This will be ACCPAY if the linked transaction was created from an invoice and SPEND if it was created from a bank transaction. Known values: ACCPAY, SPEND |
Status | string | Optional | Filter by the combination of ContactID and Status. Get all the linked transactions that have been assigned to a particular customer and have a particular status e.g. GET /LinkedTransactions?ContactID=4bb34b03-3378-4bb2-a0ed-6345abf3224e&Status=APPROVED. Known values: APPROVED, DRAFT, ONDRAFT, BILLED, VOIDED |
TargetLineItemID | string | Optional | The line item identifier from the target transaction. It is possible to link multiple billable expenses to the same TargetLineItemID. Format: uuid |
TargetTransactionID | string | Optional | Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice Format: uuid |
Type | string | Optional | This will always be BILLABLEEXPENSE. More types may be added in future. Known values: BILLABLEEXPENSE |
UpdatedDateUTC | string | Optional | The last modified date in UTC format 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 |
Referenced models: Retrieves journals — response body — Warnings item
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: xero.createlinkedtransaction. Catalog operation: createLinkedTransaction. 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.