Skip to content

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.

Terminal
npm install -g @postlark/cli

Or run without installing:

Terminal window
npx @postlark/cli --help

Verify the installation:

Terminal window
postlark --version

Run postlark login and a browser window will open. Log in with your Postlark account and click Authorize.

Terminal
postlark login
Opening 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/.postlarkrc

If you already have an API key, pass it directly:

Terminal window
postlark login pk_live_your_api_key_here

If you have multiple blogs, set a default to avoid specifying --blog every time:

Terminal window
# List your blogs
postlark blogs
# Set default
postlark blogs use <blog-id>

You can always override with --blog <id> on any command.

Terminal window
# From a Markdown file
postlark posts create --title "My First Post" --file ./post.md
# With inline content
postlark 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 tags
postlark posts create --title "TypeScript Guide" --file ./ts.md --tags "typescript,tutorial"
Terminal window
# List all posts
postlark posts
# Filter by status
postlark posts --status draft
postlark posts --status published
# View a specific post (shows full Markdown)
postlark posts get my-post-slug
# Update a post
postlark posts update my-post-slug --title "New Title"
postlark posts update my-post-slug --file ./updated.md
postlark posts update my-post-slug --tags "new-tag,another"
Terminal window
# Publish a draft
postlark posts publish my-draft-slug
# Schedule for later (Creator+ plan)
postlark posts schedule my-post --at "2026-04-01T09:00:00Z"
Terminal window
postlark posts delete my-post-slug --confirm

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.

Each .md file can include optional frontmatter:

posts/my-guide.md
---
title: My Complete Guide
slug: my-complete-guide
tags: [typescript, tutorial]
status: published
---
Your Markdown content here...
FieldRequiredDefault
titleNoFilename (without .md)
slugNoDerived from filename
tagsNoNone
statusNopublished
Terminal window
# Preview what will happen (no changes made)
postlark deploy ./posts --dry-run
# Deploy all .md files
postlark deploy ./posts
# Deploy as drafts
postlark deploy ./posts --status draft
# Delete posts on server that don't exist locally
postlark deploy ./posts --delete-missing

Example output:

+ getting-started (new)
~ typescript-guide (updated)
- old-post (deleted)
Done: 1 created, 1 updated, 1 deleted, 0 errors

Upload images to your blog’s media storage:

Terminal window
postlark upload path/to/image.jpg
# → Uploaded: https://media.postlark.ai/blog-id/uuid.jpg
# → Markdown: ![image.jpg](https://media.postlark.ai/blog-id/uuid.jpg)

Supported formats: JPEG, PNG, GIF, WebP. Maximum size: 5MB. JPEG EXIF metadata is automatically stripped for privacy.

Copy the Markdown output and paste it into your post content:

Terminal window
# 1. Upload the image
postlark upload diagram.png
# → Markdown: ![diagram.png](https://media.postlark.ai/blog-id/uuid.png)
# 2. Create a post with the image
postlark posts create --title "Architecture Guide" --content "# Architecture\n\n![diagram.png](https://media.postlark.ai/blog-id/uuid.png)\n\nHere is our system design."

Or write your Markdown file with image references and deploy:

Terminal window
postlark deploy ./posts/ --publish
Terminal window
# Search your blog
postlark search "typescript"
# Discover posts across all Postlark blogs (no auth needed)
postlark discover "kubernetes tutorial"
postlark discover "react" --tag "beginner"
Terminal window
# Blog overview (Starter+ plan)
postlark analytics
# Per-post analytics
postlark analytics post my-post-slug
Terminal window
# List blogs
postlark blogs
# Create a new blog
postlark blogs create --slug my-blog --name "My Blog" --desc "A blog about tech"
# Update blog settings
postlark blogs update <blog-id> --name "New Name"
# Delete a blog (permanent!)
postlark blogs delete <blog-id> --confirm
Terminal window
# Check domain status
postlark domains
# Set a custom domain (Creator+)
postlark domains set blog.example.com
# Remove custom domain
postlark domains remove --confirm

After setting a domain, add a CNAME record pointing to postlark.ai in your DNS settings.

Terminal window
# List tokens
postlark tokens
# Create a scoped token
postlark tokens create --name "CI/CD" --scopes "posts:read,posts:write" --expires-in 90d
# Revoke a token
postlark tokens revoke <token-id> --confirm
# Blog API keys
postlark keys
postlark keys create --name "n8n automation"
postlark keys revoke <key-id> --confirm
Terminal window
# View profile
postlark account
# Export all data (GDPR)
postlark account export --output backup.json
# Delete account (permanent!)
postlark account delete --confirm "DELETE MY ACCOUNT"
Terminal window
# Check balance (Starter+)
postlark packs
# Purchase extra posts
postlark packs purchase --type 50
postlark packs purchase --type 200

These work with any command:

OptionDescription
--api-key <key>Override stored API key
--api-base <url>Override API endpoint
--blog <id>Override default blog
--jsonOutput as JSON (for scripting)
--verboseShow HTTP request details
--helpShow help for any command
Terminal window
# Pipe to jq for processing
postlark --json posts | jq '.data[].slug'
# Use in shell scripts
SLUG=$(postlark --json posts create --title "Auto Post" --file post.md | jq -r '.slug')
echo "Created: $SLUG"

Credentials are stored in ~/.postlarkrc:

~/.postlarkrc
{
"apiKey": "pk_live_...",
"defaultBlog": "blog-uuid-here",
"apiBase": "https://api.postlark.ai/v1"
}

This file has 600 permissions (owner read/write only).

Terminal window
postlark logout

This removes ~/.postlarkrc.