KosmoKrator

accounting

Zoho Invoice Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Zoho Invoice KosmoKrator integration.

7 functions 6 read 1 write Manual OAuth token auth

Lua Namespace

Agents call this integration through app.integrations.zoho_invoice.*. Use lua_read_doc("integrations.zoho_invoice") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Zoho Invoice — Lua API Reference

Common Workflows

Create an invoice for a customer

-- Step 1: Find the customer
local contacts = app.integrations.zoho_invoice.list_contacts({
    search_text = "Acme Corp"
})
local customer_id = contacts.contacts[1].contact_id

-- Step 2: Find items to add
local items = app.integrations.zoho_invoice.list_items({
    search_text = "Consulting"
})
local item_id = items.items[1].item_id

-- Step 3: Create the invoice
local invoice = app.integrations.zoho_invoice.create_invoice({
    customer_id = customer_id,
    line_items = {
        {
            item_id = item_id,
            quantity = 10
        }
    },
    date = "2025-01-15",
    due_date = "2025-02-15",
    notes = "Thank you for your business!"
})

print("Invoice created: " .. invoice.invoice.invoice_id)
print("Total: " .. invoice.invoice.total)

List overdue invoices

local result = app.integrations.zoho_invoice.list_invoices({
    status = "overdue",
    sort_column = "date",
    sort_order = "ascending"
})

for _, inv in ipairs(result.invoices) do
    print(inv.invoice_number .. " - " .. inv.customer_name .. " - " .. inv.balance)
end

Get payments for a date range

local payments = app.integrations.zoho_invoice.list_payments({
    date_start = "2025-01-01",
    date_end = "2025-01-31"
})

local total = 0
for _, payment in ipairs(payments.payments) do
    total = total + tonumber(payment.amount)
    print(payment.date .. " - " .. payment.customer_name .. " - " .. payment.amount)
end
print("Total received: " .. total)

Check your connection

local user = app.integrations.zoho_invoice.get_current_user({})
print("Connected as: " .. user.user.name .. " (" .. user.user.email .. ")")

Invoice Statuses

StatusDescription
draftInvoice is in draft state
sentInvoice has been sent to the customer
overduePayment is past the due date
paidInvoice has been fully paid
voidInvoice has been voided
partially_paidInvoice has been partially paid

Contact Types

TypeDescription
customerCustomer contacts
vendorVendor contacts

Item Types

TypeDescription
goodsPhysical products
serviceService items

Line Item Format

When creating invoices, each line item should include:

{
    item_id = "1234567890",   -- Required: use item_id from list_items, or provide name + rate
    quantity = 1,             -- Quantity (default: 1)
    rate = 100.00,            -- Override rate (optional if item_id has a default rate)
    description = "Custom description"  -- Optional override
}

Alternatively, create line items without an existing item:

{
    name = "Custom Service",
    description = "One-time custom work",
    rate = 150.00,
    quantity = 5
}

Pagination

All list endpoints support page and per_page parameters:

local result = app.integrations.zoho_invoice.list_invoices({
    page = 2,
    per_page = 50
})

Multi-Account Usage

If you have multiple Zoho Invoice accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.zoho_invoice.list_invoices({})

-- Explicit default (portable across setups)
app.integrations.zoho_invoice.default.list_invoices({})

-- Named accounts
app.integrations.zoho_invoice.work.list_invoices({})
app.integrations.zoho_invoice.personal.list_invoices({})

All functions are identical across accounts — only the credentials differ.

Notes

  • The Organization ID is required for most API calls. Set it in the integration settings.
  • Date formats use ISO 8601 (YYYY-MM-DD).
  • The base URL varies by region — make sure to configure the correct one for your Zoho account.
  • Rate limits: 100 requests per minute per organization.
Raw agent markdown
# Zoho Invoice — Lua API Reference

## Common Workflows

### Create an invoice for a customer

```lua
-- Step 1: Find the customer
local contacts = app.integrations.zoho_invoice.list_contacts({
    search_text = "Acme Corp"
})
local customer_id = contacts.contacts[1].contact_id

-- Step 2: Find items to add
local items = app.integrations.zoho_invoice.list_items({
    search_text = "Consulting"
})
local item_id = items.items[1].item_id

-- Step 3: Create the invoice
local invoice = app.integrations.zoho_invoice.create_invoice({
    customer_id = customer_id,
    line_items = {
        {
            item_id = item_id,
            quantity = 10
        }
    },
    date = "2025-01-15",
    due_date = "2025-02-15",
    notes = "Thank you for your business!"
})

print("Invoice created: " .. invoice.invoice.invoice_id)
print("Total: " .. invoice.invoice.total)
```

### List overdue invoices

```lua
local result = app.integrations.zoho_invoice.list_invoices({
    status = "overdue",
    sort_column = "date",
    sort_order = "ascending"
})

for _, inv in ipairs(result.invoices) do
    print(inv.invoice_number .. " - " .. inv.customer_name .. " - " .. inv.balance)
end
```

### Get payments for a date range

```lua
local payments = app.integrations.zoho_invoice.list_payments({
    date_start = "2025-01-01",
    date_end = "2025-01-31"
})

local total = 0
for _, payment in ipairs(payments.payments) do
    total = total + tonumber(payment.amount)
    print(payment.date .. " - " .. payment.customer_name .. " - " .. payment.amount)
end
print("Total received: " .. total)
```

### Check your connection

```lua
local user = app.integrations.zoho_invoice.get_current_user({})
print("Connected as: " .. user.user.name .. " (" .. user.user.email .. ")")
```

## Invoice Statuses

| Status | Description |
|--------|-------------|
| `draft` | Invoice is in draft state |
| `sent` | Invoice has been sent to the customer |
| `overdue` | Payment is past the due date |
| `paid` | Invoice has been fully paid |
| `void` | Invoice has been voided |
| `partially_paid` | Invoice has been partially paid |

## Contact Types

| Type | Description |
|------|-------------|
| `customer` | Customer contacts |
| `vendor` | Vendor contacts |

## Item Types

| Type | Description |
|------|-------------|
| `goods` | Physical products |
| `service` | Service items |

## Line Item Format

When creating invoices, each line item should include:

```lua
{
    item_id = "1234567890",   -- Required: use item_id from list_items, or provide name + rate
    quantity = 1,             -- Quantity (default: 1)
    rate = 100.00,            -- Override rate (optional if item_id has a default rate)
    description = "Custom description"  -- Optional override
}
```

Alternatively, create line items without an existing item:

```lua
{
    name = "Custom Service",
    description = "One-time custom work",
    rate = 150.00,
    quantity = 5
}
```

## Pagination

All list endpoints support `page` and `per_page` parameters:

```lua
local result = app.integrations.zoho_invoice.list_invoices({
    page = 2,
    per_page = 50
})
```

## Multi-Account Usage

If you have multiple Zoho Invoice accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.zoho_invoice.list_invoices({})

-- Explicit default (portable across setups)
app.integrations.zoho_invoice.default.list_invoices({})

-- Named accounts
app.integrations.zoho_invoice.work.list_invoices({})
app.integrations.zoho_invoice.personal.list_invoices({})
```

All functions are identical across accounts — only the credentials differ.

## Notes

- The Organization ID is required for most API calls. Set it in the integration settings.
- Date formats use ISO 8601 (YYYY-MM-DD).
- The base URL varies by region — make sure to configure the correct one for your Zoho account.
- Rate limits: 100 requests per minute per organization.

Metadata-Derived Lua Example

local result = app.integrations.zoho_invoice.zohoinvoice_list_invoices({
  status = "example_status",
  customer_id = "example_customer_id",
  date_start = "example_date_start",
  date_end = "example_date_end",
  page = 1,
  per_page = 1,
  sort_column = "example_sort_column",
  sort_order = "example_sort_order"
})
print(result)

Functions

zohoinvoice_list_invoices

List invoices from Zoho Invoice. Supports filtering by status (draft, sent, overdue, paid, void, partially_paid), customer, and date range.

Operation
Read read
Full name
zoho_invoice.zohoinvoice_list_invoices
ParameterTypeRequiredDescription
status string no Filter by invoice status: draft, sent, overdue, paid, void, partially_paid.
customer_id string no Filter invoices for a specific customer by their contact ID.
date_start string no Start date for filtering (ISO 8601, e.g., "2025-01-01").
date_end string no End date for filtering (ISO 8601, e.g., "2025-12-31").
page integer no Page number for pagination (default: 1).
per_page integer no Number of invoices per page (default: 25, max: 200).
sort_column string no Column to sort by: date, total, balance, created_time.
sort_order string no Sort direction: ascending or descending.

zohoinvoice_get_invoice

Get full details of a single invoice by its ID, including line items, totals, payments, and notes.

Operation
Read read
Full name
zoho_invoice.zohoinvoice_get_invoice
ParameterTypeRequiredDescription
invoice_id string yes The unique ID of the invoice.

zohoinvoice_create_invoice

Create a new invoice in Zoho Invoice. Requires at minimum a customer_id and one line item. Returns the created invoice with its ID and total.

Operation
Write write
Full name
zoho_invoice.zohoinvoice_create_invoice
ParameterTypeRequiredDescription
customer_id string yes The contact ID of the customer to invoice.
line_items array yes Array of line items. Each item should have "item_id" or "name" and "rate" and "quantity".
invoice_number string no Custom invoice number (auto-generated if omitted).
date string no Invoice date (ISO 8601, e.g., "2025-01-15"). Defaults to today.
due_date string no Payment due date (ISO 8601, e.g., "2025-02-15").
notes string no Notes to display on the invoice.
terms string no Terms and conditions for the invoice.
reference_number string no Reference number for internal tracking.

zohoinvoice_list_contacts

List contacts (customers and vendors) from Zoho Invoice. Supports filtering by type (customer or vendor) and pagination.

Operation
Read read
Full name
zoho_invoice.zohoinvoice_list_contacts
ParameterTypeRequiredDescription
type string no Filter by contact type.
status string no Filter by status: active, inactive, draft, or archived.
page integer no Page number for pagination (default: 1).
per_page integer no Number of contacts per page (default: 25, max: 200).
search_text string no Search contacts by name or email.

zohoinvoice_list_items

List items (products and services) from Zoho Invoice. Use item IDs when creating invoices with line items.

Operation
Read read
Full name
zoho_invoice.zohoinvoice_list_items
ParameterTypeRequiredDescription
type string no Filter by item type.
status string no Filter by status: active or inactive.
page integer no Page number for pagination (default: 1).
per_page integer no Number of items per page (default: 25, max: 200).
search_text string no Search items by name or description.

zohoinvoice_list_payments

List payments received in Zoho Invoice. Supports filtering by customer, date range, and payment mode.

Operation
Read read
Full name
zoho_invoice.zohoinvoice_list_payments
ParameterTypeRequiredDescription
customer_id string no Filter payments for a specific customer by their contact ID.
date_start string no Start date for filtering (ISO 8601, e.g., "2025-01-01").
date_end string no End date for filtering (ISO 8601, e.g., "2025-12-31").
payment_mode string no Filter by payment mode: cash, check, bank_transfer, credit_card, etc.
page integer no Page number for pagination (default: 1).
per_page integer no Number of payments per page (default: 25, max: 200).

zohoinvoice_get_current_user

Get the authenticated user's profile from Zoho Invoice, including name, email, and role.

Operation
Read read
Full name
zoho_invoice.zohoinvoice_get_current_user
ParameterTypeRequiredDescription
No parameters.