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
Tạo Automation
Tạo một automation mới được kích hoạt bởi tương tác
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. Xem Tổng quan về Automations để biết mô tả đầy đủ về tính năng, bao gồm cả trạng thái Beta.
accountId trong body; yêu cầu sẽ bị từ chối như một lỗi validation nếu bạn làm như vậy. Truyền header profileKey để thao tác dưới một profile con.
Tham số Header
Tham số Body
Nền tảng đích. Chỉ
instagram được hỗ trợ trong v1.Tên ngắn có thể đọc được bởi con người. Được sử dụng trong bảng điều khiển và nhật ký activity.
Mô tả dài hơn tùy chọn.
Một hoặc nhiều trigger (1–50). Mỗi mục là một discriminated union trên
type. Xem Tổng quan / Triggers để biết danh mục đầy đủ.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
}
Một hoặc nhiều action (1–50). Mỗi mục là một discriminated union trên
type. Xem Tổng quan / Actions để biết danh mục đầy đủ. Mỗi action cũng chấp nhận một dedupWindowMinutes cấp cao nhất tùy chọn ghi đè cửa sổ dedup mặc định 7 ngày theo người nhận (0 để vô hiệu hóa, tối đa 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
}
Khả năng tương thích nền tảng. Mỗi trigger và action khai báo các nền tảng mà nó hỗ trợ. Validator từ chối yêu cầu khi
type của một mục không được hỗ trợ trên platform được yêu cầu. Tất cả trigger và send_dm hiện chỉ dành cho Instagram; fire_webhook và send_email không phụ thuộc nền tảng.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
