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

# Batch Discount Codes

> Create and manage batch discount codes for large-scale marketing campaigns

# Batch Discount Codes

## Overview

**Batch Discount Codes** allow you to create a single template with unified discount rules and automatically generate thousands of unique discount codes. This feature is perfect for targeted marketing campaigns, partner distributions, and large-scale promotional events.

### Key Features

* **Template-Based Management:** One template contains all discount rules, and all generated codes share the same rules
* **Bulk Generation:** Generate up to 10,000 unique discount codes at once
* **Automatic Uniqueness:** Each generated code is automatically unique and prevents duplicates
* **Rule Inheritance:** All codes automatically inherit discount rules from the template
* **Usage Tracking:** Track the usage status, user, and time for each individual code
* **Flexible Expansion:** Increase the template quantity after activation to generate additional codes

### Use Cases

1. **Targeted Marketing:** Send unique discount codes to 1,000 specific users via email, preventing code sharing or abuse
2. **Partner Distribution:** Pre-generate 500 codes for partners to distribute as physical coupons
3. **Large-Scale Campaigns:** Create massive promotional events with thousands of one-time-use codes
4. **Controlled Distribution:** Generate a fixed number of codes to ensure campaign scale is manageable

***

## Creating a Batch Discount Code Template

To create a batch discount code template:

1. Navigate to the **Discount Code** section in the UniBee Dashboard
2. Click **New Batch Discount** or **Create Batch Template**
3. Configure the template settings

### Template Configuration

When creating a batch template, you'll define:

| Field               | Description                                                           | Example                    |
| :------------------ | :-------------------------------------------------------------------- | :------------------------- |
| **Batch Name**      | An internal name for tracking the campaign                            | `2025 Spring VIP Campaign` |
| **Code Prefix**     | The prefix for all generated codes (must be unique at merchant level) | `VIP2025`                  |
| **Target Quantity** | The number of unique codes to generate (1-10,000)                     | `1000`                     |
| **Discount Type**   | Percentage or Fixed Amount discount                                   | `20% off` or `$10.00 off`  |
| **Applies to**      | All Products or Specific Products/Plans                               | `Premium Plan - Yearly`    |
| **Valid Date**      | Start and expiration dates for the campaign                           | `Jan 1st` to `Mar 31st`    |
| **Duration**        | One-time, Forever, or Repeating (with cycle limit)                    | `One-time` or `3 cycles`   |

### Configuration Rules

* **Code Prefix:** Must be 1-20 characters and unique at your merchant level
* **Quantity:** Can be set between 1 and 10,000 codes
* **Discount Rules:** Same configuration options as standard discount codes
* **Advanced Settings:** All advanced configuration options (scope, subscription limits, etc.) are available

After configuration, click **Save**. The template status will be set to **Editing**.

***

## Activating and Generating Codes

### Step 1: Activate the Template

1. While the template status is **Editing**, you can modify any settings
2. Click the **Activate** button to activate the template
3. Once activated, the template status changes to **Active**

**Important:** Only activated templates can generate discount codes.

### Step 2: Generate Codes

Once the template is activated, you can generate codes using one of two methods:

#### Method A: Automatic Generation

1. Click **Generate Codes** on the template detail page
2. The system automatically generates unique codes based on the target quantity
3. Codes are formatted as: `{CodePrefix}{8RandomCharacters}`
   * Example: `VIP2025A3B7C9D2`

**Generation Details:**

* Codes are automatically checked for uniqueness
* Generation process may take a few moments for large quantities
* If generation is interrupted, you can retry - the system will only generate missing codes

#### Method B: Import Custom Codes

If you need to import specific discount codes (e.g., from another system or partner-provided codes):

1. Click **Import Codes** on the template detail page
2. Prepare an Excel file with the following columns:
   * **Code**: The discount code (can be any format, must be unique)
   * **TemplateCode**: The code prefix of your template
3. Upload the file and wait for processing
4. Check the import result file for any errors

**Import Rules:**

* Codes can be in any format (no restriction)
* Each code must be unique at your merchant level
* Template must be in Active status
* Import result file will show success/failure status for each code

***

## Managing Batch Templates

### Viewing Templates

You can view all batch templates in the Discount Code section:

* **Status Filter:** Filter by Editing, Active, Inactive, or Archived
* **Search:** Search by batch name or code prefix
* **Statistics:** View total quantity, generated count, used count, and available count

### Editing Templates

**Before Activation (Editing Status):**

* You can modify all settings including quantity (increase or decrease)

**After Activation (Active Status):**

* Quantity can only be increased (for expansion)
* Quantity cannot be reduced below the number of already generated codes
* Discount rules and other settings can still be modified (changes apply to all codes)

### Expanding Template Quantity

If you need to generate more codes after activation:

1. Click **Edit** on the template
2. Increase the **Target Quantity** (e.g., from 1,000 to 1,500)
3. Save the changes
4. Click **Generate Codes** again
5. The system automatically generates only the additional codes needed

### Deactivating Templates

* Click **Deactivate** to disable the template
* All unused codes immediately become invalid
* Already used codes are not affected
* You can reactivate the template later to restore unused codes

### Archiving Templates

* Click **Archive** when the campaign is complete
* Archived templates cannot be edited or reactivated
* This helps organize completed campaigns

***

## Managing Individual Codes

### Viewing Code List

1. Open a batch template detail page
2. Navigate to the **Codes** tab
3. View the list of all generated codes with:
   * **Code:** The actual discount code
   * **Status:** Available or Redeemed
   * **Used By:** User email (if redeemed)
   * **Used At:** Date and time of redemption (if redeemed)
   * **Created At:** Code creation time

### Filtering and Searching

* **Status Filter:** Filter by Available or Redeemed
* **Code Search:** Search for specific codes
* **Pagination:** Navigate through large code lists

### Exporting Codes

You can export the code list with usage details:

1. Click **Export** on the codes list page
2. Select export format (Excel or CSV)
3. Choose export options:
   * Export all codes or filtered codes
   * Include usage details (user, date, invoice, subscription)
4. Download the file from the Tasks section when ready

**Export includes:**

* Code information
* Usage status and details
* User information (email)
* Related invoices and subscriptions
* Discount rule information
* Creation and usage timestamps

***

## Viewing Code Usage

### Individual Code Details

1. Click on any code in the list to view details
2. See complete information including:
   * Code and parent template
   * Current status
   * Usage information (if redeemed)
   * Related invoice, subscription, and payment
   * Discount rules inherited from template

### Batch Usage Statistics

On the template detail page, you can see:

* **Total Quantity:** Target number of codes
* **Generated Count:** Number of codes created
* **Used Count:** Number of codes redeemed
* **Available Count:** Number of unused codes

### Usage Tracking

Track detailed usage information for each code:

* **User Information:** Who used the code (email address)
* **Usage Time:** When the code was redeemed
* **Related Transactions:** Invoice ID, Subscription ID, Payment ID
* **Discount Applied:** Actual discount amount or percentage applied

***

## Best Practices

### Planning Your Campaign

1. **Choose Meaningful Prefixes:** Use clear, identifiable code prefixes (e.g., `VIP2025`, `SPRING2025`)
2. **Estimate Quantity:** Plan the number of codes needed, but remember you can expand later if needed
3. **Set Clear Expiration:** Ensure validity dates align with your campaign timeline

### Code Distribution

1. **Secure Distribution:** Send unique codes directly to intended users to prevent sharing
2. **Track Sources:** Use different batch templates for different distribution channels
3. **Monitor Usage:** Regularly check usage statistics to track campaign performance

### Template Management

1. **Activate Promptly:** Create and activate templates before you need to distribute codes
2. **Expand as Needed:** Start with a smaller quantity and expand if the campaign is successful
3. **Archive Completed:** Archive finished campaigns to keep your dashboard organized

### Performance Considerations

1. **Batch Size:** For very large campaigns (5,000+ codes), consider generating in phases
2. **Export Timing:** Use export features during off-peak hours for large datasets
3. **Regular Monitoring:** Check usage regularly but avoid excessive real-time monitoring

***

## Frequently Asked Questions

### Q: Can I change the discount rules for individual codes?

**A:** No. All codes in a batch inherit rules from the template. To change rules, edit the template - all codes will inherit the new rules (already used codes are not affected).

### Q: What happens if I need more codes than originally planned?

**A:** You can expand the template quantity after activation. Simply increase the target quantity and generate additional codes. The system will only create the new codes needed.

### Q: Can I reduce the quantity after codes are generated?

**A:** After activation, you cannot reduce the quantity below the number of already generated codes. Before activation, you can freely adjust the quantity.

### Q: How many codes can I generate in one batch?

**A:** You can generate up to 10,000 codes per template. For larger campaigns, create multiple templates.

### Q: Can I import codes that don't start with the template prefix?

**A:** Yes. Imported codes can be in any format. They just need to be unique and linked to the template via the TemplateCode field in the import file.

### Q: What happens to unused codes when I deactivate a template?

**A:** All unused codes become invalid immediately. Already used codes are not affected. You can reactivate the template to restore unused codes.

### Q: Can I delete a batch template?

**A:** Templates cannot be deleted to prevent accidental loss of data. Instead, archive the template when no longer needed.

### Q: How long does it take to generate codes?

**A:** Generation time depends on quantity:

* 100 codes: Almost instant
* 1,000 codes: A few seconds
* 10,000 codes: About 20 seconds

***

## Related Topics

* [Creating Standard Discount Codes](./create-edit-copy-and-archive)
* [Viewing Discount Code Usage](./view-the-usage-of-a-discount-code)
* [Exporting Discount Code Data](./inquiry-and-export)
