Complete Publishing Example#
This page shows a full end-to-end example for creating and scheduling a media post using the Swonkie API. It covers every step: fetching profiles, uploading media, creating a post, validating it, and scheduling it for publication.
Prerequisites#
Node.js 18 or higher (uses the built-in fetch API)
At least one social profile connected in your Swonkie workspace
Setup#
Define your credentials and a shared request helper used throughout the example.
Step 1 - List profiles#
Fetch the connected profiles in your workspace and pick the one you want to publish to.{
"id": "Tjg3YjhSU2xZREFqM1RqOTRnZTdpZz09",
"name": "Brand Official Page",
"username": "brandofficial",
"net": {
"name": "Facebook",
"code": "facebook"
},
"statusLevel": "OK"
}
Media upload is a four-step process: initiate, upload the file binary, confirm, then poll until processing completes.
Step 3 - Create the post#
Create a MEDIA post assigned to the selected profile. Setting publishAt saves it as a DRAFT with a scheduled time.
Step 4 - Validate the post#
Validate the post before scheduling. This checks profile connectivity, caption limits, media format support, and network-specific rules.
Step 5 - Schedule the post#
Move the post to SCHEDULED by calling the stage transition endpoint with the schedule action.A 200 response with success: true confirms the stage was changed and the post is queued for publication at the publishAt time.
Full example#
Notes#
Omitting net on captions and media applies the content to all networks assigned to the post. Set it to a specific network code (e.g. "facebook") to target one network only.
Publishing is asynchronous. A successful schedule response means the post is queued, not that it has already been published.
To publish immediately instead of scheduling, replace stage/schedule in Step 5 with stage/publishNow and remove publishAt from the post body.
The uploadUrl from Step 2 is a pre-signed URL and does not require Swonkie auth headers.
Modified at 2026-03-12 19:13:58