DunSocial CLI
Use the dun binary from the npm package dunsocial.
npm install -g dunsocial
npx dunsocial …
Prefer --json on every command so output is machine-parseable.
Remote hosts (ChatGPT web, Claude web) keep using DunSocial MCP. This CLI is for local agents, terminals, and CI.
Env vars override ~/.config/dunsocial/config.json.
Setup
Always: authenticate → select workspace → verify → list accounts → act.
Do not invent social account IDs. Do not treat drafts create as a successful publish.
Interactive auth
Browser approve at app.dunsocial.com/cli/authorize:
dun auth login
Headless auth (CI)
Create a PAT in the app under Settings → CLI (dun_pat_…), then:
export DUN_TOKEN="dun_pat_…"
export DUN_API_URL=https://api.dunsocial.com
DUN_API_URL is optional (defaults to production).
PAT rules:
- Bound to one workspace; missing scope → exit
3/ forbidden - Cannot manage other tokens, billing, or team
- Prefer PAT over browser session tokens in CI
Workspace
Interactive:
dun workspace list --json
dun workspace use <id-or-slug> --json
Headless (required with PAT):
export DUN_WORKSPACE_ID="…"
Verify
dun auth status --json
dun workspace current --json
Discovery order
dun auth status --jsondun workspace current --json(orlist+use)dun accounts list --json— capture social account ids- Act (schedule / publish / draft / media / memory)
Schedule a post
dun posts schedule \
--text "Shipped from the DunSocial CLI." \
--accounts acc_x,acc_li \
--in 1h \
--json
Absolute time: --at 2026-06-01T09:00:00Z.
Publish now
dun posts publish --text "Hello from dun" --accounts acc_x --json
Media
Upload first, then attach the returned asset id:
dun media upload ./shot.png --alt "Product screenshot" --json
dun posts schedule --text "…" --accounts acc_x --media <assetId> --in 30m --json
Drafts, memory, threads
dun drafts create --text "WIP" --platforms x,linkedin --json
dun memory collections list --json
dun memory save --collection <id> --text "…" --json
dun memory search --prompt "…" --collections <id> --json
Thread file shape: [{"content":"1"},{"content":"2"}]
dun posts schedule-thread --account acc_x --file ./thread.json --in 2h --json
Destructive ops
Require --yes (or CI=1) for delete.
Exit codes
| Code | Meaning |
|---|---|
| 0 | ok |
| 1 | usage |
| 2 | auth |
| 3 | forbidden / missing scope |
| 4 | validation |
| 5 | not found |
| 6 | rate limited |
| 7 | network |
Failure JSON:
{
"ok": false,
"error": {
"code": "validation",
"message": "…",
"details": null
}
}
Pitfalls
- Need a workspace:
workspace use,--workspace, orDUN_WORKSPACE_ID --accountsexpects DunSocial social account ids, not handles- Upload local files with
media uploadbefore attaching - Platform-specific options:
--meta '{"reddit":{…}}'when needed - MCP OAuth and CLI tokens are different systems
Help
dun --help
dun posts --help