# 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

# Update an existing post by slug
blogizi update path/to/my-post.md

# Publish a local markdown file
blogizi publish path/to/my-post.md

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

## 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` and makes the post visible on your public blog.

> You can also create and edit posts entirely in the dashboard editor — 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).
