toggl / toggl_api_docs

Documentation for the Toggl API
1.4k stars 235 forks source link

Unable to get Toggl Webhooks to fire for Time Entries #446

Closed chrisaligent closed 2 years ago

chrisaligent commented 2 years ago

Background

I'm not a Toggl Track Workspace admin, however the Documentation does not make any reference to needing special privileges to setup Webhooks. Only that if I'm not an admin, I won't be notified for changes made by other users (which is fine right now).

Goal

  1. I start my Toggl Track timer
  2. I add a summary
  3. I stop my timer
  4. My webhook receives an Event from Toggl notifying me that a Time Entry (time_entry) has been created

Replication Steps

  1. I setup a test endpoint on https://webhook.site/
  2. I use the Toggl API to create a new Subscription with my own API token, I have confirmed that I am passing the correct Workspace ID.
  3. The API responds with an HTTP 200 OK, a Subscription ID, and validated_at is `null
  4. The test endpoint receives a POST from Toggl containing the Verification info
  5. I manually verify by clicking the link, which responds "OK"
  6. I perform an HTTP GET request to list the Workspace Webhooks via the API
  7. I can see my Webhook now shows a validated_at timestamp
  8. I perform a PING request and this comes through to my Webhook successfully
  9. I record a new Toggl Track Time Entry
  10. Nothing happens
  11. I use the API to list the Events for my Subscription and it returns 0

Payload

This was the payload I submitted to create my Subscription: URL: https://api.track.toggl.com/webhooks/api/v1/subscriptions/<my-workspace-id> METHOD: POST

{
    "url_callback": "https://webhook.site/<my-unique-url>",
    "event_filters": [
        {"entity": "*", "action": "*"}
    ],
    "enabled": true,
    "description": "My first Webhooks subscription",
    "secret": "abc123"
}

Response

{
    "subscription_id": "<subscription-id>",
    "workspace_id": "<my-workspace-id>",
    "user_id": "<my-toggl-id>",
    "enabled": true,
    "description": "My first Webhooks subscription",
    "event_filters": [
        {
            "entity": "*",
            "action": "*"
        }
    ],
    "url_callback": "https://webhook.site/<my-unique-url>",
    "secret": "abc123",
    "validated_at": null,
    "has_pending_events": false,
    "created_at": "2022-06-23T05:57:13.954578Z"
}

Webhook Verification Response

This is what was posted to my Webhook:

{
  "event_id": 0,
  "created_at": "2022-06-23T05:57:13.957676008Z",
  "creator_id": "<my-user-id>",
  "metadata": {
    "request_type": "POST",
    "event_user_id": "<my-user-id>"
  },
  "payload": "ping",
  "subscription_id": "<my-subscription-id>",
  "validation_code": "<validation-code>",
  "validation_code_url": "https://track.toggl.com/webhooks/api/v1/validate/<my-workspace-id>/<my-subscription-id>/<validation-code>"
}

List Subscriptions

(After validating) URL: https://api.track.toggl.com/webhooks/api/v1/subscriptions/<my-workspace-id> METHOD: GET Result:

[
    {
        "subscription_id": "<my-subscription-id>",
        "workspace_id": "<my-workspace-id>",
        "user_id": "<my-user-id>",
        "enabled": true,
        "description": "My first Webhooks subscription",
        "event_filters": [
            {
                "entity": "*",
                "action": "*"
            }
        ],
        "url_callback": "https://webhook.site/<my-unique-id>",
        "secret": "abc123",
        "validated_at": "2022-06-23T06:00:34.683238Z",
        "has_pending_events": false,
        "created_at": "2022-06-23T05:57:13.954578Z",
        "updated_at": "2022-06-23T06:00:34.686434Z"
    }
]

So everything appears to be working as far as getting this setup, but no events are fired as I start/stop/create/update/delete Time Entries in Toggl Track. I have waited 30+ minutes but nothing comes through.

Am I missing something obvious or does this not work at all? Or am I required to be a Workspace Administrator to receive Events, even though I'm still able to create the Subscriptions?

Thanks

joeriharleman commented 2 years ago

Hi Chris!

Thank you for writing about your issue so extensively. Unfortunately this repository is unmaintained and unwatched and I would hate to see your effort go to waste, so please submit your questions to our 24/5 dedicated support team here -> you can chat with them fairly directly using the chat icon in the bottom right corner.

Regards, Joeri