curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"platform": "instagram",
"name": "Spring promo",
"triggers": [
{
"type": "comment_keyword",
"postId": "17895695668004550",
"keywords": ["INFO", "LINK"]
}
],
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com"
}
]
}' \
-X POST https://api.ayrshare.com/api/automations
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/automations", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
platform: "instagram",
name: "Spring promo",
triggers: [
{
type: "comment_keyword",
postId: "17895695668004550",
keywords: ["INFO", "LINK"],
},
],
actions: [
{
type: "send_dm",
message: "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
},
],
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
"platform": "instagram",
"name": "Spring promo",
"triggers": [
{
"type": "comment_keyword",
"postId": "17895695668004550",
"keywords": ["INFO", "LINK"],
}
],
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
}
],
}
headers = {
"Authorization": "Bearer API_KEY",
"Content-Type": "application/json",
}
r = requests.post(
"https://api.ayrshare.com/api/automations",
json=payload,
headers=headers,
)
print(r.json())
$curl = curl_init();
$data = [
"platform" => "instagram",
"name" => "Spring promo",
"triggers" => [
[
"type" => "comment_keyword",
"postId" => "17895695668004550",
"keywords" => ["INFO", "LINK"],
],
],
"actions" => [
[
"type" => "send_dm",
"message" => "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
],
],
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/automations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status": "success",
"id": "auto_9xKp2Lm4nQ"
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": [],
"fieldErrors": {
"actions": ["message contains unknown template variables"]
}
}
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": [],
"fieldErrors": {
"triggers": ["Invalid input: expected array, received undefined"]
}
}
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": ["Unrecognized key: \"accountId\""],
"fieldErrors": {}
}
}
{
"action": "automation",
"status": "error",
"code": 468,
"message": "Instagram DM automations require a Business or Enterprise plan"
}
{
"action": "request",
"status": "error",
"code": 472,
"message": "This feature is not yet available on your account. Please contact us if you'd like early access."
}
{
"action": "automation",
"status": "error",
"code": 471,
"message": "No social account linked on the requested platform for this profile. Link the account on the Social Accounts page and try again."
}
{
"action": "automation",
"status": "error",
"code": 470,
"message": "Active automation limit reached for your plan tier"
}
Automations
Create Automation
Create a new engagement-triggered automation
POST
/
automations
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"platform": "instagram",
"name": "Spring promo",
"triggers": [
{
"type": "comment_keyword",
"postId": "17895695668004550",
"keywords": ["INFO", "LINK"]
}
],
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com"
}
]
}' \
-X POST https://api.ayrshare.com/api/automations
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/automations", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
platform: "instagram",
name: "Spring promo",
triggers: [
{
type: "comment_keyword",
postId: "17895695668004550",
keywords: ["INFO", "LINK"],
},
],
actions: [
{
type: "send_dm",
message: "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
},
],
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
"platform": "instagram",
"name": "Spring promo",
"triggers": [
{
"type": "comment_keyword",
"postId": "17895695668004550",
"keywords": ["INFO", "LINK"],
}
],
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
}
],
}
headers = {
"Authorization": "Bearer API_KEY",
"Content-Type": "application/json",
}
r = requests.post(
"https://api.ayrshare.com/api/automations",
json=payload,
headers=headers,
)
print(r.json())
$curl = curl_init();
$data = [
"platform" => "instagram",
"name" => "Spring promo",
"triggers" => [
[
"type" => "comment_keyword",
"postId" => "17895695668004550",
"keywords" => ["INFO", "LINK"],
],
],
"actions" => [
[
"type" => "send_dm",
"message" => "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
],
],
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/automations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status": "success",
"id": "auto_9xKp2Lm4nQ"
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": [],
"fieldErrors": {
"actions": ["message contains unknown template variables"]
}
}
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": [],
"fieldErrors": {
"triggers": ["Invalid input: expected array, received undefined"]
}
}
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": ["Unrecognized key: \"accountId\""],
"fieldErrors": {}
}
}
{
"action": "automation",
"status": "error",
"code": 468,
"message": "Instagram DM automations require a Business or Enterprise plan"
}
{
"action": "request",
"status": "error",
"code": 472,
"message": "This feature is not yet available on your account. Please contact us if you'd like early access."
}
{
"action": "automation",
"status": "error",
"code": 471,
"message": "No social account linked on the requested platform for this profile. Link the account on the Social Accounts page and try again."
}
{
"action": "automation",
"status": "error",
"code": 470,
"message": "Active automation limit reached for your plan tier"
}
Beta. See the Automations Overview for the full feature description, including the Beta status.
accountId in the body; the request will be rejected as a validation error if you do. Pass a profileKey header to operate under a child profile.
Header Parameters
Body Parameters
Target platform. Only
instagram is supported in v1.Short human-readable name. Used in the dashboard and activity logs.
Optional longer description.
One or more triggers (1–50). Each entry is a discriminated union on
type. See Overview / Triggers for the full catalog.comment_keyword trigger
{
"type": "comment_keyword",
"postId": "17895695668004550", // required — Instagram media id
"keywords": ["INFO", "LINK"] // required — ≥1 entry, case-insensitive
}
story_reply trigger
{
"type": "story_reply",
"storyId": "17900000000000000" // optional — scope to one story
}
dm_reaction trigger
{
"type": "dm_reaction",
"emoji": "❤️" // optional — scope to one emoji
}
dm_keyword trigger
{
"type": "dm_keyword",
"keywords": ["help", "support"] // required — ≥1 entry, case-insensitive
}
One or more actions (1–50). Each entry is a discriminated union on
type. See Overview / Actions for the full catalog. Every action also accepts an optional top-level dedupWindowMinutes overriding the default 7-day per-recipient dedup window (0 to disable, max 525600).send_dm action
{
"type": "send_dm",
"message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com"
}
fire_webhook action
{
"type": "fire_webhook"
// POSTs to your account-level webhook URL (configured in the dashboard).
// See Overview for the JSON payload shape.
}
send_email action
{
"type": "send_email",
"to": "alerts@example.com",
"subject": "New {{platform}} engagement from @{{recipient_username}}",
"message": "<p>{{recipient_username}} engaged with: {{comment_text}}</p>"
}
Action with per-action dedup override
{
"type": "send_dm",
"message": "Thanks {{recipient_username}}!",
"dedupWindowMinutes": 1440 // 24h instead of the 7-day default
}
Platform compatibility. Each trigger and action declares which platforms it supports. The validator rejects the request when an entry’s
type is not supported on the requested platform. All triggers and send_dm are currently Instagram-only; fire_webhook and send_email are platform-agnostic.curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"platform": "instagram",
"name": "Spring promo",
"triggers": [
{
"type": "comment_keyword",
"postId": "17895695668004550",
"keywords": ["INFO", "LINK"]
}
],
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com"
}
]
}' \
-X POST https://api.ayrshare.com/api/automations
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/automations", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
platform: "instagram",
name: "Spring promo",
triggers: [
{
type: "comment_keyword",
postId: "17895695668004550",
keywords: ["INFO", "LINK"],
},
],
actions: [
{
type: "send_dm",
message: "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
},
],
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
"platform": "instagram",
"name": "Spring promo",
"triggers": [
{
"type": "comment_keyword",
"postId": "17895695668004550",
"keywords": ["INFO", "LINK"],
}
],
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
}
],
}
headers = {
"Authorization": "Bearer API_KEY",
"Content-Type": "application/json",
}
r = requests.post(
"https://api.ayrshare.com/api/automations",
json=payload,
headers=headers,
)
print(r.json())
$curl = curl_init();
$data = [
"platform" => "instagram",
"name" => "Spring promo",
"triggers" => [
[
"type" => "comment_keyword",
"postId" => "17895695668004550",
"keywords" => ["INFO", "LINK"],
],
],
"actions" => [
[
"type" => "send_dm",
"message" => "Hey {{recipient_username}}, here is the link you wanted: https://example.com",
],
],
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/automations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status": "success",
"id": "auto_9xKp2Lm4nQ"
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": [],
"fieldErrors": {
"actions": ["message contains unknown template variables"]
}
}
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": [],
"fieldErrors": {
"triggers": ["Invalid input: expected array, received undefined"]
}
}
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": ["Unrecognized key: \"accountId\""],
"fieldErrors": {}
}
}
{
"action": "automation",
"status": "error",
"code": 468,
"message": "Instagram DM automations require a Business or Enterprise plan"
}
{
"action": "request",
"status": "error",
"code": 472,
"message": "This feature is not yet available on your account. Please contact us if you'd like early access."
}
{
"action": "automation",
"status": "error",
"code": 471,
"message": "No social account linked on the requested platform for this profile. Link the account on the Social Accounts page and try again."
}
{
"action": "automation",
"status": "error",
"code": 470,
"message": "Active automation limit reached for your plan tier"
}
⌘I
