KosmoKrator

other

Box Lua API for KosmoKrator Agents

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

10 functions 6 read 4 write Manual OAuth token auth

Lua Namespace

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

Box — Lua API Reference

list_files

List files and folders in a Box folder.

Parameters

NameTypeRequiredDescription
folder_idstringnoThe folder ID to list. Use "0" for root. Default: "0"
limitintegernoMax items to return (1–1000, default: 100)
offsetintegernoZero-based offset for pagination (default: 0)

Examples

-- List root folder contents
local result = app.integrations.box.list_files({ folder_id = "0" })

for _, item in ipairs(result.items) do
  print(item.type .. ": " .. item.name .. " (id=" .. item.id .. ")")
end
-- Paginate through a large folder
local result = app.integrations.box.list_files({
  folder_id = "12345",
  limit = 50,
  offset = 0
})

print("Total: " .. result.total_count)
print("Has more: " .. tostring(result.has_more))

get_file

Get metadata for a Box file by ID.

Parameters

NameTypeRequiredDescription
file_idstringyesThe Box file ID

Examples

local result = app.integrations.box.get_file({ file_id = "12345" })
print("Name: " .. result.name)
print("Size: " .. result.size .. " bytes")
print("Modified: " .. result.modified_at)

upload_file

Upload a file to Box.

Parameters

NameTypeRequiredDescription
file_namestringyesFile name including extension (e.g., "report.pdf")
contentstringyesFile contents as a string
parent_folder_idstringnoParent folder ID. Default: "0" (root)

Examples

local result = app.integrations.box.upload_file({
  file_name = "notes.txt",
  content = "Hello, this is a test file.",
  parent_folder_id = "0"
})

print("Uploaded: " .. result.name .. " (id=" .. result.id .. ")")

download_file

Download a file’s contents from Box.

Parameters

NameTypeRequiredDescription
file_idstringyesThe Box file ID to download

Examples

local result = app.integrations.box.download_file({ file_id = "12345" })
print("Downloaded " .. result.size .. " bytes")
-- result.content contains the raw file contents

delete_file

Delete a file from Box (moves to trash).

Parameters

NameTypeRequiredDescription
file_idstringyesThe Box file ID to delete

Examples

local result = app.integrations.box.delete_file({ file_id = "12345" })
print(result.message) -- "File '12345' has been deleted..."

create_folder

Create a new folder in Box.

Parameters

NameTypeRequiredDescription
namestringyesThe folder name
parent_folder_idstringnoParent folder ID. Default: "0" (root)

Examples

local result = app.integrations.box.create_folder({
  name = "Project Documents",
  parent_folder_id = "0"
})

print("Created folder: " .. result.name .. " (id=" .. result.id .. ")")

get_folder

Get metadata for a Box folder.

Parameters

NameTypeRequiredDescription
folder_idstringyesThe Box folder ID. Use "0" for root

Examples

local result = app.integrations.box.get_folder({ folder_id = "12345" })
print("Folder: " .. result.name)
print("Size: " .. result.size .. " bytes")

share_file

Create a shared link for a Box file.

Parameters

NameTypeRequiredDescription
file_idstringyesThe Box file ID to share
accessstringnoAccess level: "open", "company", or "collaborators"
passwordstringnoOptional password to protect the link
expires_atstringnoExpiration timestamp (ISO 8601, e.g., "2026-12-31T23:59:59Z")

Examples

-- Create an open shared link
local result = app.integrations.box.share_file({ file_id = "12345" })
print("Shared link: " .. result.shared_link)
-- Create a password-protected link with expiration
local result = app.integrations.box.share_file({
  file_id = "12345",
  access = "open",
  password = "s3cret!",
  expires_at = "2026-12-31T23:59:59Z"
})

print("Shared link: " .. result.shared_link)

Search for files and folders in Box.

Parameters

NameTypeRequiredDescription
querystringyesThe search query string
limitintegernoMax results (1–200, default: 50)
offsetintegernoZero-based offset for pagination (default: 0)

Examples

local result = app.integrations.box.search({ query = "quarterly report" })

for _, item in ipairs(result.items) do
  print(item.type .. ": " .. item.name .. " (id=" .. item.id .. ")")
end

print("Total matches: " .. result.total_count)

get_current_user

Get the currently authenticated Box user.

Parameters

None.

Examples

local result = app.integrations.box.get_current_user({})
print("User: " .. result.name .. " (" .. result.login .. ")")
print("Enterprise: " .. tostring(result.enterprise))

Multi-Account Usage

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

-- Default account (always works)
app.integrations.box.list_files({ folder_id = "0" })

-- Explicit default (portable across setups)
app.integrations.box.default.list_files({ folder_id = "0" })

-- Named accounts
app.integrations.box.work.list_files({ folder_id = "0" })
app.integrations.box.personal.upload_file({
  file_name = "notes.txt",
  content = "Hello"
})

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

Raw agent markdown
# Box — Lua API Reference

## list_files

List files and folders in a Box folder.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `folder_id` | string | no | The folder ID to list. Use `"0"` for root. Default: `"0"` |
| `limit` | integer | no | Max items to return (1–1000, default: 100) |
| `offset` | integer | no | Zero-based offset for pagination (default: 0) |

### Examples

```lua
-- List root folder contents
local result = app.integrations.box.list_files({ folder_id = "0" })

for _, item in ipairs(result.items) do
  print(item.type .. ": " .. item.name .. " (id=" .. item.id .. ")")
end
```

```lua
-- Paginate through a large folder
local result = app.integrations.box.list_files({
  folder_id = "12345",
  limit = 50,
  offset = 0
})

print("Total: " .. result.total_count)
print("Has more: " .. tostring(result.has_more))
```

---

## get_file

Get metadata for a Box file by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_id` | string | yes | The Box file ID |

### Examples

```lua
local result = app.integrations.box.get_file({ file_id = "12345" })
print("Name: " .. result.name)
print("Size: " .. result.size .. " bytes")
print("Modified: " .. result.modified_at)
```

---

## upload_file

Upload a file to Box.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_name` | string | yes | File name including extension (e.g., `"report.pdf"`) |
| `content` | string | yes | File contents as a string |
| `parent_folder_id` | string | no | Parent folder ID. Default: `"0"` (root) |

### Examples

```lua
local result = app.integrations.box.upload_file({
  file_name = "notes.txt",
  content = "Hello, this is a test file.",
  parent_folder_id = "0"
})

print("Uploaded: " .. result.name .. " (id=" .. result.id .. ")")
```

---

## download_file

Download a file's contents from Box.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_id` | string | yes | The Box file ID to download |

### Examples

```lua
local result = app.integrations.box.download_file({ file_id = "12345" })
print("Downloaded " .. result.size .. " bytes")
-- result.content contains the raw file contents
```

---

## delete_file

Delete a file from Box (moves to trash).

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_id` | string | yes | The Box file ID to delete |

### Examples

```lua
local result = app.integrations.box.delete_file({ file_id = "12345" })
print(result.message) -- "File '12345' has been deleted..."
```

---

## create_folder

Create a new folder in Box.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | The folder name |
| `parent_folder_id` | string | no | Parent folder ID. Default: `"0"` (root) |

### Examples

```lua
local result = app.integrations.box.create_folder({
  name = "Project Documents",
  parent_folder_id = "0"
})

print("Created folder: " .. result.name .. " (id=" .. result.id .. ")")
```

---

## get_folder

Get metadata for a Box folder.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `folder_id` | string | yes | The Box folder ID. Use `"0"` for root |

### Examples

```lua
local result = app.integrations.box.get_folder({ folder_id = "12345" })
print("Folder: " .. result.name)
print("Size: " .. result.size .. " bytes")
```

---

## share_file

Create a shared link for a Box file.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_id` | string | yes | The Box file ID to share |
| `access` | string | no | Access level: `"open"`, `"company"`, or `"collaborators"` |
| `password` | string | no | Optional password to protect the link |
| `expires_at` | string | no | Expiration timestamp (ISO 8601, e.g., `"2026-12-31T23:59:59Z"`) |

### Examples

```lua
-- Create an open shared link
local result = app.integrations.box.share_file({ file_id = "12345" })
print("Shared link: " .. result.shared_link)
```

```lua
-- Create a password-protected link with expiration
local result = app.integrations.box.share_file({
  file_id = "12345",
  access = "open",
  password = "s3cret!",
  expires_at = "2026-12-31T23:59:59Z"
})

print("Shared link: " .. result.shared_link)
```

---

## search

Search for files and folders in Box.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `query` | string | yes | The search query string |
| `limit` | integer | no | Max results (1–200, default: 50) |
| `offset` | integer | no | Zero-based offset for pagination (default: 0) |

### Examples

```lua
local result = app.integrations.box.search({ query = "quarterly report" })

for _, item in ipairs(result.items) do
  print(item.type .. ": " .. item.name .. " (id=" .. item.id .. ")")
end

print("Total matches: " .. result.total_count)
```

---

## get_current_user

Get the currently authenticated Box user.

### Parameters

None.

### Examples

```lua
local result = app.integrations.box.get_current_user({})
print("User: " .. result.name .. " (" .. result.login .. ")")
print("Enterprise: " .. tostring(result.enterprise))
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.box.list_files({ folder_id = "0" })

-- Explicit default (portable across setups)
app.integrations.box.default.list_files({ folder_id = "0" })

-- Named accounts
app.integrations.box.work.list_files({ folder_id = "0" })
app.integrations.box.personal.upload_file({
  file_name = "notes.txt",
  content = "Hello"
})
```

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

Metadata-Derived Lua Example

local result = app.integrations.box.box_list_files({
  folder_id = "example_folder_id",
  limit = 1,
  offset = 1
})
print(result)

Functions

box_list_files

List files and folders in a Box folder. Returns item names, IDs, types (file or folder), sizes, and modification dates. Use folder ID "0" for the root folder.

Operation
Read read
Full name
box.box_list_files
ParameterTypeRequiredDescription
folder_id string no The folder ID to list. Use "0" for the root folder.
limit integer no Maximum number of items to return (1–1000, default: 100).
offset integer no Zero-based offset for pagination (default: 0).

box_get_file

Get metadata for a Box file by ID. Returns the file name, size, type, created/modified dates, parent folder, and shared link info.

Operation
Read read
Full name
box.box_get_file
ParameterTypeRequiredDescription
file_id string yes The Box file ID.

box_upload_file

Upload a file to Box. Provide the file name, content, and optionally a parent folder ID (defaults to root). Returns the uploaded file metadata.

Operation
Write write
Full name
box.box_upload_file
ParameterTypeRequiredDescription
file_name string yes The name for the file in Box, including extension (e.g., "report.pdf").
content string yes The file contents as a string.
parent_folder_id string no The parent folder ID. Use "0" for the root folder.

box_download_file

Download a file from Box by its ID. Returns the raw file contents. Use this to retrieve file data for processing.

Operation
Read read
Full name
box.box_download_file
ParameterTypeRequiredDescription
file_id string yes The Box file ID to download.

box_delete_file

Delete a file from Box by its ID. This action moves the file to the trash. Use with caution — deleted files can be restored from the trash within the retention period.

Operation
Write write
Full name
box.box_delete_file
ParameterTypeRequiredDescription
file_id string yes The Box file ID to delete.

box_create_folder

Create a new folder in Box. Provide a folder name and optionally a parent folder ID (defaults to root). Returns the new folder metadata.

Operation
Write write
Full name
box.box_create_folder
ParameterTypeRequiredDescription
name string yes The name for the new folder.
parent_folder_id string no The parent folder ID. Use "0" for the root folder.

box_get_folder

Get metadata for a Box folder by ID. Returns the folder name, size, created/modified dates, parent folder, and item counts. Use "0" for root.

Operation
Read read
Full name
box.box_get_folder
ParameterTypeRequiredDescription
folder_id string yes The Box folder ID. Use "0" for the root folder.

box_share_file

Create a shared link for a Box file. By default creates an open link. Optionally configure access level, password protection, and expiration.

Operation
Write write
Full name
box.box_share_file
ParameterTypeRequiredDescription
file_id string yes The Box file ID to share.
access string no Access level: "open" (anyone with link), "company" (enterprise users), "collaborators" (invited only). Default: "open".
password string no Optional password to protect the shared link.
expires_at string no Optional expiration timestamp (ISO 8601, e.g., "2026-12-31T23:59:59Z").

box_get_current_user

Get information about the currently authenticated Box user. Returns user name, email, login, and account details.

Operation
Read read
Full name
box.box_get_current_user
ParameterTypeRequiredDescription
No parameters.