changelog

Use subscriber emails as a PK!

May 19, 2023

(NERD ALERT: If you don't use the API, this post is not for you.)

If you do use the API, you might have run into a small frustration which is this:

You're trying to sync some existing corpus of subscribers (say, your userbase) with Buttondown's list. So every time someone registers an account, they become a Buttondown subscriber.

This is easy: you just make a POST request to /v1/subscribers with their email address and you're done.

But what if you want to then change something about them? Let's say you want to add a tag to them (to reflect the fact that they're a churn risk) or you want to delete them (because they've deleted their account.)

You can't do that, because you don't know their subscriber ID. You'd have to either store that subscriber ID in your database (not the end of the world, but kind of annoying) or search for them with /v1/subscribers?email=foo@bar.com and then grab their ID (again, not the end of the world, but kind of annoying.)

Now there is a better way!

Just use their email address as a PK. You can call, e.g. DELETE /v1/subscribers/justin@buttondown.email and it will Just Work.

This doesn't let you do anything you couldn't already do, but it should make integration, like, 10% easier. And that adds up.

Updated on

May 19, 2023

Written by

Justin Duke

Justin Duke is a software engineer, lover of words, and the creator of Buttondown.

No credit card required. Only pay for what you use. Cancel anytime.