Skip to content

Publishing a scheduled post (curl)

This guide walks through a complete happy-path workflow: upload media, create a scheduled post, watch it publish, and confirm the webhook.

  • An API key exported as NATIVPOST_API_KEY.
  • A publicly reachable HTTPS endpoint that returns 200 for POST requests. Use webhook.site for a quick sandbox.
  • At least one connected social account. This guide targets X.
Terminal window
MEDIA_ID=$(curl -sS -X POST https://app.nativpost.com/api/v1/media_assets \
-H "Authorization: Bearer $NATIVPOST_API_KEY" \
-F "file=@./launch-banner.jpg" \
-F "tags=launch" \
| jq -r ".id")
echo "Uploaded $MEDIA_ID"
Terminal window
curl -X POST https://app.nativpost.com/api/v1/webhooks \
-H "Authorization: Bearer $NATIVPOST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://webhook.site/your-uuid-here",
"events": ["content.published", "content.publish_failed"]
}'

Copy the returned signing_secret into your endpoint’s environment.

3. Create the post scheduled for one hour from now

Section titled “3. Create the post scheduled for one hour from now”
Terminal window
SCHEDULED_AT=$(date -u -d "+1 hour" +"%Y-%m-%dT%H:%M:%SZ")
CONTENT_ID=$(curl -sS -X POST https://app.nativpost.com/api/v1/content \
-H "Authorization: Bearer $NATIVPOST_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n \
--arg m "$MEDIA_ID" \
--arg s "$SCHEDULED_AT" \
'{
content_type: "photo",
platforms: ["x"],
body_text: "Launch day.",
media_asset_ids: [$m],
status: "scheduled",
scheduled_at: $s
}')" \
| jq -r ".id")
echo "Created $CONTENT_ID at $SCHEDULED_AT"
Terminal window
curl -sS https://app.nativpost.com/api/v1/content/$CONTENT_ID \
-H "Authorization: Bearer $NATIVPOST_API_KEY" | jq ".status, .scheduled_at"

Expect "scheduled" and the timestamp from step 3.

If you would rather not wait an hour, call publish:

Terminal window
curl -X POST https://app.nativpost.com/api/v1/content/$CONTENT_ID/publish \
-H "Authorization: Bearer $NATIVPOST_API_KEY" | jq

The response includes per-platform results. Your webhook endpoint receives a content.published event within a second or two.

Inspect the delivery log to confirm the endpoint returned 2xx:

Terminal window
curl -sS https://app.nativpost.com/api/v1/webhooks/$WEBHOOK_ID/deliveries?limit=5 \
-H "Authorization: Bearer $NATIVPOST_API_KEY" | jq

That is the entire flow. From here, wrap steps 1-3 in your own scripts or move to the Zapier / n8n guides.