Making a Trello trash can with RequestHub

In the last post we used RequestHub to route form posts to API calls that created cards on Trello. Now we are going to do something similar, but reversed: delete cards on Trello in reaction to Trello webhooks.

Trello makes it very difficult to delete cards. You must do a lot of clicks, that's a safety measure, it seems. At the same time, however, if you, like me, have multiple BoardThreads addresses shown in public landing pages, it means you'll get customer emails inside your Trello board, but also spam (yes, spam exists for all non-Gmail users and is a problem without a solution). Spam in the form of a Trello card is not a pleasant thing to deal with.

Up until today I've been using lists named "Spam" and just putting the spam cards in them. Later I would archive all the cards (archiving spam!) or, more recently, delete them in batch. But none of these solutions is great. Here's a better one: every time I move a card to the list named "Spam" it will be automatically deleted.


To start, you'll need a RequestHub account, which you can do in 2 minutes. I presume you already have a Trello account.

Also, you'll need a Trello API key and token valid for your own user. You can get these here. If you want more detailed instructions, see this section of the previous post.

The RequestHub endpoint

Go to https://requesthub.xyz and create a new endpoint. Describe it as delete cards from lists named "Spam" on Trello or anything you like. For Method, choose DELETE. In the URL field, write

if (.action.data.listAfter.name == "spam") then "https://api.trello.com/1/cards/\(.action.data.card.id)?key=<your-trello-api-key>&token=<your-trello-api-token>" else "" end

All the other fields you can leave unmodified, even Modifier can be blank.

That is because Trello DELETE endpoints do not accept any body, but we will get data from the webhook Trello dispatches when a card is being moved and use it to build an URL when appropriate (a "" URL in RequestHub is the same of not calling any endpoint).

Setting the Trello webhook

Now you'll probably need a terminal or some REST client, but first visit the URL https://api.trello.com/1/boards/<your-board-shortlink>/lists?key=<your-trello-api-key>&token=<your-trello-api-token> in your browser and find the id of the list you want to use as your bucket (in my case described here, the list is called "spam").

Now, in your terminal or REST client, do a PUT HTTP request to https://api.trello.com/1/webhooks?key=<your-trello-api-key>&token=<your-trello-api-token> with the body

  "idModel": "<your-list-id>",
  "description": "requesthub to delete things",
  "callbackURL": "https://requesthub.xyz/w/<your-requesthub-endpoint-identifier>"

Add the header Content-Type: application/json. It is important.