# CLI publishing

> Authenticate the CLI and draft or publish markdown from your terminal.

HTML version: https://blogizi.com/docs/cli-publishing
Markdown version: https://blogizi.com/docs/cli-publishing.md

The Blogizi CLI drafts and publishes local markdown files to your blog. Write posts yourself, in your editor, or with an AI coding agent — then push them with one command.

## Get your API key

Dashboard → **Account → API** (also shown under any project **Settings → API**).

Keys are **account-scoped** — one key authorizes all of your projects. Treat it like a password: never commit it to git or paste it into chat logs.

## Authenticate

```sh
npm install -g blogizi
blogizi auth YOUR_ACCOUNT_API_KEY
```

## Select a project

If your account has **more than one project**, tell the CLI which blog to publish to:

```sh
blogizi use your-project-slug
# or in one step:
blogizi auth YOUR_ACCOUNT_API_KEY --project your-project-slug
```

With a single project, the API picks it automatically — you can skip `blogizi use`.

The active slug is saved in `~/.blogizi/config.json` and sent with every `draft` / `update` / `publish` request.

## Common commands

```sh
# Save a local markdown file as a draft
blogizi draft path/to/my-post.md

# Schedule a draft (project timezone if no Z/offset)
blogizi draft path/to/my-post.md --scheduled-at "2026-10-26T09:00"

# Update an existing post by slug
blogizi update path/to/my-post.md
blogizi update path/to/my-post.md --scheduled-at "2026-10-27T14:30"
blogizi update path/to/my-post.md --unschedule

# Publish live immediately (cancels any pending schedule)
blogizi publish path/to/my-post.md

# Upload a cover or inline image for an existing post slug
blogizi upload ./diagram.png --slug my-post --type content --alt "Architecture"

# Switch which project the CLI targets
blogizi use another-project-slug
```

## Images

- Relative markdown images like `![Alt](./images/diagram.png)` are uploaded automatically on `draft` / `update` / `publish` (paths resolved from the markdown file).
- Frontmatter `coverImage: ./cover.png` (or `coverImageUrl` with an HTTPS URL) sets the post cover.
- Or upload explicitly: `blogizi upload <file> --slug <post-slug> --type content|cover`. Content uploads print a markdown snippet you can paste into the post.

## Obsidian

Prefer writing in Obsidian? See [Obsidian plugin](/docs/obsidian) for install, commands, and publishing from your vault with the same account API key.

## How publishing works

Drafts are stored on Blogizi as `draft` status. Running `blogizi draft` creates a draft. Running `blogizi update` updates an existing post by slug (and keeps its visibility unless the file sets `status`). Running `blogizi publish` (or clicking Publish in the dashboard) sets status to `published` immediately and cancels any pending schedule.

To **schedule** a go-live time, set frontmatter `scheduledAt` (ISO or local `YYYY-MM-DDTHH:mm` in the project timezone) and run `blogizi draft` or `blogizi update` — or pass `--scheduled-at` on those commands (flag wins over frontmatter). Clear a schedule with `blogizi update --unschedule` or `scheduledAt: null` in frontmatter. Blogizi publishes at that time — do not poll or re-run `publish` early. See [Write in Markdown](/docs/markdown-frontmatter).

> You can also create, schedule, and edit posts in the dashboard editor and content calendar — the CLI is optional for day-to-day use once you prefer a visual workflow.

Frontmatter format: [Write in Markdown](/docs/markdown-frontmatter). Full CLI reference: [blogizi-agent README](https://github.com/bytemindlab/blogizi-agent). HTTP details: [Public API](/docs/public-api).
