productivity
Devin Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Devin KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.devin.*.
Use lua_read_doc("integrations.devin") 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
Devin workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.devin.create_session({prompt = "example_prompt", title = "example_title", tags = "example_tags", repos = "example_repos", playbook_id = "example_playbook_id", child_playbook_id = "example_child_playbook_id", knowledge_ids = "example_knowledge_ids", secret_ids = "example_secret_ids"}))' --json kosmo integrations:lua --eval 'print(docs.read("devin"))' --json
kosmo integrations:lua --eval 'print(docs.read("devin.create_session"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local devin = app.integrations.devin
local result = devin.create_session({prompt = "example_prompt", title = "example_title", tags = "example_tags", repos = "example_repos", playbook_id = "example_playbook_id", child_playbook_id = "example_child_playbook_id", knowledge_ids = "example_knowledge_ids", secret_ids = "example_secret_ids"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.devin, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.devin.default.* or app.integrations.devin.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Devin, 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.
Devin - Lua API Reference
Namespace: app.integrations.devin
This integration targets Devin’s current v3 API by default. Configure org_id
for organization-scoped tools. If a host still uses a URL ending in /v1, the
basic session tools use legacy v1 endpoints; v3-only tools return a clear error.
Sessions
Create a session:
local session = app.integrations.devin.create_session({
prompt = "Investigate why the example.test billing specs fail",
title = "Billing spec investigation",
tags = { "billing", "tests" },
repos = { "example/example-app" }
})
List and inspect sessions:
local sessions = app.integrations.devin.list_sessions({ first = 10 })
local details = app.integrations.devin.get_session({
session_id = "devin-abc123"
})
Send follow-up instructions:
app.integrations.devin.send_message({
session_id = "devin-abc123",
message = "Please summarize the failing assertion before changing code."
})
Terminate a session:
app.integrations.devin.terminate_session({
session_id = "devin-abc123"
})
Session Metadata
Use these v3 tools after creating or discovering a session:
local messages = app.integrations.devin.list_session_messages({
session_id = "devin-abc123",
first = 25
})
local attachments = app.integrations.devin.list_session_attachments({
session_id = "devin-abc123"
})
local tags = app.integrations.devin.get_session_tags({
session_id = "devin-abc123"
})
app.integrations.devin.append_session_tags({
session_id = "devin-abc123",
tags = { "reviewed" }
})
Generate and read insights:
app.integrations.devin.generate_session_insights({
session_id = "devin-abc123"
})
local insights = app.integrations.devin.get_session_insights({
session_id = "devin-abc123"
})
Account And Secrets
Check which principal the API key represents:
local self = app.integrations.devin.get_current_user()
Manage organization secrets:
local secrets = app.integrations.devin.list_secrets({ first = 20 })
local secret = app.integrations.devin.create_secret({
type = "key-value",
key = "EXAMPLE_TOKEN",
value = "dummy-value",
is_sensitive = true,
note = "Safe fake example"
})
app.integrations.devin.delete_secret({
secret_id = secret.id
})
Secret list responses return metadata only. Do not expect secret values to be returned after creation.
Return Shapes
The integration returns Devin’s JSON objects with minimal normalization. Cursor
paginated v3 responses may include collection items and page info fields exactly
as Devin returns them. Legacy v1 session responses may use older field names such
as session_id instead of v3 IDs such as devin_id.
Multi-Account Usage
app.integrations.devin.create_session({ prompt = "..." })
app.integrations.devin.default.create_session({ prompt = "..." })
app.integrations.devin.engineering.create_session({ prompt = "..." })
All account namespaces expose the same tools; only credentials, organization ID, and API version differ.
Raw agent markdown
# Devin - Lua API Reference
Namespace: `app.integrations.devin`
This integration targets Devin's current v3 API by default. Configure `org_id`
for organization-scoped tools. If a host still uses a URL ending in `/v1`, the
basic session tools use legacy v1 endpoints; v3-only tools return a clear error.
## Sessions
Create a session:
```lua
local session = app.integrations.devin.create_session({
prompt = "Investigate why the example.test billing specs fail",
title = "Billing spec investigation",
tags = { "billing", "tests" },
repos = { "example/example-app" }
})
```
List and inspect sessions:
```lua
local sessions = app.integrations.devin.list_sessions({ first = 10 })
local details = app.integrations.devin.get_session({
session_id = "devin-abc123"
})
```
Send follow-up instructions:
```lua
app.integrations.devin.send_message({
session_id = "devin-abc123",
message = "Please summarize the failing assertion before changing code."
})
```
Terminate a session:
```lua
app.integrations.devin.terminate_session({
session_id = "devin-abc123"
})
```
## Session Metadata
Use these v3 tools after creating or discovering a session:
```lua
local messages = app.integrations.devin.list_session_messages({
session_id = "devin-abc123",
first = 25
})
local attachments = app.integrations.devin.list_session_attachments({
session_id = "devin-abc123"
})
local tags = app.integrations.devin.get_session_tags({
session_id = "devin-abc123"
})
app.integrations.devin.append_session_tags({
session_id = "devin-abc123",
tags = { "reviewed" }
})
```
Generate and read insights:
```lua
app.integrations.devin.generate_session_insights({
session_id = "devin-abc123"
})
local insights = app.integrations.devin.get_session_insights({
session_id = "devin-abc123"
})
```
## Account And Secrets
Check which principal the API key represents:
```lua
local self = app.integrations.devin.get_current_user()
```
Manage organization secrets:
```lua
local secrets = app.integrations.devin.list_secrets({ first = 20 })
local secret = app.integrations.devin.create_secret({
type = "key-value",
key = "EXAMPLE_TOKEN",
value = "dummy-value",
is_sensitive = true,
note = "Safe fake example"
})
app.integrations.devin.delete_secret({
secret_id = secret.id
})
```
Secret list responses return metadata only. Do not expect secret values to be
returned after creation.
## Return Shapes
The integration returns Devin's JSON objects with minimal normalization. Cursor
paginated v3 responses may include collection items and page info fields exactly
as Devin returns them. Legacy v1 session responses may use older field names such
as `session_id` instead of v3 IDs such as `devin_id`.
## Multi-Account Usage
```lua
app.integrations.devin.create_session({ prompt = "..." })
app.integrations.devin.default.create_session({ prompt = "..." })
app.integrations.devin.engineering.create_session({ prompt = "..." })
```
All account namespaces expose the same tools; only credentials, organization ID,
and API version differ. local result = app.integrations.devin.create_session({prompt = "example_prompt", title = "example_title", tags = "example_tags", repos = "example_repos", playbook_id = "example_playbook_id", child_playbook_id = "example_child_playbook_id", knowledge_ids = "example_knowledge_ids", secret_ids = "example_secret_ids"})
print(result) Functions
create_session Write
Create a Devin session from a task prompt. Current v3 accounts can pass tags, repositories, playbooks, knowledge IDs, secrets, attachments, title, and user attribution options.
- Lua path
app.integrations.devin.create_session- Full name
devin.devin_create_session
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | yes | The task description for Devin to execute. Be specific about what you want accomplished. |
title | string | no | Optional title for the session. |
tags | array | no | Optional tags to attach to the session. |
repos | array | no | Optional repository references for v3 sessions. |
playbook_id | string | no | Optional Devin playbook ID. |
child_playbook_id | string | no | Optional child playbook ID for v3 sessions. |
knowledge_ids | array | no | Optional Devin knowledge IDs. |
secret_ids | array | no | Optional secret IDs Devin may use. |
session_secrets | object | no | Optional per-session secrets. |
attachment_urls | array | no | Optional attachment URLs for v3 session creation. |
session_links | array | no | Optional links to associate with the v3 session. |
create_as_user_id | string | no | Optional v3 user ID to create the session as. |
max_acu_limit | number | no | Optional maximum ACU limit. |
advanced_mode | boolean | no | Whether to enable v3 advanced mode. |
bypass_approval | boolean | no | Whether v3 may bypass approval when allowed by account policy. |
idempotent | boolean | no | Legacy v1 idempotency flag. |
snapshot_id | string | no | Legacy v1 snapshot ID. |
structured_output_schema | object | no | Optional structured output schema. |
unlisted | boolean | no | Legacy v1 unlisted-session flag. |
get_session Read
Retrieve details and current status of a Devin session. Use this to check progress on a task, view the session state, or get the output.
- Lua path
app.integrations.devin.get_session- Full name
devin.devin_get_session
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. Current v3 IDs are usually prefixed with devin-. |
list_sessions Read
List Devin sessions. Current v3 accounts support cursor and timestamp filters; legacy v1 accounts support basic pagination and tag filters.
- Lua path
app.integrations.devin.list_sessions- Full name
devin.devin_list_sessions
| Parameter | Type | Required | Description |
|---|---|---|---|
first | integer | no | Maximum v3 records to return. |
after | string | no | Cursor for v3 pagination. |
session_ids | array | no | Optional v3 session ID filter. |
created_after | string | no | Optional v3 created-after timestamp. |
created_before | string | no | Optional v3 created-before timestamp. |
updated_after | string | no | Optional v3 updated-after timestamp. |
updated_before | string | no | Optional v3 updated-before timestamp. |
playbook_id | string | no | Optional v3 playbook filter. |
origins | array | no | Optional v3 origin filters such as api, cli, slack, or webapp. |
schedule_id | string | no | Optional v3 schedule ID filter. |
user_ids | array | no | Optional v3 user ID filters. |
service_user_ids | array | no | Optional v3 service user ID filters. |
limit | integer | no | Legacy v1 limit. |
offset | integer | no | Legacy v1 offset. |
skip | integer | no | Legacy v1 skip count. |
tags | array | no | Legacy v1 tag filter. |
user_email | string | no | Legacy v1 user email filter. |
send_message Write
Send a message to an existing Devin session. Use this to provide additional instructions, ask questions, or guide the AI during an active session.
- Lua path
app.integrations.devin.send_message- Full name
devin.devin_send_message
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. Current v3 IDs are usually prefixed with devin-. |
message | string | yes | The message content to send to the session. |
message_as_user_id | string | no | Optional v3 user ID to attribute the message to. |
terminate_session Write
Terminate an active Devin session by ID.
- Lua path
app.integrations.devin.terminate_session- Full name
devin.devin_terminate_session
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID to terminate. |
archive | boolean | no | For v3, archive the session while terminating so it is preserved for reference. |
list_session_messages Read
List messages for a Devin v3 session with optional cursor pagination.
- Lua path
app.integrations.devin.list_session_messages- Full name
devin.devin_list_session_messages
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. |
first | integer | no | Maximum records to return. |
after | string | no | Cursor for the next page. |
list_session_attachments Read
List attachments for a Devin v3 session with optional cursor pagination.
- Lua path
app.integrations.devin.list_session_attachments- Full name
devin.devin_list_session_attachments
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. |
first | integer | no | Maximum records to return. |
after | string | no | Cursor for the next page. |
get_session_tags Read
Get tags attached to a Devin v3 session.
- Lua path
app.integrations.devin.get_session_tags- Full name
devin.devin_get_session_tags
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. |
append_session_tags Write
Append tags to a Devin session.
- Lua path
app.integrations.devin.append_session_tags- Full name
devin.devin_append_session_tags
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. |
tags | array | yes | Tags to append. |
get_session_insights Read
Get generated insights for a Devin v3 session.
- Lua path
app.integrations.devin.get_session_insights- Full name
devin.devin_get_session_insights
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. |
generate_session_insights Write
Generate insights for a Devin v3 session.
- Lua path
app.integrations.devin.generate_session_insights- Full name
devin.devin_generate_session_insights
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | yes | The Devin session ID. |
get_current_user Read
Get information about the authenticated Devin API principal. Use this to verify the current account, user, or service user.
- Lua path
app.integrations.devin.get_current_user- Full name
devin.devin_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_secrets Read
List Devin v3 organization secrets with optional cursor pagination. Secret values are not returned.
- Lua path
app.integrations.devin.list_secrets- Full name
devin.devin_list_secrets
| Parameter | Type | Required | Description |
|---|---|---|---|
first | integer | no | Maximum records to return. |
after | string | no | Cursor for the next page. |
create_secret Write
Create a Devin v3 organization secret for use in sessions.
- Lua path
app.integrations.devin.create_secret- Full name
devin.devin_create_secret
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | yes | Secret type accepted by Devin. |
key | string | yes | Secret key or name. |
value | string | yes | Secret value to store. |
is_sensitive | boolean | no | Whether Devin should treat the value as sensitive. |
note | string | no | Optional note for humans managing the secret. |
delete_secret Write
Delete a Devin v3 organization secret by ID.
- Lua path
app.integrations.devin.delete_secret- Full name
devin.devin_delete_secret
| Parameter | Type | Required | Description |
|---|---|---|---|
secret_id | string | yes | The Devin secret ID to delete. |