data
Docusign Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Docusign KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.docusign.*.
Use lua_read_doc("integrations.docusign") 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
Docusign workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.docusign.list_envelopes({status = "example_status", from_date = "example_from_date", to_date = "example_to_date", search_text = "example_search_text", count = 1, start_position = 1, order = "example_order", order_by = "example_order_by"}))' --json kosmo integrations:lua --eval 'print(docs.read("docusign"))' --json
kosmo integrations:lua --eval 'print(docs.read("docusign.list_envelopes"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local docusign = app.integrations.docusign
local result = docusign.list_envelopes({status = "example_status", from_date = "example_from_date", to_date = "example_to_date", search_text = "example_search_text", count = 1, start_position = 1, order = "example_order", order_by = "example_order_by"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.docusign, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.docusign.default.* or app.integrations.docusign.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Docusign, 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.
DocuSign — Lua API Reference
list_envelopes
List envelopes in the DocuSign account with optional filtering.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
status | string | no | Filter by status: sent, delivered, completed, signed, declined, voided, or all (default: all) |
from_date | string | no | Start date (YYYY-MM-DD). Defaults to 30 days ago. |
to_date | string | no | End date (YYYY-MM-DD). Defaults to today. |
search_text | string | no | Search envelope subjects and recipient names |
count | integer | no | Number of results (default: 25, max: 100) |
start_position | integer | no | Zero-based pagination index |
order | string | no | Sort direction: "asc" or "desc" |
order_by | string | no | Sort field: "last_modified", "created", or "sent" |
Example
local result = app.integrations.docusign.list_envelopes({
status = "completed",
from_date = "2026-01-01",
to_date = "2026-03-31",
count = 10
})
for _, env in ipairs(result.envelopes) do
print(env.envelopeId .. ": " .. env.subject .. " (" .. env.status .. ")")
end
get_envelope
Get detailed information about a specific envelope.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
envelope_id | string | yes | The envelope ID |
include | string | no | Comma-separated: recipients, documents, extensions, custom_fields, tabs |
Example
local result = app.integrations.docusign.get_envelope({
envelope_id = "abc123-def456",
include = "recipients,documents"
})
print("Subject: " .. result.emailSubject)
print("Status: " .. result.status)
create_envelope
Create a new envelope for electronic signature.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
envelope_definition | object | yes | Full envelope definition (see below) |
Envelope Definition Fields
The envelope_definition object must contain:
| Field | Type | Required | Description |
|---|---|---|---|
emailSubject | string | yes | Email subject line |
documents | array | yes* | Array of document objects (not needed if using templateId) |
templateId | string | yes* | Template ID to create from (alternative to documents) |
recipients | object | yes | Recipient roles: signers, ccs, etc. |
status | string | no | "sent" to send immediately or "created" to save as draft (default: sent) |
Examples
-- Create from a template
local result = app.integrations.docusign.create_envelope({
envelope_definition = {
templateId = "tmpl-abc123",
emailSubject = "Please sign the NDA",
status = "sent",
templateRoles = {
{
roleName = "signer",
name = "Jane Doe",
email = "jane@example.com"
}
}
}
})
print("Envelope created: " .. result.envelopeId)
-- Create with inline documents
local result = app.integrations.docusign.create_envelope({
envelope_definition = {
emailSubject = "Contract for signature",
status = "sent",
documents = {
{
documentId = "1",
name = "Contract.pdf",
documentBase64 = "<base64-encoded PDF>"
}
},
recipients = {
signers = {
{
recipientId = "1",
name = "John Smith",
email = "john@example.com",
tabs = {
signHereTabs = {
{ documentId = "1", pageNumber = "1", xPosition = "100", yPosition = "500" }
}
}
}
}
}
}
})
list_templates
List templates available in the DocuSign account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
search_text | string | no | Filter by name or description |
count | integer | no | Number of results (default: 25) |
start_position | integer | no | Zero-based pagination index |
folder_id | string | no | Filter by folder ID |
order | string | no | Sort direction: "asc" or "desc" |
order_by | string | no | Sort field: "name" or "modified" |
Example
local result = app.integrations.docusign.list_templates({
search_text = "NDA",
count = 10
})
for _, tmpl in ipairs(result.envelopeTemplates) do
print(tmpl.templateId .. ": " .. tmpl.name)
end
get_template
Get full details for a DocuSign template.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
template_id | string | yes | The template ID |
Example
local result = app.integrations.docusign.get_template({
template_id = "tmpl-abc123"
})
print("Template: " .. result.name)
print("Documents: " .. #result.documents)
list_documents
List documents attached to an envelope.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
envelope_id | string | yes | The envelope ID |
Example
local result = app.integrations.docusign.list_documents({
envelope_id = "abc123-def456"
})
for _, doc in ipairs(result.envelopeDocuments) do
print(doc.documentId .. ": " .. doc.name .. " (" .. doc.type .. ")")
end
get_document
Download a document from an envelope.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
envelope_id | string | yes | The envelope ID |
document_id | string | yes | The document ID, or "combined" for all docs as one PDF |
Example
local result = app.integrations.docusign.get_document({
envelope_id = "abc123-def456",
document_id = "1"
})
print("Size: " .. result.size_bytes .. " bytes")
-- result.content_base64 contains the base64-encoded document
get_current_user
Get information about the authenticated DocuSign user.
Parameters
None.
Example
local result = app.integrations.docusign.get_current_user()
print("User: " .. result.name)
print("Email: " .. result.email)
for _, acct in ipairs(result.accounts) do
print("Account: " .. acct.account_id .. " - " .. acct.account_name)
end
Multi-Account Usage
If you have multiple DocuSign accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.docusign.function_name({...})
-- Explicit default (portable across setups)
app.integrations.docusign.default.function_name({...})
-- Named accounts
app.integrations.docusign.production.function_name({...})
app.integrations.docusign.sandbox.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# DocuSign — Lua API Reference
## list_envelopes
List envelopes in the DocuSign account with optional filtering.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `status` | string | no | Filter by status: `sent`, `delivered`, `completed`, `signed`, `declined`, `voided`, or `all` (default: all) |
| `from_date` | string | no | Start date (YYYY-MM-DD). Defaults to 30 days ago. |
| `to_date` | string | no | End date (YYYY-MM-DD). Defaults to today. |
| `search_text` | string | no | Search envelope subjects and recipient names |
| `count` | integer | no | Number of results (default: 25, max: 100) |
| `start_position` | integer | no | Zero-based pagination index |
| `order` | string | no | Sort direction: `"asc"` or `"desc"` |
| `order_by` | string | no | Sort field: `"last_modified"`, `"created"`, or `"sent"` |
### Example
```lua
local result = app.integrations.docusign.list_envelopes({
status = "completed",
from_date = "2026-01-01",
to_date = "2026-03-31",
count = 10
})
for _, env in ipairs(result.envelopes) do
print(env.envelopeId .. ": " .. env.subject .. " (" .. env.status .. ")")
end
```
---
## get_envelope
Get detailed information about a specific envelope.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `envelope_id` | string | yes | The envelope ID |
| `include` | string | no | Comma-separated: `recipients`, `documents`, `extensions`, `custom_fields`, `tabs` |
### Example
```lua
local result = app.integrations.docusign.get_envelope({
envelope_id = "abc123-def456",
include = "recipients,documents"
})
print("Subject: " .. result.emailSubject)
print("Status: " .. result.status)
```
---
## create_envelope
Create a new envelope for electronic signature.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `envelope_definition` | object | yes | Full envelope definition (see below) |
### Envelope Definition Fields
The `envelope_definition` object must contain:
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `emailSubject` | string | yes | Email subject line |
| `documents` | array | yes* | Array of document objects (not needed if using templateId) |
| `templateId` | string | yes* | Template ID to create from (alternative to documents) |
| `recipients` | object | yes | Recipient roles: signers, ccs, etc. |
| `status` | string | no | `"sent"` to send immediately or `"created"` to save as draft (default: sent) |
### Examples
```lua
-- Create from a template
local result = app.integrations.docusign.create_envelope({
envelope_definition = {
templateId = "tmpl-abc123",
emailSubject = "Please sign the NDA",
status = "sent",
templateRoles = {
{
roleName = "signer",
name = "Jane Doe",
email = "jane@example.com"
}
}
}
})
print("Envelope created: " .. result.envelopeId)
```
```lua
-- Create with inline documents
local result = app.integrations.docusign.create_envelope({
envelope_definition = {
emailSubject = "Contract for signature",
status = "sent",
documents = {
{
documentId = "1",
name = "Contract.pdf",
documentBase64 = "<base64-encoded PDF>"
}
},
recipients = {
signers = {
{
recipientId = "1",
name = "John Smith",
email = "john@example.com",
tabs = {
signHereTabs = {
{ documentId = "1", pageNumber = "1", xPosition = "100", yPosition = "500" }
}
}
}
}
}
}
})
```
---
## list_templates
List templates available in the DocuSign account.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `search_text` | string | no | Filter by name or description |
| `count` | integer | no | Number of results (default: 25) |
| `start_position` | integer | no | Zero-based pagination index |
| `folder_id` | string | no | Filter by folder ID |
| `order` | string | no | Sort direction: `"asc"` or `"desc"` |
| `order_by` | string | no | Sort field: `"name"` or `"modified"` |
### Example
```lua
local result = app.integrations.docusign.list_templates({
search_text = "NDA",
count = 10
})
for _, tmpl in ipairs(result.envelopeTemplates) do
print(tmpl.templateId .. ": " .. tmpl.name)
end
```
---
## get_template
Get full details for a DocuSign template.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `template_id` | string | yes | The template ID |
### Example
```lua
local result = app.integrations.docusign.get_template({
template_id = "tmpl-abc123"
})
print("Template: " .. result.name)
print("Documents: " .. #result.documents)
```
---
## list_documents
List documents attached to an envelope.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `envelope_id` | string | yes | The envelope ID |
### Example
```lua
local result = app.integrations.docusign.list_documents({
envelope_id = "abc123-def456"
})
for _, doc in ipairs(result.envelopeDocuments) do
print(doc.documentId .. ": " .. doc.name .. " (" .. doc.type .. ")")
end
```
---
## get_document
Download a document from an envelope.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `envelope_id` | string | yes | The envelope ID |
| `document_id` | string | yes | The document ID, or `"combined"` for all docs as one PDF |
### Example
```lua
local result = app.integrations.docusign.get_document({
envelope_id = "abc123-def456",
document_id = "1"
})
print("Size: " .. result.size_bytes .. " bytes")
-- result.content_base64 contains the base64-encoded document
```
---
## get_current_user
Get information about the authenticated DocuSign user.
### Parameters
None.
### Example
```lua
local result = app.integrations.docusign.get_current_user()
print("User: " .. result.name)
print("Email: " .. result.email)
for _, acct in ipairs(result.accounts) do
print("Account: " .. acct.account_id .. " - " .. acct.account_name)
end
```
---
## Multi-Account Usage
If you have multiple DocuSign accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.docusign.function_name({...})
-- Explicit default (portable across setups)
app.integrations.docusign.default.function_name({...})
-- Named accounts
app.integrations.docusign.production.function_name({...})
app.integrations.docusign.sandbox.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.docusign.list_envelopes({status = "example_status", from_date = "example_from_date", to_date = "example_to_date", search_text = "example_search_text", count = 1, start_position = 1, order = "example_order", order_by = "example_order_by"})
print(result) Functions
list_envelopes Read
List envelopes in the DocuSign account. Filter by status (sent, delivered, completed, signed, declined, voided), date range, or search text. Returns envelope summaries with IDs, subjects, statuses, and dates.
- Lua path
app.integrations.docusign.list_envelopes- Full name
docusign.docusign_list_envelopes
| Parameter | Type | Required | Description |
|---|---|---|---|
status | string | no | Filter by status: sent, delivered, completed, signed, declined, voided, or "all" (default: all). |
from_date | string | no | Start date for filter (YYYY-MM-DD). Defaults to 30 days ago if not specified. |
to_date | string | no | End date for filter (YYYY-MM-DD). Defaults to today. |
search_text | string | no | Search envelope subjects and recipient names. |
count | integer | no | Number of results to return (default: 25, max: 100). |
start_position | integer | no | Zero-based index for pagination (default: 0). |
order | string | no | Sort direction: "asc" or "desc" (default: "desc"). |
order_by | string | no | Sort field: "last_modified", "created", or "sent" (default: "last_modified"). |
get_envelope Read
Get detailed information about a DocuSign envelope including status, recipients, documents, and signing history. Use this to check if an envelope has been signed or to review its details.
- Lua path
app.integrations.docusign.get_envelope- Full name
docusign.docusign_get_envelope
| Parameter | Type | Required | Description |
|---|---|---|---|
envelope_id | string | yes | The envelope ID to retrieve. |
include | string | no | Comma-separated list of additional data to include: "recipients", "documents", "extensions", "custom_fields", "tabs". |
create_envelope Write
Create a new DocuSign envelope for electronic signature. You can create from a template (pass template_id) or from scratch with inline documents and recipients. Set status to "sent" to send immediately or "created" to save as a draft.
- Lua path
app.integrations.docusign.create_envelope- Full name
docusign.docusign_create_envelope
| Parameter | Type | Required | Description |
|---|---|---|---|
envelope_definition | object | yes | The full envelope definition JSON object. Required fields: documents (or templateId), recipients (signers, cc, etc.), emailSubject, and status ("sent" or "created"). See DocuSign eSignature REST API docs for full schema. |
list_templates Read
List templates available in the DocuSign account. Templates define reusable envelope structures with pre-configured documents, recipients, and signing tabs. Use a template ID to create envelopes from a template.
- Lua path
app.integrations.docusign.list_templates- Full name
docusign.docusign_list_templates
| Parameter | Type | Required | Description |
|---|---|---|---|
search_text | string | no | Filter templates by name or description. |
count | integer | no | Number of results to return (default: 25). |
start_position | integer | no | Zero-based index for pagination (default: 0). |
folder_id | string | no | Filter by folder ID. |
folder_ids | array | no | Filter by multiple folder IDs. |
order | string | no | Sort direction: "asc" or "desc". |
order_by | string | no | Sort field: "name" or "modified". |
get_template Read
Get details for a DocuSign template including its documents, recipient roles, signing tabs, and email settings. Use this to understand a template before creating an envelope from it.
- Lua path
app.integrations.docusign.get_template- Full name
docusign.docusign_get_template
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | yes | The template ID to retrieve. |
list_documents Read
List documents in a DocuSign envelope. Returns document IDs, names, types (content or summary), and page counts. Use document IDs to download individual documents.
- Lua path
app.integrations.docusign.list_documents- Full name
docusign.docusign_list_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
envelope_id | string | yes | The envelope ID to list documents for. |
get_document Read
Download a document from a DocuSign envelope. Returns the document content as base64-encoded data. Use "combined" as the document_id to download all documents as a single combined PDF.
- Lua path
app.integrations.docusign.get_document- Full name
docusign.docusign_get_document
| Parameter | Type | Required | Description |
|---|---|---|---|
envelope_id | string | yes | The envelope ID containing the document. |
document_id | string | yes | The document ID to download. Use "combined" to get all documents as a single PDF. |
get_current_user Read
Get information about the authenticated DocuSign user, including name, email, and associated accounts. Useful for verifying credentials and discovering account IDs.
- Lua path
app.integrations.docusign.get_current_user- Full name
docusign.docusign_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||