productivity
Autopilot Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Autopilot KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.autopilot.*.
Use lua_read_doc("integrations.autopilot") 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
Autopilot workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.autopilot.add_or_update_contact({}))' --json kosmo integrations:lua --eval 'print(docs.read("autopilot"))' --json
kosmo integrations:lua --eval 'print(docs.read("autopilot.add_or_update_contact"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local autopilot = app.integrations.autopilot
local result = autopilot.add_or_update_contact({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.autopilot, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.autopilot.default.* or app.integrations.autopilot.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Autopilot, 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.
Autopilot
Namespace: app.integrations.autopilot
Autopilot tools follow the official API Blueprint from the
autopilotdev.github.io repository. The API uses the autopilotapikey header,
not bearer authorization. Configure api_key; set url only for a test proxy.
Contacts
local contact = app.integrations.autopilot.create_contact({
payload = {
Email = "ada@example.test",
FirstName = "Ada",
LastName = "Lovelace",
Company = "Example Co",
custom_fields = {
Plan = "pro"
}
}
})
local fetched = app.integrations.autopilot.get_contact({
contact_id_or_email = "ada@example.test"
})
app.integrations.autopilot.delete_contact({
contact_id_or_email = "ada@example.test"
})
Autopilot de-duplicates contacts by Email. The create contact operation is
also the documented update path.
Lists
local list = app.integrations.autopilot.add_list({
payload = {
name = "Product-qualified leads"
}
})
local contacts = app.integrations.autopilot.get_contacts_on_list({
list_id = list.list_id
})
app.integrations.autopilot.delete_list({
payload = {
list_id = list.list_id
}
})
The official API Blueprint does not expose bulk contact listing or journey listing endpoints. Use list-specific contact lookup when you have a list ID.
Journeys
app.integrations.autopilot.eject_contact_from_journey({
journey_id = "campaign_123",
contact_id_or_email = "ada@example.test"
})
The documented journey operation removes a known contact from a known journey. The blueprint says there is no programmatic journey listing endpoint.
REST Hooks
local hook = app.integrations.autopilot.register_rest_hook({
payload = {
event = "contact_added",
target_url = "https://example.test/autopilot/hooks/contact-added"
}
})
local hooks = app.integrations.autopilot.list_rest_hooks({})
app.integrations.autopilot.unregister_rest_hook({
hook_id = hook.id
})
Supported events in the blueprint are:
contact_addedcontact_unsubscribescontact_added_to_listcontact_removed_from_listcontact_entered_segmentcontact_left_segment
Argument Shape
Path parameters are top-level snake_case arguments. Write operations accept a
payload object for the documented JSON body. Tools also accept query for
extra documented query parameters.
Empty Autopilot responses return { success = true, status = 204 }.
Multi-Account Usage
app.integrations.autopilot.get_contact({ contact_id_or_email = "ada@example.test" })
app.integrations.autopilot.default.get_contact({ contact_id_or_email = "ada@example.test" })
app.integrations.autopilot.marketing.get_contact({ contact_id_or_email = "ada@example.test" })
All account namespaces expose the same tool names. Only credentials differ.
Raw agent markdown
# Autopilot
Namespace: `app.integrations.autopilot`
Autopilot tools follow the official API Blueprint from the
`autopilotdev.github.io` repository. The API uses the `autopilotapikey` header,
not bearer authorization. Configure `api_key`; set `url` only for a test proxy.
## Contacts
```lua
local contact = app.integrations.autopilot.create_contact({
payload = {
Email = "ada@example.test",
FirstName = "Ada",
LastName = "Lovelace",
Company = "Example Co",
custom_fields = {
Plan = "pro"
}
}
})
local fetched = app.integrations.autopilot.get_contact({
contact_id_or_email = "ada@example.test"
})
app.integrations.autopilot.delete_contact({
contact_id_or_email = "ada@example.test"
})
```
Autopilot de-duplicates contacts by `Email`. The create contact operation is
also the documented update path.
## Lists
```lua
local list = app.integrations.autopilot.add_list({
payload = {
name = "Product-qualified leads"
}
})
local contacts = app.integrations.autopilot.get_contacts_on_list({
list_id = list.list_id
})
app.integrations.autopilot.delete_list({
payload = {
list_id = list.list_id
}
})
```
The official API Blueprint does not expose bulk contact listing or journey
listing endpoints. Use list-specific contact lookup when you have a list ID.
## Journeys
```lua
app.integrations.autopilot.eject_contact_from_journey({
journey_id = "campaign_123",
contact_id_or_email = "ada@example.test"
})
```
The documented journey operation removes a known contact from a known journey.
The blueprint says there is no programmatic journey listing endpoint.
## REST Hooks
```lua
local hook = app.integrations.autopilot.register_rest_hook({
payload = {
event = "contact_added",
target_url = "https://example.test/autopilot/hooks/contact-added"
}
})
local hooks = app.integrations.autopilot.list_rest_hooks({})
app.integrations.autopilot.unregister_rest_hook({
hook_id = hook.id
})
```
Supported events in the blueprint are:
- `contact_added`
- `contact_unsubscribes`
- `contact_added_to_list`
- `contact_removed_from_list`
- `contact_entered_segment`
- `contact_left_segment`
## Argument Shape
Path parameters are top-level snake_case arguments. Write operations accept a
`payload` object for the documented JSON body. Tools also accept `query` for
extra documented query parameters.
Empty Autopilot responses return `{ success = true, status = 204 }`.
## Multi-Account Usage
```lua
app.integrations.autopilot.get_contact({ contact_id_or_email = "ada@example.test" })
app.integrations.autopilot.default.get_contact({ contact_id_or_email = "ada@example.test" })
app.integrations.autopilot.marketing.get_contact({ contact_id_or_email = "ada@example.test" })
```
All account namespaces expose the same tool names. Only credentials differ. local result = app.integrations.autopilot.add_or_update_contact({})
print(result) Functions
add_or_update_contact Write
Create or update a contact. Autopilot de-duplicates contacts by Email and merges provided fields. Official Autopilot API Blueprint endpoint: POST https://api.autopilothq.com/v1/contact.
- Lua path
app.integrations.autopilot.add_or_update_contact- Full name
autopilot.autopilot_create_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_contact Read
Retrieve one contact by Autopilot contact_id or email address. Official Autopilot API Blueprint endpoint: GET https://api.autopilothq.com/v1/contact/{contact_id_or_email}.
- Lua path
app.integrations.autopilot.get_contact- Full name
autopilot.autopilot_get_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_contact Write
Permanently delete one contact by Autopilot contact_id or email address. Official Autopilot API Blueprint endpoint: DELETE https://api.autopilothq.com/v1/contact/{contact_id_or_email}.
- Lua path
app.integrations.autopilot.delete_contact- Full name
autopilot.autopilot_delete_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_contacts_list Read
Retrieve contacts belonging to a specific Autopilot list. Official Autopilot API Blueprint endpoint: GET https://api.autopilothq.com/v1/list/{list_id}.
- Lua path
app.integrations.autopilot.get_contacts_list- Full name
autopilot.autopilot_get_contacts_on_list
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
add_list Write
Create a new Autopilot list. Official Autopilot API Blueprint endpoint: POST https://api.autopilothq.com/v1/list.
- Lua path
app.integrations.autopilot.add_list- Full name
autopilot.autopilot_add_list
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_list Write
Delete an Autopilot list. Supply the documented list identifier in payload. Official Autopilot API Blueprint endpoint: DELETE https://api.autopilothq.com/v1/list.
- Lua path
app.integrations.autopilot.delete_list- Full name
autopilot.autopilot_delete_list
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
eject_contact_from_journey Write
Remove a contact from a specific journey before they complete all steps. Official Autopilot API Blueprint endpoint: DELETE https://api.autopilothq.com/v1/journey/{journey_id}/contact/{contact_id_or_email}.
- Lua path
app.integrations.autopilot.eject_contact_from_journey- Full name
autopilot.autopilot_eject_contact_from_journey
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
register_rest_hook Write
Register a REST hook target URL for a supported Autopilot event. Official Autopilot API Blueprint endpoint: POST https://api.autopilothq.com/v1/hook.
- Lua path
app.integrations.autopilot.register_rest_hook- Full name
autopilot.autopilot_register_rest_hook
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
unregister_rest_hook Write
Unregister a REST hook by hook_id. Official Autopilot API Blueprint endpoint: DELETE https://api.autopilothq.com/v1/hook/{hook_id}.
- Lua path
app.integrations.autopilot.unregister_rest_hook- Full name
autopilot.autopilot_unregister_rest_hook
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_rest_hooks Read
List registered REST hooks. Official Autopilot API Blueprint endpoint: GET https://api.autopilothq.com/v1/hooks.
- Lua path
app.integrations.autopilot.list_rest_hooks- Full name
autopilot.autopilot_list_rest_hooks
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||