KosmoKrator

other

Netsuite Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write Manual OAuth token auth

Lua Namespace

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

NetSuite ERP — Lua API Reference

list_customers

List customers from NetSuite ERP.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of customers to return (default: 50, max: 1000)
offsetintegernoZero-based offset for pagination

Example

local result = app.integrations.netsuite.list_customers({
  limit = 10,
  offset = 0
})

for _, customer in ipairs(result.items) do
  print(customer.id .. ": " .. (customer.companyname or customer.entityid))
end

get_customer

Get detailed information for a single customer.

Parameters

NameTypeRequiredDescription
idstringyesThe internal ID of the customer in NetSuite

Example

local result = app.integrations.netsuite.get_customer({
  id = "12345"
})

print("Company: " .. result.companyname)
print("Email: " .. (result.email or "N/A"))
print("Phone: " .. (result.phone or "N/A"))

create_customer

Create a new customer in NetSuite.

Parameters

NameTypeRequiredDescription
companynamestringno*Company name (required for company customers)
firstnamestringno*First name (required for individual customers)
lastnamestringno*Last name (required for individual customers)
emailstringnoPrimary email address
phonestringnoPrimary phone number
subsidiarystringnoSubsidiary internal ID (required for OneWorld accounts)
entitystatusstringnoCustomer status reference
currencystringnoCurrency internal ID
termsstringnoPayment terms reference
addressbookarraynoArray of address objects

*Either companyname or lastname is required.

Example

local result = app.integrations.netsuite.create_customer({
  companyname = "Acme Corp",
  email = "[email protected]",
  phone = "+1-555-0123",
  currency = "1",
  terms = "2"
})

print("Created customer: " .. result.id)

list_invoices

List invoices from NetSuite ERP.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of invoices to return (default: 50, max: 1000)
offsetintegernoZero-based offset for pagination

Example

local result = app.integrations.netsuite.list_invoices({
  limit = 20,
  offset = 0
})

for _, invoice in ipairs(result.items) do
  print(invoice.tranid .. ": $" .. (invoice.amountremaining or invoice.total))
end

list_sales_orders

List sales orders from NetSuite ERP.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of sales orders to return (default: 50, max: 1000)
offsetintegernoZero-based offset for pagination

Example

local result = app.integrations.netsuite.list_sales_orders({
  limit = 20,
  offset = 0
})

for _, order in ipairs(result.items) do
  print(order.tranid .. ": " .. (order.status or "Unknown"))
end

list_items

List items (products and services) from NetSuite ERP.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of items to return (default: 50, max: 1000)
offsetintegernoZero-based offset for pagination

Example

local result = app.integrations.netsuite.list_items({
  limit = 50,
  offset = 0
})

for _, item in ipairs(result.items) do
  print(item.itemid .. ": " .. (item.displayname or item.description or ""))
end

get_current_user

Get the authenticated NetSuite user’s profile.

Parameters

None.

Example

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

print("User: " .. (result.name or result.email))
print("Role: " .. (result.role or "N/A"))

Multi-Account Usage

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

-- Default account (always works)
app.integrations.netsuite.list_customers({limit = 10})

-- Explicit default (portable across setups)
app.integrations.netsuite.default.list_customers({limit = 10})

-- Named accounts
app.integrations.netsuite.production.list_customers({limit = 10})
app.integrations.netsuite.sandbox.list_customers({limit = 10})

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

Raw agent markdown
# NetSuite ERP — Lua API Reference

## list_customers

List customers from NetSuite ERP.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of customers to return (default: 50, max: 1000) |
| `offset` | integer | no | Zero-based offset for pagination |

### Example

```lua
local result = app.integrations.netsuite.list_customers({
  limit = 10,
  offset = 0
})

for _, customer in ipairs(result.items) do
  print(customer.id .. ": " .. (customer.companyname or customer.entityid))
end
```

---

## get_customer

Get detailed information for a single customer.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The internal ID of the customer in NetSuite |

### Example

```lua
local result = app.integrations.netsuite.get_customer({
  id = "12345"
})

print("Company: " .. result.companyname)
print("Email: " .. (result.email or "N/A"))
print("Phone: " .. (result.phone or "N/A"))
```

---

## create_customer

Create a new customer in NetSuite.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `companyname` | string | no* | Company name (required for company customers) |
| `firstname` | string | no* | First name (required for individual customers) |
| `lastname` | string | no* | Last name (required for individual customers) |
| `email` | string | no | Primary email address |
| `phone` | string | no | Primary phone number |
| `subsidiary` | string | no | Subsidiary internal ID (required for OneWorld accounts) |
| `entitystatus` | string | no | Customer status reference |
| `currency` | string | no | Currency internal ID |
| `terms` | string | no | Payment terms reference |
| `addressbook` | array | no | Array of address objects |

*Either `companyname` or `lastname` is required.

### Example

```lua
local result = app.integrations.netsuite.create_customer({
  companyname = "Acme Corp",
  email = "[email protected]",
  phone = "+1-555-0123",
  currency = "1",
  terms = "2"
})

print("Created customer: " .. result.id)
```

---

## list_invoices

List invoices from NetSuite ERP.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of invoices to return (default: 50, max: 1000) |
| `offset` | integer | no | Zero-based offset for pagination |

### Example

```lua
local result = app.integrations.netsuite.list_invoices({
  limit = 20,
  offset = 0
})

for _, invoice in ipairs(result.items) do
  print(invoice.tranid .. ": $" .. (invoice.amountremaining or invoice.total))
end
```

---

## list_sales_orders

List sales orders from NetSuite ERP.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of sales orders to return (default: 50, max: 1000) |
| `offset` | integer | no | Zero-based offset for pagination |

### Example

```lua
local result = app.integrations.netsuite.list_sales_orders({
  limit = 20,
  offset = 0
})

for _, order in ipairs(result.items) do
  print(order.tranid .. ": " .. (order.status or "Unknown"))
end
```

---

## list_items

List items (products and services) from NetSuite ERP.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of items to return (default: 50, max: 1000) |
| `offset` | integer | no | Zero-based offset for pagination |

### Example

```lua
local result = app.integrations.netsuite.list_items({
  limit = 50,
  offset = 0
})

for _, item in ipairs(result.items) do
  print(item.itemid .. ": " .. (item.displayname or item.description or ""))
end
```

---

## get_current_user

Get the authenticated NetSuite user's profile.

### Parameters

None.

### Example

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

print("User: " .. (result.name or result.email))
print("Role: " .. (result.role or "N/A"))
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.netsuite.list_customers({limit = 10})

-- Explicit default (portable across setups)
app.integrations.netsuite.default.list_customers({limit = 10})

-- Named accounts
app.integrations.netsuite.production.list_customers({limit = 10})
app.integrations.netsuite.sandbox.list_customers({limit = 10})
```

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

Metadata-Derived Lua Example

local result = app.integrations.netsuite.netsuite_list_customers({
  limit = 1,
  offset = 1
})
print(result)

Functions

netsuite_list_customers

List customers from NetSuite ERP. Returns customer records with names, IDs, and basic details. Use limit and offset for pagination.

Operation
Read read
Full name
netsuite.netsuite_list_customers
ParameterTypeRequiredDescription
limit integer no Maximum number of customers to return (default: 50, max: 1000).
offset integer no Zero-based offset for pagination.

netsuite_get_customer

Get detailed information for a single NetSuite customer by internal ID. Returns full customer record including contact details, addresses, and financial information.

Operation
Read read
Full name
netsuite.netsuite_get_customer
ParameterTypeRequiredDescription
id string yes The internal ID of the customer in NetSuite.

netsuite_create_customer

Create a new customer in NetSuite ERP. Provide at minimum the company name or first/last name. Additional fields like email, phone, subsidiary, and address can be included.

Operation
Write write
Full name
netsuite.netsuite_create_customer
ParameterTypeRequiredDescription
companyname string no Company name for the customer (required for company customers).
firstname string no First name (required for individual customers).
lastname string no Last name (required for individual customers).
email string no Primary email address.
phone string no Primary phone number.
subsidiary string no Subsidiary internal ID or ref (required for OneWorld accounts).
entitystatus string no Customer status (e.g., "CUSTOMER-Closed", "CUSTOMER-Lost").
currency string no Currency internal ID or ref (e.g., "1" for USD).
terms string no Payment terms internal ID or ref.
addressbook array no Array of address objects with addr1, city, state, zip, country fields.

netsuite_list_invoices

List invoices from NetSuite ERP. Returns invoice records with amounts, statuses, customer references, and dates. Use limit and offset for pagination.

Operation
Read read
Full name
netsuite.netsuite_list_invoices
ParameterTypeRequiredDescription
limit integer no Maximum number of invoices to return (default: 50, max: 1000).
offset integer no Zero-based offset for pagination.

netsuite_list_sales_orders

List sales orders from NetSuite ERP. Returns sales order records with order details, line items, customer references, and statuses. Use limit and offset for pagination.

Operation
Read read
Full name
netsuite.netsuite_list_sales_orders
ParameterTypeRequiredDescription
limit integer no Maximum number of sales orders to return (default: 50, max: 1000).
offset integer no Zero-based offset for pagination.

netsuite_list_items

List items (products and services) from NetSuite ERP. Returns item records with names, IDs, types, and pricing. Use limit and offset for pagination.

Operation
Read read
Full name
netsuite.netsuite_list_items
ParameterTypeRequiredDescription
limit integer no Maximum number of items to return (default: 50, max: 1000).
offset integer no Zero-based offset for pagination.

netsuite_get_current_user

Get the profile of the currently authenticated NetSuite user. Returns user details like name, email, role, and subsidiary.

Operation
Read read
Full name
netsuite.netsuite_get_current_user
ParameterTypeRequiredDescription
No parameters.