staqlydocs

Scripts & SDK

Write, schedule and publish posts from shell scripts, the SDKs or any HTTP client.

Edit on GitHub

Use the REST API when your automation is a script, a backend service or anything else that is not an MCP agent. Everything the dashboard and the agents do goes through this same API at http://localhost:3333. Every request carries Authorization: Bearer ...: in Staqly Community Edition the access token staqly prints at start (staqly serve token, Docker: docker exec staqly server token), in cloud mode an API key stk_.... The SDKs read it from STAQLY_API_KEY.

Example: list what is scheduled and publish a draft

This example lists next week's calendar, creates a draft and publishes it. Set CHANNEL to a channel ID (ch_7h2kq9xw3nbvd5yhzm6a) first.

API=http://localhost:3333
export STAQLY_API_KEY=$(staqly serve token)   # Docker: $(docker exec staqly server token)
AUTH="Authorization: Bearer $STAQLY_API_KEY"

# the calendar for the next seven days
curl -s "$API/v1/posts?status=scheduled&publish_after=2026-10-20&publish_before=2026-10-27" -H "$AUTH"

# a draft, then publish it now
POST=$(curl -s -X POST $API/v1/posts -H "$AUTH" -H 'Content-Type: application/json' \
  -d "{\"collection\":\"Product updates\",\"content\":\"v1.4 is out.\",\"targets\":[{\"channel_id\":\"$CHANNEL\"}]}" | jq -r .id)
curl -s -X POST $API/v1/posts/$POST/publish -H "$AUTH"

# history
curl -s $API/v1/posts/$POST/events -H "$AUTH"

The SDKs install with npm install @staqly/sdk and pip install staqly; see the TypeScript SDK and Python SDK pages.

To connect a channel first, see Connect a channel in the Quickstart.

Calling staqly from inside Docker

With the Docker image, put the script's container on a network with the staqly container and give it the alias api:

docker network create staqly-net
docker network connect --alias api staqly-net staqly
docker run --rm --network staqly-net -e STAQLY_API_KEY curlimages/curl -s http://api:3333/v1/collections \
  -H "Authorization: Bearer $STAQLY_API_KEY"

Any host name works: what lets the request in is the access token, not where it comes from.

Loading demo data

With a checkout of the repository, scripts/seed.sh loads demo collections and posts through the public API, so events and webhooks fire as usual. It calls http://localhost:3333, so it works with staqly serve and Docker alike, with the access token in STAQLY_API_KEY (STAQLY_API_KEY=$(staqly serve token) scripts/seed.sh). In cloud mode: STAQLY_API_URL=https://app.staqly.ai STAQLY_API_KEY=stk_... scripts/seed.sh.

Next steps

On this page