Automations

An automation is a trigger and a list of steps. When the trigger fires, the steps run in order and each one can use what the trigger and the earlier steps produced. Turn a new blog post into a queued post, a competitor's new video into an email digest, or a webhook from your shop into a draft.

How automations work

Create one with POST /v1/automations: a name, a trigger, up to 20 steps and active. Every step has an id (letters, numbers, dashes and underscores), a type and a config. The number of automations depends on the plan: 1 on Free, 10 on Creator, 50 on Pro and unlimited on Business.

Every new article in a feed becomes a queued post
{
  "name": "Blog to social",
  "trigger": {
    "type": "rss",
    "feedId": "feed_3hQx"
  },
  "steps": [
    {
      "id": "cap",
      "type": "ai_caption",
      "config": {
        "brief": "{{trigger.item.title}} {{trigger.item.link}}",
        "platforms": [
          "x",
          "linkedin"
        ]
      }
    },
    {
      "id": "post",
      "type": "create_post",
      "config": {
        "accountIds": [
          "acc_x_8f2k",
          "acc_li_3m9q"
        ],
        "content": "{{steps.cap.captions[0].text}}",
        "mode": "queue"
      }
    }
  ]
}
curl -X POST "https://postkea.com/api/v1/automations" \
  -H "Authorization: Bearer $POSTKEA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Blog to social",
  "trigger": {
    "type": "rss",
    "feedId": "feed_3hQx"
  },
  "steps": [
    {
      "id": "cap",
      "type": "ai_caption",
      "config": {
        "brief": "{{trigger.item.title}} {{trigger.item.link}}",
        "platforms": [
          "x",
          "linkedin"
        ]
      }
    },
    {
      "id": "post",
      "type": "create_post",
      "config": {
        "accountIds": [
          "acc_x_8f2k",
          "acc_li_3m9q"
        ],
        "content": "{{steps.cap.captions[0].text}}",
        "mode": "queue"
      }
    }
  ]
}'

Triggers

Six triggers start an automation:

TypeConfigDescription
schedule{ "everyMinutes": 60 } or { "cron": "09:00 1,3,5" }Runs every everyMinutes (5 to 43,200), or at a time of day with cron: HH:MM every day or HH:MM 1,3,5 on those weekdays (0 is Sunday), in the workspace time zone.
rss{ "feedId": "feed_..." }Runs once per new item of a followed RSS or Atom feed, up to 10 items per refresh. Follow feeds with POST /v1/feeds; they are checked every 30 minutes.
monitor{ "monitorId": "mon_..." }Runs when a monitor finds new posts.
webhook{}Runs when something posts JSON to the automation's own webhookUrl, returned when you create it.
post_published{ "platforms": ["instagram"] }Runs when one of your posts publishes, fully or partly. platforms limits it to posts that include those networks.
new_comment{ "accountId": "acc_...", "keywords": ["price"] }Runs for new comments in the inbox, optionally only for one accountId and only when the comment contains one of the keywords.

Trigger payloads

Whatever started the run is available to the steps as trigger:

TypeWhat the steps see as trigger
schedule{ "type": "schedule", "at": "..." }
rss{ "type": "rss", "feedId", "item": { "title", "link", "summary", "imageUrl" } }
monitor{ "type": "monitor.new_items", "data": { "monitorId", "name", "platform", "items": [...] } }
webhook{ "type": "webhook", "body": <your JSON>, "receivedAt" }
post_published{ "type": "post.published", "data": { "post": {...} } }
new_comment{ "type": "comment.received", "data": { "accountId", "comment": {...} } }
The webhook trigger URL is the secret: anyone who has it can start the automation, so treat it like a password. The call returns 202 right away and the run happens in the background.
cURL
curl -X POST https://postkea.com/api/hooks/automations/AUTOMATION_TOKEN \
  -H "Content-Type: application/json" \
  -d '{ "title": "New product", "url": "https://shop.example.com/p/42" }'

Steps

Steps run one after another. If a step fails, the run stops, is marked failed, and an automation.run_failed event and a notification are sent.

StepConfigOutput
scrape{ "operation": "youtube.summarize", "input": { "url": "..." } }the operation's data
download{ "url": "...", "quality": "720p", "format": "mp4" }{ "result": { "title", "durationSec", "media": { "mediaItem" } } }
summarize{ "text": "...", "title": "..." }{ "summary", "keyPoints", "topics", "takeaways", "sentiment" }
ai_rewrite{ "text": "...", "action": "shorten", "instruction": "...", "platform": "x" }{ "text" }
ai_caption{ "brief": "...", "platforms": ["x", "linkedin"], "tone": "...", "language": "en" }{ "captions": [{ "platform", "text" }] }
translate{ "text": "...", "languages": ["de", "fr"] }{ "translations": [{ "language", "text" }] }
filter{ "value": "{{trigger.item.title}}", "contains": ["launch"], "excludes": ["sponsored"] }{ "pass" }
create_post{ "accountIds": ["acc_..."], "content": "...", "mediaItems": [...], "mode": "queue" }{ "postId", "status" }
create_idea{ "title": "...", "body": "...", "url": "..." }{ "ideaId" }
webhook{ "url": "https://...", "payload": {...} }{ "status", "ok" }
notify{ "channel": "email", "title": "...", "body": "...", "link": "..." }{ "sent" }
  • scrape: Runs any scraping operation and outputs its data. Costs what the operation costs.
  • download: Downloads a video into the media library. Use result.media.mediaItem in a later create_post.
  • summarize: Summarizes text, for example a transcript from a scrape step.
  • ai_rewrite: Rewrites text with one of the rewrite actions of AI endpoints.
  • ai_caption: Writes one caption per platform from a brief.
  • translate: Translates text into one or more languages.
  • filter: Stops the run (status filtered) unless value contains one of contains and none of excludes. Matching ignores case.
  • create_post: Creates a post on accountIds. mode is draft (default), queue, now or schedule (in delayMinutes, 60 by default). Long text is split into threads automatically, and requireApproval sends it to the approval queue. platformSpecificData is keyed by account id.
  • create_idea: Saves an idea to the ideas board.
  • webhook: POSTs payload as JSON to url, or the whole run (trigger and step outputs) when there is no payload.
  • notify: Sends an in-app notification to the workspace, or an email to its owners and admins with channel: email.

Placeholders

Any string in a step's config can include placeholders in double braces. {{trigger.item.title}} reads from the trigger payload and {{steps.cap.captions[0].text}} reads from the output of the step with id cap.

  • Paths use dots and array indexes: items[0].url and items.0.url are the same.
  • When a string is only a placeholder, the value is used as it is, so objects and lists stay objects and lists. That is how media moves between steps: "mediaItems": ["{{steps.dl.result.media.mediaItem}}"].
  • Inside longer text, objects are written as JSON and missing values become empty.

Examples

Email a summary of each new competitor video

A monitor trigger on a competitor's YouTube channel, a scrape step that summarizes the newest video, and an email.

POST /v1/automations
{
  "name": "Competitor video digest",
  "trigger": {
    "type": "monitor",
    "monitorId": "mon_7Lw2"
  },
  "steps": [
    {
      "id": "sum",
      "type": "scrape",
      "config": {
        "operation": "youtube.summarize",
        "input": {
          "url": "{{trigger.data.items[0].url}}"
        }
      }
    },
    {
      "id": "tell",
      "type": "notify",
      "config": {
        "channel": "email",
        "title": "New video from {{trigger.data.name}}",
        "body": "{{steps.sum.summary}}"
      }
    }
  ]
}

Turn a webhook from your shop into a draft

Your shop posts a product to the automation's webhook URL; Postkea downloads the product video, writes a caption and saves an Instagram draft for review.

POST /v1/automations
{
  "name": "New product to Instagram",
  "trigger": {
    "type": "webhook"
  },
  "steps": [
    {
      "id": "dl",
      "type": "download",
      "config": {
        "url": "{{trigger.body.videoUrl}}",
        "quality": "1080p"
      }
    },
    {
      "id": "cap",
      "type": "ai_caption",
      "config": {
        "brief": "{{trigger.body.title}}: {{trigger.body.description}}",
        "platforms": [
          "instagram"
        ]
      }
    },
    {
      "id": "post",
      "type": "create_post",
      "config": {
        "accountIds": [
          "acc_ig_5t1p"
        ],
        "content": "{{steps.cap.captions[0].text}}",
        "mediaItems": [
          "{{steps.dl.result.media.mediaItem}}"
        ],
        "mode": "draft"
      }
    }
  ]
}

Test and inspect runs

POST /v1/automations/{id}/run runs the steps right away with a test trigger payload and returns each step's status and output. Add background: true to queue it instead.

curl -X POST "https://postkea.com/api/v1/automations/auto_9Xc1/run" \
  -H "Authorization: Bearer $POSTKEA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "trigger": {
    "type": "rss",
    "item": {
      "title": "We opened a second studio",
      "link": "https://studiolumen.com/blog/lisbon"
    }
  }
}'

GET /v1/automations/{id}/runs lists the last 100 runs with their trigger, status (succeeded, filtered or failed), each step's output and the error. Pause an automation with PATCH and active: false.