Quickstart: draft, schedule, publish
You need a personal access token and your workspace slug (it's in the app's URL). New to posts and variants? A post is the platform-agnostic container; each variant is the publishable per-platform content.
Draft → schedule → publish
BASE=https://api.writemars.com
AUTH="X-API-Key: writemars_pat_..."
WS=my-team # your workspace slug
# 1. Create a post (the platform-agnostic container)
POST_ID=$(curl -s -X POST "$BASE/api/workspaces/$WS/posts/" \
-H "$AUTH" -H "Content-Type: application/json" \
-d '{"title": "Launch announcement"}' | jq -r .id)
# 2. Choose the LinkedIn posting account
PROFILE_ID=$(curl -s -H "$AUTH" "$BASE/api/workspaces/$WS/social-profiles/?type=scheduling" \
| jq -r '.[] | select(.platform=="linkedin" and .is_active==true) | .id' | head -n 1)
# 3. Add one LinkedIn variant with the publishable content and posting account
VARIANT_ID=$(curl -s -X POST "$BASE/api/workspaces/$WS/posts/$POST_ID/variants/" \
-H "$AUTH" -H "Content-Type: application/json" \
-d "{\"platform\": \"linkedin\", \"content\": \"We just shipped something big...\", \"social_profile_id\": \"$PROFILE_ID\"}" \
| jq -r .id)
# 4a. Schedule it — WriteMars publishes it automatically at this time
curl -s -X PATCH "$BASE/api/workspaces/$WS/posts/$POST_ID/variants/$VARIANT_ID/" \
-H "$AUTH" -H "Content-Type: application/json" \
-d '{"scheduled_at": "2026-09-20T09:00:00Z"}'
# 4b. ...or publish right now (returns platform_post_url)
curl -s -X POST "$BASE/api/workspaces/$WS/posts/$POST_ID/variants/$VARIANT_ID/publish/" -H "$AUTH"
Variants need a connected posting account to schedule or publish. If you omit social_profile_id, WriteMars falls back to the platform's default connected account when one is available. Passing "social_profile_id": null creates the variant without an account so it can be assigned later. Setting "scheduled_at": null returns a scheduled variant to draft.
Publishing to a channel that requires sign-off never errors — the variant comes back with status needs_approval and goes out once the channel's approvers release it. See Approvals.
Reading data
curl -s -H "$AUTH" "$BASE/api/workspaces/$WS/posts/" # posts you can see
curl -s -H "$AUTH" "$BASE/api/workspaces/$WS/posts/$POST_ID/" # one post
curl -s -H "$AUTH" "$BASE/api/workspaces/$WS/posts/$POST_ID/variants/" # its variants
curl -s -H "$AUTH" "$BASE/api/workspaces/$WS/posts/$POST_ID/activity/" # audit log
curl -s -H "$AUTH" "$BASE/api/workspaces/$WS/social-profiles/" # connected accounts
Long lists support an opt-in envelope — see Pagination.
Next
- Full endpoint reference — every endpoint, request, and response
- Swagger UI — try them live with your token
- Something failing? Troubleshooting API errors