Core Workflows

View as Markdown

This page is the canonical request-flow reference for Publora examples. Language and framework guides provide syntax and setup; the semantics live here. For the complete API surface, use the OpenAPI document.

Setup

export PUBLORA_API_KEY="sk_YOUR_API_KEY"
export PUBLORA_PLATFORM_ID="twitter-YOUR_CONNECTION_ID"
export PUBLORA_BASE_URL="https://api.publora.com/api/v1"

REST requests require x-publora-key. Platform IDs come from List Platform Connections.

1. Create a draft

Omitting scheduledTime intentionally creates a draft. A draft does not publish.

curl -sS -X POST "$PUBLORA_BASE_URL/create-post" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"content\":\"Draft from Publora\",\"platforms\":[\"$PUBLORA_PLATFORM_ID\"]}"

The response contains success, postGroupId, and scheduledTime (null for this draft). Save the 24-character hexadecimal postGroupId for later operations.

2. One-shot schedule

scheduledTime must be a future ISO 8601 timestamp. This runnable example schedules five minutes ahead:

FUTURE_TIME=$(date -u -v+5M +%Y-%m-%dT%H:%M:%S.000Z 2>/dev/null || date -u -d '+5 minutes' +%Y-%m-%dT%H:%M:%S.000Z)
 
curl -sS -X POST "$PUBLORA_BASE_URL/create-post" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: schedule-$(date +%s)" \
  -d "{\"content\":\"Scheduled from Publora\",\"platforms\":[\"$PUBLORA_PLATFORM_ID\"],\"scheduledTime\":\"$FUTURE_TIME\"}"

Use a stable Idempotency-Key when retrying the same logical request. Do not generate a new key for each retry.

3. Upload and schedule

The presigned-upload flow is create draft → get-upload-url → upload bytes → complete-media → update-post to schedule. Scheduling last avoids the media-attachment demotion behavior.

# Create a draft and copy postGroupId from the response.
POST_GROUP_ID="64f1a2b3c4d5e6f7890abcde"
 
# Request an upload URL. Copy uploadUrl and mediaId from the response.
curl -sS -X POST "$PUBLORA_BASE_URL/get-upload-url" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"fileName\":\"photo.jpg\",\"contentType\":\"image/jpeg\",\"type\":\"image\",\"postGroupId\":\"$POST_GROUP_ID\"}"
 
UPLOAD_URL="<UPLOAD_URL_FROM_RESPONSE>"
MEDIA_FILE_ID="<MEDIA_ID_FROM_RESPONSE>"
 
curl -sS -X PUT "$UPLOAD_URL" -H "Content-Type: image/jpeg" --data-binary @photo.jpg
 
# Probe/finalize the uploaded object before scheduling.
curl -sS -X POST "$PUBLORA_BASE_URL/complete-media/$MEDIA_FILE_ID" \
  -H "x-publora-key: $PUBLORA_API_KEY"
 
FUTURE_TIME=$(date -u -v+5M +%Y-%m-%dT%H:%M:%S.000Z 2>/dev/null || date -u -d '+5 minutes' +%Y-%m-%dT%H:%M:%S.000Z)
curl -sS -X PUT "$PUBLORA_BASE_URL/update-post/$POST_GROUP_ID" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: media-schedule-$POST_GROUP_ID" \
  -d "{\"status\":\"scheduled\",\"scheduledTime\":\"$FUTURE_TIME\"}"

For public HTTPS assets, mediaUrls on create/update is a shorter ingestion path. See Media Uploads for its limits and append semantics.

For a file reference, meaning a download URL plus a stable file ID such as ChatGPT supplies, use attach-media. It downloads the file right away and leaves the post in draft. The idempotency key matches on the file ID and name, so a retry with a refreshed URL doesn't attach the file twice:

curl -sS -X POST "$PUBLORA_BASE_URL/attach-media/$POST_GROUP_ID" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: attach-$POST_GROUP_ID-file-abc123" \
  -d '{"file":{"download_url":"https://files.example.com/download/abc123?signature=TEMPORARY","file_id":"file-abc123"},"fileName":"spring-launch-banner.png"}'

Then schedule with update-post as above. See Attach Media.

4. Update a post

Update accepts at least one of publishNow, status, scheduledTime, content, platforms, platformSettings, firstComment, firstComments, or mediaUrls. Omitted fields keep their stored value. mediaUrls appends media rather than replacing existing items; platforms does the opposite — it replaces the whole target set.

POST_GROUP_ID="64f1a2b3c4d5e6f7890abcde"
FUTURE_TIME=$(date -u -v+10M +%Y-%m-%dT%H:%M:%S.000Z 2>/dev/null || date -u -d '+10 minutes' +%Y-%m-%dT%H:%M:%S.000Z)
 
curl -sS -X PUT "$PUBLORA_BASE_URL/update-post/$POST_GROUP_ID" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: reschedule-$POST_GROUP_ID" \
  -d "{\"status\":\"scheduled\",\"scheduledTime\":\"$FUTURE_TIME\"}"

Correct the text and the target accounts of a draft or scheduled post. Copy the connection IDs verbatim from GET /platform-connections — the array replaces the stored one:

curl -sS -X PUT "$PUBLORA_BASE_URL/update-post/$POST_GROUP_ID" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: edit-$POST_GROUP_ID" \
  -d '{"content":"Corrected launch announcement.","platforms":["linkedin-ABC123","threads-DEF456"]}'

Publish a draft or scheduled post immediately, at server time:

curl -sS -X PUT "$PUBLORA_BASE_URL/update-post/$POST_GROUP_ID" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: publish-now-$POST_GROUP_ID" \
  -d '{"publishNow":true}'

See Update Post for validation and state behavior, and Publish now for the limits it uses.

5. Verify a webhook

Publora signs the exact request-body bytes with HMAC-SHA256. Verify the raw bytes before parsing JSON.

import crypto from 'node:crypto';
import express from 'express';
 
const app = express();
const secret = process.env.PUBLORA_WEBHOOK_SECRET;
 
app.post('/publora-webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const received = req.get('x-publora-signature') || '';
  const expected = crypto.createHmac('sha256', secret).update(req.body).digest('hex');
  const valid = received.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected));
 
  if (!valid) return res.sendStatus(401);
  const envelope = JSON.parse(req.body.toString('utf8'));
  console.log(envelope.event, envelope.data);
  return res.sendStatus(200);
});

Delivery is a single attempt per event, not a retry queue. Respond quickly with 2xx; see Webhooks for events, failure counting, and re-enabling disabled webhooks.

The five workflows above are the shared example contract, not the entire API. Use the endpoint pages and OpenAPI for connections, account context (GET /account-context: plan, quotas and schedule horizon), listing and deleting posts, platform limits, post logs, LinkedIn engagement and analytics, Mastodon and Bluesky statistics, and webhook administration.

Agency platform settings

Company endpoints use an exact Workspace header and a stable mutation key. Verify the available formats with Company /platforms before using newly added settings. See the Agency platform settings guide for the complete upload and approval workflow. Choose a new key for every new intended edit (including another post or different settings); reuse it only for retries of the identical request. Set EDIT_KEY once for this edit; when retrying, keep its value and rerun only the curl command:

EDIT_KEY="$(uuidgen)"
 
curl -X PATCH "https://api.publora.com/api/v1/company/post-groups/$POST_GROUP_ID" \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "X-Publora-Workspace-Id: $WORKSPACE_ID" \
  -H "Idempotency-Key: $EDIT_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"platformSettings":{"threads":{"replyControl":"mentioned_only"}}}'

This example replaces the complete settings map. Include the desired settings for other selected platforms in a multi-platform draft.

Agency LinkedIn Page sources

List published posts of a connected Company Page to pick a reshare source. The request is read-only and needs no Idempotency-Key. Use the Page connection's database ID from Company /connections, and follow paging.nextStart until it is null. See Agency LinkedIn Page reshares for drafts, reviews and decision webhooks.

curl -X POST 'https://api.publora.com/api/v1/company/linkedin-page-posts' \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "X-Publora-Workspace-Id: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"connectionId":"'"$PAGE_CONNECTION_ID"'","count":10}'

Read known Page posts by ID, with comment and reaction summaries, then list one post's comments or reactions. Follow paging.nextStart until it is null. See Agency LinkedIn Page reads for permissions and per-post errors.

curl -X POST 'https://api.publora.com/api/v1/company/linkedin-page-posts/batch' \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "X-Publora-Workspace-Id: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"connectionId":"'"$PAGE_CONNECTION_ID"'","postedIds":["'"$POSTED_ID"'"],"includeEngagement":true}'
 
curl -X POST 'https://api.publora.com/api/v1/company/linkedin-page-posts/comments' \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "X-Publora-Workspace-Id: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"connectionId":"'"$PAGE_CONNECTION_ID"'","postedId":"'"$POSTED_ID"'","count":10}'
 
curl -X POST 'https://api.publora.com/api/v1/company/linkedin-page-posts/reactions' \
  -H "x-publora-key: $PUBLORA_API_KEY" \
  -H "X-Publora-Workspace-Id: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"connectionId":"'"$PAGE_CONNECTION_ID"'","postedId":"'"$POSTED_ID"'","count":10}'