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

# Delete Campaign

> Delete a campaign and all associated data including promotions, store associations, and historical records.

This endpoint permanently removes a campaign and all its associated data from the system. This includes promotions, store associations, usage statistics, and historical performance data.

<Warning>
  Campaign deletion is irreversible. All associated promotions will be deactivated immediately, and historical data will be permanently lost. Consider archiving campaigns instead of deletion for data retention.
</Warning>

### Path Parameters

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

<ParamField path="campaign_id" type="string" required>
  The unique identifier of the campaign to delete
</ParamField>

### Query Parameters

<ParamField query="current_local_date" type="string" optional>
  Current local date for audit and timezone purposes (e.g., "Nov 15 2024 03:46:34")
</ParamField>

<ParamField query="force_delete" type="boolean" optional default="false">
  Force deletion even if campaign has active promotions or associations
</ParamField>

<ParamField query="archive_data" type="boolean" optional default="true">
  Whether to create an archive backup before deletion
</ParamField>

### Response

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

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

<ResponseField name="campaign_id" type="string">
  The ID of the deleted campaign
</ResponseField>

<ResponseField name="deleted_at" type="string">
  Timestamp when the deletion occurred
</ResponseField>

<ResponseField name="affected_items" type="object">
  Summary of what was deleted along with the campaign

  <Expandable title="Deletion Impact">
    <ResponseField name="promotions_deleted" type="integer">
      Number of promotions that were deleted
    </ResponseField>

    <ResponseField name="store_associations_removed" type="integer">
      Number of store associations that were removed
    </ResponseField>

    <ResponseField name="historical_records_archived" type="integer">
      Number of historical records that were archived
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="archive_location" type="string">
  Location where archived data was stored (if archive\_data=true)
</ResponseField>

### Response Example

```json theme={null}
{
  "success": true,
  "message": "Campaign successfully deleted",
  "campaign_id": "1000010",
  "deleted_at": "2024-01-15T16:45:00Z",
  "affected_items": {
    "promotions_deleted": 3,
    "store_associations_removed": 5,
    "historical_records_archived": 1247
  },
  "archive_location": "s3://campaign-archives/company-1000058/campaign-1000010-20240115.json"
}
```

<Accordion title="Deletion Process Workflow">
  When a campaign is deleted, the following occurs in sequence:

  1. **Validation**: Verify deletion permissions and campaign status
  2. **Promotion Deactivation**: Immediately stop all active promotions
  3. **Store Disassociation**: Remove campaign from all associated stores
  4. **Data Archival**: Create backup of all campaign data (if enabled)
  5. **Record Deletion**: Remove campaign and related records from active database
  6. **Cache Invalidation**: Clear all cached campaign data across systems
  7. **Audit Logging**: Record deletion event for compliance and tracking
</Accordion>

<Note>
  **Data Archival**: By default, campaign data is archived before deletion. This allows for potential data recovery and historical analysis while removing the campaign from active systems.
</Note>

<Tip>
  **Alternative to Deletion**: Consider setting campaign status to "inactive" or "archived" instead of deletion to preserve historical data while removing the campaign from customer-facing systems.
</Tip>

### Pre-Deletion Checks

<Accordion title="Deletion Safety Checks">
  **Active Promotions Check**

  * Verifies if campaign has active promotions
  * Warns about customer impact of immediate deactivation
  * Requires force\_delete=true to proceed with active promotions

  **Store Associations Check**

  * Identifies all stores currently using the campaign
  * Estimates impact on store operations
  * Provides list of affected store locations

  **Historical Data Check**

  * Calculates amount of historical data that will be lost
  * Estimates analytics impact
  * Recommends archival before deletion

  **Dependency Check**

  * Identifies other campaigns that reference this campaign
  * Checks for integration dependencies
  * Verifies no business-critical dependencies exist
</Accordion>

### Use Cases

<Accordion title="Common Deletion Scenarios">
  **Campaign Cleanup**

  * Remove test or duplicate campaigns
  * Clean up failed campaign launches
  * Eliminate outdated promotional campaigns

  **Compliance Requirements**

  * Delete campaigns containing expired promotional content
  * Remove campaigns with data privacy concerns
  * Comply with data retention policies

  **System Maintenance**

  * Remove campaigns that are causing system issues
  * Clean up campaigns with corrupted data
  * Eliminate campaigns that are no longer relevant

  **Business Restructuring**

  * Delete campaigns from discontinued product lines
  * Remove campaigns from closed store locations
  * Eliminate campaigns that don't align with new business strategy
</Accordion>

### Error Responses

<Accordion title="Common Error Scenarios">
  **Campaign Not Found**

  ```json theme={null}
  {
    "success": false,
    "message": "Campaign not found",
    "error_code": "CAMPAIGN_NOT_FOUND",
    "campaign_id": "invalid-id"
  }
  ```

  **Active Promotions Prevent Deletion**

  ```json theme={null}
  {
    "success": false,
    "message": "Cannot delete campaign with active promotions",
    "error_code": "ACTIVE_PROMOTIONS_EXIST",
    "active_promotions": 3,
    "suggestion": "Set force_delete=true to override"
  }
  ```

  **Insufficient Permissions**

  ```json theme={null}
  {
    "success": false,
    "message": "Insufficient permissions to delete campaign",
    "error_code": "PERMISSION_DENIED",
    "required_role": "campaign_admin"
  }
  ```

  **Dependency Conflict**

  ```json theme={null}
  {
    "success": false,
    "message": "Campaign cannot be deleted due to dependencies",
    "error_code": "DEPENDENCY_CONFLICT",
    "dependencies": [
      "Linked to active store integrations",
      "Referenced by reporting system"
    ]
  }
  ```
</Accordion>

<Warning>
  **Immediate Impact**: Campaign deletion immediately affects all customer-facing systems. Active promotions will stop working instantly, which may impact customer experience and pending orders.
</Warning>

### Recovery Options

<Accordion title="Post-Deletion Recovery">
  **Archive Recovery**

  * Archived data can be restored within 30 days
  * Requires administrative approval
  * May not restore all system integrations

  **Backup Systems**

  * System backups may contain campaign data
  * Recovery requires technical intervention
  * Data consistency cannot be guaranteed

  **Manual Reconstruction**

  * Campaign settings can be manually recreated
  * Historical performance data will be lost
  * Promotions and associations must be rebuilt
</Accordion>
