KosmoKrator

productivity

Toggl Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write API token auth

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.

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

NameTypeRequiredDescription
workspace_idstringyesThe workspace ID
activebooleannoFilter 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

NameTypeRequiredDescription
workspace_idstringyesThe workspace ID
project_idstringyesThe 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

NameTypeRequiredDescription
start_datestringnoStart date filter (ISO 8601 date, e.g. "2026-01-01")
end_datestringnoEnd 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

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

NameTypeRequiredDescription
workspace_idstringyesThe workspace ID
descriptionstringnoDescription of the time entry
startstringnoStart time (ISO 8601, e.g. "2026-04-05T09:00:00Z"). Defaults to now.
stopstringnoStop time (ISO 8601). Omit for a running timer.
durationintegernoDuration in seconds. Use -1 for a running timer (default: -1)
project_idstringnoProject ID to assign the time entry to
tagsarraynoTags 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.

Metadata-Derived Lua Example

local result = app.integrations.toggl.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

toggl_create_time_entry

Create a new time entry in a Toggl workspace. Provide a description, start time, and optionally a project and stop time.

Operation
Write write
Full name
toggl.toggl_create_time_entry
ParameterTypeRequiredDescription
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.

toggl_get_current_user

Get the authenticated Toggl user profile. Use this to verify your API token is working.

Operation
Read read
Full name
toggl.toggl_get_current_user
ParameterTypeRequiredDescription
No parameters.

toggl_get_project

Get details for a single Toggl project by ID.

Operation
Read read
Full name
toggl.toggl_get_project
ParameterTypeRequiredDescription
workspace_id string yes The workspace ID.
project_id string yes The project ID.

toggl_get_time_entry

Get details for a single Toggl time entry by ID.

Operation
Read read
Full name
toggl.toggl_get_time_entry
ParameterTypeRequiredDescription
time_entry_id string yes The time entry ID.

toggl_list_projects

List projects in a Toggl workspace. Optionally filter for active projects only.

Operation
Read read
Full name
toggl.toggl_list_projects
ParameterTypeRequiredDescription
workspace_id string yes The workspace ID.
active boolean no Filter for active projects only (default: true).

toggl_list_time_entries

List recent Toggl time entries. Optionally filter by date range.

Operation
Read read
Full name
toggl.toggl_list_time_entries
ParameterTypeRequiredDescription
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).

toggl_list_workspaces

List all Toggl workspaces the authenticated user belongs to. Returns workspace IDs and names needed for other Toggl tools.

Operation
Read read
Full name
toggl.toggl_list_workspaces
ParameterTypeRequiredDescription
No parameters.