| name | trello-api-7-webhooks |
| description | Sub-skill of trello-api: 7. Webhooks. |
| version | 1.0.0 |
| category | business |
| type | reference |
| scripts_exempt | true |
7. Webhooks
7. Webhooks
REST API - Webhooks:
curl -s -X POST "https://api.trello.com/1/webhooks" \
-d "key=$TRELLO_API_KEY" \
-d "token=$TRELLO_TOKEN" \
-d "callbackURL=https://your-server.com/webhook/trello" \
-d "idModel=BOARD_ID" \
-d "description=Board events webhook" | jq
curl -s "https://api.trello.com/1/tokens/$TRELLO_TOKEN/webhooks?key=$TRELLO_API_KEY" | jq
curl -s "https://api.trello.com/1/webhooks/WEBHOOK_ID?key=$TRELLO_API_KEY&token=$TRELLO_TOKEN" | jq
curl -s -X PUT "https://api.trello.com/1/webhooks/WEBHOOK_ID" \
-d "key=$TRELLO_API_KEY" \
-d "token=$TRELLO_TOKEN" \
-d "callbackURL=https://new-server.com/webhook/trello" | jq
curl -s -X DELETE "https://api.trello.com/1/webhooks/WEBHOOK_ID?key=$TRELLO_API_KEY&token=$TRELLO_TOKEN"
Webhook Handler Example:
from flask import Flask, request, jsonify
import json
app = Flask(__name__)
@app.route("/webhook/trello", methods=["HEAD", "POST"])
def trello_webhook():
if request.method == "HEAD":
return "", 200
data = request.json
action = data.get("action", {})
action_type = action.get("type")
print(f"Received Trello webhook: {action_type}")
if action_type == "createCard":
handle_card_created(action)
elif action_type == "updateCard":
handle_card_updated(action)
elif action_type == "moveCardToBoard":
handle_card_moved(action)
elif action_type == "addMemberToCard":
handle_member_assigned(action)
elif action_type == "commentCard":
handle_comment_added(action)
elif action_type == "updateCheckItemStateOnCard":
handle_checklist_item_updated(action)
return jsonify({"status": "ok"})
def handle_card_created(action):
card_data = action.get("data", {}).get("card", {})
print()
():
card_data = action.get(, {}).get(, {})
old_data = action.get(, {}).get(, {})
()
old_data:
list_after = action.get(, {}).get(, {})
list_before = action.get(, {}).get(, {})
()
():
card_data = action.get(, {}).get(, {})
()
():
card_data = action.get(, {}).get(, {})
member_data = action.get(, {}).get(, {})
()
():
card_data = action.get(, {}).get(, {})
text = action.get(, {}).get(, )
()
():
card_data = action.get(, {}).get(, {})
item = action.get(, {}).get(, {})
state = item.get()
()
__name__ == :
app.run(port=)
Webhook Events:
WEBHOOK_ACTIONS = {
"updateBoard": "Board settings changed",
"addMemberToBoard": "Member added to board",
"removeMemberFromBoard": "Member removed from board",
"createList": "List created",
"updateList": "List updated (renamed, moved, archived)",
"moveListToBoard": "List moved to different board",
"createCard": "Card created",
"updateCard": "Card updated (name, desc, due date, position, list)",
"deleteCard": "Card deleted",
"moveCardToBoard": "Card moved to different board",
"copyCard": "Card copied",
"convertToCardFromCheckItem": "Checklist item converted to card",
"addMemberToCard": "Member assigned to card",
"removeMemberFromCard": "Member removed from card",
"addLabelToCard": "Label added to card",
"removeLabelFromCard": "Label removed from card",
"addAttachmentToCard": "Attachment added",
"deleteAttachmentFromCard": "Attachment deleted",
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
}