KosmoKrator

sales

Avalara Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.avalara.*. Use lua_read_doc("integrations.avalara") 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.

Avalara — Lua API Reference

list_transactions

List transactions from Avalara with optional filtering and pagination.

Parameters

NameTypeRequiredDescription
topintegernoNumber of transactions per page (default 20)
skipintegernoNumber of records to skip for pagination
filterstringnoOData filter expression, e.g. "status eq 'Committed'" or "date ge 2024-01-01"
orderBystringnoOData order-by expression, e.g. "date desc"

Example

local result = app.integrations.avalara.list_transactions({
  filter = "status eq 'Committed'",
  top = 25
})

for _, txn in ipairs(result.transactions) do
  print(txn.id .. " — " .. txn.type .. " — " .. txn.totalAmount)
end

-- Paginate with skip
if result.count >= 25 then
  local page2 = app.integrations.avalara.list_transactions({
    filter = "status eq 'Committed'",
    top = 25,
    skip = 25
  })
end

get_transaction

Retrieve details of a single transaction.

Parameters

NameTypeRequiredDescription
idstringyesThe transaction ID or code

Example

local result = app.integrations.avalara.get_transaction({
  id = "123456"
})

local txn = result
print("Type: " .. txn.type)
print("Total: " .. txn.totalAmount)
print("Tax: " .. txn.totalTax)

create_transaction

Create a new transaction (sales order or invoice) for tax calculation.

Parameters

NameTypeRequiredDescription
companyCodestringyesThe company code
typestringnoTransaction type: "SalesOrder" or "SalesInvoice" (default "SalesOrder")
datestringnoTransaction date in YYYY-MM-DD format
codestringnoUnique reference code for the transaction
customerCodestringnoCustomer code
linesarrayyesLine items, each with amount, quantity, and optionally taxCode, description
addressesobjectnoAddress info with shipFrom and shipTo containing city, region, country, postalCode
commitbooleannoWhether to commit immediately (default false)
descriptionstringnoTransaction description

Example

local result = app.integrations.avalara.create_transaction({
  companyCode = "DEFAULT",
  type = "SalesInvoice",
  code = "INV-001",
  customerCode = "CUST-100",
  date = "2024-06-15",
  lines = {
    { amount = 100.00, quantity = 1, taxCode = "P0000000", description = "Tangible personal property" },
    { amount = 50.00, quantity = 2, description = "Consulting service" }
  },
  addresses = {
    shipFrom = { city = "Seattle", region = "WA", country = "US", postalCode = "98101" },
    shipTo = { city = "Portland", region = "OR", country = "US", postalCode = "97201" }
  },
  commit = true,
  description = "June invoice"
})

print("Total tax: " .. result.totalTax)
print("Total amount: " .. result.totalAmount)

list_companies

List companies configured in your Avalara account.

Parameters

NameTypeRequiredDescription
topintegernoNumber of companies per page (default 20)
skipintegernoNumber of records to skip for pagination
filterstringnoOData filter expression, e.g. "isDefault eq true"

Example

local result = app.integrations.avalara.list_companies({
  top = 50
})

for _, company in ipairs(result.companies) do
  print(company.id .. " — " .. company.name .. " — " .. company.companyCode)
end

get_company

Retrieve details of a single company.

Parameters

NameTypeRequiredDescription
idstringyesThe company ID

Example

local result = app.integrations.avalara.get_company({
  id = "12345"
})

print("Name: " .. result.name)
print("Code: " .. result.companyCode)
print("Default: " .. tostring(result.isDefault))

list_tax_codes

List tax codes available in Avalara.

Parameters

NameTypeRequiredDescription
topintegernoNumber of tax codes per page (default 20)
skipintegernoNumber of records to skip for pagination
filterstringnoOData filter expression, e.g. "isActive eq true"

Example

local result = app.integrations.avalara.list_tax_codes({
  filter = "isActive eq true",
  top = 50
})

for _, tc in ipairs(result.tax_codes) do
  print(tc.taxCode .. " — " .. tc.description)
end

get_current_user

Retrieve the current authenticated Avalara user information.

Parameters

None.

Example

local result = app.integrations.avalara.get_current_user({})

print("User: " .. (result.userName or "N/A"))
print("Email: " .. (result.email or "N/A"))

Multi-Account Usage

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

-- Default account (always works)
app.integrations.avalara.list_transactions({top = 10})

-- Explicit default (portable across setups)
app.integrations.avalara.default.list_transactions({top = 10})

-- Named accounts
app.integrations.avalara.production.list_transactions({top = 10})
app.integrations.avalara.sandbox.list_transactions({top = 10})

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

Raw agent markdown
# Avalara — Lua API Reference

## list_transactions

List transactions from Avalara with optional filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Number of transactions per page (default 20) |
| `skip` | integer | no | Number of records to skip for pagination |
| `filter` | string | no | OData filter expression, e.g. `"status eq 'Committed'"` or `"date ge 2024-01-01"` |
| `orderBy` | string | no | OData order-by expression, e.g. `"date desc"` |

### Example

```lua
local result = app.integrations.avalara.list_transactions({
  filter = "status eq 'Committed'",
  top = 25
})

for _, txn in ipairs(result.transactions) do
  print(txn.id .. " — " .. txn.type .. " — " .. txn.totalAmount)
end

-- Paginate with skip
if result.count >= 25 then
  local page2 = app.integrations.avalara.list_transactions({
    filter = "status eq 'Committed'",
    top = 25,
    skip = 25
  })
end
```

---

## get_transaction

Retrieve details of a single transaction.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The transaction ID or code |

### Example

```lua
local result = app.integrations.avalara.get_transaction({
  id = "123456"
})

local txn = result
print("Type: " .. txn.type)
print("Total: " .. txn.totalAmount)
print("Tax: " .. txn.totalTax)
```

---

## create_transaction

Create a new transaction (sales order or invoice) for tax calculation.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `companyCode` | string | yes | The company code |
| `type` | string | no | Transaction type: `"SalesOrder"` or `"SalesInvoice"` (default `"SalesOrder"`) |
| `date` | string | no | Transaction date in YYYY-MM-DD format |
| `code` | string | no | Unique reference code for the transaction |
| `customerCode` | string | no | Customer code |
| `lines` | array | yes | Line items, each with `amount`, `quantity`, and optionally `taxCode`, `description` |
| `addresses` | object | no | Address info with `shipFrom` and `shipTo` containing `city`, `region`, `country`, `postalCode` |
| `commit` | boolean | no | Whether to commit immediately (default false) |
| `description` | string | no | Transaction description |

### Example

```lua
local result = app.integrations.avalara.create_transaction({
  companyCode = "DEFAULT",
  type = "SalesInvoice",
  code = "INV-001",
  customerCode = "CUST-100",
  date = "2024-06-15",
  lines = {
    { amount = 100.00, quantity = 1, taxCode = "P0000000", description = "Tangible personal property" },
    { amount = 50.00, quantity = 2, description = "Consulting service" }
  },
  addresses = {
    shipFrom = { city = "Seattle", region = "WA", country = "US", postalCode = "98101" },
    shipTo = { city = "Portland", region = "OR", country = "US", postalCode = "97201" }
  },
  commit = true,
  description = "June invoice"
})

print("Total tax: " .. result.totalTax)
print("Total amount: " .. result.totalAmount)
```

---

## list_companies

List companies configured in your Avalara account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Number of companies per page (default 20) |
| `skip` | integer | no | Number of records to skip for pagination |
| `filter` | string | no | OData filter expression, e.g. `"isDefault eq true"` |

### Example

```lua
local result = app.integrations.avalara.list_companies({
  top = 50
})

for _, company in ipairs(result.companies) do
  print(company.id .. " — " .. company.name .. " — " .. company.companyCode)
end
```

---

## get_company

Retrieve details of a single company.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The company ID |

### Example

```lua
local result = app.integrations.avalara.get_company({
  id = "12345"
})

print("Name: " .. result.name)
print("Code: " .. result.companyCode)
print("Default: " .. tostring(result.isDefault))
```

---

## list_tax_codes

List tax codes available in Avalara.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Number of tax codes per page (default 20) |
| `skip` | integer | no | Number of records to skip for pagination |
| `filter` | string | no | OData filter expression, e.g. `"isActive eq true"` |

### Example

```lua
local result = app.integrations.avalara.list_tax_codes({
  filter = "isActive eq true",
  top = 50
})

for _, tc in ipairs(result.tax_codes) do
  print(tc.taxCode .. " — " .. tc.description)
end
```

---

## get_current_user

Retrieve the current authenticated Avalara user information.

### Parameters

None.

### Example

```lua
local result = app.integrations.avalara.get_current_user({})

print("User: " .. (result.userName or "N/A"))
print("Email: " .. (result.email or "N/A"))
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.avalara.list_transactions({top = 10})

-- Explicit default (portable across setups)
app.integrations.avalara.default.list_transactions({top = 10})

-- Named accounts
app.integrations.avalara.production.list_transactions({top = 10})
app.integrations.avalara.sandbox.list_transactions({top = 10})
```

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

Metadata-Derived Lua Example

local result = app.integrations.avalara.avalara_list_transactions({
  top = 1,
  skip = 1,
  filter = "example_filter",
  orderBy = "example_orderBy"
})
print(result)

Functions

avalara_list_transactions

List transactions from Avalara. Supports filtering by date, status, and other criteria with pagination.

Operation
Read read
Full name
avalara.avalara_list_transactions
ParameterTypeRequiredDescription
top integer no Number of transactions to return per page (default 20).
skip integer no Number of records to skip for pagination.
filter string no OData filter expression, e.g. "status eq 'Committed'" or "date ge 2024-01-01".
orderBy string no OData order-by expression, e.g. "date desc".

avalara_get_transaction

Retrieve details of a single transaction in Avalara by its ID.

Operation
Read read
Full name
avalara.avalara_get_transaction
ParameterTypeRequiredDescription
id string yes The transaction ID (can be the Avalara transaction ID or the code).

avalara_create_transaction

Create a new transaction (sales order or invoice) in Avalara for tax calculation. Requires company code, transaction type, date, and line items.

Operation
Write write
Full name
avalara.avalara_create_transaction
ParameterTypeRequiredDescription
companyCode string yes The company code for the transaction.
type string no Transaction type: "SalesOrder" or "SalesInvoice" (default "SalesOrder").
date string no Transaction date in YYYY-MM-DD format. Defaults to today.
code string no A unique reference code for this transaction.
customerCode string no The customer code for the transaction.
lines array yes Array of line items. Each line should include "amount", "quantity", and optionally "taxCode", "description".
addresses object no Address information for tax calculation, including "shipFrom" and "shipTo" with "city", "region", "country", "postalCode".
commit boolean no Whether to commit the transaction immediately (default false).
description string no Description of the transaction.

avalara_list_companies

List companies configured in your Avalara account. Supports filtering and pagination.

Operation
Read read
Full name
avalara.avalara_list_companies
ParameterTypeRequiredDescription
top integer no Number of companies to return per page (default 20).
skip integer no Number of records to skip for pagination.
filter string no OData filter expression, e.g. "isDefault eq true".

avalara_get_company

Retrieve details of a single company configured in Avalara by its ID.

Operation
Read read
Full name
avalara.avalara_get_company
ParameterTypeRequiredDescription
id string yes The company ID in Avalara.

avalara_list_tax_codes

List tax codes available in Avalara. Tax codes classify products and services for tax purposes. Supports filtering and pagination.

Operation
Read read
Full name
avalara.avalara_list_tax_codes
ParameterTypeRequiredDescription
top integer no Number of tax codes to return per page (default 20).
skip integer no Number of records to skip for pagination.
filter string no OData filter expression, e.g. "isActive eq true" or "taxCode eq 'P0000000'".

avalara_get_current_user

Retrieve the current authenticated Avalara user information.

Operation
Read read
Full name
avalara.avalara_get_current_user
ParameterTypeRequiredDescription
No parameters.