Don't just write your newsletter. Program it.

Buttondown has a pleasant REST API to let you supercharge your newsletter.

Buttondown is a tool that's unabashedly proud of being technical — without demanding a technical user.

Part of being technical means having a great, ergonomic API.

Now, you shouldn't have to use the API. The interface and integrations like Zapier should get the job done for the vast majority of use cases.

But if you've got a special connection you have in mind (like wanting to programmatically build and deliver emails for your SaaS, or to integrate with your own analytics stack) — or, hell, because you're just a nerd and prefer sending your newsletter from the comfort of emacs rather than Chrome or Safari, Buttondown is the tool for you.

Buttondown makes it as easy as possible to tailor your newsletter to your specific needs, with endpoints for the following resources:

  1. Subscribers, so you can programmatically pull, update, or create subscribers
  2. Emails, so you can send emails without ever having to log into the interface
  3. Newsletters, so you can programmatically build newsletters for your customers and users without having to fiddle around with any of the internals yourself
  4. plus drafts, scheduled emails, and a couple other more esoteric use cases.

Some of examples of what you can do with just a few lines of code:

Generate and pull subscribers

python
ruby
typescript
Copy to clipboard
1import requests
2
3headers = {
4 "Authorization": f"Token {BUTTONDOWN_API_KEY}"
5}
6BASE_URL = "https://api.buttondown.email"
7ENDPOINT = "/v1/subscribers"
8
9# Pull your subscribers to sync them with your database!
10
11requests.get(BASE_URL + ENDPOINT, headers=headers).json()

Want to sync your subscribers with Buttondown's database or run your own custom analyses, or to sync with your app's database? That takes five lines of Python.

Programmatically generate emails

python
ruby
typescript
Copy to clipboard
1import requests
2import json
3
4headers = {
5 "Authorization": f"Token {BUTTONDOWN_API_KEY}"
6}
7base_url = "https://api.buttondown.email"
8endpoint = "/v1/emails"
9data = {
10 "subject": "We've published a new dataset!",
11 "body": "...",
12 "status": "draft" # Remove to send a live email
13
14requests.post(
15 base_url + endpoint,
16 headers=headers,
17 data=json.dumps(data)
18).json()

What if you wanted to create new emails and send them (or schedule them) every day, or in response to certain events? Write nine lines of Python.

Build an ecosystem

python
ruby
typescript
Copy to clipboard
1import requests
2import json
3
4headers = {
5 "Authorization": f"Token {BUTTONDOWN_API_KEY}"
6}
7base_url = "https://api.buttondown.email"
8endpoint = "/v1/newsletters"
9data = {
10 "username": "amandagreen02",
11 "name": "Amanda Green",
12 "description": "Newsletter for updates from Amanda's Ghost blog"
13}
14
15requests.post(
16 base_url + endpoint,
17 headers=headers,
18 data=json.dumps(data)
19).json()

If you're building a service like a job board or a changelog, you might want to be able to manage and operate newsletters for each user on your service. That is a whopping eleven lines of Python.

Kind words from happy writers

The whole process was really smooth and I got the APIs hooked up for subscribing as well as viewing subscriber counts on my dashboard.

Lee Robinson
Head of DevRel, Vercel

I must say that using Buttondown has been a joy. Such a nice email newsletter service with a super easy API.

Kevin Lewis
You Got This

Ready for a better newsletter?

See why thousands of businesses and creators use Buttondown to send millions of emails every day.

Best practices, news, and more. Every month.

See why thousands of businesses and creators use Buttondown to send millions of emails every day.

Have a question? We’re here to help.

We're email experts who are always available to answer your questions.