Direct API integration for social media posting. No n8n workflows needed.
# Core configuration
export POSTIZ_URL="https://your-postiz-instance.com"
export POSTIZ_EMAIL="your@email.com"
export POSTIZ_PASSWORD="your-password"
# Integration IDs (get from Postiz dashboard → Integrations)
export POSTIZ_X_ID="your-x-integration-id"
export POSTIZ_LINKEDIN_ID="your-linkedin-integration-id"
export POSTIZ_BLUESKY_ID="your-bluesky-integration-id"
To find your integration IDs:
GET /api/integrations/list)| Platform | Character Limit | Notes |
|---|---|---|
| ---------- | ----------------- | ------- |
| X/Twitter | 280 | Links count as 23 chars (t.co shortening) |
| 3,000 | First 140 chars show in preview | |
| Bluesky | 300 | Growing tech/developer audience |
# Login and save cookie (required before any API call)
curl -s -c /tmp/postiz-cookies.txt \
"$POSTIZ_URL/api/auth/login" \
-H 'Content-Type: application/json' \
-d "{\"email\":\"$POSTIZ_EMAIL\",\"password\":\"$POSTIZ_PASSWORD\",\"provider\":\"LOCAL\"}"
Cookie expires periodically. Re-run login if you get 401 errors.
curl -s -b /tmp/postiz-cookies.txt \
"$POSTIZ_URL/api/posts/find-slot/$POSTIZ_X_ID"
Returns the next open time slot for a given channel. Useful for auto-scheduling without conflicts.
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"}'
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\": \"$POSTIZ_X_ID\"},
\"value\": [{\"content\": \"Your tweet here (max 280 chars)\", \"image\": []}],
\"settings\": {\"__type\": \"x\"}
}]
}"
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\": \"$POSTIZ_X_ID\"},
\"value\": [{\"content\": \"Short X version (280 chars max)\", \"image\": []}],
\"settings\": {\"__type\": \"x\"}
},
{
\"integration\": {\"id\": \"$POSTIZ_LINKEDIN_ID\"},
\"value\": [{\"content\": \"Longer LinkedIn version with more context and professional tone. Can be up to 3000 characters.\", \"image\": []}],
\"settings\": {\"__type\": \"linkedin\"}
},
{
\"integration\": {\"id\": \"$POSTIZ_BLUESKY_ID\"},
\"value\": [{\"content\": \"Bluesky version (300 chars max)\", \"image\": []}],
\"settings\": {\"__type\": \"bluesky\"}
}
]
}"
schedule — Auto-publish at specified date/timedraft — Save for review (won't auto-publish)now — Publish immediatelycurl -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]}'
# Get recent posts and check content similarity
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])"'
| State | Description |
|---|---|
| ------- | ------------- |
QUEUE | Scheduled, waiting to publish |
PUBLISHED | Successfully posted |
ERROR | Failed to publish |
DRAFT | Saved but not scheduled |
# Upload returns {id, path}
curl -s -b /tmp/postiz-cookies.txt \
"$POSTIZ_URL/api/media/upload-simple" \
-F 'file=@/path/to/image.png'
"value": [{
"content": "Post with image",
"image": [{"id": "MEDIA_ID", "path": "/uploads/..."}]
}]
For longer content on X, create a thread:
"value": [
{"content": "Tweet 1/3: Introduction to the topic...", "image": []},
{"content": "Tweet 2/3: The main point explained...", "image": []},
{"content": "Tweet 3/3: Conclusion and call to action.", "image": []}
]
curl -s -b /tmp/postiz-cookies.txt -X DELETE \
"$POSTIZ_URL/api/posts/POST_ID"
curl -s -b /tmp/postiz-cookies.txt -X PUT \
"$POSTIZ_URL/api/posts/POST_ID/date" \
-H 'Content-Type: application/json' \
-d '{"date": "2026-02-06T10:00:00Z"}'
Don't just truncate! Rewrite for each platform:
# Single platform
uv run scripts/post.py \
--platform x \
--content "Your tweet here" \
--schedule "2026-02-05T15:00:00Z"
# Multi-platform with different content
uv run scripts/post.py \
--x "Short X version" \
--linkedin "Longer LinkedIn version with more detail" \
--bluesky "Bluesky version" \
--schedule "2026-02-05T15:00:00Z"
# Post immediately
uv run scripts/post.py \
--platform x \
--content "Posting now!" \
--now
# Validate without posting
uv run scripts/post.py \
--x "Test content" \
--validate
# Check last 30 days
uv run scripts/check_duplicates.py
# Check last 7 days
uv run scripts/check_duplicates.py --days 7
# Check if specific content would be duplicate
uv run scripts/check_duplicates.py --content "Your proposed post content"
Re-run the login curl command to refresh cookie.
QUEUE not DRAFTAlways check existing posts before creating. The API doesn't deduplicate automatically.
Scripts will tell you which env vars are missing. Set them in your shell or .env file:
export POSTIZ_URL="https://your-postiz.example.com"
export POSTIZ_EMAIL="your@email.com"
export POSTIZ_PASSWORD="your-password"
export POSTIZ_X_ID="your-integration-id"
共 1 个版本