KosmoKrator

documents

PandaDoc Lua API for KosmoKrator Agents

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

9 functions 6 read 3 write Manual OAuth token auth

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.

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

NameTypeRequiredDescription
pageintegernoPage number for pagination (default: 1)
countintegernoNumber 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

NameTypeRequiredDescription
idstringyesThe 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

NameTypeRequiredDescription
namestringyesName for the new document
template_idstringyesUUID of the template to use
recipientsarraynoList of recipients with email, first_name, last_name, role
tokensarraynoTemplate tokens to fill, each with name and value
fieldsarraynoPrefill fields, each with name (or field_uuid) and value
metadataobjectnoCustom metadata key-value pairs

Examples

local result = app.integrations.pandadoc.create_document({
  name = "NDA - Acme Corp",
  template_id = "template-uuid-here",
  recipients = {
    {
      email = "[email protected]",
      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

NameTypeRequiredDescription
idstringyesThe document UUID to send
messagestringnoCustom message for the email notification
silentbooleannoIf 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

NameTypeRequiredDescription
pageintegernoPage 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

NameTypeRequiredDescription
idstringyesThe 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

NameTypeRequiredDescription
idstringyesThe 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 a signed sharing link for a document.

Parameters

NameTypeRequiredDescription
idstringyesThe document UUID
lifetimeintegernoSession 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 = "[email protected]", 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 = "[email protected]",
      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 = "[email protected]", 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)
```

Metadata-Derived Lua Example

local result = app.integrations.pandadoc.pandadoc_list_documents({
  page = 1,
  count = 1
})
print(result)

Functions

pandadoc_list_documents

List documents from PandaDoc. Returns a paginated list of documents with their IDs, names, status, and metadata.

Operation
Read read
Full name
pandadoc.pandadoc_list_documents
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).
count integer no Number of documents per page (default: 50, max: 100).

pandadoc_get_document

Get details of a specific PandaDoc document by ID. Returns document metadata, status, recipients, and fields.

Operation
Read read
Full name
pandadoc.pandadoc_get_document
ParameterTypeRequiredDescription
id string yes The document UUID.

pandadoc_create_document

Create a new PandaDoc document from an existing template. The document is created in draft status and can then be sent for signature.

Operation
Write write
Full name
pandadoc.pandadoc_create_document
ParameterTypeRequiredDescription
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.

pandadoc_send_document

Send a PandaDoc document to recipients for signature. The document must be in draft status. Once sent, recipients will receive an email notification.

Operation
Write write
Full name
pandadoc.pandadoc_send_document
ParameterTypeRequiredDescription
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).

pandadoc_list_templates

List available document templates from PandaDoc. Returns template IDs, names, and metadata for creating new documents.

Operation
Read read
Full name
pandadoc.pandadoc_list_templates
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).

pandadoc_get_template

Get details of a specific PandaDoc template by ID. Returns template metadata, fields, tokens, and recipient roles.

Operation
Read read
Full name
pandadoc.pandadoc_get_template
ParameterTypeRequiredDescription
id string yes The template UUID.

pandadoc_download_document

Download a PandaDoc document as a PDF. Returns the PDF content as a base64-encoded string.

Operation
Read read
Full name
pandadoc.pandadoc_download_document
ParameterTypeRequiredDescription
id string yes The document UUID to download.

pandadoc_get_current_user

Get the profile of the currently authenticated PandaDoc user. Useful for verifying the connection and identifying the account.

Operation
Read read
Full name
pandadoc.pandadoc_get_current_user
ParameterTypeRequiredDescription
No parameters.