How to grant badges using Automation?

Oh wow, I didn’t know about that. Thanks for the tip @JammyDodger!

I guess it would also be possible to get the result of an SQL query from the Data Explorer plugin, then use the api to grant the badge.