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

# Create Campaign

> Create a new campaign with configuration and customer records.

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication (e.g., `Bearer <your_token>`).
</ParamField>

### Body Parameters

<ParamField body="name" type="string" required>
  The name of the campaign.
</ParamField>

<ParamField body="description" type="string" required>
  A brief description of the campaign's purpose.
</ParamField>

<ParamField body="campaignType" type="string" required>
  The type of campaign (e.g., `emi`, `edi`, `lead`).

  <Expandable title="options">
    * `emi`
    * `edi`
    * `lead`
  </Expandable>
</ParamField>

<ParamField body="workflowId" type="string">
  The ID of the workflow to associate with this campaign.
</ParamField>

<ParamField body="startDate" type="string" required>
  Start date in `YYYY-MM-DD` format.
</ParamField>

<ParamField body="startTime" type="string" required>
  Start time in `HH:MM` format (24-hour).
</ParamField>

<ParamField body="endDate" type="string" required>
  End date in `YYYY-MM-DD` format.
</ParamField>

<ParamField body="endTime" type="string" required>
  End time in `HH:MM` format (24-hour).
</ParamField>

<ParamField body="languages" type="string[]" required placeholder="e.g. &#x22;hindi&#x22;">
  List of languages supported in this campaign (e.g., `["english", "hindi"]`).

  <Expandable title="options">
    * `hindi`
    * `english`
    * `bengali`
    * `telugu`
    * `marathi`
    * `tamil`
    * `gujarati`
    * `kannada`
    * `malayalam`
    * `punjabi`
    * `odia`
    * `assamese`
  </Expandable>
</ParamField>

<ParamField body="region" type="string" required>
  Target region for the campaign  (e.g., `north`).

  <Expandable title="options">
    * `north`
    * `south`
    * `east`
    * `west`
    * `central`
  </Expandable>
</ParamField>

<ParamField body="tags" type="string[]">
  Tags for categorization (e.g., `["priority", "q1"]`).
</ParamField>

<ParamField body="jsonData" type="array" required>
  Array of customer objects. The required fields within these objects change based on your campaign focus.

  <Note>
    **Identifier Requirement**

    Depending on your campaign type, you must provide either a `loan_id` (for Debt Collection) or a `lead_id` (for Lead Generation). Requests missing both will return a 400 Bad Request.
  </Note>

  <Tabs>
    <Tab title="Debt Collection">
      **Use this structure if you are managing existing loans.**

      <Expandable title="item properties">
        <ParamField body="loan_id" type="string" required>Unique identifier for the loan record.</ParamField>
        <ParamField body="first_name" type="string" required>Customer's first name as registered in the system.</ParamField>
        <ParamField body="last_name" type="string" required>Customer's last name as registered in the system.</ParamField>
        <ParamField body="phone_number" type="string" required>Customer's primary contact number for payment reminders and notifications.</ParamField>
        <ParamField body="loan_amount" type="number" required>Total principal amount of the loan in the account currency.</ParamField>
        <ParamField body="emi_amount" type="number" required>Equated Monthly Installment (EMI) amount due for the current billing cycle.</ParamField>
        <ParamField body="loan_period" type="number" required>Total loan tenure expressed as the number of monthly installments.</ParamField>
        <ParamField body="current_emi" type="number" required>The current installment number in the repayment schedule (e.g., 5 of 12).</ParamField>
        <ParamField body="emi_due_date" type="string" required>Due date for the current EMI payment. Format: `YYYY-MM-DD`.</ParamField>

        <ParamField body="payment_status" type="string" required>
          Current status of the customer's EMI payment.

          <Expandable title="options">
            * `bounced` — Payment was attempted but failed (e.g., insufficient funds).
            * `pending` — Payment is due but not yet initiated.
            * `partial` — Customer has made a partial payment.
            * `paid` — Payment has been completed by the customer.
            * `received` — Payment has been completed by the customer.
          </Expandable>
        </ParamField>

        <ParamField body="language" type="string">Preferred language for the AI agent to use during the customer conversation (e.g., `english`, `hindi`, `tamil`).</ParamField>
      </Expandable>
    </Tab>

    <Tab title="Lead Generation">
      **Use this structure for new sales or lead acquisition.**

      <Expandable title="item properties">
        <ParamField body="lead_id" type="string">Unique identifier for the lead record.</ParamField>
        <ParamField body="first_name" type="string" required>Customer's first name as registered in the system.</ParamField>
        <ParamField body="last_name" type="string" required>Customer's last name as registered in the system.</ParamField>
        <ParamField body="phone_number" type="string" required>Customer's primary contact number for outreach and follow-ups.</ParamField>
        <ParamField body="lead_date" type="string" required>Date the lead was created or captured. Format: `YYYY-MM-DD`.</ParamField>
        <ParamField body="language" type="string">Preferred language for the AI agent to use during the customer conversation (e.g., `english`, `hindi`, `tamil`).</ParamField>
      </Expandable>
    </Tab>
  </Tabs>
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates if the creation was successful.
</ResponseField>

<ResponseField name="message" type="string">
  A confirmation message.
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="string">
      The unique ID of the newly created campaign.
    </ResponseField>

    <ResponseField name="name" type="string">
      The name the newly created campaign.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="error" type="string">
  The error type or code (Error responses only).
</ResponseField>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "success": true,
    "message": "Campaign created successfully",
    "data": {
      "id": "camp_abc123",
      "name": "Debt Collection Q1"
    }
  }

  ```

  ```json 400 Bad Request theme={null}
  {
    "success": false,
    "error": "ValidationError",
    "message": "Missing required field: workflowId"
  }

  ```

  ```json 401 Unauthorized theme={null}
  {
    "success": false,
    "error": "Unauthorized",
    "message": "Missing or invalid authorization header"
  }

  ```

  ```json 500 Server Error theme={null}
  {
    "success": false,
    "error": "InternalServerError",
    "message": "An unexpected error occurred"
  }

  ```
</ResponseExample>
