> ## 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.

# Bulk Update Campaign

> Update multiple campaigns simultaneously with the same changes, ideal for bulk campaign management and maintenance operations.

This endpoint allows you to apply the same updates to multiple campaigns at once, streamlining campaign management for scenarios where you need to modify several campaigns with identical changes.

<Info>
  Bulk updates are processed as a single transaction. If any campaign update fails, the entire operation is rolled back to maintain data consistency.
</Info>

### Path Parameters

<ParamField path="company_id" type="string" required>
  The unique identifier of the company that owns the campaigns
</ParamField>

### Request Body

<ParamField body="campaignIds" type="array" required>
  Array of campaign IDs to update
</ParamField>

<ParamField body="updates" type="object" required>
  Object containing the updates to apply to all specified campaigns

  <Expandable title="Update Fields">
    <ParamField body="name" type="string" optional>
      New campaign name (will be applied to all campaigns)
    </ParamField>

    <ParamField body="description" type="string" optional>
      New campaign description
    </ParamField>

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

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

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

    <ParamField body="additional_settings" type="object" optional>
      Additional campaign settings to update
    </ParamField>
  </Expandable>
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates whether the bulk update was successful
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message or error details
</ResponseField>

<ResponseField name="campaignIds" type="array">
  Array of campaign IDs that were updated
</ResponseField>

<ResponseField name="updates" type="object">
  Echo of the updates that were applied
</ResponseField>

<ResponseField name="updated_count" type="integer">
  Number of campaigns successfully updated
</ResponseField>

<ResponseField name="failed_updates" type="array">
  Array of campaigns that failed to update with error details

  <Expandable title="Failed Update Details">
    <ResponseField name="campaign_id" type="string">Campaign ID that failed</ResponseField>
    <ResponseField name="error" type="string">Error message for this campaign</ResponseField>
    <ResponseField name="error_code" type="string">Error code for troubleshooting</ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="timestamp" type="string">
  Timestamp when the bulk update was processed
</ResponseField>

### Request Example

```json theme={null}
{
  "campaignIds": [
    1000013
  ],
  "updates": {
    "name": "Get the Turkey club combo $10.99",
    "description": "Hey! You can avail the opportunity this time and get benefits by choosing 'Get the Turkey club combo $10.99'",
    "end_date": "2025-03-25",
    "start_date": "2025-12-31",
    "status": "inactive"
  }
}
```

### Response Example

```json theme={null}
{
  "success": true,
  "message": "Bulk update completed successfully",
  "campaignIds": [
    1000013
  ],
  "updates": {
    "name": "Get the Turkey club combo $10.99",
    "description": "Hey! You can avail the opportunity this time and get benefits by choosing 'Get the Turkey club combo $10.99'",
    "end_date": "2025-03-25",
    "start_date": "2025-12-31",
    "status": "inactive"
  },
  "updated_count": 1,
  "failed_updates": [],
  "timestamp": "2024-01-15T16:45:00Z"
}
```

<Accordion title="Bulk Update Process">
  The bulk update process follows these steps:

  1. **Validation**: All campaign IDs are validated for existence and permissions
  2. **Pre-Check**: Updates are validated against business rules for each campaign
  3. **Transaction Start**: Database transaction begins to ensure consistency
  4. **Sequential Updates**: Each campaign is updated in sequence
  5. **Error Handling**: Any failures trigger rollback of all changes
  6. **Confirmation**: Successful completion commits all changes
  7. **Notification**: Affected systems are notified of changes
</Accordion>

<Note>
  **Transaction Safety**: Bulk updates use database transactions to ensure either all campaigns are updated successfully or none are modified, maintaining data consistency.
</Note>

<Tip>
  **Performance Consideration**: For large numbers of campaigns (>50), consider breaking the update into smaller batches to avoid timeout issues and improve processing speed.
</Tip>

### Use Cases

<Accordion title="Common Bulk Update Scenarios">
  **Seasonal Campaign Management**

  * Update end dates for all seasonal campaigns
  * Change status of holiday campaigns to inactive
  * Extend successful campaigns across multiple products

  **Compliance Updates**

  * Update campaign descriptions for regulatory compliance
  * Modify campaign terms across all active promotions
  * Apply uniform changes for legal requirements

  **Brand Standardization**

  * Update campaign naming conventions
  * Standardize descriptions across campaigns
  * Apply consistent messaging and branding

  **Performance Optimization**

  * Pause underperforming campaigns simultaneously
  * Extend high-performing campaigns
  * Adjust timing based on analytics insights

  **Administrative Maintenance**

  * Archive completed campaigns
  * Update campaign ownership or management
  * Apply system-wide configuration changes
</Accordion>

### Error Handling

<Accordion title="Bulk Update Error Scenarios">
  **Partial Failure Response**

  ```json theme={null}
  {
    "success": false,
    "message": "Bulk update completed with errors",
    "campaignIds": [1000013, 1000014, 1000015],
    "updated_count": 2,
    "failed_updates": [
      {
        "campaign_id": "1000015",
        "error": "Campaign not found",
        "error_code": "CAMPAIGN_NOT_FOUND"
      }
    ],
    "timestamp": "2024-01-15T16:45:00Z"
  }
  ```

  **Validation Error**

  ```json theme={null}
  {
    "success": false,
    "message": "Validation failed for bulk update",
    "error_code": "VALIDATION_ERROR",
    "validation_errors": [
      {
        "field": "end_date",
        "error": "End date must be after start date"
      }
    ]
  }
  ```

  **Transaction Rollback**

  ```json theme={null}
  {
    "success": false,
    "message": "Bulk update failed and was rolled back",
    "error_code": "TRANSACTION_FAILED",
    "rollback_reason": "Database constraint violation",
    "affected_campaigns": 0
  }
  ```
</Accordion>

<Warning>
  **Impact Assessment**: Bulk updates affect multiple campaigns simultaneously. Ensure you understand the impact on active promotions, customer experience, and store operations before proceeding.
</Warning>

### Best Practices

<Accordion title="Bulk Update Best Practices">
  **Planning**

  * Test bulk updates on a small subset first
  * Verify campaign IDs before executing large updates
  * Consider timing of updates relative to customer activity

  **Data Validation**

  * Ensure all update fields are valid for all target campaigns
  * Check date ranges and status transitions for consistency
  * Validate permissions for all campaigns being updated

  **Monitoring**

  * Monitor system performance during large bulk updates
  * Track success rates and error patterns
  * Set up alerts for bulk update failures

  **Recovery Planning**

  * Have rollback procedures ready for failed updates
  * Maintain backups before large bulk operations
  * Document changes for audit and troubleshooting
</Accordion>

### Limitations

<Accordion title="Bulk Update Limitations">
  **Campaign Limits**

  * Maximum 100 campaigns per bulk update request
  * Processing timeout after 5 minutes
  * Memory limitations for very large updates

  **Field Restrictions**

  * Some fields may not be suitable for bulk updates
  * Campaign-specific settings cannot be bulk updated
  * Image uploads not supported in bulk operations

  **Status Constraints**

  * Some status transitions may not be allowed for all campaigns
  * Campaign dependencies may prevent bulk status changes
  * Business rules apply to each campaign individually
</Accordion>
