What are the possible kinds of webhooks Trello can

2020-07-27 04:14发布

问题:

I'm developing an app that is tightly integrated with Trello and uses Trello webhooks for a lot of things. However, I can't find anywhere in Trello's developer documentation what are the "actions" that may trigger a webhook and what data will come in each of these.

In fact, in my experience, the data that comes with each webhook is kinda random. For example, while most webhooks contain the shortLink of the card which is being the target of some action, some do not, in a totally unpredictable way. Also, creating cards from checklists doesn't seem to trigger the same webhook that is triggered when a card is created normally, and so on.

So, is that documented somewhere?

回答1:

After fighting against these issues and my raw memory of what data should come in each webhook, along with the name of each different action, I decided to document this myself and released it as a (constantly updating as I find new webhooks out there) set of JSON files showing samples of the data each webhook will send to your endpoint:

https://github.com/fiatjaf/trello-webhooks

For example, when a board is closed, a webhook will be sent with

{
  "id": "55d7232fc3597726f3e13ddf",
  "idMemberCreator": "50e853a3a98492ed05002257",
  "data": {
    "old": {
      "closed": false
    },
    "board": {
      "shortLink": "V50D5SXr",
      "id": "55af0b659f5c12edf972ac2e",
      "closed": true,
      "name": "Communal Website"
    }
  },
  "type": "updateBoard",
  "date": "2015-08-21T13:10:07.216Z",
  "memberCreator": {
    "username": "fiatjaf",
    "fullName": "fiatjaf",
    "avatarHash": "d2f9f8c8995019e2d3fda00f45d939b8",
    "id": "50e853a3a98492ed05002257",
    "initials": "F"
  }
}

In fact, what comes is a JSON object like {"model": ..., "action": ... the data you see up there...}, but I've removed these for the sake o brevity and I'm showing only what comes inside the "action" key.



回答2:

based on @flatjaf's repo, I gathered and summarized all* the webhooks types.

addAttachmentToCard
addChecklistToCard
addLabelToCard
addMemberToBoard
addMemberToCard
commentCard
convertToCardFromCheckItem
copyCard
createCard
createCheckItem
createLabel
createList
deleteAttachmentFromCard
deleteCard
deleteCheckItem
deleteComment
deleteLabel
emailCard
moveCardFromBoard
moveCardToBoard
moveListFromBoard
moveListToBoard
removeChecklistFromCard
removeLabelFromCard
removeMemberFromBoard
removeMemberFromCard
updateBoard
updateCard
updateCheckItem
updateCheckItemStateOnCard
updateChecklist
updateComment
updateLabel
updateList

hope it helps!

*I don't know if that list includes all the available webhooks types because as i already said, it's based on flatjaf's repo created 2 years ago