|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Unified CLI |
| 4 | +--- |
| 5 | + |
| 6 | +# Unified CLI |
| 7 | + |
| 8 | +Global options such as `--json`, `--cookies`, and `--publication-url` must |
| 9 | +appear before the command. |
| 10 | + |
| 11 | +## Create an unpublished draft |
| 12 | + |
| 13 | +```bash |
| 14 | +substack drafts create post.md |
| 15 | +``` |
| 16 | + |
| 17 | +The title comes from the first Markdown heading, then the filename if the file |
| 18 | +has no heading. Use `--title` to override it. |
| 19 | + |
| 20 | +## Select a publication |
| 21 | + |
| 22 | +List every publication available to the authenticated account: |
| 23 | + |
| 24 | +```bash |
| 25 | +substack publications list |
| 26 | +``` |
| 27 | + |
| 28 | +Select one for a single command: |
| 29 | + |
| 30 | +```bash |
| 31 | +substack --publication-url https://example.substack.com drafts list |
| 32 | +``` |
| 33 | + |
| 34 | +## Schedule an existing draft |
| 35 | + |
| 36 | +Pass an ISO 8601 timestamp with a timezone offset or `Z`: |
| 37 | + |
| 38 | +```bash |
| 39 | +substack drafts schedule 12345 --at 2030-01-02T09:00:00+01:00 |
| 40 | +``` |
| 41 | + |
| 42 | +Remove the schedule without deleting the draft: |
| 43 | + |
| 44 | +```bash |
| 45 | +substack drafts unschedule 12345 |
| 46 | +``` |
| 47 | + |
| 48 | +## Stable JSON for automation |
| 49 | + |
| 50 | +```bash |
| 51 | +substack --json drafts list --limit 10 |
| 52 | +``` |
| 53 | + |
| 54 | +The command writes a JSON object containing `drafts`, `count`, `filter`, |
| 55 | +`offset`, and `limit`. Errors are also JSON when `--json` is present. |
| 56 | + |
| 57 | +## Publish and delete |
| 58 | + |
| 59 | +```bash |
| 60 | +substack drafts publish 12345 --no-send |
| 61 | +substack drafts delete 12345 --yes |
| 62 | +``` |
| 63 | + |
| 64 | +Publishing and deletion require confirmation. JSON and noninteractive |
| 65 | +workflows must pass `--yes`. Publishing runs Substack's prepublish check first. |
| 66 | +See [safety and publishing behavior](safety.md). |
| 67 | + |
| 68 | +The original console scripts remain supported. See |
| 69 | +[legacy CLI commands](legacy-cli.md). |
0 commit comments