Buttondown Documentation
The Buttondown CLI (Command Line Interface) is a powerful tool that lets you manage your newsletter content from your local machine. It enables workflows like editing newsletters in your preferred text editor, backing up your content, and syncing media files.
Install the CLI globally using npm:
Or use it with npx without installing:
The CLI provides several capabilities:
Before using the CLI, you need to authenticate with your Buttondown API key:
You'll be prompted to enter your API key, which you can find in your Buttondown settings.
To download your newsletters from Buttondown:
This creates a ./buttondown
directory with all your content.
Create a new draft:
Then edit the created Markdown file with your preferred editor.
When you're ready to save your changes back to Buttondown:
Important: buttondown push
doesn't publish emails with the status: draft
field, which is the default status for new emails. See the Publishing Behavior section below for details on how to actually send your emails.
When you run buttondown push
, it syncs your content to Buttondown maintaining the status in the frontmatter. Here's how publishing works:
The status
field in your email's frontmatter determines what happens:
Status | Description |
---|---|
draft | Email remains a draft when pushed |
scheduled | Email will be sent at the specified publish_date |
about_to_send | Email is queued and will be sent very soon (typically within a few minutes) |
sent | Email has already been sent -- editing these will change their body in the archives |
More information on statuses is available in the API reference.
The CLI creates this structure in your local folder:
Each newsletter is stored as a Markdown file with YAML frontmatter:
When creating emails via the CLI, only one field is truly required:
Field | Type | Description | Required When |
---|---|---|---|
subject | string | The email subject line | Always required for API creation |
title | string | Used by CLI create command (becomes subject ) | Required for buttondown create command |
All other fields are optional and have sensible defaults:
Field | Type | Default | Description |
---|---|---|---|
body | string | "" | Email content (HTML or Markdown) |
status | string | "about_to_send" | Email status |
email_type | string | "public" | Email visibility type |
slug | string | null | URL-friendly identifier |
description | string | "" | Human-readable description |
image | string | "" | Primary image URL |
publish_date | datetime | null | Scheduled publish date |
attachments | array<UUID> | [] | List of attachment IDs |
metadata | object | {} | Custom metadata fields |
canonical_url | string | "" | Original content URL |
secondary_id | integer | null | Informal issue number |
filters | object | FilterGroup() | Subscriber filtering rules |
commenting_mode | string | "enabled" | Comment settings |
related_email_ids | array<string> | [] | Related email IDs |
featured | boolean | false | Archive highlighting |
Value | Description |
---|---|
public | Visible to all subscribers and in archives |
private | Only visible to subscribers |
premium | Only visible to paid subscribers |
free | Only visible to free subscribers |
churned | Only visible to churned subscribers |
archival | For imported/archived content |
Value | Description |
---|---|
draft | Email is being composed |
about_to_send | Email is ready to send |
scheduled | Email is scheduled for future |
in_flight | Email is currently sending |
sent | Email has been sent |
paused | Sending was paused |
imported | Email was imported from external source |
validate_slug
)media/
directorybuttondown push
, the CLI uploads the images and updates the URLsConsider adding this to a scheduled task for regular backups.
You can work with different newsletters using different directories:
Create a script like publish.sh
:
Make it executable with chmod +x publish.sh
Command | Description |
---|---|
buttondown login | Authenticate with Buttondown |
buttondown logout | Clear stored credentials |
buttondown pull | Download content from Buttondown |
buttondown push | Upload content to Buttondown |
buttondown create | Create a new draft email locally |
If you encounter authentication errors:
If you've modified the same email both locally and on Buttondown:
cp -r ./buttondown ./buttondown-backup
buttondown pull --force
buttondown push
The CLI provides specific error messages for common issues:
Error: --title is required for the create command
Skipping [file]: Invalid format (missing frontmatter)
Failed to upload image [filename]: [error message]
Failed to create email: [error details]
For more information, contact Buttondown support.