Postiz Social Media Scheduler
Direct API integration for social media posting. No n8n workflows needed.
Setup
Required Environment Variables
CODEBLOCK0
To find your integration IDs:
- 1. Go to your Postiz dashboard
- Navigate to Integrations or Channels
- Each connected account shows an ID (or use the API:
GET /api/integrations/list)
Platform Limits
| Platform | Character Limit | Notes |
|---|
| X/Twitter | 280 | Links count as 23 chars (t.co shortening) |
| LinkedIn |
3,000 | First 140 chars show in preview |
| Bluesky |
300 | Growing tech/developer audience |
Platform Content Guidelines
X/Twitter (280 chars)
- - Short, punchy content
- 1-2 hashtags max
- Threads for longer content (multiple tweets)
LinkedIn (3,000 chars)
- - Professional tone
- Can be longer-form
- Hashtags at end (3-5 recommended)
- First 140 chars show in preview — make them count!
Bluesky (300 chars)
- - Similar to X but slightly more room
- No official hashtag support (use sparingly)
- Growing tech/developer audience
Authentication
CODEBLOCK1
Cookie expires periodically. Re-run login if you get 401 errors.
Find Next Available Slot
CODEBLOCK2
Returns the next open time slot for a given channel. Useful for auto-scheduling without conflicts.
Upload Media from URL
CODEBLOCK3
Creating Posts
Schedule a Post (Single Platform)
CODEBLOCK4
Multi-Platform Post (Adapted Content)
CODEBLOCK5
Post Types
- -
schedule — Auto-publish at specified date/time - INLINECODE2 — Save for review (won't auto-publish)
- INLINECODE3 — Publish immediately
Listing & Querying Posts
Get Posts by Date Range (Required!)
CODEBLOCK6
Check for Duplicates Before Posting
CODEBLOCK7
Post States
| State | Description |
|---|
| INLINECODE4 | Scheduled, waiting to publish |
| INLINECODE5 |
Successfully posted |
|
ERROR | Failed to publish |
|
DRAFT | Saved but not scheduled |
Media Upload
Upload Image
CODEBLOCK8
Use in Post
CODEBLOCK9
Twitter/X Threads
For longer content on X, create a thread:
CODEBLOCK10
Managing Posts
Delete Post
CODEBLOCK11
Update Schedule
CODEBLOCK12
Best Practices
Avoid Duplicates
- 1. Always query existing posts before creating new ones
- Use unique identifiers in content (dates, specific references)
- Check both QUEUE and PUBLISHED states
Scheduling
- - Space posts at least 2-4 hours apart per platform
- Best times: 9 AM, 12 PM, 5 PM (audience timezone)
- Avoid posting same content to all platforms simultaneously
Content Adaptation
Don't just truncate! Rewrite for each platform:
- - X: Hook + key insight + CTA
- LinkedIn: Context + value + engagement question
- Bluesky: Casual tech-friendly tone
Helper Scripts
Post to Multiple Platforms
CODEBLOCK13
Check for Duplicates
CODEBLOCK14
Troubleshooting
401 Unauthorized
Re-run the login curl command to refresh cookie.
Post Not Publishing
- 1. Check state is
QUEUE not INLINECODE9 - Verify date is in the future
- Check integration is still connected in UI
Duplicate Posts
Always check existing posts before creating. The API doesn't deduplicate automatically.
Missing Environment Variables
Scripts will tell you which env vars are missing. Set them in your shell or
.env file:
CODEBLOCK15
Postiz 社交媒体调度器
用于社交媒体发布的直接 API 集成。无需 n8n 工作流。
设置
所需环境变量
bash
核心配置
export POSTIZ_URL=https://your-postiz-instance.com
export POSTIZ_EMAIL=your@email.com
export POSTIZ_PASSWORD=your-password
集成 ID(从 Postiz 仪表板 → 集成获取)
export POSTIZ
XID=your-x-integration-id
export POSTIZ
LINKEDINID=your-linkedin-integration-id
export POSTIZ
BLUESKYID=your-bluesky-integration-id
查找集成 ID 的方法:
- 1. 进入 Postiz 仪表板
- 导航至集成或频道
- 每个已连接的账户都会显示一个 ID(或使用 API:GET /api/integrations/list)
平台限制
| 平台 | 字符限制 | 备注 |
|---|
| X/Twitter | 280 | 链接计为 23 个字符(t.co 短链接) |
| LinkedIn |
3,000 | 前 140 个字符显示在预览中 |
| Bluesky |
300 | 不断增长的技术/开发者受众 |
平台内容指南
X/Twitter(280 字符)
- - 简短有力的内容
- 最多 1-2 个话题标签
- 长内容使用线程(多条推文)
LinkedIn(3,000 字符)
- - 专业语气
- 可较长篇幅
- 话题标签放在末尾(建议 3-5 个)
- 前 140 个字符显示在预览中——务必精心设计!
Bluesky(300 字符)
- - 类似 X 但空间稍大
- 无官方话题标签支持(谨慎使用)
- 不断增长的技术/开发者受众
身份验证
bash
登录并保存 Cookie(在任何 API 调用前必需)
curl -s -c /tmp/postiz-cookies.txt \
$POSTIZ_URL/api/auth/login \
-H Content-Type: application/json \
-d {\email\:\$POSTIZ
EMAIL\,\password\:\$POSTIZPASSWORD\,\provider\:\LOCAL\}
Cookie 会定期过期。如果遇到 401 错误,请重新运行登录。
查找下一个可用时段
bash
curl -s -b /tmp/postiz-cookies.txt \
$POSTIZURL/api/posts/find-slot/$POSTIZX_ID
返回指定频道的下一个空闲时段。用于自动调度时避免冲突。
从 URL 上传媒体
bash
curl -s -b /tmp/postiz-cookies.txt \
$POSTIZ_URL/api/media/upload-from-url \
-H Content-Type: application/json \
-d {url: https://example.com/image.png}
创建帖子
调度帖子(单平台)
bash
curl -s -b /tmp/postiz-cookies.txt \
$POSTIZ_URL/api/posts \
-H Content-Type: application/json \
-d {
\type\: \schedule\,
\date\: \2026-02-05T15:00:00Z\,
\posts\: [{
\integration\: {\id\: \$POSTIZXID\},
\value\: [{\content\: \您的推文内容(最多 280 字符)\, \image\: []}],
\settings\: {\type\: \x\}
}]
}
多平台帖子(适配内容)
bash
curl -s -b /tmp/postiz-cookies.txt \
$POSTIZ_URL/api/posts \
-H Content-Type: application/json \
-d {
\type\: \schedule\,
\date\: \2026-02-05T15:00:00Z\,
\posts\: [
{
\integration\: {\id\: \$POSTIZXID\},
\value\: [{\content\: \简短的 X 版本(最多 280 字符)\, \image\: []}],
\settings\: {\type\: \x\}
},
{
\integration\: {\id\: \$POSTIZLINKEDINID\},
\value\: [{\content\: \较长的 LinkedIn 版本,包含更多上下文和专业语气。最多可达 3000 字符。\, \image\: []}],
\settings\: {\type\: \linkedin\}
},
{
\integration\: {\id\: \$POSTIZBLUESKYID\},
\value\: [{\content\: \Bluesky 版本(最多 300 字符)\, \image\: []}],
\settings\: {\type\: \bluesky\}
}
]
}
帖子类型
- - schedule — 在指定日期/时间自动发布
- draft — 保存以供审核(不会自动发布)
- now — 立即发布
列出和查询帖子
按日期范围获取帖子(必需!)
bash
curl -s -b /tmp/postiz-cookies.txt \
$POSTIZ_URL/api/posts?startDate=2026-02-01T00:00:00Z&endDate=2026-02-08T00:00:00Z \
| jq .posts[] | {id, state, publishDate, platform: .integration.providerIdentifier, content: .content[0:60]}
发布前检查重复
bash
获取最近帖子并检查内容相似度
curl -s -b /tmp/postiz-cookies.txt \
$POSTIZ_URL/api/posts?startDate=2026-02-01T00:00:00Z&endDate=2026-02-08T00:00:00Z \
| jq -r .posts[] | \(.integration.providerIdentifier): \(.content[0:80])
帖子状态
| 状态 | 描述 |
|---|
| QUEUE | 已调度,等待发布 |
| PUBLISHED |
已成功发布 |
| ERROR | 发布失败 |
| DRAFT | 已保存但未调度 |
媒体上传
上传图片
bash
上传返回 {id, path}
curl -s -b /tmp/postiz-cookies.txt \
$POSTIZ_URL/api/media/upload-simple \
-F file=@/path/to/image.png
在帖子中使用
json
value: [{
content: 带图片的帖子,
image: [{id: MEDIA_ID, path: /uploads/...}]
}]
Twitter/X 线程
在 X 上发布较长内容时,创建线程:
json
value: [
{content: 推文 1/3:主题介绍..., image: []},
{content: 推文 2/3:主要观点解释..., image: []},
{content: 推文 3/3:结论和行动号召。, image: []}
]
管理帖子
删除帖子
bash
curl -s -b /tmp/postiz-cookies.txt -X DELETE \
$POSTIZ
URL/api/posts/POSTID
更新调度
bash
curl -s -b /tmp/postiz-cookies.txt -X PUT \
$POSTIZ
URL/api/posts/POSTID/date \
-H Content-Type: application/json \
-d {date: 2026-02-06T10:00:00Z}
最佳实践
避免重复
- 1. 在创建新帖子前始终查询现有帖子
- 在内容中使用唯一标识符(日期、特定引用)
- 同时检查 QUEUE 和 PUBLISHED 状态
调度
- - 每个平台帖子间隔至少 2-4 小时
- 最佳时间:上午 9 点、中午 12 点、下午 5 点(受众时区)
- 避免同时在所有平台发布相同内容
内容适配
不要只是截断!为每个平台重新编写:
- - X:钩子 + 关键见解 + 行动号召
- LinkedIn:上下文 + 价值 + 互动问题
- Bluesky:随意的技术友好语气
辅助脚本
发布到多个平台
bash
单平台
uv run scripts/post.py \
--platform x \
--content 您的推文内容 \
--schedule 2026-02-05T15:00:00Z
多平台不同内容
uv run scripts/post.py \
--x 简短的 X 版本 \
--linkedin 较