Install as a skill
npx skills add gitroomhq/postiz-agentPostiz CLI
Social media automation CLI for AI agents - Schedule posts across 28+ platforms programmatically.
The Postiz CLI provides a command-line interface to the Postiz API, enabling developers and AI agents to automate social media posting, manage content, and handle media uploads across platforms like Twitter/X, LinkedIn, Reddit, YouTube, TikTok, Instagram, Facebook, and more.
Installation
From npm (Recommended)
npm install -g postiz
# or
pnpm install -g postizAuthentication
Option 1: OAuth2 (Recommended)
Authenticate using the device flow — no client ID or secret needed:
postiz auth:loginThis will:
- Display a one-time code in your terminal
- Open your browser to authorize
- Automatically save credentials to
~/.postiz/credentials.json
# Check current auth status (verifies credentials are still valid)
postiz auth:status
# Remove stored credentials
postiz auth:logoutSelf-Hosting the Auth Server
By default, postiz auth:login uses the hosted auth server at cli-auth.postiz.com. If you want to self-host the OAuth2 device flow server, follow the guide in server/SERVER.md.
Option 2: API Key
export POSTIZ_API_KEY=your_api_key_hereOptional: Custom API endpoint
export POSTIZ_API_URL=https://your-custom-api.comNote: OAuth2 credentials take priority over the API key when both are present.
Commands
Discovery & Settings
List all connected integrations
postiz integrations:list
postiz integrations:list --group "customer-id"Returns integration IDs, provider names, and metadata. Use --group to return only the channels assigned to a specific group (customer).
List all groups (customers)
postiz integrations:groupsReturns all groups (customers) for your organization as {id, name}. Use a group's id with integrations:list --group to filter channels.
Get integration settings schema
postiz integrations:settings <integration-id>Returns character limits, required settings, and available tools for fetching dynamic data.
Trigger integration tools
postiz integrations:trigger <integration-id> <method-name>
postiz integrations:trigger <integration-id> <method-name> -d '{"key":"value"}'Fetch dynamic data like Reddit flairs, YouTube playlists, LinkedIn companies, etc.
Examples:
# Get Reddit flairs
postiz integrations:trigger reddit-123 getFlairs -d '{"subreddit":"programming"}'
# Get YouTube playlists
postiz integrations:trigger youtube-456 getPlaylists
# Get LinkedIn companies
postiz integrations:trigger linkedin-789 getCompaniesCreating Posts
Simple scheduled post
postiz posts:create -c "Content" -s "2024-12-31T12:00:00Z" -i "integration-id"Draft post
postiz posts:create -c "Content" -s "2024-12-31T12:00:00Z" -t draft -i "integration-id"Post with media
postiz posts:create -c "Content" -m "img1.jpg,img2.jpg" -s "2024-12-31T12:00:00Z" -i "integration-id"Post with comments (each comment can have its own media)
postiz posts:create \
-c "Main post" -m "main.jpg" \
-c "First comment" -m "comment1.jpg" \
-c "Second comment" -m "comment2.jpg,comment3.jpg" \
-s "2024-12-31T12:00:00Z" \
-i "integration-id"Multi-platform post
postiz posts:create -c "Content" -s "2024-12-31T12:00:00Z" -i "twitter-id,linkedin-id,facebook-id"Platform-specific settings
postiz posts:create \
-c "Content" \
-s "2024-12-31T12:00:00Z" \
--settings '{"subreddit":[{"value":{"subreddit":"programming","title":"Post Title","type":"text"}}]}' \
-i "reddit-id"Complex post from JSON file
postiz posts:create --json post.jsonOptions:
-c, --content- Post/comment content (use multiple times for posts with comments)-s, --date- Schedule date in ISO 8601 format (REQUIRED)-t, --type- Post type: "schedule" or "draft" (default: "schedule")-m, --media- Comma-separated media URLs for corresponding-c-i, --integrations- Comma-separated integration IDs (required)-d, --delay- Delay between comments in minutes (default: 0)--settings- Platform-specific settings as JSON string-j, --json- Path to JSON file with full post structure--shortLink- Use short links (default: true)
Managing Posts
List posts
postiz posts:list
postiz posts:list --startDate "2024-01-01T00:00:00Z" --endDate "2024-12-31T23:59:59Z"
postiz posts:list --customer "customer-id"Defaults to last 30 days to next 30 days if dates not specified.
Delete post
postiz posts:delete <post-id>Change post status (draft ↔ schedule)
postiz posts:status <post-id> --status draft
postiz posts:status <post-id> --status scheduleMove a scheduled post back to a draft, or promote a draft into the publishing queue. Switching to draft also terminates any workflow that's already running for the post, so it won't publish. Switching to schedule queues the post for publishing at its stored date.
Analytics
Get platform analytics
postiz analytics:platform <integration-id>
postiz analytics:platform <integration-id> -d 30Returns metrics like followers, impressions, and engagement over time for a specific integration/channel. The -d flag specifies the number of days to look back (default: 7).
Get post analytics
postiz analytics:post <post-id>
postiz analytics:post <post-id> -d 30Returns metrics like likes, comments, shares, and impressions for a specific published post.
⚠️ If analytics:post returns {"missing": true}, the post was published but the platform didn't return a usable post ID. You must resolve this before analytics will work:
# 1. List available content from the provider
postiz posts:missing <post-id>
# 2. Connect the correct content to the post
postiz posts:connect <post-id> --release-id "7321456789012345678"
# 3. Analytics will now work
postiz analytics:post <post-id>Connecting Missing Posts
Some platforms (e.g. TikTok) don't return a post ID immediately after publishing. The post's releaseId is set to "missing" and analytics won't work until resolved.
List available content from the provider
postiz posts:missing <post-id>Returns an array of {id, url} items representing recent content from the provider. Returns an empty array if the provider doesn't support this feature.
Connect a post to its published content
postiz posts:connect <post-id> --release-id "<content-id>"Media Upload
Upload file and get URL
postiz upload <file-path>⚠️ IMPORTANT: Upload Files Before Posting
You must upload media files to Postiz before using them in posts. Many platforms (especially TikTok, Instagram, and YouTube) require verified/trusted URLs and will reject external links.
Workflow:
- Upload your file using
postiz upload - Extract the returned URL
- Use that URL in your post's
-mparameter
Supported formats:
- Images: PNG, JPG, JPEG, GIF
- Videos: MP4
Example:
# 1. Upload the file first
RESULT=$(postiz upload video.mp4)
PATH=$(echo "$RESULT" | jq -r '.path')
# 2. Use the Postiz URL in your post
postiz posts:create -c "Check out my video!" -s "2024-12-31T12:00:00Z" -m "$PATH" -i "tiktok-id"Why this is required:
- TikTok, Instagram, YouTube only accept URLs from trusted domains
- Security: Platforms verify media sources to prevent abuse
- Reliability: Postiz ensures your media is always accessible
Platform-Specific Features
# Get available flairs
postiz integrations:trigger reddit-id getFlairs -d '{"subreddit":"programming"}'
# Post with subreddit and flair
postiz posts:create \
-c "Content" \
-s "2024-12-31T12:00:00Z" \
--settings '{"subreddit":[{"value":{"subreddit":"programming","title":"My Post","type":"text","is_flair_required":true,"flair":{"id":"flair-123","name":"Discussion"}}}]}' \
-i "reddit-id"YouTube
# Get playlists
postiz integrations:trigger youtube-id getPlaylists
# Upload video FIRST (required!)
VIDEO=$(postiz upload video.mp4)
VIDEO_URL=$(echo "$VIDEO" | jq -r '.path')
# Post with uploaded video URL
postiz posts:create \
-c "Video description" \
-s "2024-12-31T12:00:00Z" \
--settings '{"title":"Video Title","type":"public","tags":[{"value":"tech","label":"Tech"}],"playlistId":"playlist-id"}' \
-m "$VIDEO_URL" \
-i "youtube-id"TikTok
# Upload video FIRST (TikTok only accepts verified URLs!)
VIDEO=$(postiz upload video.mp4)
VIDEO_URL=$(echo "$VIDEO" | jq -r '.path')
# Post with uploaded video URL
postiz posts:create \
-c "Video caption #fyp" \
-s "2024-12-31T12:00:00Z" \
--settings '{"privacy":"PUBLIC_TO_EVERYONE","duet":true,"stitch":true}' \
-m "$VIDEO_URL" \
-i "tiktok-id"# Get companies you can post to
postiz integrations:trigger linkedin-id getCompanies
# Post as company
postiz posts:create \
-c "Company announcement" \
-s "2024-12-31T12:00:00Z" \
--settings '{"companyId":"company-123"}' \
-i "linkedin-id"X (Twitter)
# Create thread
postiz posts:create \
-c "Thread 1/3 🧵" \
-c "Thread 2/3" \
-c "Thread 3/3" \
-s "2024-12-31T12:00:00Z" \
-d 2000 \
-i "twitter-id"
# With reply settings
postiz posts:create \
-c "Tweet content" \
-s "2024-12-31T12:00:00Z" \
--settings '{"who_can_reply_post":"everyone"}' \
-i "twitter-id"# Upload image FIRST (Instagram requires verified URLs!)
IMAGE=$(postiz upload image.jpg)
IMAGE_URL=$(echo "$IMAGE" | jq -r '.path')
# Regular post
postiz posts:create \
-c "Caption #hashtag" \
-s "2024-12-31T12:00:00Z" \
--settings '{"post_type":"post"}' \
-m "$IMAGE_URL" \
-i "instagram-id"
# Story (upload first)
STORY=$(postiz upload story.jpg)
STORY_URL=$(echo "$STORY" | jq -r '.path')
postiz posts:create \
-c "" \
-s "2024-12-31T12:00:00Z" \
--settings '{"post_type":"story"}' \
-m "$STORY_URL" \
-i "instagram-id"See PROVIDER_SETTINGS.md for all 28+ platforms.
Features for AI Agents
Discovery Workflow
The CLI enables dynamic discovery of integration capabilities:
- List integrations - Get available social media accounts
- Get settings - Retrieve character limits, required fields, and available tools
- Trigger tools - Fetch dynamic data (flairs, playlists, boards, etc.)
- Create posts - Use discovered data in posts
- Analyze - Get post analytics; if
{"missing": true}is returned, resolve withposts:missing+posts:connect
This allows AI agents to adapt to different platforms without hardcoded knowledge.
JSON Mode
For complex posts with multiple platforms and settings:
postiz posts:create --json complex-post.jsonJSON structure:
{
"integrations": ["twitter-123", "linkedin-456"],
"posts": [
{
"provider": "twitter",
"post": [
{
"content": "Tweet version",
"image": ["twitter-image.jpg"]
}
]
},
{
"provider": "linkedin",
"post": [
{
"content": "LinkedIn version with more context...",
"image": ["linkedin-image.jpg"]
}
],
"settings": {
"__type": "linkedin",
"companyId": "company-123"
}
}
]
}All Output is JSON
Every command outputs JSON for easy parsing:
INTEGRATIONS=$(postiz integrations:list | jq -r '.')
REDDIT_ID=$(echo "$INTEGRATIONS" | jq -r '.[] | select(.identifier=="reddit") | .id')Threading Support
Comments are automatically converted to
…