> ## Documentation Index
> Fetch the complete documentation index at: https://developer.lulacommerce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Campaign

> Create a new marketing campaign for a company with detailed configuration including scheduling, targeting, and media assets.

This endpoint allows you to create comprehensive marketing campaigns for your company. Campaigns can include rich media content, precise scheduling, and detailed targeting criteria to maximize marketing effectiveness.

<Info>
  New campaigns are created in the specified status and can be immediately associated with stores and promotions for complete marketing campaign setup.
</Info>

### Path Parameters

<ParamField path="company_id" type="string" required>
  The unique identifier of the company creating the campaign
</ParamField>

### Request Body

<ParamField body="name" type="string" required>
  Campaign name for identification and management
</ParamField>

<ParamField body="description" type="string" required>
  Detailed description of the campaign objectives and content
</ParamField>

<ParamField body="start_date" type="string" required>
  Campaign start date (YYYY-MM-DD format)
</ParamField>

<ParamField body="end_date" type="string" required>
  Campaign end date (YYYY-MM-DD format)
</ParamField>

<ParamField body="status" type="string" required>
  Campaign status: "active", "inactive", "scheduled", "expired"
</ParamField>

<ParamField body="image" type="string" optional>
  Base64 encoded image data for campaign visual assets
</ParamField>

### Response

<ResponseField name="id" type="string">
  Unique campaign identifier
</ResponseField>

<ResponseField name="company_id" type="string">
  Company identifier this campaign belongs to
</ResponseField>

<ResponseField name="name" type="string">
  Campaign name
</ResponseField>

<ResponseField name="description" type="string">
  Campaign description
</ResponseField>

<ResponseField name="start_date" type="string">
  Campaign start date
</ResponseField>

<ResponseField name="end_date" type="string">
  Campaign end date
</ResponseField>

<ResponseField name="status" type="string">
  Current campaign status
</ResponseField>

<ResponseField name="image" type="string">
  URL to the uploaded campaign image
</ResponseField>

<ResponseField name="created_by" type="string">
  ID of the user who created the campaign
</ResponseField>

<ResponseField name="updated_by" type="string">
  ID of the user who last updated the campaign
</ResponseField>

<ResponseField name="created_at" type="string">
  Campaign creation timestamp
</ResponseField>

<ResponseField name="updated_at" type="string">
  Campaign last update timestamp
</ResponseField>

<ResponseField name="deletedAt" type="string">
  Deletion timestamp (null for active campaigns)
</ResponseField>

### Request Example

```json theme={null}
{
  "description": "Spring seasonal promotion featuring fresh products and outdoor essentials",
  "end_date": "2025-03-25",
  "start_date": "2025-12-31",
  "name": "Spring Fresh Campaign",
  "status": "active",
  "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=="
}
```

### Response Example

```json theme={null}
{
  "id": "1000010",
  "company_id": "1000058",
  "description": "Spring seasonal promotion featuring fresh products and outdoor essentials",
  "end_date": "2025-03-25",
  "start_date": "2025-12-31",
  "name": "Spring Fresh Campaign",
  "status": "active",
  "image": "https://lula-stores-service-staging.s3.amazonaws.com/company/1000058/campaigns/1000010/1744591882710.webp",
  "created_by": "1000418",
  "updated_by": "1000418",
  "updated_at": "2025-04-14T00:51:22.994Z",
  "created_at": "2025-04-14T00:51:22.994Z",
  "deletedAt": null
}
```

<Accordion title="Campaign Creation Workflow">
  When a campaign is created, the following processes occur:

  1. **Validation**: Campaign data is validated for completeness and consistency
  2. **Image Processing**: Base64 image is processed and uploaded to cloud storage
  3. **ID Generation**: Unique campaign identifier is generated
  4. **Database Storage**: Campaign details are stored with audit information
  5. **Status Initialization**: Campaign is set to specified initial status
  6. **Availability Setup**: Campaign becomes available for store association and promotion creation
</Accordion>

<Note>
  **Image Processing**: Campaign images are automatically processed, optimized, and stored in cloud storage. The response includes the final image URL for use in marketing materials.
</Note>

<Tip>
  **Date Validation**: Ensure end\_date is after start\_date and both dates are in the future for scheduled campaigns. Past dates are allowed for historical campaign tracking.
</Tip>

### Campaign Status Guide

<Accordion title="Campaign Status Meanings">
  **active**

  * Campaign is currently running and accepting customers
  * Promotions are being applied to qualifying orders
  * Campaign is visible in customer-facing applications

  **inactive**

  * Campaign is created but not currently running
  * Promotions are not being applied
  * Campaign can be activated when ready

  **scheduled**

  * Campaign is set to start at a future date
  * System will automatically activate when start\_date arrives
  * Useful for planned marketing initiatives

  **expired**

  * Campaign has passed its end\_date
  * No longer accepting new customers
  * Historical data remains available for analysis
</Accordion>

### Error Responses

<Accordion title="Common Error Scenarios">
  **Invalid Date Range**

  ```json theme={null}
  {
    "error": "Invalid date range",
    "message": "End date must be after start date",
    "code": "INVALID_DATE_RANGE"
  }
  ```

  **Company Not Found**

  ```json theme={null}
  {
    "error": "Company not found",
    "message": "The specified company does not exist",
    "code": "COMPANY_NOT_FOUND"
  }
  ```

  **Image Processing Error**

  ```json theme={null}
  {
    "error": "Image processing failed",
    "message": "Unable to process the provided image data",
    "code": "IMAGE_PROCESSING_ERROR"
  }
  ```

  **Validation Error**

  ```json theme={null}
  {
    "error": "Validation failed",
    "message": "Required fields are missing or invalid",
    "code": "VALIDATION_ERROR",
    "details": {
      "name": "Campaign name is required",
      "description": "Description cannot be empty"
    }
  }
  ```
</Accordion>

<Warning>
  **Image Size**: Campaign images should be optimized for web use. Large images may cause processing delays or failures. Recommended maximum size is 2MB.
</Warning>

### Use Cases

<Accordion title="Common Campaign Scenarios">
  **Seasonal Campaigns**

  * Holiday promotions (Christmas, Halloween, Valentine's Day)
  * Seasonal product features (summer drinks, winter clothing)
  * Weather-based campaigns (rainy day specials, heat wave promotions)

  **Product Launch Campaigns**

  * New product introductions with special pricing
  * Limited edition product features
  * Brand partnership campaigns

  **Customer Acquisition Campaigns**

  * Welcome campaigns for new customers
  * Referral program promotions
  * Social media engagement campaigns

  **Revenue Optimization Campaigns**

  * Clearance campaigns for slow-moving inventory
  * Upselling campaigns for high-margin products
  * Bundle promotion campaigns
</Accordion>
