productivity
Toggl Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Toggl KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.toggl.*.
Use lua_read_doc("integrations.toggl") 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
Toggl workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.toggl.create_time_entry({workspace_id = "example_workspace_id", description = "example_description", start = "example_start", stop = "example_stop", duration = 1, project_id = "example_project_id", tags = "example_tags"}))' --json kosmo integrations:lua --eval 'print(docs.read("toggl"))' --json
kosmo integrations:lua --eval 'print(docs.read("toggl.create_time_entry"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local toggl = app.integrations.toggl
local result = toggl.create_time_entry({workspace_id = "example_workspace_id", description = "example_description", start = "example_start", stop = "example_stop", duration = 1, project_id = "example_project_id", tags = "example_tags"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.toggl, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.toggl.default.* or app.integrations.toggl.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Toggl, 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.
Toggl — Lua API Reference
toggl_list_workspaces
List all Toggl workspaces the authenticated user belongs to.
Parameters
None
Example
local workspaces = app.integrations.toggl.list_workspaces()
for _, ws in ipairs(workspaces) do
print(ws.id .. ": " .. ws.name)
end
toggl_list_projects
List projects in a Toggl workspace.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspace_id | string | yes | The workspace ID |
active | boolean | no | Filter for active projects only (default: true) |
Example
local projects = app.integrations.toggl.list_projects({
workspace_id = "123456"
})
for _, p in ipairs(projects) do
print(p.id .. ": " .. p.name)
end
toggl_get_project
Get details for a single Toggl project.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspace_id | string | yes | The workspace ID |
project_id | string | yes | The project ID |
Example
local project = app.integrations.toggl.get_project({
workspace_id = "123456",
project_id = "789012"
})
print(project.name .. " — " .. (project.active and "active" or "inactive"))
toggl_list_time_entries
List recent Toggl time entries.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
start_date | string | no | Start date filter (ISO 8601 date, e.g. "2026-01-01") |
end_date | string | no | End date filter (ISO 8601 date) |
Example
local entries = app.integrations.toggl.list_time_entries({
start_date = "2026-04-01",
end_date = "2026-04-05"
})
for _, e in ipairs(entries) do
print(e.description .. ": " .. e.start .. " → " .. (e.stop or "running"))
end
toggl_get_time_entry
Get details for a single Toggl time entry.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
time_entry_id | string | yes | The time entry ID |
Example
local entry = app.integrations.toggl.get_time_entry({
time_entry_id = "1234567890"
})
print(entry.description)
toggl_create_time_entry
Create a new time entry in a Toggl workspace.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
workspace_id | string | yes | The workspace ID |
description | string | no | Description of the time entry |
start | string | no | Start time (ISO 8601, e.g. "2026-04-05T09:00:00Z"). Defaults to now. |
stop | string | no | Stop time (ISO 8601). Omit for a running timer. |
duration | integer | no | Duration in seconds. Use -1 for a running timer (default: -1) |
project_id | string | no | Project ID to assign the time entry to |
tags | array | no | Tags for the time entry |
Example
local entry = app.integrations.toggl.create_time_entry({
workspace_id = "123456",
description = "Worked on API integration",
start = "2026-04-05T09:00:00Z",
stop = "2026-04-05T12:30:00Z",
project_id = "789012",
tags = { "development", "backend" }
})
print("Created entry: " .. entry.id)
Start a running timer
local entry = app.integrations.toggl.create_time_entry({
workspace_id = "123456",
description = "Meeting with team"
})
print("Timer started: " .. entry.id)
toggl_get_current_user
Get the authenticated Toggl user profile. Useful for verifying API token validity.
Parameters
None
Example
local user = app.integrations.toggl.get_current_user()
print(user.fullname .. " <" .. user.email .. ">")
Multi-Account Usage
If you have multiple Toggl accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.toggl.function_name({...})
-- Explicit default (portable across setups)
app.integrations.toggl.default.function_name({...})
-- Named accounts
app.integrations.toggl.work.function_name({...})
app.integrations.toggl.personal.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Toggl — Lua API Reference
## toggl_list_workspaces
List all Toggl workspaces the authenticated user belongs to.
### Parameters
_None_
### Example
```lua
local workspaces = app.integrations.toggl.list_workspaces()
for _, ws in ipairs(workspaces) do
print(ws.id .. ": " .. ws.name)
end
```
---
## toggl_list_projects
List projects in a Toggl workspace.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `workspace_id` | string | yes | The workspace ID |
| `active` | boolean | no | Filter for active projects only (default: `true`) |
### Example
```lua
local projects = app.integrations.toggl.list_projects({
workspace_id = "123456"
})
for _, p in ipairs(projects) do
print(p.id .. ": " .. p.name)
end
```
---
## toggl_get_project
Get details for a single Toggl project.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `workspace_id` | string | yes | The workspace ID |
| `project_id` | string | yes | The project ID |
### Example
```lua
local project = app.integrations.toggl.get_project({
workspace_id = "123456",
project_id = "789012"
})
print(project.name .. " — " .. (project.active and "active" or "inactive"))
```
---
## toggl_list_time_entries
List recent Toggl time entries.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `start_date` | string | no | Start date filter (ISO 8601 date, e.g. `"2026-01-01"`) |
| `end_date` | string | no | End date filter (ISO 8601 date) |
### Example
```lua
local entries = app.integrations.toggl.list_time_entries({
start_date = "2026-04-01",
end_date = "2026-04-05"
})
for _, e in ipairs(entries) do
print(e.description .. ": " .. e.start .. " → " .. (e.stop or "running"))
end
```
---
## toggl_get_time_entry
Get details for a single Toggl time entry.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `time_entry_id` | string | yes | The time entry ID |
### Example
```lua
local entry = app.integrations.toggl.get_time_entry({
time_entry_id = "1234567890"
})
print(entry.description)
```
---
## toggl_create_time_entry
Create a new time entry in a Toggl workspace.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `workspace_id` | string | yes | The workspace ID |
| `description` | string | no | Description of the time entry |
| `start` | string | no | Start time (ISO 8601, e.g. `"2026-04-05T09:00:00Z"`). Defaults to now. |
| `stop` | string | no | Stop time (ISO 8601). Omit for a running timer. |
| `duration` | integer | no | Duration in seconds. Use -1 for a running timer (default: -1) |
| `project_id` | string | no | Project ID to assign the time entry to |
| `tags` | array | no | Tags for the time entry |
### Example
```lua
local entry = app.integrations.toggl.create_time_entry({
workspace_id = "123456",
description = "Worked on API integration",
start = "2026-04-05T09:00:00Z",
stop = "2026-04-05T12:30:00Z",
project_id = "789012",
tags = { "development", "backend" }
})
print("Created entry: " .. entry.id)
```
### Start a running timer
```lua
local entry = app.integrations.toggl.create_time_entry({
workspace_id = "123456",
description = "Meeting with team"
})
print("Timer started: " .. entry.id)
```
---
## toggl_get_current_user
Get the authenticated Toggl user profile. Useful for verifying API token validity.
### Parameters
_None_
### Example
```lua
local user = app.integrations.toggl.get_current_user()
print(user.fullname .. " <" .. user.email .. ">")
```
---
## Multi-Account Usage
If you have multiple Toggl accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.toggl.function_name({...})
-- Explicit default (portable across setups)
app.integrations.toggl.default.function_name({...})
-- Named accounts
app.integrations.toggl.work.function_name({...})
app.integrations.toggl.personal.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.toggl.create_time_entry({workspace_id = "example_workspace_id", description = "example_description", start = "example_start", stop = "example_stop", duration = 1, project_id = "example_project_id", tags = "example_tags"})
print(result) Functions
create_time_entry Write
Create a new time entry in a Toggl workspace. Provide a description, start time, and optionally a project and stop time.
- Lua path
app.integrations.toggl.create_time_entry- Full name
toggl.toggl_create_time_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | string | yes | The workspace ID. |
description | string | no | Description of the time entry. |
start | string | no | Start time (ISO 8601, e.g. "2026-04-05T09:00:00Z"). Defaults to now. |
stop | string | no | Stop time (ISO 8601). Omit for a running timer. |
duration | integer | no | Duration in seconds. Use -1 for a running timer (default: -1). |
project_id | string | no | Project ID to assign the time entry to. |
tags | array | no | Tags for the time entry. |
get_current_user Read
Get the authenticated Toggl user profile. Use this to verify your API token is working.
- Lua path
app.integrations.toggl.get_current_user- Full name
toggl.toggl_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_project Read
Get details for a single Toggl project by ID.
- Lua path
app.integrations.toggl.get_project- Full name
toggl.toggl_get_project
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | string | yes | The workspace ID. |
project_id | string | yes | The project ID. |
get_time_entry Read
Get details for a single Toggl time entry by ID.
- Lua path
app.integrations.toggl.get_time_entry- Full name
toggl.toggl_get_time_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
time_entry_id | string | yes | The time entry ID. |
list_projects Read
List projects in a Toggl workspace. Optionally filter for active projects only.
- Lua path
app.integrations.toggl.list_projects- Full name
toggl.toggl_list_projects
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | string | yes | The workspace ID. |
active | boolean | no | Filter for active projects only (default: true). |
list_time_entries Read
List recent Toggl time entries. Optionally filter by date range.
- Lua path
app.integrations.toggl.list_time_entries- Full name
toggl.toggl_list_time_entries
| Parameter | Type | Required | Description |
|---|---|---|---|
start_date | string | no | Start date filter (ISO 8601 date, e.g. "2026-01-01"). |
end_date | string | no | End date filter (ISO 8601 date). |
list_workspaces Read
List all Toggl workspaces the authenticated user belongs to. Returns workspace IDs and names needed for other Toggl tools.
- Lua path
app.integrations.toggl.list_workspaces- Full name
toggl.toggl_list_workspaces
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_project Write
Create a new project in a Toggl Track workspace.
- Lua path
app.integrations.toggl.create_project- Full name
toggl.toggl_create_project
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | integer | yes | The workspace ID. |
name | string | yes | Project name (e.g., "Website Redesign"). |
color | string | no | Project color as a hex code (e.g., "#0b83d9"). |
billable | boolean | no | Whether the project is billable. Defaults to false. |
is_private | boolean | no | Whether the project is private. Defaults to false. |
active | boolean | no | Whether the project is active. Defaults to true. |
estimated_hours | number | no | Estimated hours for the project. |
client_id | integer | no | Client ID to associate with the project. |
update_time_entry Write
Update an existing time entry in Toggl Track. Use this to edit description, times, project, tags, or billable status.
- Lua path
app.integrations.toggl.update_time_entry- Full name
toggl.toggl_update_time_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | integer | yes | The workspace ID. |
time_entry_id | integer | yes | The time entry ID to update. |
description | string | no | Updated description. |
start | string | no | Updated start time in ISO 8601 format. |
stop | string | no | Updated stop time in ISO 8601 format. |
duration | integer | no | Updated duration in seconds. |
project_id | integer | no | Updated project ID. |
task_id | integer | no | Updated task ID. |
tags | array | no | Updated array of tag names. |
tag_ids | array | no | Updated array of tag IDs. |
billable | boolean | no | Updated billable status. |
delete_time_entry Write
Delete a time entry from Toggl Track. This action is permanent and cannot be undone.
- Lua path
app.integrations.toggl.delete_time_entry- Full name
toggl.toggl_delete_time_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace_id | integer | yes | The workspace ID. |
time_entry_id | integer | yes | The time entry ID to delete. |