CLI Guide
The Postlark CLI lets you manage your blog entirely from the terminal — write posts, publish, check analytics, and more without opening a browser.
Install
Section titled “Install”npm install -g @postlark/cliOr run without installing:
npx @postlark/cli --helpVerify the installation:
postlark --versionLog In
Section titled “Log In”Browser Login (recommended)
Section titled “Browser Login (recommended)”Run postlark login and a browser window will open. Log in with your Postlark account and click Authorize.
postlark loginOpening browser for authentication...
Your confirmation code: K7XT-NMGD
Open this URL in your browser: https://app.postlark.ai/cli-auth?code=K7XT-NMGD
Waiting for authorization... done!
Logged in as John ([email protected]) API key saved to /home/john/.postlarkrcDirect API Key
Section titled “Direct API Key”If you already have an API key, pass it directly:
postlark login pk_live_your_api_key_hereSet Your Default Blog
Section titled “Set Your Default Blog”If you have multiple blogs, set a default to avoid specifying --blog every time:
# List your blogspostlark blogs
# Set defaultpostlark blogs use <blog-id>You can always override with --blog <id> on any command.
Writing & Publishing Posts
Section titled “Writing & Publishing Posts”Create a Post
Section titled “Create a Post”# From a Markdown filepostlark posts create --title "My First Post" --file ./post.md
# With inline contentpostlark posts create --title "Quick Note" --content "Hello, world!"
# As a draft (default is published)postlark posts create --title "Work in Progress" --file ./draft.md --status draft
# With tagspostlark posts create --title "TypeScript Guide" --file ./ts.md --tags "typescript,tutorial"View & Edit Posts
Section titled “View & Edit Posts”# List all postspostlark posts
# Filter by statuspostlark posts --status draftpostlark posts --status published
# View a specific post (shows full Markdown)postlark posts get my-post-slug
# Update a postpostlark posts update my-post-slug --title "New Title"postlark posts update my-post-slug --file ./updated.mdpostlark posts update my-post-slug --tags "new-tag,another"Publish & Schedule
Section titled “Publish & Schedule”# Publish a draftpostlark posts publish my-draft-slug
# Schedule for later (Creator+ plan)postlark posts schedule my-post --at "2026-04-01T09:00:00Z"Delete a Post
Section titled “Delete a Post”postlark posts delete my-post-slug --confirmDeploy: Batch Publish from a Directory
Section titled “Deploy: Batch Publish from a Directory”The deploy command is the CLI’s most powerful feature. Point it at a directory of .md files, and it will create or update posts automatically.
Frontmatter Format
Section titled “Frontmatter Format”Each .md file can include optional frontmatter:
---title: My Complete Guideslug: my-complete-guidetags: [typescript, tutorial]status: published---
Your Markdown content here...| Field | Required | Default |
|---|---|---|
title | No | Filename (without .md) |
slug | No | Derived from filename |
tags | No | None |
status | No | published |
Deploy Workflow
Section titled “Deploy Workflow”# Preview what will happen (no changes made)postlark deploy ./posts --dry-run
# Deploy all .md filespostlark deploy ./posts
# Deploy as draftspostlark deploy ./posts --status draft
# Delete posts on server that don't exist locallypostlark deploy ./posts --delete-missingExample output:
+ getting-started (new) ~ typescript-guide (updated) - old-post (deleted)
Done: 1 created, 1 updated, 1 deleted, 0 errorsImage Upload
Section titled “Image Upload”Upload images to your blog’s media storage:
postlark upload path/to/image.jpg# → Uploaded: https://media.postlark.ai/blog-id/uuid.jpg# → Markdown: Supported formats: JPEG, PNG, GIF, WebP. Maximum size: 5MB. JPEG EXIF metadata is automatically stripped for privacy.
Using uploaded images in posts
Section titled “Using uploaded images in posts”Copy the Markdown output and paste it into your post content:
# 1. Upload the imagepostlark upload diagram.png# → Markdown: 
# 2. Create a post with the imagepostlark posts create --title "Architecture Guide" --content "# Architecture\n\n\n\nHere is our system design."Or write your Markdown file with image references and deploy:
postlark deploy ./posts/ --publishSearch
Section titled “Search”# Search your blogpostlark search "typescript"
# Discover posts across all Postlark blogs (no auth needed)postlark discover "kubernetes tutorial"postlark discover "react" --tag "beginner"Analytics
Section titled “Analytics”# Blog overview (Starter+ plan)postlark analytics
# Per-post analyticspostlark analytics post my-post-slugBlog Management
Section titled “Blog Management”# List blogspostlark blogs
# Create a new blogpostlark blogs create --slug my-blog --name "My Blog" --desc "A blog about tech"
# Update blog settingspostlark blogs update <blog-id> --name "New Name"
# Delete a blog (permanent!)postlark blogs delete <blog-id> --confirmCustom Domain
Section titled “Custom Domain”# Check domain statuspostlark domains
# Set a custom domain (Creator+)postlark domains set blog.example.com
# Remove custom domainpostlark domains remove --confirmAfter setting a domain, add a CNAME record pointing to postlark.ai in your DNS settings.
Access Tokens & API Keys
Section titled “Access Tokens & API Keys”# List tokenspostlark tokens
# Create a scoped tokenpostlark tokens create --name "CI/CD" --scopes "posts:read,posts:write" --expires-in 90d
# Revoke a tokenpostlark tokens revoke <token-id> --confirm
# Blog API keyspostlark keyspostlark keys create --name "n8n automation"postlark keys revoke <key-id> --confirmAccount
Section titled “Account”# View profilepostlark account
# Export all data (GDPR)postlark account export --output backup.json
# Delete account (permanent!)postlark account delete --confirm "DELETE MY ACCOUNT"Post Packs
Section titled “Post Packs”# Check balance (Starter+)postlark packs
# Purchase extra postspostlark packs purchase --type 50postlark packs purchase --type 200Global Options
Section titled “Global Options”These work with any command:
| Option | Description |
|---|---|
--api-key <key> | Override stored API key |
--api-base <url> | Override API endpoint |
--blog <id> | Override default blog |
--json | Output as JSON (for scripting) |
--verbose | Show HTTP request details |
--help | Show help for any command |
JSON Output for Scripting
Section titled “JSON Output for Scripting”# Pipe to jq for processingpostlark --json posts | jq '.data[].slug'
# Use in shell scriptsSLUG=$(postlark --json posts create --title "Auto Post" --file post.md | jq -r '.slug')echo "Created: $SLUG"Configuration File
Section titled “Configuration File”Credentials are stored in ~/.postlarkrc:
{ "apiKey": "pk_live_...", "defaultBlog": "blog-uuid-here", "apiBase": "https://api.postlark.ai/v1"}This file has 600 permissions (owner read/write only).
Log Out
Section titled “Log Out”postlark logoutThis removes ~/.postlarkrc.
Next Steps
Section titled “Next Steps”- MCP Server — Use Postlark with Claude Code or Cursor
- Dashboard Guide — Manage your blog in the browser
- Markdown Features — Supported Markdown extensions