How to post to Substack via API
Substack has no official public posting API. You can use this Substack MCP server - it can: post, draft, publish, delete, and more.
Choose your path:
For newsletter writers (non-technical users)
Substack has no official public posting API. You can use this Substack MCP server - it can: post, draft, publish, delete, and more.
Example: https://substack.com/@ignalex runs this daily newsletter on autopilot via Claude + MCP.
Steps
- Install the Substack API MCP into Claude, Cursor, or Codex.
- Register on API Substack.
- Generate your API key.
- Copy your Substack session cookie (`substack.sid`).
- Ask the agent to write and post.
Step 1 - Install MCP (Claude, Cursor, or Codex)
MCP (Model Context Protocol) is a small connector that gives your AI tools it can call for you. With the Substack API MCP installed, Claude, Cursor, or Codex can draft, publish, schedule, update, and tag posts - without you opening the Substack editor. More detail lives in the MCP setup guide.
Install once:
- Clone or download substack-api-mcp.
- Create a Python virtual environment and run `pip install -e .`.
- Add the server to Claude Desktop, Cursor, or Codex with one of the configs below (use absolute paths).
- Leave `YOUR_API_KEY` and `YOUR_SUBSTACK_SID_VALUE` as placeholders for now - you will fill them in the next steps.
- Restart the host after you save the config.
Claude Desktop - put this in your Claude Desktop MCP config (`claude_desktop_config.json`):
Claude Desktop — mcpServers JSON
{
"mcpServers": {
"substack-api": {
"command": "/ABSOLUTE/PATH/TO/Substack-API-MCP/.venv/bin/substack-api-mcp",
"args": [],
"env": {
"APISUBSTACK_API_KEY": "YOUR_API_KEY",
"SUBSTACK_PUBLICATION_URL": "https://yourname.substack.com",
"SUBSTACK_SID": "YOUR_SUBSTACK_SID_VALUE"
}
}
}
}Cursor - put this in Cursor MCP settings (`.cursor/mcp.json` or Cursor Settings → MCP):
Cursor — mcpServers JSON
{
"mcpServers": {
"substack-api": {
"command": "/ABSOLUTE/PATH/TO/Substack-API-MCP/.venv/bin/substack-api-mcp",
"args": [],
"env": {
"APISUBSTACK_API_KEY": "YOUR_API_KEY",
"SUBSTACK_PUBLICATION_URL": "https://yourname.substack.com",
"SUBSTACK_SID": "YOUR_SUBSTACK_SID_VALUE"
}
}
}
}Codex - put this in `~/.codex/config.toml` (Codex uses TOML, not JSON):
Codex — config.toml
[mcp_servers.substack-api]
command = "/ABSOLUTE/PATH/TO/Substack-API-MCP/.venv/bin/substack-api-mcp"
args = []
[mcp_servers.substack-api.env]
APISUBSTACK_API_KEY = "YOUR_API_KEY"
SUBSTACK_PUBLICATION_URL = "https://yourname.substack.com"
SUBSTACK_SID = "YOUR_SUBSTACK_SID_VALUE"Step 2 - Register and get your API key
Go to apisubstack.com, sign in, start the free trial, and generate an API key. Copy the key when it appears - the full value is shown only once. Paste it into `APISUBSTACK_API_KEY` in your MCP config from Step 1.
Step 3 - Connect your Substack publication
You need two Substack values: your publication URL (for example `https://yourname.substack.com`) and your browser session cookie named `substack.sid`. Substack has no public OAuth write API for posts, so the session cookie is how authors authenticate today.
How to copy `substack.sid`:
- Open Chrome and sign in to Substack.
- Open DevTools → Application → Cookies.
- Select `https://substack.com` (or your publication host).
- Find the cookie named `substack.sid` and copy its Value.
Paste the cookie into `SUBSTACK_SID` and set `SUBSTACK_PUBLICATION_URL` in your MCP config. Keep the cookie private - it is as sensitive as a login. Important corner case: cookies expire. If posting suddenly fails with 401 or 403, refresh `substack.sid` from the browser and update it in your MCP settings.
Step 4 - Write and send from the chat
Once the connector is live, talk like you would talk to an editor. Examples:
- Write a draft titled … with these bullet points and save it to my Substack.
- Publish this draft now.
- Schedule this post for Tuesday 9am UTC.
- Add the tags newsletter and product.
Under the hood the agent calls tools such as `test_connection`, `create_post`, `get_draft`, `update_draft`, `publish_post`, `schedule_post`, and tag helpers. You do not need to memorize those names - ask in plain English and approve the tool calls when the agent proposes them.
What you can do
- Create drafts
- Update drafts
- Publish now
- Schedule releases
- Work with tags
Same posting job whether you use MCP, the CLI / Python client, or automation tools - each is a separate product. For most bloggers, Claude / Cursor / Codex + MCP is the path that matches how you already write. See also the MCP setup guide.
Corner cases to know before you rely on it
- `substack.sid` expires - refresh it when auth fails.
- Never paste your API key or cookie into a public chat or commit them to a shared file.
- Publications that use Sections may need a section before some publishes succeed.
- Image upload and Substack Notes are not the focus of this posting flow - it is built for newsletter posts: draft, publish, schedule.
- This is unofficial and not affiliated with Substack. Endpoints can change. Keep a browser login as backup for anything mission-critical.
For developers
Download this library: substack-api-client.
Get an API key - then run your automation with the Python client, CLI, or your own scripts.
- Download the library
- Get API key - run your automation