-
Notifications
You must be signed in to change notification settings - Fork 1
fix(toggl): use ActionResult/ActionError, add cost_usd, upgrade SDK to 1.1.1 #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Shubhank-Jonnada
wants to merge
4
commits into
master
Choose a base branch
from
fix/toggl-action-error-sdk-upgrade-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
15b3343
fix(toggl): use ActionResult/ActionError, add cost_usd, upgrade SDK t…
Shubhank-Jonnada c9ee82c
fix(toggl): bump version to 0.1.1
Shubhank-Jonnada 0ffb6a8
fix(toggl): return ActionError on non-2xx fetch responses
Shubhank-Jonnada f8ec086
fix(toggl): upgrade SDK to 2.0.0 to fix dict has no attribute status …
Shubhank-Jonnada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,86 @@ | ||
| # Toggl Track Integration for Autohive | ||
|
|
||
| Creates time entries in Toggl Track using the official API. | ||
| Creates time entries in Toggl Track using the official v9 API. Ideal for automating time tracking workflows, logging billable hours, and syncing work sessions into Toggl from external systems. | ||
|
|
||
| ## Key Features | ||
|
|
||
| - Create time entries in any Toggl workspace | ||
| - Supports start/stop times, duration, project and task assignment | ||
| - Billable flag and tag support (by name or ID) | ||
| - API token authentication via HTTP Basic Auth | ||
|
|
||
| ## Setup & Authentication | ||
|
|
||
| - Auth type: API token via HTTP Basic Auth. | ||
| - Field required in connection: | ||
| - `api_token` (password): Find it at https://track.toggl.com/profile | ||
| **Auth type:** Custom (API token) | ||
|
|
||
| **Required field:** | ||
| - `api_token` — Your Toggl API token. Find it at https://track.toggl.com/profile under "Profile settings" → "API Token". | ||
|
|
||
| The integration uses HTTP Basic Auth with `api_token` as both the username and the literal string `api_token` as the password, as required by Toggl's API. | ||
|
|
||
| ## Actions | ||
|
|
||
| The request uses Basic auth with username = your API token and password = `api_token`. | ||
| #### create_time_entry | ||
|
|
||
| ## Action: create_time_entry | ||
| Creates a new time entry in the specified Toggl workspace. | ||
|
|
||
| Creates a time entry in a workspace. | ||
| **Inputs:** | ||
|
|
||
| Inputs: | ||
| - `workspace_id` (integer, required) | ||
| - `start` (string, required) — UTC time, e.g. `2006-01-02T15:04:05Z` | ||
| - `stop` (string, optional) | ||
| - `duration` (integer, optional) — in seconds; for running entries use `-1` | ||
| - `description` (string, optional) | ||
| - `project_id` (integer, optional) | ||
| - `task_id` (integer, optional) | ||
| - `billable` (boolean, optional) | ||
| - `tags` (array[string], optional) | ||
| - `tag_ids` (array[integer], optional) | ||
| - `user_id` (integer, optional) | ||
| | Parameter | Type | Required | Description | | ||
| |-----------|------|----------|-------------| | ||
| | `workspace_id` | integer | ✅ | Numeric Toggl workspace ID | | ||
| | `start` | string | ✅ | Start time in UTC, format `2006-01-02T15:04:05Z` | | ||
| | `stop` | string | optional | Stop time in UTC; omit if the entry is still running or using `duration` | | ||
| | `duration` | integer | optional | Duration in seconds. Use `-1` for a running (in-progress) entry | | ||
| | `description` | string | optional | Human-readable label for the time entry | | ||
| | `project_id` | integer | optional | ID of the project to assign the entry to | | ||
| | `task_id` | integer | optional | ID of the task within the project | | ||
| | `billable` | boolean | optional | Whether the entry is billable (default: `false`) | | ||
| | `tags` | array[string] | optional | Tag names to apply to the entry | | ||
| | `tag_ids` | array[integer] | optional | Tag IDs to apply to the entry | | ||
| | `user_id` | integer | optional | ID of the user creating the entry; defaults to the authenticated user | | ||
|
|
||
| Notes: | ||
| - The integration automatically sets `created_with` to `autohive-integrations` as required by Toggl. | ||
| - Provide either `stop` or `duration` unless you're creating a running entry with `duration = -1`. | ||
| **Notes:** | ||
| - Provide either `stop` or `duration` (not both) unless creating a running entry with `duration = -1`. | ||
| - The integration automatically sets `created_with: autohive-integrations` as required by Toggl. | ||
|
|
||
| **Outputs:** | ||
|
|
||
| The response mirrors the Toggl API time entry object, including fields such as `id`, `workspace_id`, `project_id`, `start`, `stop`, `duration`, `description`, `billable`, `tags`, and `at` (last updated timestamp). | ||
|
|
||
| ## Requirements | ||
|
|
||
| - `autohive_integrations_sdk` | ||
|
|
||
| ## Example | ||
|
|
||
| ```json | ||
| { | ||
| "workspace_id": 1234567, | ||
| "start": "2025-08-14T10:00:00Z", | ||
| "stop": "2025-08-14T11:00:00Z", | ||
| "description": "Planning meeting", | ||
| "project_id": 7654321, | ||
| "billable": true, | ||
| "tags": ["meeting", "planning"] | ||
| } | ||
| ``` | ||
| - `autohive-integrations-sdk~=2.0.0` | ||
|
|
||
| ## API Info | ||
|
|
||
| - **Base URL:** `https://api.track.toggl.com/api/v9` | ||
| - **Official docs:** https://developers.track.toggl.com/docs/ | ||
| - **API version:** v9 | ||
|
|
||
| ## Rate Limiting | ||
|
|
||
| Toggl's API enforces per-user rate limits. Standard limits allow up to 1 request per second. Exceeding this returns HTTP 429. No automatic retry is built into this integration. | ||
|
|
||
| ## Error Handling | ||
|
|
||
| | Error | Cause | | ||
| |-------|-------| | ||
| | `Missing API token` | `api_token` field not present in auth credentials | | ||
| | HTTP 403 | Invalid or expired API token | | ||
| | HTTP 400 | Missing required fields or malformed body (e.g. `workspace_id` mismatch) | | ||
| | HTTP 429 | Rate limit exceeded | | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| - **403 Forbidden:** Double-check your API token at https://track.toggl.com/profile. Tokens can be regenerated there. | ||
| - **400 Bad Request:** Ensure `workspace_id` matches the workspace the project/task belong to. Toggl rejects mismatches. | ||
| - **Entry not appearing:** Confirm `start` is in UTC ISO 8601 format (`2006-01-02T15:04:05Z`). Local timezone offsets cause silent failures. | ||
| - **Running entry not stopping:** For running entries use `duration: -1` and omit `stop`. To stop it later, use the Toggl UI or a separate API call. | ||
| - **Tags not applying:** Tag names are case-sensitive and must already exist in the workspace. Use `tag_ids` for reliability. | ||
|
|
||
| ## Version History | ||
|
|
||
| | Version | Notes | | ||
| |---------|-------| | ||
| | v1.0.0 | Initial release — `create_time_entry` action with full Toggl v9 API support | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| autohive-integrations-sdk~=1.0.2 | ||
| autohive-integrations-sdk~=2.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.