> ## 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.

# Update 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.** पूर्ण फ़ीचर विवरण के लिए [Automations Overview](/apis/automations/overview) देखें।
</Note>

आंशिक अद्यतन। केवल सूचीबद्ध fields संपादन योग्य हैं; किसी अन्य को भेजना (जैसे `platform`, `accountId`) एक validation error के रूप में अस्वीकार किया जाता है।

`triggers` या `actions` भेजना मौजूदा children को atomically **प्रतिस्थापित** करता है: पुराना set हटा दिया जाता है और नया set एक ही Firestore transaction में लिखा जाता है। केवल एक trigger बदलने के लिए, पूर्ण नई array भेजें।

पहले से inactive automation को पुनः सक्रिय करना (`active: true`) active-cap की पुनः जाँच करता है। यदि cap पहले से सीमा पर है, तो अद्यतन code `470` के साथ विफल हो जाता है और कोई परिवर्तन नहीं किया जाता।

## Header Parameters

<HeaderAPI />

## Path Parameters

<ParamField path="id" type="string" required>
  `POST /automations` से लौटाया गया automation ID।
</ParamField>

## Body Parameters

<ParamField body="name" type="string">
  नया नाम।
</ParamField>

<ParamField body="description" type="string">
  नया विवरण।
</ParamField>

<ParamField body="active" type="boolean">
  automation को on या off toggle करें। इसे `false` से `true` पर सेट करने पर active automation cap की पुनः जाँच होती है।
</ParamField>

<ParamField body="triggers" type="array">
  triggers का पूर्ण प्रतिस्थापन set (1–50)। create endpoint के समान आकार।
</ParamField>

<ParamField body="actions" type="array">
  actions का पूर्ण प्रतिस्थापन set (1–50)। create endpoint के समान आकार।
</ParamField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Spring promo (updated)",
    "active": true,
    "actions": [
      {
        "type": "send_dm",
        "message": "Hey {{recipient_username}}! New link: https://example.com/spring"
      }
    ]
  }' \
  -X PUT https://api.ayrshare.com/api/automations/auto_9xKp2Lm4nQ
  ```

  ```javascript JavaScript theme={"system"}
  const API_KEY = "API_KEY";
  const id = "auto_9xKp2Lm4nQ";

  fetch(`https://api.ayrshare.com/api/automations/${id}`, {
    method: "PUT",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      name: "Spring promo (updated)",
      active: true,
      actions: [
        {
          type: "send_dm",
          message: "Hey {{recipient_username}}! New link: https://example.com/spring",
        },
      ],
    }),
  })
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch(console.error);
  ```

  ```python Python theme={"system"}
  import requests

  headers = {
      "Authorization": "Bearer API_KEY",
      "Content-Type": "application/json",
  }
  automation_id = "auto_9xKp2Lm4nQ"

  payload = {
      "name": "Spring promo (updated)",
      "active": True,
      "actions": [
          {
              "type": "send_dm",
              "message": "Hey {{recipient_username}}! New link: https://example.com/spring",
          }
      ],
  }

  r = requests.put(
      f"https://api.ayrshare.com/api/automations/{automation_id}",
      json=payload,
      headers=headers,
  )

  print(r.json())
  ```

  ```php PHP theme={"system"}
  $id = "auto_9xKp2Lm4nQ";

  $data = [
      "name" => "Spring promo (updated)",
      "active" => true,
      "actions" => [
          [
              "type" => "send_dm",
              "message" => "Hey {{recipient_username}}! New link: https://example.com/spring",
          ],
      ],
  ];

  $curl = curl_init();
  curl_setopt_array($curl, [
      CURLOPT_URL => "https://api.ayrshare.com/api/automations/" . $id,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => "PUT",
      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 — editing platform is not allowed theme={"system"}
  {
    "action": "request",
    "status": "error",
    "code": 473,
    "message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
    "details": {
      "formErrors": ["Unrecognized key: \"platform\""],
      "fieldErrors": {}
    }
  }
  ```

  ```json 404: Not found theme={"system"}
  {
    "action": "automation",
    "status": "error",
    "code": 469,
    "message": "Automation not found"
  }
  ```

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