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
Créer une automatisation
Créez une nouvelle automatisation déclenchée par l’engagement
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"
}
Bêta. Voir la Vue d’ensemble des automatisations pour la description complète de la fonctionnalité, y compris le statut Bêta.
accountId dans le corps ; la requête sera rejetée avec une erreur de validation si vous le faites. Passez un en-tête profileKey pour opérer sous un profil enfant.
Paramètres d’en-tête
Paramètres du corps
Plateforme cible. Seul
instagram est pris en charge en v1.Nom court lisible par l’humain. Utilisé dans le tableau de bord et les journaux d’activité.
Description plus longue optionnelle.
Un ou plusieurs déclencheurs (1 à 50). Chaque entrée est une union discriminée sur
type. Voir Vue d’ensemble / Déclencheurs pour le catalogue complet.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
}
Une ou plusieurs actions (1 à 50). Chaque entrée est une union discriminée sur
type. Voir Vue d’ensemble / Actions pour le catalogue complet. Chaque action accepte également un champ optionnel de premier niveau dedupWindowMinutes qui remplace la fenêtre de dédup par destinataire par défaut de 7 jours (0 pour désactiver, 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
}
Compatibilité des plateformes. Chaque déclencheur et action déclare quelles plateformes il prend en charge. Le validateur rejette la requête lorsque le
type d’une entrée n’est pas pris en charge sur la platform demandée. Tous les déclencheurs et send_dm sont actuellement uniquement Instagram ; fire_webhook et send_email sont indépendants de la plateforme.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
