productivity
PandaDoc Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the PandaDoc KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.pandadoc.*.
Use lua_read_doc("integrations.pandadoc") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
PandaDoc workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.pandadoc.list_documents({page = 1, count = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("pandadoc"))' --json
kosmo integrations:lua --eval 'print(docs.read("pandadoc.list_documents"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local pandadoc = app.integrations.pandadoc
local result = pandadoc.list_documents({page = 1, count = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.pandadoc, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.pandadoc.default.* or app.integrations.pandadoc.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need PandaDoc, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
PandaDoc — Lua API Reference
list_documents
List documents from PandaDoc.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (default: 1) |
count | integer | no | Number of documents per page (default: 50, max: 100) |
Examples
local result = app.integrations.pandadoc.list_documents({
page = 1,
count = 20
})
for _, doc in ipairs(result.results) do
print(doc.name .. " — " .. doc.status)
end
get_document
Get details of a specific PandaDoc document.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID |
Examples
local result = app.integrations.pandadoc.get_document({
id = "abc123-def456-..."
})
print("Document: " .. result.name)
print("Status: " .. result.status)
create_document
Create a new document from an existing PandaDoc template.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Name for the new document |
template_id | string | yes | UUID of the template to use |
recipients | array | no | List of recipients with email, first_name, last_name, role |
tokens | array | no | Template tokens to fill, each with name and value |
fields | array | no | Prefill fields, each with name (or field_uuid) and value |
metadata | object | no | Custom metadata key-value pairs |
Examples
local result = app.integrations.pandadoc.create_document({
name = "NDA - Acme Corp",
template_id = "template-uuid-here",
recipients = {
{
email = "john@example.com",
first_name = "John",
last_name = "Doe",
role = "Signer"
}
},
tokens = {
{ name = "Company Name", value = "Acme Corp" },
{ name = "Date", value = "2026-04-05" }
}
})
print("Created document: " .. result.id)
send_document
Send a document to recipients for signature.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID to send |
message | string | no | Custom message for the email notification |
silent | boolean | no | If true, change status without sending email (default: false) |
Examples
local result = app.integrations.pandadoc.send_document({
id = "document-uuid-here",
message = "Please review and sign this document at your earliest convenience."
})
print("Document sent successfully")
list_templates
List available document templates.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (default: 1) |
Examples
local result = app.integrations.pandadoc.list_templates({
page = 1
})
for _, tmpl in ipairs(result.results) do
print(tmpl.name .. " — " .. tmpl.id)
end
get_template
Get details of a specific PandaDoc template.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The template UUID |
Examples
local result = app.integrations.pandadoc.get_template({
id = "template-uuid-here"
})
print("Template: " .. result.name)
print("Fields: " .. #result.fields)
download_document
Download a document as PDF. Returns base64-encoded content.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID to download |
Examples
local result = app.integrations.pandadoc.download_document({
id = "document-uuid-here"
})
print("Content type: " .. result.content_type)
-- result.content is base64-encoded PDF data
create_link
Create a signed sharing link for a document.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID |
lifetime | integer | no | Session lifetime in seconds (default: 3600) |
Examples
local result = app.integrations.pandadoc.create_link({
id = "document-uuid-here",
lifetime = 7200
})
print("Sharing link: " .. result.session_url)
get_current_user
Get the profile of the currently authenticated PandaDoc user.
Parameters
None.
Examples
local result = app.integrations.pandadoc.get_current_user({})
print("Logged in as: " .. result.first_name .. " " .. result.last_name)
print("Email: " .. result.email)
print("Company: " .. result.company)
Multi-Account Usage
If you have multiple PandaDoc accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.pandadoc.function_name({...})
-- Explicit default (portable across setups)
app.integrations.pandadoc.default.function_name({...})
-- Named accounts
app.integrations.pandadoc.sales.function_name({...})
app.integrations.pandadoc.legal.function_name({...})
All functions are identical across accounts — only the credentials differ.
Typical Workflow
-- 1. Find a template
local templates = app.integrations.pandadoc.list_templates({})
local template_id = templates.results[1].id
-- 2. Create a document from the template
local doc = app.integrations.pandadoc.create_document({
name = "Service Agreement - New Client",
template_id = template_id,
recipients = {
{ email = "client@example.com", first_name = "Jane", last_name = "Smith", role = "Client" }
},
tokens = {
{ name = "Client Name", value = "Jane Smith" },
{ name = "Service Date", value = "2026-04-05" }
}
})
-- 3. Send for signature
app.integrations.pandadoc.send_document({
id = doc.id,
message = "Please review and sign at your convenience."
})
-- 4. Share a link for viewing
local link = app.integrations.pandadoc.create_link({
id = doc.id,
lifetime = 86400
})
print("View link: " .. link.session_url)Raw agent markdown
# PandaDoc — Lua API Reference
## list_documents
List documents from PandaDoc.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number for pagination (default: 1) |
| `count` | integer | no | Number of documents per page (default: 50, max: 100) |
### Examples
```lua
local result = app.integrations.pandadoc.list_documents({
page = 1,
count = 20
})
for _, doc in ipairs(result.results) do
print(doc.name .. " — " .. doc.status)
end
```
---
## get_document
Get details of a specific PandaDoc document.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The document UUID |
### Examples
```lua
local result = app.integrations.pandadoc.get_document({
id = "abc123-def456-..."
})
print("Document: " .. result.name)
print("Status: " .. result.status)
```
---
## create_document
Create a new document from an existing PandaDoc template.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Name for the new document |
| `template_id` | string | yes | UUID of the template to use |
| `recipients` | array | no | List of recipients with `email`, `first_name`, `last_name`, `role` |
| `tokens` | array | no | Template tokens to fill, each with `name` and `value` |
| `fields` | array | no | Prefill fields, each with `name` (or `field_uuid`) and `value` |
| `metadata` | object | no | Custom metadata key-value pairs |
### Examples
```lua
local result = app.integrations.pandadoc.create_document({
name = "NDA - Acme Corp",
template_id = "template-uuid-here",
recipients = {
{
email = "john@example.com",
first_name = "John",
last_name = "Doe",
role = "Signer"
}
},
tokens = {
{ name = "Company Name", value = "Acme Corp" },
{ name = "Date", value = "2026-04-05" }
}
})
print("Created document: " .. result.id)
```
---
## send_document
Send a document to recipients for signature.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The document UUID to send |
| `message` | string | no | Custom message for the email notification |
| `silent` | boolean | no | If true, change status without sending email (default: false) |
### Examples
```lua
local result = app.integrations.pandadoc.send_document({
id = "document-uuid-here",
message = "Please review and sign this document at your earliest convenience."
})
print("Document sent successfully")
```
---
## list_templates
List available document templates.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number for pagination (default: 1) |
### Examples
```lua
local result = app.integrations.pandadoc.list_templates({
page = 1
})
for _, tmpl in ipairs(result.results) do
print(tmpl.name .. " — " .. tmpl.id)
end
```
---
## get_template
Get details of a specific PandaDoc template.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The template UUID |
### Examples
```lua
local result = app.integrations.pandadoc.get_template({
id = "template-uuid-here"
})
print("Template: " .. result.name)
print("Fields: " .. #result.fields)
```
---
## download_document
Download a document as PDF. Returns base64-encoded content.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The document UUID to download |
### Examples
```lua
local result = app.integrations.pandadoc.download_document({
id = "document-uuid-here"
})
print("Content type: " .. result.content_type)
-- result.content is base64-encoded PDF data
```
---
## create_link
Create a signed sharing link for a document.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The document UUID |
| `lifetime` | integer | no | Session lifetime in seconds (default: 3600) |
### Examples
```lua
local result = app.integrations.pandadoc.create_link({
id = "document-uuid-here",
lifetime = 7200
})
print("Sharing link: " .. result.session_url)
```
---
## get_current_user
Get the profile of the currently authenticated PandaDoc user.
### Parameters
None.
### Examples
```lua
local result = app.integrations.pandadoc.get_current_user({})
print("Logged in as: " .. result.first_name .. " " .. result.last_name)
print("Email: " .. result.email)
print("Company: " .. result.company)
```
---
## Multi-Account Usage
If you have multiple PandaDoc accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.pandadoc.function_name({...})
-- Explicit default (portable across setups)
app.integrations.pandadoc.default.function_name({...})
-- Named accounts
app.integrations.pandadoc.sales.function_name({...})
app.integrations.pandadoc.legal.function_name({...})
```
All functions are identical across accounts — only the credentials differ.
## Typical Workflow
```lua
-- 1. Find a template
local templates = app.integrations.pandadoc.list_templates({})
local template_id = templates.results[1].id
-- 2. Create a document from the template
local doc = app.integrations.pandadoc.create_document({
name = "Service Agreement - New Client",
template_id = template_id,
recipients = {
{ email = "client@example.com", first_name = "Jane", last_name = "Smith", role = "Client" }
},
tokens = {
{ name = "Client Name", value = "Jane Smith" },
{ name = "Service Date", value = "2026-04-05" }
}
})
-- 3. Send for signature
app.integrations.pandadoc.send_document({
id = doc.id,
message = "Please review and sign at your convenience."
})
-- 4. Share a link for viewing
local link = app.integrations.pandadoc.create_link({
id = doc.id,
lifetime = 86400
})
print("View link: " .. link.session_url)
``` local result = app.integrations.pandadoc.list_documents({page = 1, count = 1})
print(result) Functions
list_documents Read
List documents from PandaDoc. Returns a paginated list of documents with their IDs, names, status, and metadata.
- Lua path
app.integrations.pandadoc.list_documents- Full name
pandadoc.pandadoc_list_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (default: 1). |
count | integer | no | Number of documents per page (default: 50, max: 100). |
get_document Read
Get details of a specific PandaDoc document by ID. Returns document metadata, status, recipients, and fields.
- Lua path
app.integrations.pandadoc.get_document- Full name
pandadoc.pandadoc_get_document
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID. |
create_document Write
Create a new PandaDoc document from an existing template. The document is created in draft status and can then be sent for signature.
- Lua path
app.integrations.pandadoc.create_document- Full name
pandadoc.pandadoc_create_document
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Name for the new document. |
template_id | string | yes | UUID of the template to create the document from. |
recipients | array | no | List of recipients. Each recipient should have "email" and optionally "first_name", "last_name", "role". |
tokens | array | no | List of template tokens to fill. Each token should have "name" and "value". |
fields | array | no | Prefill fields. Each field should have "name" (or "field_uuid") and "value". |
metadata | object | no | Custom metadata key-value pairs to attach to the document. |
send_document Write
Send a PandaDoc document to recipients for signature. The document must be in draft status. Once sent, recipients will receive an email notification.
- Lua path
app.integrations.pandadoc.send_document- Full name
pandadoc.pandadoc_send_document
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID to send. |
message | string | no | Custom message to include in the email notification to recipients. |
silent | boolean | no | If true, the document changes status to sent but no email is sent to recipients (default: false). |
list_templates Read
List available document templates from PandaDoc. Returns template IDs, names, and metadata for creating new documents.
- Lua path
app.integrations.pandadoc.list_templates- Full name
pandadoc.pandadoc_list_templates
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (default: 1). |
get_template Read
Get details of a specific PandaDoc template by ID. Returns template metadata, fields, tokens, and recipient roles.
- Lua path
app.integrations.pandadoc.get_template- Full name
pandadoc.pandadoc_get_template
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The template UUID. |
download_document Read
Download a PandaDoc document as a PDF. Returns the PDF content as a base64-encoded string.
- Lua path
app.integrations.pandadoc.download_document- Full name
pandadoc.pandadoc_download_document
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID to download. |
create_sharing_link Write
Create a signed sharing link (session) for a PandaDoc document. The link allows viewing the document without authentication.
- Lua path
app.integrations.pandadoc.create_sharing_link- Full name
pandadoc.pandadoc_create_link
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The document UUID to create a sharing link for. |
lifetime | integer | no | Session lifetime in seconds (default: 3600). After this time the link expires. |
get_current_user Read
Get the profile of the currently authenticated PandaDoc user. Useful for verifying the connection and identifying the account.
- Lua path
app.integrations.pandadoc.get_current_user- Full name
pandadoc.pandadoc_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||