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

# Update campaign

> Update an existing campaign.

<ParamField path="campaign_id" type="integer" required>
  Campaign ID.
</ParamField>

<ParamField body="title" type="string" required>
  Campaign title.
</ParamField>

<ParamField body="from_name" type="string" required>
  Sender's name.
</ParamField>

<ParamField body="from_email" type="string" required>
  Sender's email address.
</ParamField>

<ParamField body="reply_to" type="string" required>
  Reply-to email address.
</ParamField>

<ParamField body="subject" type="string" required>
  Campaign subject line.
</ParamField>

<ParamField body="html_text" type="string" required>
  HTML content of the campaign.
</ParamField>

<ParamField body="recepient_lists" type="array|object" required>
  Array of list IDs or an object with segments.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT https://api2.ecomailapp.cz/campaigns/1 \
    -H "key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "title": "Campaign title",
      "from_name": "Senders name",
      "from_email": "test@ecomailapp.cz",
      "reply_to": "test@ecomailapp.cz",
      "subject": "New campaign subject",
      "html_text": "HTML content of new campaign",
      "recepient_lists": [1, 2]
    }'
  ```

  ```php PHP theme={null}
  $campaignId = 1;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://api2.ecomailapp.cz/campaigns/{$campaignId}");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'key: YOUR_API_KEY',
      'Content-Type: application/json',
  ]);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
      'title' => 'Campaign title',
      'from_name' => 'Senders name',
      'from_email' => 'test@ecomailapp.cz',
      'reply_to' => 'test@ecomailapp.cz',
      'subject' => 'New campaign subject',
      'html_text' => 'HTML content of new campaign',
      'recepient_lists' => [1, 2],
  ]));
  $response = curl_exec($ch);
  curl_close($ch);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 1,
    "from_name": "From name",
    "from_email": "from@foo.cz",
    "reply_to": "reply@bar.cz",
    "title": "My first campaign",
    "subject": "First hello",
    "status": 0,
    "archive_url": "https://foo.ecomailapp.cz/campaigns/render/1"
  }
  ```
</ResponseExample>
