The Postiz CLI is a complete command-line interface package for interacting with the Postiz social media scheduling API. It's designed for developers and AI agents to automate social media posting.
apps/cli/
├── src/ # Source code
│ ├── index.ts # Main CLI entry point
│ ├── api.ts # API client for Postiz API
│ ├── config.ts # Configuration and environment handling
│ └── commands/ # Command implementations
│ ├── posts.ts # Posts management commands
│ ├── integrations.ts # Integrations listing
│ └── upload.ts # Media upload command
│
├── examples/ # Usage examples
│ └── basic-usage.sh # Shell script example
│
├── dist/ # Build output (generated)
│ ├── index.js # Compiled CLI executable
│ └── index.js.map # Source map
│
├── package.json # Package configuration
├── tsconfig.json # TypeScript configuration
├── tsup.config.ts # Build configuration
│
├── README.md # Main documentation
├── SKILL.md # AI agent usage guide
├── QUICK_START.md # Quick start guide
├── CHANGELOG.md # Version history
├── PROJECT_STRUCTURE.md # This file
│
├── .gitignore # Git ignore rules
└── .npmignore # npm publish ignore rules
- Main entry point for the CLI
- Uses
yargsfor command parsing - Defines all available commands and their options
- Contains help text and usage examples
- API client class
PostizAPI - Handles all HTTP requests to the Postiz API
- Methods for:
- Creating posts
- Listing posts
- Deleting posts
- Uploading files
- Listing integrations
- Error handling and response parsing
- Configuration management
- Environment variable handling
- Validates required settings (API key)
- Provides default values
- Post management commands implementation
createPost()- Create new social media postslistPosts()- List posts with filtersdeletePost()- Delete posts by ID
- Integration management
listIntegrations()- Show connected accounts
- Media upload functionality
uploadFile()- Upload images to Postiz
- Package name:
postiz - Version:
1.0.0 - Executable bin:
postiz→dist/index.js - Scripts:
dev,build,start,publish - Repository and metadata information
- Extends base config from monorepo
- Target: ES2017
- Module: CommonJS
- Enables decorators and source maps
- Build tool configuration
- Entry point:
src/index.ts - Output format: CommonJS
- Adds shebang for Node.js execution
- Generates source maps
- Main package documentation
- Installation instructions
- Usage examples
- API reference
- Development guide
- Comprehensive guide for AI agents
- Usage patterns and workflows
- Command examples
- Best practices
- Error handling
- Fast onboarding guide
- Installation steps
- Basic commands
- Common workflows
- Troubleshooting
- Version history
- Release notes
- Feature additions
- Bug fixes
- Bash script example
- Demonstrates basic CLI workflow
- Shows integration listing, post creation, and deletion
pnpm run dev- Watches for file changes
- Rebuilds automatically
- Useful during development
pnpm run build- Cleans
dist/directory - Compiles TypeScript → JavaScript
- Bundles dependencies
- Adds shebang for executable
- Generates source maps
- Makes output executable
dist/index.js- Main executable (~490KB)dist/index.js.map- Source map (~920KB)
User Input
↓
index.ts (yargs parser)
↓
Command Handler (posts.ts, integrations.ts, upload.ts)
↓
config.ts (get API key)
↓
api.ts (make API request)
↓
Response / Error
↓
Output to console
-
posts:create
- Options:
--content,--integrations,--schedule,--image - Handler:
commands/posts.ts::createPost()
- Options:
-
posts:list
- Options:
--page,--limit,--search - Handler:
commands/posts.ts::listPosts()
- Options:
-
posts:delete
- Positional:
<id> - Handler:
commands/posts.ts::deletePost()
- Positional:
-
integrations:list
- No options
- Handler:
commands/integrations.ts::listIntegrations()
-
upload
- Positional:
<file> - Handler:
commands/upload.ts::uploadFile()
- Positional:
| Variable | Required | Default | Usage |
|---|---|---|---|
POSTIZ_API_KEY |
✅ Yes | - | Authentication token |
POSTIZ_API_URL |
❌ No | https://api.postiz.com |
Custom API endpoint |
yargs- CLI argument parsingnode-fetch- HTTP requests- Standard Node.js modules (
fs,path)
tsup- TypeScript bundlertypescript- Type checking@types/yargs- TypeScript types
-
Build Scripts
- Added to root
package.json pnpm run build:cli- Build the CLIpnpm run publish-cli- Publish to npm
- Added to root
-
TypeScript Config
- Extends
tsconfig.base.json - Shares common compiler options
- Extends
-
Dependencies
- Uses shared dependencies from root
- No duplicate packages
-
Endpoints Used
POST /public/v1/posts- Create postGET /public/v1/posts- List postsDELETE /public/v1/posts/:id- Delete postGET /public/v1/integrations- List integrationsPOST /public/v1/upload- Upload media
-
Authentication
- API key via
Authorizationheader - Configured through environment variable
- API key via
pnpm run publish-cliThis will:
- Build the package
- Publish to npm with public access
- Include only
dist/,README.md, andSKILL.md
Included:
dist/- Compiled codeREADME.md- Documentation
Excluded:
src/- Source codeexamples/- Examples- Config files
- Other markdown files
# Test help
node dist/index.js --help
# Test without API key (should error)
node dist/index.js posts:list
# Test with API key (requires valid key)
POSTIZ_API_KEY=test node dist/index.js integrations:list- Unit tests for API client
- Integration tests for commands
- E2E tests with mock API
-
More Commands
- Analytics retrieval
- Team management
- Settings configuration
-
Features
- Interactive mode
- Config file support (~/.postizrc)
- Output formatting (JSON, table, CSV)
- Verbose/debug mode
- Batch operations from file
-
Developer Experience
- TypeScript types export
- Programmatic API
- Plugin system
- Custom integrations
- Issues: https://github.com/gitroomhq/postiz-app/issues
- Docs: See README.md, SKILL.md, QUICK_START.md
- Website: https://postiz.com