postiz 1.0.0 โ†’ 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/SKILL.md ADDED
@@ -0,0 +1,468 @@
1
+ # Postiz CLI Skill
2
+
3
+ ## Description
4
+
5
+ The Postiz CLI is a command-line interface for interacting with the Postiz social media scheduling API. It allows AI agents and developers to programmatically manage posts, integrations, and media uploads.
6
+
7
+ ## Prerequisites
8
+
9
+ - API Key: You need a valid Postiz API key
10
+ - Set the environment variable: `export POSTIZ_API_KEY=your_api_key`
11
+ - Optional: Set custom API URL with `export POSTIZ_API_URL=https://your-api-url.com`
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ # From the monorepo root
17
+ pnpm install
18
+
19
+ # Build the CLI
20
+ pnpm --filter postiz run build
21
+
22
+ # Link globally (optional)
23
+ cd apps/cli
24
+ pnpm link --global
25
+ ```
26
+
27
+ ## Available Commands
28
+
29
+ ### Posts Management
30
+
31
+ #### Create a Post
32
+
33
+ The CLI supports both **simple** and **complex** post creation:
34
+
35
+ ##### Simple Post Creation (Command-line)
36
+
37
+ ```bash
38
+ postiz posts:create -c "Your post content" -i "integration-id-1,integration-id-2"
39
+ ```
40
+
41
+ Options:
42
+ - `-c, --content <text>`: Post content/text
43
+ - `-i, --integrations <ids>`: Comma-separated integration IDs (required)
44
+ - `-s, --schedule <date>`: Schedule date in ISO 8601 format
45
+ - `--image <urls>`: Comma-separated image URLs or paths (multiple images supported)
46
+ - `--comments <text>`: Semicolon-separated comments
47
+ - `--shortLink`: Use URL shortener (default: true)
48
+
49
+ Examples:
50
+ ```bash
51
+ # Create immediate post
52
+ postiz posts:create -c "Hello World!" -i "twitter-123,linkedin-456"
53
+
54
+ # Create scheduled post
55
+ postiz posts:create -c "Future post" -s "2024-12-31T12:00:00Z" -i "twitter-123"
56
+
57
+ # Create post with multiple images
58
+ postiz posts:create -c "Check these out!" --image "url1.jpg,url2.jpg,url3.jpg" -i "twitter-123"
59
+
60
+ # Create post with comments (simple)
61
+ postiz posts:create -c "Main post" --comments "First comment;Second comment" -i "twitter-123"
62
+ ```
63
+
64
+ ##### Complex Post Creation (JSON File)
65
+
66
+ For posts with **comments that have their own media**, use JSON files:
67
+
68
+ ```bash
69
+ postiz posts:create --json ./my-post.json
70
+ ```
71
+
72
+ **JSON Structure:**
73
+ ```json
74
+ {
75
+ "type": "now",
76
+ "date": "2024-01-15T12:00:00Z",
77
+ "shortLink": true,
78
+ "tags": [],
79
+ "posts": [
80
+ {
81
+ "integration": { "id": "twitter-123" },
82
+ "value": [
83
+ {
84
+ "content": "Main post with media ๐Ÿš€",
85
+ "image": [
86
+ { "id": "img1", "path": "https://example.com/main1.jpg" },
87
+ { "id": "img2", "path": "https://example.com/main2.jpg" }
88
+ ]
89
+ },
90
+ {
91
+ "content": "First comment with its own media ๐Ÿ“ธ",
92
+ "image": [
93
+ { "id": "img3", "path": "https://example.com/comment1.jpg" }
94
+ ],
95
+ "delay": 5000
96
+ },
97
+ {
98
+ "content": "Second comment with different media ๐ŸŽจ",
99
+ "image": [
100
+ { "id": "img4", "path": "https://example.com/comment2.jpg" }
101
+ ],
102
+ "delay": 10000
103
+ }
104
+ ],
105
+ "settings": { "__type": "EmptySettings" }
106
+ }
107
+ ]
108
+ }
109
+ ```
110
+
111
+ **Key Features:**
112
+ - โœ… **Multiple posts** to different platforms in one request
113
+ - โœ… **Each post can have multiple values** (main post + comments/thread)
114
+ - โœ… **Each value can have multiple images** (array of MediaDto)
115
+ - โœ… **Delays between comments** (in milliseconds)
116
+ - โœ… **Platform-specific content** (different content per integration)
117
+
118
+ See `examples/` directory for:
119
+ - `post-with-comments.json` - Post with comments, each having their own media
120
+ - `multi-platform-post.json` - Post to multiple platforms with different content
121
+ - `thread-post.json` - Create a Twitter thread with 5 tweets
122
+ - `EXAMPLES.md` - Comprehensive guide with all use cases
123
+
124
+ #### List Posts
125
+ ```bash
126
+ postiz posts:list
127
+ ```
128
+
129
+ Options:
130
+ - `-p, --page <number>`: Page number (default: 1)
131
+ - `-l, --limit <number>`: Posts per page (default: 10)
132
+ - `-s, --search <query>`: Search query
133
+
134
+ Examples:
135
+ ```bash
136
+ # List all posts
137
+ postiz posts:list
138
+
139
+ # List with pagination
140
+ postiz posts:list -p 2 -l 20
141
+
142
+ # Search posts
143
+ postiz posts:list -s "hello"
144
+ ```
145
+
146
+ #### Delete a Post
147
+ ```bash
148
+ postiz posts:delete <post-id>
149
+ ```
150
+
151
+ Example:
152
+ ```bash
153
+ postiz posts:delete abc123xyz
154
+ ```
155
+
156
+ ### Integrations
157
+
158
+ #### List Connected Integrations
159
+ ```bash
160
+ postiz integrations:list
161
+ ```
162
+
163
+ This command shows all connected social media accounts and their IDs, which can be used when creating posts.
164
+
165
+ ### Media Upload
166
+
167
+ #### Upload a File
168
+ ```bash
169
+ postiz upload <file-path>
170
+ ```
171
+
172
+ Example:
173
+ ```bash
174
+ postiz upload ./images/photo.png
175
+ ```
176
+
177
+ Supported formats: PNG, JPG, JPEG, GIF
178
+
179
+ ## Usage for AI Agents
180
+
181
+ AI agents can use this CLI to automate social media scheduling. The CLI supports both simple and advanced post structures, including posts with comments where each has its own media.
182
+
183
+ ### Understanding the Post Structure
184
+
185
+ ```typescript
186
+ CreatePostDto {
187
+ type: 'now' | 'schedule' | 'draft' | 'update',
188
+ date: string, // ISO 8601 timestamp
189
+ shortLink: boolean, // Enable URL shortening
190
+ tags: Tag[], // Array of tags
191
+ posts: [ // Can post to multiple platforms
192
+ {
193
+ integration: { id: string }, // Platform integration ID
194
+ value: [ // Main post + comments/thread
195
+ {
196
+ content: string, // Text content
197
+ image: MediaDto[], // Array of media (multiple images)
198
+ delay?: number, // Delay in ms (for comments)
199
+ id?: string // Optional ID
200
+ }
201
+ ],
202
+ settings: { __type: 'EmptySettings' }
203
+ }
204
+ ]
205
+ }
206
+ ```
207
+
208
+ ### Common Patterns
209
+
210
+ ### Pattern 1: Create and Schedule Multiple Posts
211
+ ```bash
212
+ # Set API key once
213
+ export POSTIZ_API_KEY=your_key
214
+
215
+ # Create posts programmatically
216
+ postiz posts:create -c "Morning update" -s "2024-01-15T09:00:00Z" -i "twitter-123"
217
+ postiz posts:create -c "Afternoon update" -s "2024-01-15T15:00:00Z" -i "twitter-123"
218
+ postiz posts:create -c "Evening update" -s "2024-01-15T20:00:00Z" -i "twitter-123"
219
+ ```
220
+
221
+ ### Pattern 2: Upload Media and Create Post
222
+ ```bash
223
+ # First, upload the media
224
+ UPLOAD_RESULT=$(postiz upload ./image.png)
225
+
226
+ # Extract the URL from the result (you'll need to parse the JSON)
227
+ # Then create post with the media URL
228
+ postiz posts:create -c "Check out this image!" --image "<url-from-upload>"
229
+ ```
230
+
231
+ ### Pattern 3: Check Integrations Before Posting
232
+ ```bash
233
+ # List available integrations
234
+ postiz integrations:list
235
+
236
+ # Use the integration IDs from the response to create posts
237
+ postiz posts:create -c "Multi-platform post" -i "twitter-123,linkedin-456,facebook-789"
238
+ ```
239
+
240
+ ### Pattern 4: Manage Existing Posts
241
+ ```bash
242
+ # List all posts to get IDs
243
+ postiz posts:list
244
+
245
+ # Delete a specific post
246
+ postiz posts:delete <post-id-from-list>
247
+ ```
248
+
249
+ ### Pattern 5: Create Post with Comments and Media (Advanced)
250
+
251
+ ```bash
252
+ # Create a JSON file programmatically
253
+ cat > post.json << 'EOF'
254
+ {
255
+ "type": "now",
256
+ "date": "2024-01-15T12:00:00Z",
257
+ "shortLink": true,
258
+ "tags": [],
259
+ "posts": [{
260
+ "integration": { "id": "twitter-123" },
261
+ "value": [
262
+ {
263
+ "content": "Main post with 2 images ๐Ÿš€",
264
+ "image": [
265
+ { "id": "1", "path": "https://example.com/img1.jpg" },
266
+ { "id": "2", "path": "https://example.com/img2.jpg" }
267
+ ]
268
+ },
269
+ {
270
+ "content": "First comment with its own image ๐Ÿ“ธ",
271
+ "image": [
272
+ { "id": "3", "path": "https://example.com/comment-img.jpg" }
273
+ ],
274
+ "delay": 5000
275
+ }
276
+ ],
277
+ "settings": { "__type": "EmptySettings" }
278
+ }]
279
+ }
280
+ EOF
281
+
282
+ # Post it
283
+ postiz posts:create --json post.json
284
+ ```
285
+
286
+ ### Pattern 6: Multi-Platform Campaign
287
+
288
+ ```javascript
289
+ // AI Agent: Create coordinated multi-platform posts
290
+ const campaign = {
291
+ type: "schedule",
292
+ date: "2024-12-25T12:00:00Z",
293
+ shortLink: true,
294
+ tags: [{ value: "campaign", label: "Campaign" }],
295
+ posts: [
296
+ {
297
+ integration: { id: "twitter-123" },
298
+ value: [{
299
+ content: "Twitter-optimized content ๐Ÿฆ",
300
+ image: [{ id: "t1", path: "twitter-image.jpg" }]
301
+ }]
302
+ },
303
+ {
304
+ integration: { id: "linkedin-456" },
305
+ value: [{
306
+ content: "Professional LinkedIn content ๐Ÿ’ผ",
307
+ image: [{ id: "l1", path: "linkedin-image.jpg" }]
308
+ }]
309
+ },
310
+ {
311
+ integration: { id: "facebook-789" },
312
+ value: [
313
+ {
314
+ content: "Facebook main post ๐Ÿ“ฑ",
315
+ image: [{ id: "f1", path: "facebook-main.jpg" }]
316
+ },
317
+ {
318
+ content: "Additional context in comments",
319
+ image: [{ id: "f2", path: "facebook-comment.jpg" }],
320
+ delay: 300000 // 5 minutes later
321
+ }
322
+ ]
323
+ }
324
+ ]
325
+ };
326
+
327
+ require('fs').writeFileSync('campaign.json', JSON.stringify(campaign, null, 2));
328
+ execSync('postiz posts:create --json campaign.json');
329
+ ```
330
+
331
+ ### Pattern 7: Twitter Thread Creation
332
+
333
+ ```bash
334
+ # Create a thread with multiple tweets, each with media
335
+ postiz posts:create --json - << 'EOF'
336
+ {
337
+ "type": "now",
338
+ "date": "2024-01-15T12:00:00Z",
339
+ "shortLink": true,
340
+ "tags": [],
341
+ "posts": [{
342
+ "integration": { "id": "twitter-123" },
343
+ "value": [
344
+ {
345
+ "content": "๐Ÿงต Thread about X (1/3)",
346
+ "image": [{ "id": "1", "path": "https://example.com/thread-1.jpg" }]
347
+ },
348
+ {
349
+ "content": "Key point number 1 (2/3)",
350
+ "image": [{ "id": "2", "path": "https://example.com/thread-2.jpg" }],
351
+ "delay": 2000
352
+ },
353
+ {
354
+ "content": "Conclusion and CTA (3/3)",
355
+ "image": [{ "id": "3", "path": "https://example.com/thread-3.jpg" }],
356
+ "delay": 2000
357
+ }
358
+ ],
359
+ "settings": { "__type": "EmptySettings" }
360
+ }]
361
+ }
362
+ EOF
363
+ ```
364
+
365
+ ### Pattern 8: Upload Media, Then Post
366
+
367
+ ```bash
368
+ # 1. Upload images first
369
+ IMG1=$(postiz upload ./image1.jpg | jq -r '.path')
370
+ IMG2=$(postiz upload ./image2.jpg | jq -r '.path')
371
+
372
+ # 2. Create post with uploaded images
373
+ cat > post.json << EOF
374
+ {
375
+ "type": "now",
376
+ "date": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
377
+ "shortLink": true,
378
+ "tags": [],
379
+ "posts": [{
380
+ "integration": { "id": "twitter-123" },
381
+ "value": [{
382
+ "content": "Check out these images!",
383
+ "image": [
384
+ { "id": "img1", "path": "$IMG1" },
385
+ { "id": "img2", "path": "$IMG2" }
386
+ ]
387
+ }],
388
+ "settings": { "__type": "EmptySettings" }
389
+ }]
390
+ }
391
+ EOF
392
+
393
+ postiz posts:create --json post.json
394
+ ```
395
+
396
+ ## Output Format
397
+
398
+ All commands return JSON output, making it easy for AI agents to parse and process results:
399
+
400
+ ```json
401
+ {
402
+ "success": true,
403
+ "data": {
404
+ "id": "post-123",
405
+ "content": "Hello World!",
406
+ "scheduledDate": "2024-01-15T12:00:00Z"
407
+ }
408
+ }
409
+ ```
410
+
411
+ ## Error Handling
412
+
413
+ The CLI provides clear error messages:
414
+
415
+ - Missing API key: `โŒ Error: POSTIZ_API_KEY environment variable is required`
416
+ - API errors: `โŒ API Error (status): message`
417
+ - File not found: `โŒ Failed to upload file: message`
418
+
419
+ Exit codes:
420
+ - `0`: Success
421
+ - `1`: Error occurred
422
+
423
+ ## Environment Variables
424
+
425
+ | Variable | Required | Default | Description |
426
+ |----------|----------|---------|-------------|
427
+ | `POSTIZ_API_KEY` | Yes | - | Your Postiz API key |
428
+ | `POSTIZ_API_URL` | No | `https://api.postiz.com` | Custom API endpoint |
429
+
430
+ ## Tips for AI Agents
431
+
432
+ 1. **Always set the API key** before running commands
433
+ 2. **Parse JSON output** using tools like `jq` for scripting
434
+ 3. **Check exit codes** to determine if commands succeeded
435
+ 4. **Use integrations:list** first to get valid integration IDs
436
+ 5. **Schedule posts** in the future using ISO 8601 date format
437
+ 6. **Upload media first** before referencing in posts
438
+
439
+ ## Example Workflow Script
440
+
441
+ ```bash
442
+ #!/bin/bash
443
+
444
+ # Set API key
445
+ export POSTIZ_API_KEY="your-api-key-here"
446
+
447
+ # Get integrations
448
+ INTEGRATIONS=$(postiz integrations:list)
449
+ echo "Available integrations: $INTEGRATIONS"
450
+
451
+ # Create a post
452
+ postiz posts:create \
453
+ -c "Automated post from AI agent" \
454
+ -s "2024-12-25T12:00:00Z" \
455
+ -i "twitter-123,linkedin-456"
456
+
457
+ # List all posts
458
+ postiz posts:list -l 5
459
+
460
+ echo "โœ… Workflow completed!"
461
+ ```
462
+
463
+ ## Support
464
+
465
+ For issues or questions:
466
+ - GitHub: https://github.com/gitroomhq/postiz-app
467
+ - Documentation: https://postiz.com/docs
468
+ - API Reference: https://postiz.com/api-docs