# Substack Publishing
<!--
ref: @integrations/substack-publishing
type: protocol
tags: [substack, publishing, newsletter, browser-automation, cdp, tiptap, drafts]
triggers: [draft a Substack post, change Substack settings, operate Substack, publish to Substack, Substack welcome email, Substack about page, stage a newsletter draft]
trigger_prompt: When any agent is asked to operate Substack on the account holder's behalf — staging post drafts, editing publication settings (basics/about/welcome email), or reading engagement — drive it through the automation Chrome profile per this protocol.
version: 4
updated_at: 2026-10-24T21:30:04.840Z
-->

> **Operate Substack through the automation browser (test-chrome, CDP), never through the public API or the browser the account holder uses.** Substack has no first-class write API; everything here is CDP-driven DOM automation against a profile-persisted logged-in session. The "populated ≠ saved" persistence rule (rule 4) is load-bearing throughout.

## Hard ground rules (read first)

1. **Publish is ALWAYS the operator's tap.** Agents stage drafts and settings only. Never click **Publish**, **Send**, **Continue → Publish**, or **Import contacts**. A staged draft sits at `/publish/post/<id>` until the account holder sends it himself. Staging every surface is in-scope; the final send is not.
2. **Auth is a profile-persisted session — never touch credentials.** The logged-in cookie lives in the automation Chrome profile. If `/settings` (or any writer URL) 302-redirects to `/sign-in`, or `window._preloads.user` is null, **STOP and escalate for a one-time interactive login** (the account holder clicks the email magic-link / enters the OTP by hand). Never enter an email, password, or OTP yourself; never read or reuse credential material.
3. **Authored choices vs untouched defaults.** Never overwrite something the operator set. Fresh-publication defaults (listed in *Defaults that read as gaps* below) are fillable gaps; anything else is an authored choice — leave it. When unsure whether a value is a default or a choice, escalate rather than overwrite.
4. **Populated ≠ saved — reload is the only persistence proof.** Basics fields are React-controlled: a Playwright `fill()`/`blur()` does not persist. Only real keystrokes surface a Save/Cancel pair, and only clicking Save fires the `PUT`. After any settings write, **reload the page and re-read the field** — that round-trip is the sole trustworthy check that it stuck.
5. **Reading state requires the browser too — drafts are INVISIBLE from the public web.** The rule above is usually read as "write through the automation browser"; it governs *reads* just as hard. Drafts, scheduled posts, settings values, and subscriber state exist only behind the authenticated session, so the public surface (`https://<subdomain>.substack.com`, `/about`, `/archive`) shows **published posts only**. An empty public archive is therefore not evidence of anything — it is the expected appearance of a publication whose posts are all still drafts. Any claim about whether a draft exists, survived a rename, or is publish-ready MUST come from `/publish/posts` inside the automation profile. Field-hit: after a publication rename, an agent verified the rename from the public page — correctly confirming the name, author, and About copy — but could not see the staged drafts, and had to hand back "strong inference, not proof" on the one question that actually gated the launch. Inferring private state from a public surface is a false-confidence trap; the fix is to read it in the automation browser, which has access to drafts. Corollary: when reporting readiness, state plainly which facts came from the authenticated surface and which did not.

## Session / auth detection

Before any operation, confirm the session is live:

- `window._preloads.user` — non-null ⇒ signed in; the object also carries the account identity.
- Navigate to `/publish/settings` (or `/settings`) and check for a 302 to `/sign-in`. A redirect means the session is dead → escalate for interactive login (rule 2). Do **not** attempt to re-auth programmatically.
- The cookie persists in the Chrome profile across runs, so a healthy session needs no per-run login.

## Publication discovery

- `window._preloads.{user,pub}` on any writer page exposes the current user and publication objects.
- The account-level `substack.com/settings` lists all **Publications** the user has plus their **role** on each.
- The **subdomain drives every writer URL** — `https://<subdomain>.substack.com/publish/...`. Resolve the subdomain from `_preloads.pub` (or the account settings list) before constructing URLs; do not hardcode.

## Settings surfaces (field map)

All settings editors are TipTap/ProseMirror. Saving fires `PUT /api/v1/publication`. Reload to confirm (rule 4).

| Surface | URL | Fields |
|---|---|---|
| **Basics** | `/publish/settings` | name = `input[name="name"]`, tagline = `textarea[name="hero_text"]` |
| **About page** | `/publish/settings/edit?title=About%20page&bodyField=subscribe_content` | body (default = "Why subscribe?…") |
| **Welcome email** | `/publish/settings/edit?bodyField=welcome_email_content&titleField=welcome_email_subject` | subject + body. A separate *imported-subscribers* welcome variant exists — don't conflate. |
| **Email header/footer** | `/publish/settings/preamble` | `bodyField=email_preamble_for_free_writer` (header) / `email_postscript_for_free_writer` (footer) |

⚠️ **Welcome email ≠ email header/footer.** The welcome email is a one-time onboarding message (`/settings/edit`); the header/footer preamble wraps every issue (`/settings/preamble`). Easy to mistake — check the `bodyField` in the URL.

## Post editor + autosave semantics

- Navigate to `/publish/post` — this **mints a draft instantly** and redirects to `/publish/post/<id>`.
- The editor **autosaves via `PUT /api/v1/drafts/<id>` on any change**. There is no Save button. Publishing is a separate **Continue → Publish** flow — which agents never touch (rule 1).
- Fields:
  - Title: `textarea[placeholder="Title"]`
  - Subtitle: `textarea[placeholder^="Add a subtitle"]` (**maxlength 200**)
  - Body: `div.tiptap.ProseMirror` (the **first** one on the page)

## Rich-text insertion recipe

- **Body HTML** — dispatch a synthetic `ClipboardEvent('paste')` carrying a `DataTransfer` with `text/html`. Headings, bold, links, blockquotes, and dividers convert cleanly this way.
- **Title / subtitle** — use `keyboard.insertText` (atomic). Char-by-char typing races the autosave re-render and drops the tail of the string.
- **Tables — THERE IS NO TABLE FEATURE. Do not send an agent looking for one.** (Corrected 2026-07-19; the previous instruction here said "build tables natively via the editor toolbar," which sent a worker hunting for a control that does not exist.) HTML `<table>` paste is rejected/flattened to paragraphs, AND the editor offers no table insertion: the "More" menu carries Code block, Divider, Financial chart, Footnote, LaTeX, Poetry, Poll, Prediction market, and Recipe — no table — and there is no `/table` slash command. **Author tabular content in a non-table shape before staging.** Two that work: (a) paired lines with explicit bold labels (`*Then:* … / *Now:* …`), one pair per row plus a legend pair — preserves every word and reads correctly on mobile; (b) a code block, when the data is genuinely columnar and monospace alignment helps. Flattening a table to bare em-dash pairs is the failure mode to avoid — the row dashes become indistinguishable from prose em-dashes.

## Platform constraints (hit live)

- **Subtitle hard cap 200 chars** — clips mid-phrase past the limit. Trim before insertion.
- **No table support at all** — see above; author tabular content as labelled paired lines or a code block before staging.
- **Never send a bare `Backspace` (or `Meta+A`+`Backspace`) without first asserting which element has focus.** Field-hit 2026-07-19: a title/subtitle clear-and-retype sequence had its keystrokes land in the wrong field and truncated a draft title to its first few characters; the reload check caught it and it was repaired, but the draft briefly carried a broken title. Assert the focused element, then edit — and let the post-reload read (rule 4) be what proves it, since this class of error is invisible until you look.

## Defaults that read as gaps, not choices

A fresh publication ships these boilerplate values. Treat them as fillable gaps (safe to author over per rule 3), and distinguish from anything the operator actually set:

- Publication name: `"<Account first name>'s Substack"` (Substack derives this from the account name)
- Tagline: `"My personal Substack"`
- About page: `"Why subscribe?…"` boilerplate
- Welcome email: boilerplate body

## Browser mechanics — `@integrations/agent-browser` is canonical

**Do not re-derive browser mechanics here, and do not restate them.** `@integrations/agent-browser` owns how to reach and drive the automation browser: self-bootstrap, lifecycle (keep one Test-Chrome alive, do not bounce it), `connectOverCDP` and its timeout form, the node-not-bun requirement, background-page-only / never-`newPage()` focus protection, and profile handling. **Fetch it before any Substack run** — this protocol assumes it and adds only what is Substack-specific.

Substack-specific facts that sit on top of it:

- **The authenticated Substack session lives in that browser's profile.** That is *why* both writes and reads must happen there (rule 5) — it is the only surface where drafts exist.
- **Losing the profile costs an interactive re-auth.** Anything that flushes the profile's cookies (per agent-browser's lifecycle rules) destroys the Substack login specifically, and recovery requires the operator to click a magic-link/OTP by hand (rule 2). Treat the session as expensive, not disposable.

## Post cover image — the "Thumbnail" control is NOT it

**Verified negative (2026-07-19, cost a full run):** the post editor's **File Settings → Thumbnail** panel, whose helper text reads *"Will be cropped to a 3:2 aspect ratio"*, is **not** the post cover. Its container is `post-editor-file-edit-sidebar` — it edits an **embedded file attachment**. It sits permanently translated off-canvas (`translateX(480px)`, anchored past `innerWidth`), no editor control opens it, and driving its file input directly is **inert**: `input`/`change` fire with `files=1` and no network request follows. `setInputFiles`, filechooser interception, viewport widening, and forcing the transform were all no-ops. Do not send an agent at this panel.

**Where the cover actually lives: the pre-publish `Continue` screen.** *Unconfirmed at time of writing* — inspecting it was correctly refused under the no-publish rule, since that screen is the publish flow. Treat this as the next thing to verify, not as established fact, and verify it **read-only** without advancing the flow.

**What IS confirmed about the upload half:** an image can be uploaded to Substack's media store through the app's own authenticated image API, and it lands **unmodified** — a 1196x797 source arrived at 1196x797, no crop, no re-encode. So pre-cropping to 3:2 before upload is respected. The remaining unknown is only which field/flow binds that hosted URL to the draft as its cover.

**Cover art constraints** (from the publication surface, generically): covers composite against the publication background colour, so art must fill the frame or fall off to that colour — a light-background image renders as a bright slab on a dark publication. The site logo is chrome, not an overlay, so cover art need not reserve space for it.

## Renames — resolve, never hardcode

**A publication can be renamed at any time, and renames do NOT leave a redirect** — the old subdomain returns 404. Observed live: a publication renamed twice inside a single day, with both prior subdomains dead afterward. This fails loudly rather than resolving to the wrong place, which is the good case; the bad case is a protocol, script, or bookmark carrying a stale literal.

**Always resolve the live subdomain from `_preloads.pub`** (or the account-level publications list) at the start of every run. Never hardcode a subdomain — including in this protocol, which deliberately names none.

Note also that a rename preserves the publication itself: posts, drafts, About page, and settings all survive, because it is the same publication object under a new name. Do not treat a rename as a re-create, and do not re-stage content that is still there.

## Validation provenance

Every surface in this protocol was exercised in a live staging run (2026-07-19) that set up a publication end-to-end — basics, about page, and welcome email settings, plus two post drafts — with each step verified by reload rather than by the editor's appearance. Field names, URLs, selectors, and constraints above are from that run, not inference.

---

*Related: `@integrations/agent-browser` · `@content/web/substack/2026-11-26-innermost-loop-november-23` · `@content/youtube/daniel-priestley/how-to-become-famous-in-your-industry-and-make-1-million` · `@content/youtube/daniel-priestley/how-to-become-famous-in-your-industry` · `@integrations/loom`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*