Run Atomatize from a script or scheduled job

Create an API key for a server, a cron job or CI, and turn articles into drafts with a short script.

Assistants you chat with connect by signing you in. Something that runs on its own, such as a cron job, a CI pipeline or an agent on a server, can't open a browser to do that, so it uses an API key instead.

Create a key

  1. Go to Settings > API & agents and choose Create an API key.
  2. Name it after where it will run, such as "Blog cron on web-01", so you know which key to revoke later.
  3. Tick only what the job needs. For a job that writes drafts, that's Read and Write. Leave Publish off for anything that runs unattended: drafts then wait for you to review and publish them.
  4. Tick the brands it may use. It can't see any other brand.
  5. Choose when it expires, then Create key.

Copy the key straight away. It starts with atz_ and is shown only once. If you lose it, revoke it and create another.

You can have up to 10 keys. Each key can make 60 calls a minute.

Keep it safe

A key acts as you within its brands and permissions. Store it in your secret store, CI secrets or an environment file only the job can read. Don't commit it to a repository, and don't paste it into a chat with an assistant. If a key might have leaked, Revoke it in Settings > API & agents; anything using it is cut off at once.

Use it from an MCP client

Most agent tools that run on a server accept an MCP server with headers. Add Atomatize with the key as a bearer token:

{
  "mcpServers": {
    "atomatize": {
      "type": "streamable-http",
      "url": "https://atomatize.com/api/mcp",
      "headers": { "Authorization": "Bearer atz_your_key" }
    }
  }
}

The agent then has the same tools as one that signed in. agents.md tells it how to use them.

Call it from a script

You don't need an MCP library. Each call is a single HTTPS request: a JSON-RPC tools/call posted to https://atomatize.com/api/mcp, with the key in an Authorization: Bearer header and Accept: application/json, text/event-stream. The answer is plain JSON. No session or handshake is needed first.

This script turns an article into drafts and waits until they're written, usually one to two minutes. It needs curl and jq.

#!/usr/bin/env bash
# Turn an article into Atomatize drafts, then wait until they're written.
# Needs ATOMATIZE_API_KEY (an API key with read and write) and jq. If the key covers
# more than one brand, set ATOMATIZE_BRAND to the brand's name or id.
set -euo pipefail
shopt -s inherit_errexit

ATOMATIZE_URL="${ATOMATIZE_URL:-https://atomatize.com/api/mcp}"

# Call one Atomatize tool and print its result as JSON. Stops the script on an error.
atomatize() {
  local body response error
  body=$(jq -n --arg name "$1" --argjson args "$2" --arg brand "${ATOMATIZE_BRAND:-}" \
    '{jsonrpc: "2.0", id: 1, method: "tools/call",
      params: {name: $name, arguments: ($args + if $brand == "" then {} else {brand: $brand} end)}}')
  response=$(curl -sS "$ATOMATIZE_URL" \
    -H "Authorization: Bearer $ATOMATIZE_API_KEY" \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json, text/event-stream' \
    -d "$body")
  error=$(jq -r '.error.message // if .result.isError then .result.content[0].text else empty end' <<<"$response")
  if [ -n "$error" ]; then
    echo "Atomatize: $error" >&2
    exit 1
  fi
  jq '.result.structuredContent' <<<"$response"
}

article="$1"
content_id=$(atomatize generate_drafts "$(jq -n --arg url "$article" '{url: $url}')" | jq -r '.content_id')
echo "Writing drafts for $article ($content_id)"

for _ in $(seq 1 30); do
  sleep 15
  status=$(atomatize get_content "$(jq -n --arg id "$content_id" '{content_id: $id}')" | jq -r '.content.status')
  case "$status" in
    ready) echo "Drafts are ready to review in Atomatize."; exit 0 ;;
    processing|pending) ;;
    *) echo "Generation ended with status $status. Open the source in Atomatize to retry." >&2; exit 1 ;;
  esac
done
echo "Still writing after 7 minutes. Check Atomatize later." >&2
exit 1

Save it as atomatize-drafts.sh, make it executable, and run it with an article or YouTube link:

ATOMATIZE_API_KEY=atz_your_key ./atomatize-drafts.sh https://example.com/blog/my-post

When it finishes, the drafts are in the web app, ready to review. If something goes wrong, the script prints Atomatize's message, such as an invalid key or a used-up monthly limit, and exits with an error.

Run it on a schedule

Call the script from the job that publishes your blog, so each new post becomes drafts, or from cron. Keep the key in a file only you can read rather than in the crontab:

# ~/.config/atomatize.env (chmod 600)
export ATOMATIZE_API_KEY=atz_your_key
# crontab: every Monday at 08:00
0 8 * * 1  . "$HOME/.config/atomatize.env" && "$HOME/bin/atomatize-drafts.sh" https://example.com/blog/this-week

Before you schedule anything:

  • Mind your monthly limit. Each source counts once toward it, the same as in the web app, so a job that runs often can use up the month. get_usage shows what's left.
  • Don't let it publish. A key without Publish can't post. Review the drafts in the web app, then publish or schedule the ones you like.
  • Check on it. Settings > API & agents shows when each key was last used.

Other tools

The script uses generate_drafts and get_content. The rest, such as list_brands, get_usage, list_content, regenerate_output and schedule_output, work the same way: change the tool name and the arguments. agents.md lists the flow and what each error means, and tools/list returns every tool with its arguments.