Add

[POST] .../v1/campaign/add

Creates a campaign Use this method to create an SMS, Telegram or Email campaign, collect recipients from retail customers, partners or CRM clients and register the campaign in the external campaign handler. The method validates type, name, message, recipient rules, integration settings, optional Telegram image and scheduled run date, stores the campaign and recipient list, creates a schedule and returns new_id. Required fields are type, run_immediately, name and message; run_date is required only when run_immediately is false and is ignored when run_immediately is true. Name is limited to 150 characters, message to 3000 characters, recepients[].entity_type must not be Default and run_date must not be in the past when run_immediately is false. The caller must have marketing campaign add permission; missing body or required fields, invalid or inactive integration, integration handler mismatch, missing default SMS or Telegram handler, unsupported Email handler, invalid image, no recipients, schedule creation failure, database errors and action-log or handler errors are returned as HTTP 200 ErrorResult business errors.

Request Parameters

Name Type Required Description
connected_integration_id String Optional Connected integration ID. Takes precedence over integration_key when both fields are provided.
file String Optional Base64-encoded image file.
message String Required Mailing message text.
name String Required Mailing name.
recepients Array of CampaignRecepient Optional Recipient array. If not provided or empty, RetailCustomer without filters is used as the default behavior.
run_date Int64 Optional Mailing run date as Unix time in seconds. Required when run_immediately is false; ignored when run_immediately is true.
run_immediately Boolean Required Indicates whether the mailing starts immediately after creation: true - starts immediately and run_date is ignored, false - starts on the date specified in run_date.
type String Required Mailing type. Allowed values: Default, SMS, Telegram, Email.

Request Example

{
  "type": "SMS",
  "connected_integration_id": "c98210addc4f4e1bb50b17a8c1299a37",
  "run_immediately": true,
  "name": "January loyalty campaign",
  "message": "Visit us this week and get a loyalty bonus.",
  "recepients": [
    {
      "entity_type": "RetailCustomer",
      "filters": [
        {
          "Field": "main_phone",
          "Operator": "Exists"
        }
      ]
    }
  ]
}

Response Parameters

Name Type Description
ok Boolean Indicates whether the request completed successfully.
result Insert Created record result.

Response Example

{
  "ok": true,
  "result": {
    "new_id": 1
  }
}