Create a DM automation from a template
postkey_create_automationPostkey: Builds a new DRAFT Instagram DM automation from a template and returns its automation_id, for example comment-to-DM: send a link by DM when someone comments a keyword. It is made the same way as on Postkey's New automation screen. Use it for a new automation; to change one that exists use postkey_update_automation. It is not switched on: nobody gets a message until postkey_publish_automation (preview that first). Pass keyword and link_url when the template's needs_keyword or needs_link is true. The answer says back runs_on and followers_only (follow_note when follow-gated). Flow Builder templates come with SAMPLE words, listed in messages: rewrite them with postkey_update_automation messages before the preview. Refused before anything is made: no Instagram connected for DMs (needs_a_person: give the person the link in the message), an X account or one not connected for DMs (invalid_arguments), and a follow-gated automation on a Facebook Page (not_on_this_network). template_key x_comment_reply drafts replies to comments on X: pass keyword, link_url, one X account in social_account_ids, optionally replies and post_id. The answer has replies_preview, daily_ceiling, and needs_consent with consent_url if a person must first agree to replies on that account (only they can).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"template_key": "<template_key>"
},
"name": "postkey_create_automation"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dms | No | x_comment_reply only: DM each commenter instead of replying. 3-10 clearly different wordings; every {a|b} version needs a STOP line ("Reply STOP and I won't message you again."), max 50 versions. {{link}}, {{name}} work. Needs post_id of a post saying "Comment WORD and I'll DM you", and DMs turned on for that X account by the person in Postkey. replies become the fallback for closed DMs. | |
| name | No | A name for it, at most 120 characters. Left out: the template's own name. | |
| keyword | No | The word people comment or send to start it, for example "GUIDE". At most 60 characters. | |
| post_id | No | template x_comment_reply only: one post, as a post_id from postkey_list_posts or the link of a post on X. Left out: any post with this keyword. | |
| replies | No | template x_comment_reply only: the fixed replies, up to 10, in the order they rotate. Each carries the link: put {{link}} where it goes, or it is added at the end. No other variable works, and nothing is written per comment. Left out on create: the account's saved voice, or Postkey's suggestions. | |
| link_url | No | The link it hands out, https://... | |
| template_key | Yes | The template's key from postkey_list_automation_templates, for example comment_to_link. An unknown or unavailable key is refused. | |
| followers_only | No | Whether only followers get the link. People who have not messaged the account before first get a short "follow, then tap" message; followers then get the link, anyone else is asked to follow and tap again. false sends it to everyone. Left out: the account's default for new automations (on unless the account switched it off). Instagram only: true is refused for a Facebook Page (not_on_this_network). | |
| social_account_ids | No | The accounts it runs on, by id from postkey_list_social_accounts (accounts used for DMs: dms in used_for in postkey_get_started), up to 10. Left out: the profile's first active account connected for DMs, which may be a Facebook Page (a follow-gated template there is refused, code refused): pass an Instagram id to be sure. An X account, or one not used for DMs, is refused invalid_arguments. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | false: refused (isError; code, message, guide_topic, url); no change. | |
| url | No | Where a person opens it in Postkey. | |
| note | No | The next steps. | |
| limit | No | The plan's limit on automations switched on at once; null: none or not known. | |
| status | No | draft. | |
| runs_on | No | The accounts it runs on: platform, handle. | |
| live_now | No | Automations switched on now. | |
| messages | No | A Flow Builder template: its sample messages (step, kind, says, buttons, cards). Rewrite them with postkey_update_automation messages. | |
| connect_url | No | When no social account is connected: where the person connects one. | |
| follow_note | No | When follow-gated: where it runs, and that a Facebook Page cannot check follows. | |
| switched_on | No | Always false. | |
| connect_note | No | When no social account is connected: why it cannot go live yet. | |
| automation_id | No | The new automation's id. | |
| followers_only | No | true: only followers get the link. |