Automations
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.
{
"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"
}
}
]
}'const res = await fetch("https://postkea.com/api/v1/automations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.POSTKEA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
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",
},
},
],
}),
});
const { data: automation } = await res.json();
console.log(automation);import os, requests
r = requests.post(
"https://postkea.com/api/v1/automations",
headers={"Authorization": f"Bearer {os.environ['POSTKEA_API_KEY']}"},
json={
"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",
},
},
],
},
)
automation = r.json()["data"]
print(automation)Triggers
Six triggers start an automation:
Trigger payloads
Whatever started the run is available to the steps as trigger:
202 right away and the run happens in the background.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.
scrape: Runs any scraping operation and outputs its data. Costs what the operation costs.download: Downloads a video into the media library. Useresult.media.mediaItemin a latercreate_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 (statusfiltered) unlessvaluecontains one ofcontainsand none ofexcludes. Matching ignores case.create_post: Creates a post onaccountIds.modeisdraft(default),queue,noworschedule(indelayMinutes, 60 by default). Long text is split into threads automatically, andrequireApprovalsends it to the approval queue.platformSpecificDatais keyed by account id.create_idea: Saves an idea to the ideas board.webhook: POSTspayloadas JSON tourl, 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 withchannel: 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].urlanditems.0.urlare 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.
{
"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.
{
"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"
}
}
}'const res = await fetch("https://postkea.com/api/v1/automations/auto_9Xc1/run", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.POSTKEA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
trigger: {
type: "rss",
item: {
title: "We opened a second studio",
link: "https://studiolumen.com/blog/lisbon",
},
},
}),
});
const { data: run } = await res.json();
console.log(run);import os, requests
r = requests.post(
"https://postkea.com/api/v1/automations/auto_9Xc1/run",
headers={"Authorization": f"Bearer {os.environ['POSTKEA_API_KEY']}"},
json={
"trigger": {
"type": "rss",
"item": {
"title": "We opened a second studio",
"link": "https://studiolumen.com/blog/lisbon",
},
},
},
)
run = r.json()["data"]
print(run)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.