# Schedule Campaign

POST https://services.leadconnectorhq.com/emails/locations/{locationId}/campaigns/emails/{campaignId}/schedule

Schedule or start an email campaign. The campaign must be `draft`, `paused` or `cancelled`; otherwise 409. 

Before scheduling a tag, segment or other filter audience, call Estimate Recipients and confirm that count with the user; never state a recipient count or sending limit you did not get from a response. Every `scheduleType` except `batch` sends to the whole audience at once (now, or at `sendAt`). A sending rate ("N every M minutes", "N per day") means `batch` with `batchSize` = N and the interval set to match. 

Requirements by `scheduleType`: 
- `immediate`: `scheduleConfig` (can be `{}`); sends now. 
- `scheduled`: `scheduleConfig.sendAt`. 
- `smart_send`: `scheduleConfig.sendAt`; smart send starting at that time. 
- `batch`: `scheduleConfig.sendAt` (first batch) and `scheduleConfig.batch` (`batchSize`, `interval`, `intervalUnit`, optional `skipDays`, `windowStart`/`windowEnd`). 
- `rss`: `rssConfig` (`name`, `rssFeedURL`, `repeatAfter`, `repeatAfterTime`, plus `startAtDay` for `every_week` or `startAtMonthDay` for `every_month`). `scheduleConfig` is ignored and `abTestConfig` is rejected (400). 

`sendAt` format is `YYYY-MM-DD hh:mm A` (e.g. `2026-04-01 09:00 AM`), interpreted in `timeZone` (IANA name). 

A/B test (any `scheduleType` except `rss`): set `abTestConfig`. With `batch`, the test starts at `sendAt` but `scheduleConfig.batch` settings are not applied to A/B sends. 
- `testType=subjectLine`: one entry per variation in `abTestConfig.variations` with its `subject`; every variation sends the campaign content. 
- `testType=emailContent`: version A (index 0) is the campaign content (set with Update Email Campaign). For each index ≥ 1 call Upsert A/B Variation first and pass the returned `documentId` as `abTestConfig.variations[index].documentId`. Never pass a template ID. A variation never created with Upsert A/B Variation and sent without `documentId` uses the campaign content. 

To change a scheduled campaign: Pause Email Campaign (or Cancel Email Campaign), edit, then call Schedule Campaign again.

How an A/B test works (follow these steps in order): 
1. Version A is the campaign itself. Create it with Create Email Campaign and edit it with Update Email Campaign. 
2. Versions B, C, ... are stored inside the same campaign, not as separate campaigns or templates. Create or edit each one with Upsert A/B Variation (`index` 1 = B, 2 = C, ...; create them in order). Never create another campaign or template to make a version. Versions do not show in the campaign list, and the builder only shows them once the test is scheduled. 
3. Check the versions before sending: Get Email Campaign lists them in `abVersions` (with each `documentId`); Validate Email Campaign checks every version (issues carry `variationIndex`); Preview Email Campaign and Test Send Email Campaign take `variationIndex` to show or test-send one version. Use these to read a version; Upsert A/B Variation creates the version when it is missing. 
4. Start the test with Schedule Campaign `abTestConfig`: `testType=emailContent` with `variations[index].documentId` from `abVersions` (index 0 = version A, no documentId needed), or `testType=subjectLine` with one `subject` per version. Without `abTestConfig` the campaign sends version A only, and versions B, C, ... are never sent. The test group must give every version at least 10 contacts (see `abTestConfig.testSize`); otherwise Schedule Campaign returns 400.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `emails/campaigns.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Idempotency-Key` | string | No | Unique key per intended write (max 255 chars). Retrying with the same key and body within 24 hours returns the first response instead of creating another resource. Reusing the key with a different body returns 422; a retry while the first request is still running returns 409. |
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID |
| `campaignId` | string | Yes | Campaign ID |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/emails/locations/{locationId}/campaigns/emails/{campaignId}/schedule": {
      "post": {
        "summary": "Schedule Campaign",
        "operationId": "scheduleCampaign",
        "description": "Schedule or start an email campaign. The campaign must be `draft`, `paused` or `cancelled`; otherwise 409. \n\nBefore scheduling a tag, segment or other filter audience, call Estimate Recipients and confirm that count with the user; never state a recipient count or sending limit you did not get from a response. Every `scheduleType` except `batch` sends to the whole audience at once (now, or at `sendAt`). A sending rate (\"N every M minutes\", \"N per day\") means `batch` with `batchSize` = N and the interval set to match. \n\nRequirements by `scheduleType`: \n- `immediate`: `scheduleConfig` (can be `{}`); sends now. \n- `scheduled`: `scheduleConfig.sendAt`. \n- `smart_send`: `scheduleConfig.sendAt`; smart send starting at that time. \n- `batch`: `scheduleConfig.sendAt` (first batch) and `scheduleConfig.batch` (`batchSize`, `interval`, `intervalUnit`, optional `skipDays`, `windowStart`/`windowEnd`). \n- `rss`: `rssConfig` (`name`, `rssFeedURL`, `repeatAfter`, `repeatAfterTime`, plus `startAtDay` for `every_week` or `startAtMonthDay` for `every_month`). `scheduleConfig` is ignored and `abTestConfig` is rejected (400). \n\n`sendAt` format is `YYYY-MM-DD hh:mm A` (e.g. `2026-04-01 09:00 AM`), interpreted in `timeZone` (IANA name). \n\nA/B test (any `scheduleType` except `rss`): set `abTestConfig`. With `batch`, the test starts at `sendAt` but `scheduleConfig.batch` settings are not applied to A/B sends. \n- `testType=subjectLine`: one entry per variation in `abTestConfig.variations` with its `subject`; every variation sends the campaign content. \n- `testType=emailContent`: version A (index 0) is the campaign content (set with Update Email Campaign). For each index ≥ 1 call Upsert A/B Variation first and pass the returned `documentId` as `abTestConfig.variations[index].documentId`. Never pass a template ID. A variation never created with Upsert A/B Variation and sent without `documentId` uses the campaign content. \n\nTo change a scheduled campaign: Pause Email Campaign (or Cancel Email Campaign), edit, then call Schedule Campaign again.\n\nHow an A/B test works (follow these steps in order): \n1. Version A is the campaign itself. Create it with Create Email Campaign and edit it with Update Email Campaign. \n2. Versions B, C, ... are stored inside the same campaign, not as separate campaigns or templates. Create or edit each one with Upsert A/B Variation (`index` 1 = B, 2 = C, ...; create them in order). Never create another campaign or template to make a version. Versions do not show in the campaign list, and the builder only shows them once the test is scheduled. \n3. Check the versions before sending: Get Email Campaign lists them in `abVersions` (with each `documentId`); Validate Email Campaign checks every version (issues carry `variationIndex`); Preview Email Campaign and Test Send Email Campaign take `variationIndex` to show or test-send one version. Use these to read a version; Upsert A/B Variation creates the version when it is missing. \n4. Start the test with Schedule Campaign `abTestConfig`: `testType=emailContent` with `variations[index].documentId` from `abVersions` (index 0 = version A, no documentId needed), or `testType=subjectLine` with one `subject` per version. Without `abTestConfig` the campaign sends version A only, and versions B, C, ... are never sent. The test group must give every version at least 10 contacts (see `abTestConfig.testSize`); otherwise Schedule Campaign returns 400.",
        "parameters": [
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location ID",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          },
          {
            "name": "campaignId",
            "required": true,
            "in": "path",
            "description": "Campaign ID",
            "schema": {
              "example": "67f15c2ae99226d5bcccb8f3",
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Unique key per intended write (max 255 chars). Retrying with the same key and body within 24 hours returns the first response instead of creating another resource. Reusing the key with a different body returns 422; a retry while the first request is still running returns 409.",
            "required": false,
            "schema": {
              "type": "string",
              "example": "0f8fad5b-d9cb-469f-a165-70867728950e"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduleCampaignPublicV2BodyDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleCampaignPublicV2ResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "403": {
            "description": "The token does not have access to this location",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvalidLocationDTO"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundDTO"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Campaign is already scheduled or being processed, or a request with the same Idempotency-Key is still in progress"
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - rate limit exceeded; retry after a short delay"
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "emails/campaigns.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "ScheduleCampaignPublicV2BodyDto": {
        "type": "object",
        "properties": {
          "scheduleType": {
            "type": "string",
            "description": "`immediate` (send now), `scheduled` (at `sendAt`), `smart_send` (smart send from `sendAt`), `batch` (drip in batches from `sendAt`, needs `scheduleConfig.batch`), `rss` (recurring from an RSS feed, needs `rssConfig`).",
            "enum": [
              "immediate",
              "scheduled",
              "batch",
              "rss",
              "smart_send"
            ],
            "example": "immediate"
          },
          "timeZone": {
            "type": "string",
            "description": "IANA timezone used to interpret `sendAt` and batch/RSS times",
            "example": "America/New_York"
          },
          "userId": {
            "type": "string",
            "description": "ID of the user performing this action",
            "example": "507f1f77bcf86cd799439099"
          },
          "userName": {
            "type": "string",
            "description": "Name of the user performing this action",
            "example": "John Doe"
          },
          "emailMeta": {
            "description": "Email subject, sender, and content metadata",
            "example": {
              "subject": "Our February Newsletter",
              "fromName": "John Doe",
              "fromEmail": "john@example.com"
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "subject": {
                    "type": "string",
                    "description": "Email subject line",
                    "example": "Our February Newsletter"
                  },
                  "fromName": {
                    "type": "string",
                    "description": "Sender display name",
                    "example": "John Doe"
                  },
                  "fromEmail": {
                    "type": "string",
                    "description": "Sender email address",
                    "example": "john@example.com"
                  },
                  "replyToAddress": {
                    "type": "string",
                    "description": "Reply-to email address",
                    "example": "reply@example.com"
                  },
                  "previewText": {
                    "type": "string",
                    "description": "Preview text shown in inbox after subject",
                    "example": "Check out our latest news"
                  },
                  "attachments": {
                    "description": "Attachment download URLs",
                    "example": [
                      "https://example.com/file.pdf"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "subject",
                  "fromName",
                  "fromEmail"
                ],
                "title": "ScheduleCampaignEmailMetaPublicV2Dto"
              }
            ]
          },
          "recipients": {
            "description": "Who receives the email. Must provide either contactIds or filter.",
            "example": {
              "type": "contact",
              "contactIds": [
                "contactId1",
                "contactId2"
              ]
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Recipient selection type. smart_list, custom_segment and all resolve like the Schedule page; use Estimate Recipients first to confirm the size. all sends to every contact in the location.",
                    "enum": [
                      "contact",
                      "tag",
                      "segment",
                      "smart_list",
                      "custom_segment",
                      "all"
                    ],
                    "example": "contact"
                  },
                  "contactIds": {
                    "description": "Contact IDs to send to. Required when type is contact. Every ID must be a contact in this location; if any is not, nothing is scheduled and the request returns 422. Review the number of contacts with the user before sending.",
                    "example": [
                      "contactId1",
                      "contactId2"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "tagIds": {
                    "description": "Tag IDs to filter recipients by. Required when type is tag.",
                    "example": [
                      "tagId1",
                      "tagId2"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "segment": {
                    "type": "string",
                    "description": "Segment type for pre-built segments. Required when type is segment.",
                    "enum": [
                      "engaged_last_7_days",
                      "engaged_last_30_days",
                      "engaged_last_60_days",
                      "engaged_last_5_campaigns",
                      "unengaged_last_5_campaigns"
                    ],
                    "example": "engaged_last_7_days"
                  },
                  "smartListIds": {
                    "description": "Smart list IDs (from List Audience Options, source smart_list). Required when type is smart_list; only the first is used.",
                    "example": [
                      "smartListId1"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "conditions": {
                    "description": "Built segment rows, the Schedule page \"Build segments\" picker. Required when type is custom_segment.",
                    "example": [
                      {
                        "kind": "tag",
                        "values": [
                          "6YMlGPn0LHi5OmJaXdLB"
                        ],
                        "negate": false
                      }
                    ],
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "description": "What this row matches on",
                          "enum": [
                            "contact",
                            "tag",
                            "smart_list",
                            "segment"
                          ],
                          "example": "tag"
                        },
                        "values": {
                          "description": "Contact ids, tag ids, smart list ids, or one segment type",
                          "example": [
                            "6YMlGPn0LHi5OmJaXdLB"
                          ],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "negate": {
                          "type": "boolean",
                          "description": "`is-not`. Unsupported for smart lists.",
                          "example": false
                        },
                        "join": {
                          "type": "string",
                          "description": "Operator joining this row to the previous one",
                          "enum": [
                            "and",
                            "or"
                          ],
                          "example": "and"
                        }
                      },
                      "title": "AudienceConditionDto"
                    }
                  },
                  "freezeList": {
                    "type": "boolean",
                    "description": "Freeze the contact list at schedule time — new matching contacts will not be added later",
                    "example": true,
                    "default": true
                  }
                },
                "required": [
                  "type"
                ],
                "title": "ScheduleCampaignRecipientsPublicV2Dto"
              }
            ]
          },
          "sendDays": {
            "type": "array",
            "description": "Days of the week to allow sending. Used for batch and RSS scheduleTypes.",
            "example": [
              "Mon",
              "Tue",
              "Wed",
              "Thu",
              "Fri",
              "Sat",
              "Sun"
            ],
            "items": {
              "type": "string",
              "enum": [
                "Mon",
                "Tue",
                "Wed",
                "Thu",
                "Fri",
                "Sat",
                "Sun"
              ]
            }
          },
          "scheduleConfig": {
            "description": "Schedule configuration for immediate, scheduled, batch, and smart_send types. Required when scheduleType is not rss.",
            "example": {
              "sendAt": "2026-04-01 09:00 AM"
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "sendAt": {
                    "type": "string",
                    "description": "Date/time to send, format `YYYY-MM-DD hh:mm A` in the body `timeZone`. Required for scheduled, batch (first batch) and smart_send. Ignored for immediate.",
                    "example": "2026-04-01 09:00 AM"
                  },
                  "batch": {
                    "description": "Batch/drip configuration. Required when scheduleType is batch. Ignored otherwise, and not applied to A/B tests.",
                    "example": {
                      "batchSize": 100,
                      "interval": 2,
                      "intervalUnit": "hours"
                    },
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "batchSize": {
                            "type": "number",
                            "description": "Number of contacts to process per batch",
                            "example": 100
                          },
                          "interval": {
                            "type": "number",
                            "description": "Delay between batches",
                            "example": 2
                          },
                          "intervalUnit": {
                            "type": "string",
                            "description": "Unit for the interval",
                            "example": "hours",
                            "enum": [
                              "minutes",
                              "hours",
                              "days"
                            ]
                          },
                          "skipDays": {
                            "type": "array",
                            "description": "Days to skip sending",
                            "example": [
                              "Sat",
                              "Sun"
                            ],
                            "items": {
                              "type": "string",
                              "enum": [
                                "Mon",
                                "Tue",
                                "Wed",
                                "Thu",
                                "Fri",
                                "Sat",
                                "Sun"
                              ]
                            }
                          },
                          "windowStart": {
                            "type": "string",
                            "description": "Earliest time to send batches",
                            "example": "09:00 AM"
                          },
                          "windowEnd": {
                            "type": "string",
                            "description": "Latest time to send batches",
                            "example": "05:00 PM"
                          }
                        },
                        "required": [
                          "batchSize",
                          "interval",
                          "intervalUnit"
                        ],
                        "title": "ScheduleCampaignBatchConfigPublicV2Dto"
                      }
                    ]
                  },
                  "tracking": {
                    "description": "Click and UTM tracking options",
                    "example": {
                      "clickTracking": true,
                      "utmTracking": false
                    },
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "clickTracking": {
                            "type": "boolean",
                            "description": "Enable click tracking on links",
                            "example": true
                          },
                          "utmTracking": {
                            "type": "boolean",
                            "description": "Enable UTM parameters on links",
                            "example": false
                          }
                        },
                        "title": "ScheduleCampaignTrackingPublicV2Dto"
                      }
                    ]
                  },
                  "resend": {
                    "description": "Auto-resend to contacts who did not open",
                    "example": {
                      "enabled": false
                    },
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "enabled": {
                            "type": "boolean",
                            "description": "Enable resend to contacts who did not open",
                            "example": false
                          },
                          "waitHours": {
                            "type": "number",
                            "description": "Hours to wait before resending. Required when enabled is true.",
                            "example": 12
                          },
                          "subject": {
                            "type": "string",
                            "description": "Override subject line for the resend email",
                            "example": "Did you miss this?"
                          }
                        },
                        "title": "ScheduleCampaignResendPublicV2Dto"
                      }
                    ]
                  },
                  "emailPreferenceId": {
                    "type": "string",
                    "description": "Email preference type ID for categorizing this campaign",
                    "example": "preference-type-id"
                  }
                },
                "title": "ScheduleCampaignScheduleConfigPublicV2Dto"
              }
            ]
          },
          "rssConfig": {
            "description": "RSS feed configuration. Required when scheduleType is rss.",
            "example": {
              "name": "Weekly Digest",
              "rssFeedURL": "https://example.com/rss",
              "repeatAfter": "every_day",
              "repeatAfterTime": "09:00 AM"
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "RSS schedule name",
                    "example": "Weekly Digest"
                  },
                  "rssFeedURL": {
                    "type": "string",
                    "description": "RSS feed URL",
                    "example": "https://example.com/rss"
                  },
                  "repeatAfter": {
                    "type": "string",
                    "description": "How often to check the feed",
                    "example": "every_day",
                    "enum": [
                      "every_day",
                      "every_week",
                      "every_month"
                    ]
                  },
                  "repeatAfterTime": {
                    "type": "string",
                    "description": "Time of day to send, format `hh:mm A`, in the body `timeZone`",
                    "example": "09:00 AM"
                  },
                  "rssFeedLimit": {
                    "type": "number",
                    "description": "Max number of RSS items per email",
                    "example": 10
                  },
                  "startAtDay": {
                    "type": "string",
                    "description": "Day of week. Use with repeatAfter `every_week`.",
                    "enum": [
                      "Monday",
                      "Tuesday",
                      "Wednesday",
                      "Thursday",
                      "Friday",
                      "Saturday",
                      "Sunday"
                    ],
                    "example": "Monday"
                  },
                  "startAtMonthDay": {
                    "type": "string",
                    "description": "Day of month (1-31). Use with repeatAfter `every_month`.",
                    "example": "15"
                  },
                  "firstExecutionDate": {
                    "type": "string",
                    "description": "Override first execution date/time",
                    "example": "2026-04-01 10:00:00"
                  }
                },
                "required": [
                  "name",
                  "rssFeedURL",
                  "repeatAfter",
                  "repeatAfterTime"
                ],
                "title": "ScheduleCampaignRssConfigPublicV2Dto"
              }
            ]
          },
          "abTestConfig": {
            "description": "A/B test configuration. Can be combined with any scheduleType except rss.",
            "example": {
              "testType": "subjectLine",
              "testDuration": 3600,
              "variationCount": 2,
              "testSize": 30,
              "winningCriteria": "openRate",
              "variations": [
                {
                  "subject": "Subject A"
                },
                {
                  "subject": "Subject B"
                }
              ]
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "testType": {
                    "type": "string",
                    "description": "`subjectLine`: variations differ only by `subject`. `emailContent`: variations differ by content; create versions B, C, ... with Upsert A/B Variation first.",
                    "enum": [
                      "emailContent",
                      "subjectLine"
                    ],
                    "example": "subjectLine"
                  },
                  "testDuration": {
                    "type": "number",
                    "description": "Seconds to run the test before picking a winner",
                    "example": 3600
                  },
                  "variationCount": {
                    "type": "number",
                    "description": "Number of variations, including version A. Must match `variations.length`.",
                    "example": 2
                  },
                  "testSize": {
                    "type": "number",
                    "description": "Percentage of the audience in the test group (0-100). Each version must get at least 10 contacts: floor(floor(audience × testSize / 100) / variationCount) must be 10 or more, or Schedule Campaign returns 400. Example: 27 contacts and 2 versions need testSize 75 or higher.",
                    "example": 30
                  },
                  "winningCriteria": {
                    "type": "string",
                    "description": "How to pick the winner",
                    "enum": [
                      "openRate",
                      "clickRate"
                    ],
                    "example": "openRate"
                  },
                  "variations": {
                    "description": "One entry per variation; index 0 is version A (the campaign itself).",
                    "example": [
                      {
                        "subject": "Subject A"
                      },
                      {
                        "subject": "Subject B"
                      }
                    ],
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "subject": {
                          "type": "string",
                          "description": "Subject line for this variation",
                          "example": "Subject A"
                        },
                        "documentId": {
                          "type": "string",
                          "description": "Variation document ID, for testType `emailContent` only. Index 0: omit (the campaign content is used). Index ≥ 1: the `documentId` returned by Upsert A/B Variation for that index. Never a template ID. When omitted, a variation already created with Upsert A/B Variation keeps its document; otherwise the campaign content is sent.",
                          "example": "67f15c2ae99226d5bcccb8f9"
                        }
                      },
                      "title": "ScheduleCampaignABTestVariationPublicV2Dto"
                    }
                  }
                },
                "required": [
                  "testType",
                  "testDuration",
                  "variationCount",
                  "testSize",
                  "winningCriteria",
                  "variations"
                ],
                "title": "ScheduleCampaignABTestConfigPublicV2Dto"
              }
            ]
          }
        },
        "required": [
          "scheduleType",
          "timeZone",
          "userId",
          "emailMeta",
          "recipients"
        ],
        "title": "ScheduleCampaignPublicV2BodyDto"
      },
      "ScheduleCampaignPublicV2ResponseDto": {
        "type": "object",
        "properties": {
          "campaignId": {
            "type": "string",
            "description": "Campaign ID",
            "example": "67f15c2ae99226d5bcccb8f3"
          },
          "sourceId": {
            "type": "string",
            "description": "Source ID for fetching campaign statistics",
            "example": "B67vyPIAfq3Bnk3FVioE",
            "nullable": true
          },
          "traceId": {
            "type": "string",
            "description": "Trace ID of the request",
            "example": "019e4ef5-a65e-4198-8cf9-8e93dca9bda4"
          }
        },
        "required": [
          "campaignId",
          "sourceId"
        ],
        "title": "ScheduleCampaignPublicV2ResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "InvalidLocationDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for invalid location access",
            "example": 403
          },
          "message": {
            "type": "string",
            "description": "Error message describing the location access failure",
            "example": "The token does not have access to this location"
          }
        },
        "title": "InvalidLocationDTO"
      },
      "NotFoundDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for not found",
            "example": 404
          },
          "message": {
            "type": "string",
            "description": "Error message describing the not found failure",
            "example": "Not Found"
          },
          "error": {
            "type": "string",
            "description": "Error type identifier",
            "example": "The requested resource was not found"
          }
        },
        "title": "NotFoundDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      },
      "InternalServerErrorDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for an unexpected server error",
            "example": 500
          },
          "message": {
            "type": "string",
            "description": "Error message describing the server failure",
            "example": "Internal Server Error"
          }
        },
        "title": "InternalServerErrorDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/emails/locations/<locationId>/campaigns/emails/<campaignId>/schedule' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "scheduleType": "immediate",
  "timeZone": "America/New_York",
  "userId": "507f1f77bcf86cd799439099",
  "userName": "John Doe",
  "emailMeta": {
    "subject": "Our February Newsletter",
    "fromName": "John Doe",
    "fromEmail": "john@example.com"
  },
  "recipients": {
    "type": "contact",
    "contactIds": [
      "contactId1",
      "contactId2"
    ]
  },
  "sendDays": [
    "Mon",
    "Tue",
    "Wed",
    "Thu",
    "Fri",
    "Sat",
    "Sun"
  ],
  "scheduleConfig": {
    "sendAt": "2026-04-01 09:00 AM"
  },
  "rssConfig": {
    "name": "Weekly Digest",
    "rssFeedURL": "https://example.com/rss",
    "repeatAfter": "every_day",
    "repeatAfterTime": "09:00 AM"
  },
  "abTestConfig": {
    "testType": "subjectLine",
    "testDuration": 3600,
    "variationCount": 2,
    "testSize": 30,
    "winningCriteria": "openRate",
    "variations": [
      {
        "subject": "Subject A"
      },
      {
        "subject": "Subject B"
      }
    ]
  }
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "scheduleType": "immediate",
      "timeZone": "America/New_York",
      "userId": "507f1f77bcf86cd799439099",
      "userName": "John Doe",
      "emailMeta": {
        "subject": "Our February Newsletter",
        "fromName": "John Doe",
        "fromEmail": "john@example.com"
      },
      "recipients": {
        "type": "contact",
        "contactIds": [
          "contactId1",
          "contactId2"
        ]
      },
      "sendDays": [
        "Mon",
        "Tue",
        "Wed",
        "Thu",
        "Fri",
        "Sat",
        "Sun"
      ],
      "scheduleConfig": {
        "sendAt": "2026-04-01 09:00 AM"
      },
      "rssConfig": {
        "name": "Weekly Digest",
        "rssFeedURL": "https://example.com/rss",
        "repeatAfter": "every_day",
        "repeatAfterTime": "09:00 AM"
      },
      "abTestConfig": {
        "testType": "subjectLine",
        "testDuration": 3600,
        "variationCount": 2,
        "testSize": 30,
        "winningCriteria": "openRate",
        "variations": [
          {
            "subject": "Subject A"
          },
          {
            "subject": "Subject B"
          }
        ]
      }
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/emails/locations/<locationId>/campaigns/emails/<campaignId>/schedule', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/emails/locations/{locationId}/campaigns/emails/{campaignId}/schedule"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "scheduleType": "immediate",
    "timeZone": "America/New_York",
    "userId": "507f1f77bcf86cd799439099",
    "userName": "John Doe",
    "emailMeta": {
        "subject": "Our February Newsletter",
        "fromName": "John Doe",
        "fromEmail": "john@example.com"
    },
    "recipients": {
        "type": "contact",
        "contactIds": [
            "contactId1",
            "contactId2"
        ]
    },
    "sendDays": [
        "Mon",
        "Tue",
        "Wed",
        "Thu",
        "Fri",
        "Sat",
        "Sun"
    ],
    "scheduleConfig": {
        "sendAt": "2026-04-01 09:00 AM"
    },
    "rssConfig": {
        "name": "Weekly Digest",
        "rssFeedURL": "https://example.com/rss",
        "repeatAfter": "every_day",
        "repeatAfterTime": "09:00 AM"
    },
    "abTestConfig": {
        "testType": "subjectLine",
        "testDuration": 3600,
        "variationCount": 2,
        "testSize": 30,
        "winningCriteria": "openRate",
        "variations": [
            {
                "subject": "Subject A"
            },
            {
                "subject": "Subject B"
            }
        ]
    }
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/emails/locations/<locationId>/campaigns/emails/<campaignId>/schedule',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "scheduleType": "immediate",
  "timeZone": "America/New_York",
  "userId": "507f1f77bcf86cd799439099",
  "userName": "John Doe",
  "emailMeta": {
    "subject": "Our February Newsletter",
    "fromName": "John Doe",
    "fromEmail": "john@example.com"
  },
  "recipients": {
    "type": "contact",
    "contactIds": [
      "contactId1",
      "contactId2"
    ]
  },
  "sendDays": [
    "Mon",
    "Tue",
    "Wed",
    "Thu",
    "Fri",
    "Sat",
    "Sun"
  ],
  "scheduleConfig": {
    "sendAt": "2026-04-01 09:00 AM"
  },
  "rssConfig": {
    "name": "Weekly Digest",
    "rssFeedURL": "https://example.com/rss",
    "repeatAfter": "every_day",
    "repeatAfterTime": "09:00 AM"
  },
  "abTestConfig": {
    "testType": "subjectLine",
    "testDuration": 3600,
    "variationCount": 2,
    "testSize": 30,
    "winningCriteria": "openRate",
    "variations": [
      {
        "subject": "Subject A"
      },
      {
        "subject": "Subject B"
      }
    ]
  }
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/emails/locations/<locationId>/campaigns/emails/<campaignId>/schedule")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"scheduleType\":\"immediate\",\"timeZone\":\"America/New_York\",\"userId\":\"507f1f77bcf86cd799439099\",\"userName\":\"John Doe\",\"emailMeta\":{\"subject\":\"Our February Newsletter\",\"fromName\":\"John Doe\",\"fromEmail\":\"john@example.com\"},\"recipients\":{\"type\":\"contact\",\"contactIds\":[\"contactId1\",\"contactId2\"]},\"sendDays\":[\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\"],\"scheduleConfig\":{\"sendAt\":\"2026-04-01 09:00 AM\"},\"rssConfig\":{\"name\":\"Weekly Digest\",\"rssFeedURL\":\"https://example.com/rss\",\"repeatAfter\":\"every_day\",\"repeatAfterTime\":\"09:00 AM\"},\"abTestConfig\":{\"testType\":\"subjectLine\",\"testDuration\":3600,\"variationCount\":2,\"testSize\":30,\"winningCriteria\":\"openRate\",\"variations\":[{\"subject\":\"Subject A\"},{\"subject\":\"Subject B\"}]}}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/emails/locations/<locationId>/campaigns/emails/<campaignId>/schedule"
  payload := strings.NewReader(`{
  "scheduleType": "immediate",
  "timeZone": "America/New_York",
  "userId": "507f1f77bcf86cd799439099",
  "userName": "John Doe",
  "emailMeta": {
    "subject": "Our February Newsletter",
    "fromName": "John Doe",
    "fromEmail": "john@example.com"
  },
  "recipients": {
    "type": "contact",
    "contactIds": [
      "contactId1",
      "contactId2"
    ]
  },
  "sendDays": [
    "Mon",
    "Tue",
    "Wed",
    "Thu",
    "Fri",
    "Sat",
    "Sun"
  ],
  "scheduleConfig": {
    "sendAt": "2026-04-01 09:00 AM"
  },
  "rssConfig": {
    "name": "Weekly Digest",
    "rssFeedURL": "https://example.com/rss",
    "repeatAfter": "every_day",
    "repeatAfterTime": "09:00 AM"
  },
  "abTestConfig": {
    "testType": "subjectLine",
    "testDuration": 3600,
    "variationCount": 2,
    "testSize": 30,
    "winningCriteria": "openRate",
    "variations": [
      {
        "subject": "Subject A"
      },
      {
        "subject": "Subject B"
      }
    ]
  }
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/emails/locations/<locationId>/campaigns/emails/<campaignId>/schedule")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "scheduleType": "immediate",
  "timeZone": "America/New_York",
  "userId": "507f1f77bcf86cd799439099",
  "userName": "John Doe",
  "emailMeta": {
    "subject": "Our February Newsletter",
    "fromName": "John Doe",
    "fromEmail": "john@example.com"
  },
  "recipients": {
    "type": "contact",
    "contactIds": [
      "contactId1",
      "contactId2"
    ]
  },
  "sendDays": [
    "Mon",
    "Tue",
    "Wed",
    "Thu",
    "Fri",
    "Sat",
    "Sun"
  ],
  "scheduleConfig": {
    "sendAt": "2026-04-01 09:00 AM"
  },
  "rssConfig": {
    "name": "Weekly Digest",
    "rssFeedURL": "https://example.com/rss",
    "repeatAfter": "every_day",
    "repeatAfterTime": "09:00 AM"
  },
  "abTestConfig": {
    "testType": "subjectLine",
    "testDuration": 3600,
    "variationCount": 2,
    "testSize": 30,
    "winningCriteria": "openRate",
    "variations": [
      {
        "subject": "Subject A"
      },
      {
        "subject": "Subject B"
      }
    ]
  }
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "scheduleType": "immediate",
  "timeZone": "America/New_York",
  "userId": "507f1f77bcf86cd799439099",
  "userName": "John Doe",
  "emailMeta": {
    "subject": "Our February Newsletter",
    "fromName": "John Doe",
    "fromEmail": "john@example.com"
  },
  "recipients": {
    "type": "contact",
    "contactIds": [
      "contactId1",
      "contactId2"
    ]
  },
  "sendDays": [
    "Mon",
    "Tue",
    "Wed",
    "Thu",
    "Fri",
    "Sat",
    "Sun"
  ],
  "scheduleConfig": {
    "sendAt": "2026-04-01 09:00 AM"
  },
  "rssConfig": {
    "name": "Weekly Digest",
    "rssFeedURL": "https://example.com/rss",
    "repeatAfter": "every_day",
    "repeatAfterTime": "09:00 AM"
  },
  "abTestConfig": {
    "testType": "subjectLine",
    "testDuration": 3600,
    "variationCount": 2,
    "testSize": 30,
    "winningCriteria": "openRate",
    "variations": [
      {
        "subject": "Subject A"
      },
      {
        "subject": "Subject B"
      }
    ]
  }
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/emails/locations/<locationId>/campaigns/emails/<campaignId>/schedule' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
