data
Xero Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Xero KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.xero.*.
Use lua_read_doc("integrations.xero") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Xero workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.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 kosmo integrations:lua --eval 'print(docs.read("xero"))' --json
kosmo integrations:lua --eval 'print(docs.read("xero.create_invoice"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local xero = app.integrations.xero
local result = 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"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.xero, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.xero.default.* or app.integrations.xero.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Xero, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
Client for the Xero Accounting REST API — Lua API Reference
xero_list_invoices
List Xero invoices with pagination and filtering. Returns invoice IDs, numbers, amounts, status, and dates.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
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”). |
Example
local result = app.integrations.xero.xero_list_invoices({
page = 1
pageSize = 50
statuses = "AUTHORISED"
})
xero_get_invoice
Retrieve a Xero invoice by its ID. Returns the full invoice including line items, contact details, and totals.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
invoice_id | string | yes | Xero invoice ID (UUID). |
Example
local result = app.integrations.xero.xero_get_invoice({
invoice_id = "abc123-def456-..."
})
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.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | Xero contact ID (UUID) to invoice. |
type | string | no | Invoice type: “ACCREC” or “ACCPAY”. 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. |
status | string | no | Invoice status: “DRAFT” or “AUTHORISED”. Default: DRAFT. |
Example
local result = app.integrations.xero.xero_create_invoice({
contact_id = "abc123-def456-..."
type = "ACCREC"
date = "2026-04-07"
due_date = "2026-05-07"
reference = "Order #12345"
line_items = {
{ description = "Consulting services", quantity = 10, unit_amount = 150.00, account_code = "200" }
{ description = "Software license", quantity = 1, unit_amount = 500.00, account_code = "400" }
}
status = "AUTHORISED"
})
xero_list_contacts
List Xero contacts with pagination. Returns contact IDs, names, emails, and types.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
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). |
Example
local result = app.integrations.xero.xero_list_contacts({
page = 1
order = "Name ASC"
})
xero_get_contact
Retrieve a Xero contact by its ID. Returns the contact’s ID, name, email, phone, addresses, and status.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | Xero contact ID (UUID). |
Example
local result = app.integrations.xero.xero_get_contact({
contact_id = "abc123-def456-..."
})
xero_list_accounts
List Xero chart of accounts. Returns account codes, names, types, tax types, and statuses.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
where | string | no | Xero where filter expression (e.g. Type==“BANK”). |
order | string | no | Sort order (e.g. “Code ASC”). |
Example
local result = app.integrations.xero.xero_list_accounts({
order = "Code ASC"
})
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.
Example
local result = app.integrations.xero.xero_get_current_user({
})
Multi-Account Usage
If you have multiple xero accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.xero.function_name({...})
-- Explicit default (portable across setups)
app.integrations.xero.default.function_name({...})
-- Named accounts
app.integrations.xero.work.function_name({...})
app.integrations.xero.personal.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Client for the Xero Accounting REST API — Lua API Reference
## xero_list_invoices
List Xero invoices with pagination and filtering.
Returns invoice IDs, numbers, amounts, status, and dates.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `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"). |
### Example
```lua
local result = app.integrations.xero.xero_list_invoices({
page = 1
pageSize = 50
statuses = "AUTHORISED"
})
```
## xero_get_invoice
Retrieve a Xero invoice by its ID.
Returns the full invoice including line items, contact details, and totals.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `invoice_id` | string | yes | Xero invoice ID (UUID). |
### Example
```lua
local result = app.integrations.xero.xero_get_invoice({
invoice_id = "abc123-def456-..."
})
```
## 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.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `contact_id` | string | yes | Xero contact ID (UUID) to invoice. |
| `type` | string | no | Invoice type: "ACCREC" or "ACCPAY". 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. |
| `status` | string | no | Invoice status: "DRAFT" or "AUTHORISED". Default: DRAFT. |
### Example
```lua
local result = app.integrations.xero.xero_create_invoice({
contact_id = "abc123-def456-..."
type = "ACCREC"
date = "2026-04-07"
due_date = "2026-05-07"
reference = "Order #12345"
line_items = {
{ description = "Consulting services", quantity = 10, unit_amount = 150.00, account_code = "200" }
{ description = "Software license", quantity = 1, unit_amount = 500.00, account_code = "400" }
}
status = "AUTHORISED"
})
```
## xero_list_contacts
List Xero contacts with pagination.
Returns contact IDs, names, emails, and types.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `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). |
### Example
```lua
local result = app.integrations.xero.xero_list_contacts({
page = 1
order = "Name ASC"
})
```
## xero_get_contact
Retrieve a Xero contact by its ID.
Returns the contact's ID, name, email, phone, addresses, and status.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `contact_id` | string | yes | Xero contact ID (UUID). |
### Example
```lua
local result = app.integrations.xero.xero_get_contact({
contact_id = "abc123-def456-..."
})
```
## xero_list_accounts
List Xero chart of accounts.
Returns account codes, names, types, tax types, and statuses.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `where` | string | no | Xero where filter expression (e.g. Type=="BANK"). |
| `order` | string | no | Sort order (e.g. "Code ASC"). |
### Example
```lua
local result = app.integrations.xero.xero_list_accounts({
order = "Code ASC"
})
```
## 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.
### Example
```lua
local result = app.integrations.xero.xero_get_current_user({
})
```
---
## Multi-Account Usage
If you have multiple xero accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.xero.function_name({...})
-- Explicit default (portable across setups)
app.integrations.xero.default.function_name({...})
-- Named accounts
app.integrations.xero.work.function_name({...})
app.integrations.xero.personal.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.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"})
print(result) Functions
create_invoice 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.
- Lua path
app.integrations.xero.create_invoice- Full name
xero.xero_create_invoice
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
get_contact Read
Retrieve a Xero contact by its ID. Returns the contact's ID, name, email, phone, addresses, and status.
- Lua path
app.integrations.xero.get_contact- Full name
xero.xero_get_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
contact_id | string | yes | Xero contact ID (UUID). |
get_current_user 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.
- Lua path
app.integrations.xero.get_current_user- Full name
xero.xero_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_invoice Read
Retrieve a Xero invoice by its ID. Returns the full invoice including line items, contact details, and totals.
- Lua path
app.integrations.xero.get_invoice- Full name
xero.xero_get_invoice
| Parameter | Type | Required | Description |
|---|---|---|---|
invoice_id | string | yes | Xero invoice ID (UUID). |
list_accounts Read
List Xero chart of accounts. Returns account codes, names, types, tax types, and statuses.
- Lua path
app.integrations.xero.list_accounts- Full name
xero.xero_list_accounts
| Parameter | Type | Required | Description |
|---|---|---|---|
where | string | no | Xero where filter expression (e.g. Type=="BANK"). |
order | string | no | Sort order (e.g. "Code ASC"). |
list_contacts Read
List Xero contacts with pagination. Returns contact IDs, names, emails, and types. Use page for pagination (1-indexed).
- Lua path
app.integrations.xero.list_contacts- Full name
xero.xero_list_contacts
| Parameter | Type | Required | Description |
|---|---|---|---|
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). |
list_invoices Read
List Xero invoices with pagination and filtering. Returns invoice IDs, numbers, amounts, status, and dates. Use page and pageSize for pagination.
- Lua path
app.integrations.xero.list_invoices- Full name
xero.xero_list_invoices
| Parameter | Type | Required | Description |
|---|---|---|---|
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"). |