1. Examples
swonkie.dev
  • Introduction
  • 🆕 MCP Server
  • Changelog
  • Quick Start
  • Social Networks
    • Instagram v2
    • Google My Business
    • YouTube
    • X (Twitter)
    • Threads
    • Instagram
    • LinkedIn
    • TikTok
    • Facebook
  • ✨ Andie
    • Generate an Image
      POST
  • Search
    • Search Profiles
      GET
  • Profiles
    • My Profiles
      GET
    • Competitors
      GET
  • Competitors
    • Add Competitor
      POST
    • Delete Competitor
      DELETE
  • Insights
    • Getting Started
    • My Profile Insights Metrics
      GET
    • My Profile Insights
      GET
    • My Profile Insights Posts
      GET
    • Competitor Insights Metrics
      GET
    • Competitor Insights
      GET
    • Competitor Insights Posts
      GET
  • Posts
    • Getting Started
    • Limits by Social Network
    • List Posts
    • Get a Post
    • Create a Post
    • Update a Post
    • Validate a Post
    • Delete a Post
    • Change Post Stage
  • Labels
    • Getting Started
    • List Labels
    • Create a Label
  • Media
    • Get a Media
    • Create a Media
    • Upload File to Media
    • Confirm Uploaded Media
    • Delete a Media
    • Create a Media from URL
  • 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-06-19 16:25:33
Previous
Examples
Built with