1. Examples
swonkie.dev
  • Introduction
  • Quick Start
  • Changelog
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • TikTok
    • Threads
  • Profiles
    • My Profiles
      GET
    • Competitors
      GET
  • Insights
    • Getting Started
    • My Profile Insights
      GET
    • My Profile Insights Posts
      GET
    • Competitor Insights
      GET
    • Competitor Insights Posts
      GET
  • Posts
    • Getting Started
    • List Posts
      GET
    • Get a Post
      GET
    • Create a Post
      POST
    • Update a Post
      PUT
    • Validate a Post
      GET
    • Delete a Post
      DELETE
    • Change Post Stage
      PATCH
  • Labels
    • Getting Started
    • List Labels
      GET
    • Create a Label
      POST
  • Media
    • Get a Media
    • Create a Media
    • Upload File to Media
    • Confirm Uploaded Media
    • Delete a Media
  • Examples
    • Publish
Back to Home
Back to Home
Login
  1. Examples

Publish

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
An App ID and API Key from app.swonkie.com/settings/workspace/public-api

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.
Response item shape
{
    "id": "Tjg3YjhSU2xZREFqM1RqOTRnZTdpZz09",
    "name": "Brand Official Page",
    "username": "brandofficial",
    "net": {
        "name": "Facebook",
        "code": "facebook"
    },
    "statusLevel": "OK"
}

Step 2 - Upload media#

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
Previous
Examples
Built with