# Discount Codes Import From File

The **Import from File** feature lets you bulk-import discount codes from a CSV file. Each row in the file becomes one discount code, and you can configure value, dates, usage limits, minimum requirements, and combinations independently for each row. Optionally, the app can also email each code to the customer specified in the row.

> **When to use this vs other discount operations:**
>
> * Use this when you have a list of codes (or per-row settings) coming from another system.
> * Use [**Bulk Create**](/bulk-operations/discount-codes-bulk-create.md) to generate a batch of codes that share the same rules.
> * Use [**Bulk Send**](/bulk-operations/discount-codes-bulk-send.md) to generate codes *and* email a unique one to each recipient with shared rules.

### 💡 **Common Use Cases**

* **Import from another system** — load codes generated outside Shopify.
* **Per-customer welcome codes** — each row holds a unique customer email and a one-time code.
* **Mixed campaigns in one upload** — different rules per row (different discount values, dates, limits).
* **Pre-staging seasonal campaigns** — import codes with future `starts_at` so they activate automatically.
* **Bulk-order incentives** — different `minimum_purchase_amount` tiers per row.

### **🪜 Step-by-Step Instructions**

<figure><img src="/files/lO3S17EPSweUL1fpBeop" alt=""><figcaption></figcaption></figure>

1. **Download a template.** A simple template with the most common columns and an advanced template with every supported column are available below.

{% file src="/files/nmCTaj4iHCZ2VC8moYHm" %}

{% file src="/files/ucgfQ1qdjSiExtB77hMW" %}

2. **Fill in your data.** Only `title`, `discount_type`, and `discount_value` are required. Remove columns you don't use.
3. **Upload the file.** The form accepts `.csv`, `.tsv`, and `.txt` files up to **10 MB**. After upload, a summary shows the detected separator, row count, and column names. Validation errors (if any) are listed.
4. **Resolve ambiguous dates.** If your `starts_at` or `ends_at` columns contain dates like `01/05/2026`, you'll be asked whether the first number is the day or the month.
5. **Configure customer delivery (if applicable).** When the file contains an `email` or `customer_id` column, a **Send discount codes to customers** checkbox appears. Enable it and choose a sending method to email each row's code to that row's customer.
6. **Choose internal delivery options.** Allow data download and / or send yourself a summary email.
7. **Click Import now or Schedule.**

### **📋 CSV Columns**

#### Required

| Column           | Notes                                                                                                                                                          |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `title`          | Internal title shown in Shopify Admin → Discounts. Helps you identify the discount.                                                                            |
| `discount_type`  | `fixed` or `percentage` (lowercase).                                                                                                                           |
| `discount_value` | Numeric. For `fixed` it's the amount in your store currency; for `percentage` it's the percent (e.g. `20` for 20%). Decimal commas are auto-converted to dots. |

#### Code

| Column   | Notes                                                                                                                            |
| -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `code`   | The discount code. **3–20 characters**, letters/numbers/hyphens/underscores only. If empty or omitted, a code is auto-generated. |
| `prefix` | Optional prefix (max 4 characters) used only when `code` is empty.                                                               |

#### Date & Time

| Column      | Notes                                                        |
| ----------- | ------------------------------------------------------------ |
| `starts_at` | Date when the discount becomes active. See formats below.    |
| `ends_at`   | Date when the discount expires. Leave blank for no end date. |

Supported date formats:

* `YYYY-MM-DD` (recommended): `2026-12-25`
* `DD/MM/YYYY` or `DD-MM-YYYY`: `25/12/2026` / `25-12-2026`
* `MM/DD/YYYY` or `MM-DD-YYYY`: `12/25/2026` / `12-25-2026`

If the file contains ambiguous dates (e.g. `01/05/2026`), the form asks you whether the first number represents day or month, and applies that interpretation to all rows.

#### Usage limits

| Column              | Notes                                                                           |
| ------------------- | ------------------------------------------------------------------------------- |
| `usage_limit`       | Total number of times this code can be used. Leave blank for unlimited.         |
| `once_per_customer` | `true` / `false`. Limits each customer to one redemption.                       |
| `once_per_order`    | `true` / `false`. For **fixed** discounts: applies once per order vs. per item. |

#### Minimum requirements

| Column                    | Notes                                        |
| ------------------------- | -------------------------------------------- |
| `minimum_purchase_amount` | Minimum order amount in your store currency. |
| `minimum_quantity`        | Minimum number of items in the order.        |

> Only one minimum requirement applies per discount code. If both columns are populated for the same row, behavior follows Shopify's rules — pick one per row to be safe.

#### Purchase type

| Column          | Notes                                            |
| --------------- | ------------------------------------------------ |
| `purchase_type` | `one-time` (default), `subscription`, or `both`. |

#### Combinations

`true` / `false` flags controlling whether the discount can be combined with other discount types:

* `combines_with_product_discounts`
* `combines_with_order_discounts`
* `combines_with_shipping_discounts`

#### Customer notification

| Column        | Notes                                                                                |
| ------------- | ------------------------------------------------------------------------------------ |
| `email`       | Customer email. Used to send the row's code to that customer if delivery is enabled. |
| `customer_id` | Numeric Shopify customer ID. Alternative to `email`.                                 |

> Adding `email` or `customer_id` to your file enables the **Send discount codes to customers** option in the form. Without one of these columns, codes are still imported but no recipient emails are sent.

### **📨 Customer Notification (Optional)**

If your file has an `email` or `customer_id` column, you can email each row's code to its customer. Enable **Send discount codes to customers**, then pick a sending method:

* **App Email** — uses Gift Card Factory's email infrastructure with a customizable template (built from the **Discount codes import from file** or **Custom** template type). Preview before sending.
* **Shopify Flow** — fires a Flow trigger; you configure the action that sends the email.
* **Klaviyo** — fires a Klaviyo metric; you configure a flow that responds to the metric.

> Shopify Email is **not** available for discount codes — Shopify has no native discount-code email template. See [Sending Customer Notifications](/misc/sending-customer-notifications.md) for setup details.

### **📤 Internal Delivery Options**

Independent of customer notifications, you can also receive the import results yourself:

* **Allow discount codes data download**: Creates a download link in the **Bulk Operations** section. The link expires after **3 days**.
* **Send internal email with all generated discount codes**: Sends the full list of codes to an email address you specify (multiple addresses allowed, comma-separated).

### **▶️ Running the Operation**

* **Import now**: Runs the operation immediately.
* **Schedule**: Runs the operation at a future date and time. The discount codes still respect each row's own `starts_at` / `ends_at` for when they are usable.

The submit button stays disabled until a file is uploaded.

### **🧪 Examples**

#### Simple seasonal discounts

```csv
title,discount_type,discount_value,starts_at,ends_at
Summer Sale 2026,percentage,20,2026-06-01,2026-08-31
Fall Discount,fixed,10,2026-09-01,2026-11-30
Winter Special,percentage,25,2026-12-01,2027-02-28
```

#### Customer-specific welcome codes (one-time per customer)

```csv
title,discount_type,discount_value,email,usage_limit,once_per_customer
Welcome Discount,percentage,15,newcustomer@example.com,1,true
Welcome Discount,percentage,15,another@example.com,1,true
```

#### Tiered bulk-order incentives

```csv
title,discount_type,discount_value,minimum_purchase_amount,starts_at,ends_at
Bulk 10% off,percentage,10,100,2026-01-01,2026-12-31
Bulk 15% off,percentage,15,200,2026-01-01,2026-12-31
Bulk 20% off,percentage,20,300,2026-01-01,2026-12-31
```

#### Auto-generated codes with a brand prefix

```csv
title,discount_type,discount_value,prefix
Flash Sale,percentage,20,FLSH
```

Generated codes will start with `FLSH` followed by random characters.

### **🚫 Limitations**

* **Product / collection targeting**: Imported codes apply to all products and collections. For product- or collection-specific discounts, use [Bulk Create](/bulk-operations/discount-codes-bulk-create.md).
* **Customer eligibility**: Imported codes are available to all customers. Per-segment or per-customer eligibility is not supported via import.
* **Code format**: Codes must be 3–20 characters, letters / numbers / hyphens / underscores only.

### **FAQ**

**Why was my row rejected with "code length must be between 3 and 20 characters"?**\
Codes you supply yourself must be 3–20 characters long, using letters, numbers, hyphens, and underscores only. Auto-generated codes (when `code` is empty) always conform.

**Why doesn't `discount_value=$10` work?**\
The value must be numeric — no currency symbols or `%`. Use `10`, not `$10` or `10%`.

**My file has dates like `05/06/2026` and the import got the months and days swapped.**\
The form asks for a "Date format" only when it detects ambiguous dates. If you imported with the wrong choice, fix the dates (or change the column to `YYYY-MM-DD`) and re-import. There's no way to retroactively flip the interpretation on already-imported codes.

**Recipients didn't get their emails.**\
Confirm **Send discount codes to customers** is enabled, your file actually contains the `email` or `customer_id` column with valid values, and the chosen sender is configured (App Email enabled / Flow configured / Klaviyo flow listening on the metric).

**Can I update or edit the imported codes later?**\
Imported codes can't be edited from the app. Use Shopify Admin → Discounts to disable an individual code, then re-import or use [Bulk Create](/bulk-operations/discount-codes-bulk-create.md) for the corrected version.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.giftcardfactory.app/bulk-operations/discount-codes-import-from-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
