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

# Send test campaign

> Sends a test version of a draft campaign to up to 5 recipients.

<Note>Only campaigns in draft status can be tested. The test send is rate limited per account.</Note>

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

<ParamField body="emails" type="array" required>
  Recipients of the test email. At least 1 and at most 5 email addresses.
</ParamField>

<ParamField body="merge" type="object">
  Optional map of merge-tag values used to personalize the test email. Keys are merge-tag names, values are their replacements; empty values are ignored.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api2.ecomailapp.cz/campaigns/1/send-test \
    -H "key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "emails": ["test@foo.cz", "qa@foo.cz"],
      "merge": {
        "first_name": "Foo"
      }
    }'
  ```

  ```php PHP theme={null}
  $campaignId = 1;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://api2.ecomailapp.cz/campaigns/{$campaignId}/send-test");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
      'emails' => ['test@foo.cz', 'qa@foo.cz'],
      'merge' => [
          'first_name' => 'Foo',
      ],
  ]));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'key: YOUR_API_KEY',
      'Content-Type: application/json',
  ]);
  $response = curl_exec($ch);
  curl_close($ch);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "campaign_id": 1,
    "sent_emails_count": 2
  }
  ```

  ```json 403 theme={null}
  {
    "errors": ["You can not do this because you have a blocked account"]
  }
  ```

  ```json 409 theme={null}
  {
    "errors": ["Only draft campaigns can be tested."]
  }
  ```

  ```json 422 theme={null}
  {
    "errors": {
      "emails": ["The emails field is required."]
    }
  }
  ```

  ```json 429 theme={null}
  {
    "errors": ["You have exceeded daily limit of sent test emails of 50."]
  }
  ```
</ResponseExample>
