Guy
Guy

Reputation: 13336

Finding out existing Webhooks IDs on Trello

I've added webhooks using Trello's API (Node JS package). How do I get the current webhooks or how do I get an existing webhook ID?

Could'nt find a way through the API: https://developers.trello.com/advanced-reference/webhook

Here it says that:

There are three ways to delete webhooks.

  1. Using the DELETE route on webhooks DELETE https://api.trello.com/1/webhooks/[WEBHOOK_ID]?key=[APPLICATION_KEY]&token=[USER_TOKEN]
  2. If the webhook request from Trello, when POSTing to the callbackURL, receives an HTTP 410 Gone response, the webhook will be deleted.
  3. If the token that the webhook is bound to is revoked or expires, then the webhook will be deleted

First method required the ID, second method requires me to take down the server everytime I want to erase a webhook and third is not better. Any idea how to get the IDs?

Upvotes: 5

Views: 3702

Answers (3)

javmah
javmah

Reputation: 157

I tried all the answers, but none of them worked. Then I found this endpoint: https://api.trello.com/1/tokens/{{userToken}}/webhooks?key={{appKey}}. It’s working fine, and it returns all the Trello webhooks. The data looks like the following:

[
    {
        "id": "*****427fb4***dsucd475*****",
        "description": "my test webhook",
        "idModel": "*****8df4sdy9u5gd6886f20c*****",
        "callbackURL": "https://******sum.ngrok-free.app/trello-webhook",
        "active": true,
        "consecutiveFailures": 0,
        "firstConsecutiveFailDate": null
    }
]

Upvotes: 2

Benjamin Root
Benjamin Root

Reputation: 151

Here is the API request to get all of the webhooks that have been created by the application:

GET https://api.trello.com/1/members/me/tokens?webhooks=true&key=[APPLICATION_KEY]&token=[USER_TOKEN]

Relevant Section of the Trello API Documentation /1/members/[id]/tokens listed below:

GET /1/members/[idMember or username]/tokenslink Required permissions: read, own, account

Arguments

  • filter (optional)
    • Default: all
    • Valid Values: One of: all, none
  • webhooks (optional)
    • Default: false
    • Valid Values: One of: true, false

Also, note that me is used as the idMember or Username

Note: If you specify me as the username, this call will respond as if you had supplied the username associated with the supplied token

See Trello API documentation /1/members/me

Here is a sample JSON response I get:

{
"id": "568d40cc3aa021f1b3602ea0",
"identifier": "Server Token",
"idMember": "562d50bc3aa020f1b3602ec0",
"dateCreated": "2016-05-30T22:01:15.721Z",
"dateExpires": null,
"permissions": [
  {
    "idModel": "562d50bc3aa071f1b3602ec6",
    "modelType": "Member",
    "read": true,
    "write": true
  },
  {
    "idModel": "*",
    "modelType": "Board",
    "read": true,
    "write": true
  },
  {
    "idModel": "*",
    "modelType": "Organization",
    "read": true,
    "write": true
  }
],
"webhooks": [
  {
    "id": "5675a0a8159fbeef4b796da3",
    "description": "Feature Requests Board",
    "idModel": "55a1176a0b620663da985753",
    "callbackURL": "http://example.com/trello/webhook-callback?type=features",
    "active": true
  },
  {
    "id": "5673a0ac6ab60af7ec3a706b",
    "description": "Bugs Board",
    "idModel": "541ebcf34c03910922ff0fc3",
    "callbackURL": "http://example.com/trello/webhook-callback?type=bugs",
    "active": true
  }
}

Upvotes: 13

Casey Benko
Casey Benko

Reputation: 2308

You can see a list of webhooks by using the token resource.

See here: https://developers.trello.com/advanced-reference/token#get-1-tokens-token-webhooks

GET /1/tokens/[token]/webhooks

[token] equals [USER_TOKEN] if you created the webhook with the same token.

Upvotes: 2

Related Questions