> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Automation बनाएँ

> एक नया एंगेजमेंट-ट्रिगर्ड automation बनाएँ

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

<PlansAvailable plans={["business", "enterprise"]} maxPackRequired={false} />

<Note>
  **Beta.** पूर्ण फ़ीचर विवरण के लिए, जिसमें Beta स्थिति भी शामिल है, [Automations Overview](/apis/automations/overview) देखें।
</Note>

एक नया automation बनाएँ जो अपने किसी भी ट्रिगर के मेल खाने पर एक या अधिक क्रियाओं को सक्रिय करता है। Automation तुरंत सक्रिय हो जाता है। ट्रिगर, क्रियाओं, टेम्पलेट वेरिएबल और सीमाओं की पूर्ण सूची के लिए [Overview](/apis/automations/overview) देखें।

कनेक्ट किया गया Instagram अकाउंट कॉलर की लिंक की गई प्रोफ़ाइल से सर्वर-साइड पर व्युत्पन्न किया जाता है — बॉडी में **`accountId` न भेजें**; यदि आप ऐसा करते हैं तो अनुरोध वैलिडेशन एरर के रूप में अस्वीकार कर दिया जाएगा। चाइल्ड प्रोफ़ाइल के अंतर्गत काम करने के लिए `profileKey` हेडर पास करें।

## Header Parameters

<HeaderAPI noProfileKey={false} />

## Body Parameters

<ParamField body="platform" type="string" required>
  लक्ष्य प्लेटफ़ॉर्म। v1 में केवल `instagram` समर्थित है।
</ParamField>

<ParamField body="name" type="string" required>
  छोटा मानव-पठनीय नाम। डैशबोर्ड और गतिविधि लॉग में उपयोग किया जाता है।
</ParamField>

<ParamField body="description" type="string">
  वैकल्पिक लंबा विवरण।
</ParamField>

<ParamField body="triggers" type="array" required>
  एक या अधिक ट्रिगर (1–50)। प्रत्येक प्रविष्टि `type` पर एक विवेकित यूनियन है। पूर्ण कैटलॉग के लिए [Overview / Triggers](/apis/automations/overview#triggers) देखें।

  ```json comment_keyword trigger theme={"system"}
  {
    "type": "comment_keyword",
    "postId": "17895695668004550",       // required — Instagram media id
    "keywords": ["INFO", "LINK"]         // required — ≥1 entry, case-insensitive
  }
  ```

  ```json story_reply trigger theme={"system"}
  {
    "type": "story_reply",
    "storyId": "17900000000000000"       // optional — scope to one story
  }
  ```

  ```json dm_reaction trigger theme={"system"}
  {
    "type": "dm_reaction",
    "emoji": "❤️"                         // optional — scope to one emoji
  }
  ```

  ```json dm_keyword trigger theme={"system"}
  {
    "type": "dm_keyword",
    "keywords": ["help", "support"]      // required — ≥1 entry, case-insensitive
  }
  ```
</ParamField>

<ParamField body="actions" type="array" required>
  एक या अधिक क्रियाएँ (1–50)। प्रत्येक प्रविष्टि `type` पर एक विवेकित यूनियन है। पूर्ण कैटलॉग के लिए [Overview / Actions](/apis/automations/overview#actions) देखें। प्रत्येक क्रिया एक वैकल्पिक शीर्ष-स्तरीय `dedupWindowMinutes` भी स्वीकार करती है जो डिफ़ॉल्ट 7-दिन प्रति-प्राप्तकर्ता dedup विंडो को ओवरराइड करती है (`0` अक्षम करने के लिए, अधिकतम `525600`)।

  ```json send_dm action theme={"system"}
  {
    "type": "send_dm",
    "message": "Hey {{recipient_username}}, here is the link you wanted: https://example.com"
  }
  ```

  ```json fire_webhook action theme={"system"}
  {
    "type": "fire_webhook"
    // POSTs to your account-level webhook URL (configured in the dashboard).
    // See Overview for the JSON payload shape.
  }
  ```

  ```json send_email action theme={"system"}
  {
    "type": "send_email",
    "to": "alerts@example.com",
    "subject": "New {{platform}} engagement from @{{recipient_username}}",
    "message": "<p>{{recipient_username}} engaged with: {{comment_text}}</p>"
  }
  ```

  ```json Action with per-action dedup override theme={"system"}
  {
    "type": "send_dm",
    "message": "Thanks {{recipient_username}}!",
    "dedupWindowMinutes": 1440           // 24h instead of the 7-day default
  }
  ```
</ParamField>

<Note>
  **प्लेटफ़ॉर्म संगतता।** प्रत्येक ट्रिगर और क्रिया घोषित करती है कि वह किन प्लेटफ़ॉर्म का समर्थन करती है। जब किसी प्रविष्टि का `type` अनुरोधित `platform` पर समर्थित नहीं होता, तो वैलिडेटर अनुरोध को अस्वीकार कर देता है। सभी ट्रिगर और `send_dm` वर्तमान में केवल Instagram के लिए हैं; `fire_webhook` और `send_email` प्लेटफ़ॉर्म-अज्ञेय हैं।
</Note>

<RequestExample>
  ```bash cURL theme={"system"}
  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
  ```

  ```javascript JavaScript theme={"system"}
  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);
  ```

  ```python Python theme={"system"}
  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())
  ```

  ```php PHP theme={"system"}
  $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;
  ```
</RequestExample>

<ResponseExample>
  ```json 200: Success theme={"system"}
  {
    "status": "success",
    "id": "auto_9xKp2Lm4nQ"
  }
  ```

  ```json 400: Validation failed — unknown template variable theme={"system"}
  {
    "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"]
      }
    }
  }
  ```

  ```json 400: Validation failed — comment_keyword trigger missing keywords theme={"system"}
  {
    "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"]
      }
    }
  }
  ```

  ```json 400: Validation failed — unrecognized field (e.g. accountId) theme={"system"}
  {
    "action": "request",
    "status": "error",
    "code": 473,
    "message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
    "details": {
      "formErrors": ["Unrecognized key: \"accountId\""],
      "fieldErrors": {}
    }
  }
  ```

  ```json 403: Plan tier required theme={"system"}
  {
    "action": "automation",
    "status": "error",
    "code": 468,
    "message": "Instagram DM automations require a Business or Enterprise plan"
  }
  ```

  ```json 403: Feature flag not yet enabled theme={"system"}
  {
    "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."
  }
  ```

  ```json 400: No linked social account for this platform theme={"system"}
  {
    "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."
  }
  ```

  ```json 429: Active automation cap reached theme={"system"}
  {
    "action": "automation",
    "status": "error",
    "code": 470,
    "message": "Active automation limit reached for your plan tier"
  }
  ```
</ResponseExample>
