KosmoKrator

sales

WooCommerce Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write Bearer token auth

Lua Namespace

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

WooCommerce — Lua API Reference

list_products

List products from the WooCommerce catalog with filtering and pagination.

Parameters

NameTypeRequiredDescription
per_pageintegernoNumber of products per page (default: 10, max: 100)
pageintegernoPage number for pagination (default: 1)
searchstringnoSearch products by name or description
statusstringnoFilter by status: “publish”, “draft”, “pending”, “private”, “trash”
categorystringnoFilter by category ID
skustringnoFilter by SKU
orderbystringnoSort field (“date”, “id”, “title”, “slug”, “price”)
orderstringnoSort direction: “asc” or “desc”

Example

local result = app.integrations.woocommerce.list_products({
  per_page = 10,
  orderby = "price",
  order = "desc"
})

for _, product in ipairs(result) do
  print(product.name .. " - $" .. product.regular_price)
end

get_product

Get a single product by ID with full details.

Parameters

NameTypeRequiredDescription
idintegeryesThe product ID

Example

local product = app.integrations.woocommerce.get_product({
  id = 123
})

print(product.name)
print("Price: $" .. product.regular_price)
print("SKU: " .. (product.sku or "N/A"))

create_product

Create a new product in the WooCommerce catalog.

Parameters

NameTypeRequiredDescription
namestringyesProduct name
regular_pricestringyesBase price (e.g., “29.99”)
typestringnoProduct type: “simple”, “grouped”, “external”, “variable” (default: “simple”)
skustringnoUnique SKU
descriptionstringnoProduct description (HTML allowed)
short_descriptionstringnoShort description
weightstringnoProduct weight
categoriesarraynoArray of {id} objects
manage_stockbooleannoEnable stock management
stock_quantityintegernoStock level
statusstringno”publish”, “draft”, “pending”, “private”
imagesarraynoArray of {src} objects

Example

local product = app.integrations.woocommerce.create_product({
  name = "Premium Widget",
  regular_price = "49.99",
  type = "simple",
  sku = "WDG-PREM-001",
  weight = "0.75",
  categories = {{id = 1}, {id = 5}},
  manage_stock = true,
  stock_quantity = 100,
  description = "<p>A premium quality widget.</p>"
})

print("Created product ID: " .. product.id)

list_orders

List orders with filtering and pagination.

Parameters

NameTypeRequiredDescription
per_pageintegernoOrders per page (default: 10, max: 100)
pageintegernoPage number (default: 1)
statusstringnoFilter by status: “pending”, “processing”, “on-hold”, “completed”, “cancelled”, “refunded”, “failed”
customerintegernoFilter by customer ID
afterstringnoOrders created after this date (ISO 8601)
beforestringnoOrders created before this date (ISO 8601)
orderbystringnoSort field
orderstringnoSort direction: “asc” or “desc”

Example

local orders = app.integrations.woocommerce.list_orders({
  status = "completed",
  per_page = 10,
  orderby = "date",
  order = "desc"
})

for _, order in ipairs(orders) do
  print("Order #" .. order.id .. " - $" .. order.total)
end

get_order

Get a single order by ID.

Parameters

NameTypeRequiredDescription
idintegeryesThe order ID

Example

local order = app.integrations.woocommerce.get_order({
  id = 456
})

print("Order #" .. order.id)
print("Status: " .. order.status)
print("Total: $" .. order.total)

list_customers

List customers with filtering and pagination.

Parameters

NameTypeRequiredDescription
per_pageintegernoCustomers per page (default: 10)
pageintegernoPage number (default: 1)
searchstringnoSearch by name or email
orderbystringnoSort field
orderstringnoSort direction

Example

local customers = app.integrations.woocommerce.list_customers({
  per_page = 10,
  orderby = "registered_date",
  order = "desc"
})

for _, customer in ipairs(customers) do
  print(customer.first_name .. " " .. customer.last_name .. " - " .. customer.email)
end

get_current_user

Get system status and verify the API connection.

Parameters

None.

Example

local status = app.integrations.woocommerce.get_current_user({})

print("Store: " .. (status.store_name or "N/A"))

Multi-Account Usage

If you have multiple WooCommerce stores configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.woocommerce.list_products({per_page = 10})

-- Explicit default (portable across setups)
app.integrations.woocommerce.default.list_products({per_page = 10})

-- Named accounts (e.g., different stores)
app.integrations.woocommerce.us_store.list_products({per_page = 10})
app.integrations.woocommerce.eu_store.list_products({per_page = 10})

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

Raw agent markdown
# WooCommerce — Lua API Reference

## list_products

List products from the WooCommerce catalog with filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Number of products per page (default: 10, max: 100) |
| `page` | integer | no | Page number for pagination (default: 1) |
| `search` | string | no | Search products by name or description |
| `status` | string | no | Filter by status: "publish", "draft", "pending", "private", "trash" |
| `category` | string | no | Filter by category ID |
| `sku` | string | no | Filter by SKU |
| `orderby` | string | no | Sort field ("date", "id", "title", "slug", "price") |
| `order` | string | no | Sort direction: "asc" or "desc" |

### Example

```lua
local result = app.integrations.woocommerce.list_products({
  per_page = 10,
  orderby = "price",
  order = "desc"
})

for _, product in ipairs(result) do
  print(product.name .. " - $" .. product.regular_price)
end
```

---

## get_product

Get a single product by ID with full details.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The product ID |

### Example

```lua
local product = app.integrations.woocommerce.get_product({
  id = 123
})

print(product.name)
print("Price: $" .. product.regular_price)
print("SKU: " .. (product.sku or "N/A"))
```

---

## create_product

Create a new product in the WooCommerce catalog.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Product name |
| `regular_price` | string | yes | Base price (e.g., "29.99") |
| `type` | string | no | Product type: "simple", "grouped", "external", "variable" (default: "simple") |
| `sku` | string | no | Unique SKU |
| `description` | string | no | Product description (HTML allowed) |
| `short_description` | string | no | Short description |
| `weight` | string | no | Product weight |
| `categories` | array | no | Array of {id} objects |
| `manage_stock` | boolean | no | Enable stock management |
| `stock_quantity` | integer | no | Stock level |
| `status` | string | no | "publish", "draft", "pending", "private" |
| `images` | array | no | Array of {src} objects |

### Example

```lua
local product = app.integrations.woocommerce.create_product({
  name = "Premium Widget",
  regular_price = "49.99",
  type = "simple",
  sku = "WDG-PREM-001",
  weight = "0.75",
  categories = {{id = 1}, {id = 5}},
  manage_stock = true,
  stock_quantity = 100,
  description = "<p>A premium quality widget.</p>"
})

print("Created product ID: " .. product.id)
```

---

## list_orders

List orders with filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Orders per page (default: 10, max: 100) |
| `page` | integer | no | Page number (default: 1) |
| `status` | string | no | Filter by status: "pending", "processing", "on-hold", "completed", "cancelled", "refunded", "failed" |
| `customer` | integer | no | Filter by customer ID |
| `after` | string | no | Orders created after this date (ISO 8601) |
| `before` | string | no | Orders created before this date (ISO 8601) |
| `orderby` | string | no | Sort field |
| `order` | string | no | Sort direction: "asc" or "desc" |

### Example

```lua
local orders = app.integrations.woocommerce.list_orders({
  status = "completed",
  per_page = 10,
  orderby = "date",
  order = "desc"
})

for _, order in ipairs(orders) do
  print("Order #" .. order.id .. " - $" .. order.total)
end
```

---

## get_order

Get a single order by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The order ID |

### Example

```lua
local order = app.integrations.woocommerce.get_order({
  id = 456
})

print("Order #" .. order.id)
print("Status: " .. order.status)
print("Total: $" .. order.total)
```

---

## list_customers

List customers with filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `per_page` | integer | no | Customers per page (default: 10) |
| `page` | integer | no | Page number (default: 1) |
| `search` | string | no | Search by name or email |
| `orderby` | string | no | Sort field |
| `order` | string | no | Sort direction |

### Example

```lua
local customers = app.integrations.woocommerce.list_customers({
  per_page = 10,
  orderby = "registered_date",
  order = "desc"
})

for _, customer in ipairs(customers) do
  print(customer.first_name .. " " .. customer.last_name .. " - " .. customer.email)
end
```

---

## get_current_user

Get system status and verify the API connection.

### Parameters

None.

### Example

```lua
local status = app.integrations.woocommerce.get_current_user({})

print("Store: " .. (status.store_name or "N/A"))
```

---

## Multi-Account Usage

If you have multiple WooCommerce stores configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.woocommerce.list_products({per_page = 10})

-- Explicit default (portable across setups)
app.integrations.woocommerce.default.list_products({per_page = 10})

-- Named accounts (e.g., different stores)
app.integrations.woocommerce.us_store.list_products({per_page = 10})
app.integrations.woocommerce.eu_store.list_products({per_page = 10})
```

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

Metadata-Derived Lua Example

local result = app.integrations.woocommerce.woocommerce_list_products({
  per_page = 1,
  page = 1,
  search = "example_search",
  status = "example_status",
  category = "example_category",
  sku = "example_sku",
  orderby = "example_orderby",
  order = "example_order"
})
print(result)

Functions

woocommerce_list_products

List products from the WooCommerce catalog. Supports pagination, filtering by name or SKU, and including variants/images.

Operation
Read read
Full name
woocommerce.woocommerce_list_products
ParameterTypeRequiredDescription
per_page integer no Number of products to return per page (default: 10, max: 100).
page integer no Page number for pagination (default: 1).
search string no Search products by name or description.
status string no Filter by product status: "publish", "draft", "pending", "private", or "trash".
category string no Filter by category ID.
sku string no Filter by SKU.
orderby string no Sort collection by field (e.g., "date", "id", "title", "slug", "price").
order string no Sort direction: "asc" or "desc".

woocommerce_get_product

Get a single product from the WooCommerce catalog by its ID. Returns full product details.

Operation
Read read
Full name
woocommerce.woocommerce_get_product
ParameterTypeRequiredDescription
id integer yes The product ID.

woocommerce_create_product

Create a new product in the WooCommerce catalog. Requires name and regular_price. Supports type (simple, grouped, external, variable), SKU, description, and more.

Operation
Write write
Full name
woocommerce.woocommerce_create_product
ParameterTypeRequiredDescription
name string yes Product name.
regular_price string yes Base price (e.g., "29.99").
type string no Product type: "simple", "grouped", "external", or "variable" (default: "simple").
sku string no Unique SKU for the product.
description string no Product description (HTML allowed).
short_description string no Short product description.
weight string no Weight of the product.
categories array no Array of category objects with "id" keys.
manage_stock boolean no Whether to enable stock management (default: false).
stock_quantity integer no Stock level (when manage_stock is true).
status string no Product status: "publish", "draft", "pending", or "private" (default: "publish").
images array no Array of image objects with "src" key.

woocommerce_list_orders

List orders from the WooCommerce store. Supports filtering by status, customer, and pagination.

Operation
Read read
Full name
woocommerce.woocommerce_list_orders
ParameterTypeRequiredDescription
per_page integer no Number of orders per page (default: 10, max: 100).
page integer no Page number for pagination (default: 1).
status string no Filter by order status: "pending", "processing", "on-hold", "completed", "cancelled", "refunded", or "failed".
customer integer no Filter by customer ID.
after string no Limit response to orders created after this date (ISO 8601, e.g., "2025-01-01T00:00:00").
before string no Limit response to orders created before this date (ISO 8601).
orderby string no Sort collection by field (e.g., "date", "id", "total").
order string no Sort direction: "asc" or "desc".

woocommerce_get_order

Get a single order from the WooCommerce store by its ID. Returns full order details including line items and totals.

Operation
Read read
Full name
woocommerce.woocommerce_get_order
ParameterTypeRequiredDescription
id integer yes The order ID.

woocommerce_list_customers

List customers from the WooCommerce store. Supports filtering by name or email and pagination.

Operation
Read read
Full name
woocommerce.woocommerce_list_customers
ParameterTypeRequiredDescription
per_page integer no Number of customers per page (default: 10, max: 100).
page integer no Page number for pagination (default: 1).
search string no Search by customer name or email.
orderby string no Sort collection by field (e.g., "id", "name", "registered_date").
order string no Sort direction: "asc" or "desc".

woocommerce_get_current_user

Get the system status from WooCommerce. Use this to verify the API connection is working and retrieve store information.

Operation
Read read
Full name
woocommerce.woocommerce_get_current_user
ParameterTypeRequiredDescription
No parameters.