KosmoKrator

finance

Xero CLI for AI Agents

Use the Xero CLI from KosmoKrator to call Xero tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

7 functions 6 read 1 write Manual OAuth token auth

Xero CLI Setup

Xero can be configured headlessly with `kosmokrator integrations:configure xero`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure xero --set access_token="$XERO_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor xero --json
kosmokrator integrations:status --json

Credentials

Authentication type: Manual OAuth token oauth2_manual_token. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
access_token XERO_ACCESS_TOKEN Secret secret yes Access Token
base_url XERO_BASE_URL URL url no API Base URL

Call Xero Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call xero.xero_create_invoice '{
  "contact_id": "example_contact_id",
  "type": "example_type",
  "date": "example_date",
  "due_date": "example_due_date",
  "reference": "example_reference",
  "line_items": "example_line_items",
  "status": "example_status"
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:xero xero_create_invoice '{
  "contact_id": "example_contact_id",
  "type": "example_type",
  "date": "example_date",
  "due_date": "example_due_date",
  "reference": "example_reference",
  "line_items": "example_line_items",
  "status": "example_status"
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs xero --json
kosmo integrations:docs xero.xero_create_invoice --json
kosmo integrations:schema xero.xero_create_invoice --json
kosmo integrations:search "Xero" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Xero.

xero.xero_create_invoice

Write write

Create a new invoice in Xero. Requires a contact_id and at least one line item with description and unit_amount. Returns the created invoice with its ID and number.

Parameters
contact_id, type, date, due_date, reference, line_items, status

Generic CLI call

kosmo integrations:call xero.xero_create_invoice '{"contact_id":"example_contact_id","type":"example_type","date":"example_date","due_date":"example_due_date","reference":"example_reference","line_items":"example_line_items","status":"example_status"}' --json

Provider shortcut

kosmo integrations:xero xero_create_invoice '{"contact_id":"example_contact_id","type":"example_type","date":"example_date","due_date":"example_due_date","reference":"example_reference","line_items":"example_line_items","status":"example_status"}' --json

xero.xero_get_contact

Read read

Retrieve a Xero contact by its ID. Returns the contact's ID, name, email, phone, addresses, and status.

Parameters
contact_id

Generic CLI call

kosmo integrations:call xero.xero_get_contact '{"contact_id":"example_contact_id"}' --json

Provider shortcut

kosmo integrations:xero xero_get_contact '{"contact_id":"example_contact_id"}' --json

xero.xero_get_current_user

Read read

Retrieve the currently authenticated Xero user. Returns the user's ID, name, and email. Useful for identifying which Xero organisation or token is in use.

Parameters
none

Generic CLI call

kosmo integrations:call xero.xero_get_current_user '{}' --json

Provider shortcut

kosmo integrations:xero xero_get_current_user '{}' --json

xero.xero_get_invoice

Read read

Retrieve a Xero invoice by its ID. Returns the full invoice including line items, contact details, and totals.

Parameters
invoice_id

Generic CLI call

kosmo integrations:call xero.xero_get_invoice '{"invoice_id":"example_invoice_id"}' --json

Provider shortcut

kosmo integrations:xero xero_get_invoice '{"invoice_id":"example_invoice_id"}' --json

xero.xero_list_accounts

Read read

List Xero chart of accounts. Returns account codes, names, types, tax types, and statuses.

Parameters
where, order

Generic CLI call

kosmo integrations:call xero.xero_list_accounts '{"where":"example_where","order":"example_order"}' --json

Provider shortcut

kosmo integrations:xero xero_list_accounts '{"where":"example_where","order":"example_order"}' --json

xero.xero_list_contacts

Read read

List Xero contacts with pagination. Returns contact IDs, names, emails, and types. Use page for pagination (1-indexed).

Parameters
page, where, order, include_archived

Generic CLI call

kosmo integrations:call xero.xero_list_contacts '{"page":1,"where":"example_where","order":"example_order","include_archived":true}' --json

Provider shortcut

kosmo integrations:xero xero_list_contacts '{"page":1,"where":"example_where","order":"example_order","include_archived":true}' --json

xero.xero_list_invoices

Read read

List Xero invoices with pagination and filtering. Returns invoice IDs, numbers, amounts, status, and dates. Use page and pageSize for pagination.

Parameters
page, pageSize, statuses, where, order

Generic CLI call

kosmo integrations:call xero.xero_list_invoices '{"page":1,"pageSize":1,"statuses":"example_statuses","where":"example_where","order":"example_order"}' --json

Provider shortcut

kosmo integrations:xero xero_list_invoices '{"page":1,"pageSize":1,"statuses":"example_statuses","where":"example_where","order":"example_order"}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

xero.xero_create_invoice

Create a new invoice in Xero. Requires a contact_id and at least one line item with description and unit_amount. Returns the created invoice with its ID and number.

Operation
Write write
Schema command
kosmo integrations:schema xero.xero_create_invoice --json
ParameterTypeRequiredDescription
contact_id string yes Xero contact ID (UUID) to invoice.
type string no Invoice type: "ACCREC" (accounts receivable) or "ACCPAY" (accounts payable). Default: ACCREC.
date string no Invoice date (YYYY-MM-DD). Defaults to today.
due_date string no Due date (YYYY-MM-DD).
reference string no Reference text for the invoice.
line_items array yes Array of line items, each with description, quantity, unit_amount, account_code, tax_type.
status string no Invoice status: "DRAFT" or "AUTHORISED". Default: DRAFT.

xero.xero_get_contact

Retrieve a Xero contact by its ID. Returns the contact's ID, name, email, phone, addresses, and status.

Operation
Read read
Schema command
kosmo integrations:schema xero.xero_get_contact --json
ParameterTypeRequiredDescription
contact_id string yes Xero contact ID (UUID).

xero.xero_get_current_user

Retrieve the currently authenticated Xero user. Returns the user's ID, name, and email. Useful for identifying which Xero organisation or token is in use.

Operation
Read read
Schema command
kosmo integrations:schema xero.xero_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

xero.xero_get_invoice

Retrieve a Xero invoice by its ID. Returns the full invoice including line items, contact details, and totals.

Operation
Read read
Schema command
kosmo integrations:schema xero.xero_get_invoice --json
ParameterTypeRequiredDescription
invoice_id string yes Xero invoice ID (UUID).

xero.xero_list_accounts

List Xero chart of accounts. Returns account codes, names, types, tax types, and statuses.

Operation
Read read
Schema command
kosmo integrations:schema xero.xero_list_accounts --json
ParameterTypeRequiredDescription
where string no Xero where filter expression (e.g. Type=="BANK").
order string no Sort order (e.g. "Code ASC").

xero.xero_list_contacts

List Xero contacts with pagination. Returns contact IDs, names, emails, and types. Use page for pagination (1-indexed).

Operation
Read read
Schema command
kosmo integrations:schema xero.xero_list_contacts --json
ParameterTypeRequiredDescription
page integer no Page number (default 1).
where string no Xero where filter expression.
order string no Sort order (e.g. "Name ASC").
include_archived boolean no Include archived contacts (default false).

xero.xero_list_invoices

List Xero invoices with pagination and filtering. Returns invoice IDs, numbers, amounts, status, and dates. Use page and pageSize for pagination.

Operation
Read read
Schema command
kosmo integrations:schema xero.xero_list_invoices --json
ParameterTypeRequiredDescription
page integer no Page number (default 1).
pageSize integer no Number of invoices per page (default 100, max 2000).
statuses string no Comma-separated filter: DRAFT, SUBMITTED, AUTHORISED, PAID, VOIDED, DELETED.
where string no Xero where filter expression (e.g. Type=="ACCREC").
order string no Sort order (e.g. "Date DESC", "InvoiceNumber ASC").

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.