Want to see how your draft is shaping up? You can conjure it with an email ID, along with a few new lines of code.
Before we get to the code, here are two ways to find your email ID:
Pinpoint your email ID in the response of your last successful request for that particular draft.
Mosey over to the “Emails” tab of your Buttondown dashboard, and click on the draft in question. From there, you can copy your email ID from the draft’s URL.
Now you're ready to use the following code.
import requests# You can find this key in your API requests page:# https://buttondown.com/requestsBUTTONDOWN_API_KEY = "your-api-key-here"EMAIL_ID = "your-email-id-here"headers = {"Authorization": f"Token #{BUTTONDOWN_API_KEY}"}BASE_URL = "https://api.buttondown.email"ENDPOINT = f"/v1/emails/{EMAIL_ID}"response = requests.get(f"{BASE_URL}{ENDPOINT}", headers=headers)print(response.json())
If the editing mood strikes, you can always update the body of your draft using the code below.
import jsonimport requests# You can find this key in your API requests page:# https://buttondown.com/requestsBUTTONDOWN_API_KEY = "your-api-key-here"EMAIL_ID = "your-email-id-here"headers = {"Authorization": f"Token #{BUTTONDOWN_API_KEY}"}data = {"body": "These are my edits!"}base_url = "https://api.buttondown.email"endpoint = f"/v1/emails/{EMAIL_ID}"response = requests.patch(base_url + endpoint, headers=headers, data=json.dumps(data))print(response)
Congratulations, your draft is ready to become a fully-fledged email! Go ahead and send it out with just a few more adjustments to your code.
The main change will be to your draft’s “Status.” We’ll switch it from “Draft” to “About to Send.” Once you submit your request, Buttondown will automatically begin the process of sending your email.
(Pro tip: If you spot a typo and want to undo sending your email, you’ll still have a few minutes to do so! All you need to do is change the “Status” back to “Draft.”)
import jsonimport requests# You can find this key in your API requests page:# https://buttondown.com/requestsBUTTONDOWN_API_KEY = "your-api-key-here"EMAIL_ID = "your-email-id-here"headers = {"Authorization": f"Token #{BUTTONDOWN_API_KEY}"}data = {"status": "about_to_send",}base_url = "https://api.buttondown.email"endpoint = f"/v1/emails/{EMAIL_ID}"response = requests.patch(base_url + endpoint, headers=headers, data=json.dumps(data))print(response)
If you’d rather wait a bit to send your draft, you can simply change your draft “Status” to “Scheduled” instead. You’ll also need to add a “Publish date” in the following format: “YYYY-MM-DDTHH:MM:SSZ.”
import jsonimport requests# You can find this key in your API requests page:# https://buttondown.com/requestsBUTTONDOWN_API_KEY = "your-api-key-here"EMAIL_ID = "your-email-id-here"headers = {"Authorization": f"Token #{BUTTONDOWN_API_KEY}"}data = {"status": "scheduled","publish_date": "2027-08-24T14:15:22Z",}base_url = "https://api.buttondown.email"endpoint = f"/v1/emails/{EMAIL_ID}"response = requests.patch(base_url + endpoint, headers=headers, data=json.dumps(data))print(response)