A complete, battle-tested guide and toolkit for publishing to Meta Threads via API — packaged as a Claude Code Skill.
Includes setup flow, multi-post threading with images, executable scripts, and Chrome automation guides for AI-driven workflows.
- Full setup flow — from creating a Meta App to obtaining a long-lived token (60-day)
- Multi-post threads — chain posts with
reply_to_id, mix text and images - Image support — upload to public URL (catbox.moe) + attach via
image_url - Executable script —
post-thread.shready to use with.envcredentials - Chrome automation guides — for both Claude Code and OpenAI Codex
- Pitfall documentation — 10+ real pitfalls encountered and documented at each step
git clone https://github.com/PRODUCTIVITYENHANCE/threads-api-skill.git
cd threads-api-skill
# Copy and fill in your credentials
cp .env.example .env
# Edit .env with your THREADS_APP_ID, THREADS_APP_SECRET, THREADS_USER_ID, THREADS_ACCESS_TOKEN# Edit content in post-thread.sh, then:
chmod +x post-thread.sh
./post-thread.shCopy the .claude/skills/threads-api/ folder into your project:
cp -r .claude/skills/threads-api/ YOUR_PROJECT/.claude/skills/threads-api/Then invoke in Claude Code:
/threads-api
.
├── README.md
├── .env.example ← Credential template
├── post-thread.sh ← Executable posting script
└── .claude/skills/threads-api/
├── SKILL.md ← Skill entry point
├── setup.md ← Full setup flow + 10 pitfalls
├── post-thread.md ← Thread posting guide + 7 pitfalls
├── post-thread.sh ← Script (also in skill folder)
├── chrome-setup-claude.md ← Claude Code × Chrome guide
└── chrome-setup-codex.md ← Codex × Chrome guide
Create Meta App → Add Tester → Accept Invitation
→ Graph API Explorer (switch to .threads.net/)
→ Generate Short-lived Token (1 hour)
→ Exchange for Long-lived Token (60 days)
Create Container (text/image) → Wait 30s → Publish
↓
Create Reply Container (reply_to_id) → Wait 30s → Publish
| Action | Method | Endpoint |
|---|---|---|
| Create container | POST | /{user_id}/threads |
| Publish | POST | /{user_id}/threads_publish |
| Refresh token | GET | /refresh_access_token |
These are real issues encountered during development — not hypothetical:
| # | Pitfall | Solution |
|---|---|---|
| 1 | Graph API Explorer defaults to .facebook.com/ |
Must switch API selector to .threads.net/ |
| 2 | "Generate Token" button missing | Switch API selector first — button only appears for Threads API |
| 3 | Image URL must be publicly accessible | Use catbox.moe (free, no signup); 0x0.st is dead |
| 4 | Container publish fails immediately | Wait 30 seconds between create and publish |
| 5 | Token expires silently | Long-lived token = 60 days; set a reminder to refresh |
See setup.md and post-thread.md for the full list.
This project includes guides for letting AI tools operate Chrome to handle login-gated steps (Meta Developer Console, Graph API Explorer):
- Claude Code →
chrome-setup-claude.md - OpenAI Codex →
chrome-setup-codex.md
# Refresh before expiry (within the 60-day window):
curl "https://graph.threads.net/refresh_access_token?grant_type=th_refresh_token&access_token=YOUR_TOKEN"MIT