Skip to main content
POST

Overview

Create a campaign and add its contacts from a CSV or Excel file in one request. The file is validated, the campaign is created, and each row becomes a contact. Calling starts when you call Start Campaign. An inbound campaign takes no file: it only links the calling numbers to the new campaign so incoming calls are recorded on it.

Prerequisites

  • An API key for your workspace
  • A CSV or Excel file with a phoneNumber column and any variables the agent needs (not needed for inbound).
  • At least one phone number with an outbound agent assigned. All numbers must use agents of the same conversation type.

Request

string
required
Your workspace API key. Create one from the profile menu in the dashboard → API Keys.
CSV/Excel File Requirements:
  • Supported formats: CSV (.csv) or Excel (.xls, .xlsx)
  • Must include a header row
  • Must include phoneNumber column (required)
  • Every row must have a value for each variable listed in mandatoryVariables
  • CSV headers should match agent variable keys (e.g., phoneNumber, name, account_id, custom_field_1)
  • The phoneNumber column is required; all other columns are flexible based on your agent’s needs
  • Extra columns are stored and forwarded to the agent state machine
  • File encoding should be UTF-8
  • Empty files or files with no valid rows will be rejected
File Processing:
  • The system automatically detects file type by extension
  • Excel files use the first sheet
  • Invalid rows are identified and reported (unless type="true")
  • Data is normalized and validated against agent requirements
  • Phone numbers are deduplicated (only the first occurrence is kept)
  • A file with no valid rows is always rejected

Response

array[object]
required
The created campaign. The campaign ID is data.batch[0]._id.
string
required
ID of this upload. Pass it as uuid to Start Campaign to start calling these contacts. For inbound campaigns there are no contacts to start.

Error Handling

Errors return status: false, with the reason in errorMessage.
  • 400 Bad Request
    • Batch name required, Invalid batch type, callingNumbers required, CSV file required or Unsupported file type.
    • callHours required or Invalid callHours format – callingHour is missing or not in HH:MM format.
    • Invalid input format – callingHour, callingNumbers, allowedDays or mandatoryVariables is not valid JSON.
    • Invalid pushingCrms format, or a pushingCrms entry fails validation.
    • DNC not enabled for organization.
    • Invalid holidayListId or Holiday list not found.
    • All phoneNumbers must have same agent type – the numbers’ outbound agents have different conversation types.
    • The file is empty or has no valid rows.
  • 404 Not Found – Phone(s) not found: … or No agent linked to phone …: a calling number doesn’t exist or has no outbound agent.
  • 400 Bad Request (invalid rows) – The file has invalid rows and type is "false". data contains code: "INVALID_CSV_ROWS", totalInvalidRows, validRows, truncated and invalidRows (each { rowNumber, phoneNumber, reason }). Fix the rows, or resend with type="true" to skip them.
  • 401 Unauthorized – Missing or invalid API key.
  • 409 Conflict – inbound campaigns only. A calling number is already active on another inbound campaign. data.requiresConfirmation is true and data.conflicts lists each number as { phoneId, phoneNumber, currentBatchId, currentBatchName }. Resend with confirmReassign="true" to move them.
  • 500 Internal Server Error – File parsing failed, database error, or other server errors.
Then call POST /api/call/start-calling with the campaign ID and data.uuid to start calling. Use GET /api/call/batch-details/{batchId} to confirm the imported rows match the expected total.