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

# Overwrite in test mode

> shopify_discount_update replaces an existing discount's rule in Shopify and puts it back into test mode, so it only applies to your store's test email address.

Replaces an existing discount's rule in Shopify — and puts it back into **test mode**.

> [!NOTE]
>
> **Tool name:** `shopify_discount_update` · **Writes to Shopify** · Marked destructive, so most clients will ask before every call

## When to use it

Only when the merchant has actually asked for an existing discount to be changed in Shopify, and understands that it goes back into test mode.

[Draft a discount](https://aiodapp.com/docs/mcp-server/tools/shopify-discount-draft.md) with `targetDiscountId` proposes the same edit and changes nothing in Shopify. [Create in test mode](https://aiodapp.com/docs/mcp-server/tools/shopify-discount-publish.md) makes a new discount instead. **This tool never creates one.**

## What overwriting really does

It replaces the discount's rule in Shopify and re-creates it in test mode. AIOD attaches an email condition so it **only ever applies to the store's test email address** — returned to you as `testModeEmail`.

So a discount that was live for shoppers **stops applying to them** until a person opens it in the AIOD editor and switches it to active. **No tool here can make that switch, activate a discount, or delete one.**

> [!WARNING]
>
> This is why the tool is marked destructive. Confirm with the merchant, in words, before overwriting a discount that is live.

## Parameters

| Name | Type | Required | What it does |
| - | - | - | - |
| `targetDiscountId` | string | **Yes** | The discount to overwrite, from [Find discounts](https://aiodapp.com/docs/mcp-server/tools/shopify-discount-find.md). |
| `config` | object | **Yes** | A sparse patch: only the fields that change. It is merged onto the stored configuration. Same shape as [Draft a discount](https://aiodapp.com/docs/mcp-server/tools/shopify-discount-draft.md). |

Read the discount with [Read a discount](https://aiodapp.com/docs/mcp-server/tools/shopify-discount-get.md) first. The patch is written against its current values, and the saved discount's template cannot change.

There is no `mode` parameter. Test mode is fixed in the server — nothing a caller sends can push a chat-authored discount live.

## What comes back

When it works, the response has the same fields as [Create in test mode](https://aiodapp.com/docs/mcp-server/tools/shopify-discount-publish.md#when-it-works): `discountId`, `url`, `title`, `status`, `testModeEmail`, `warnings`, and a `message`.

If validation or simulation fails, or the patch would leave the rule unchanged (`edit_changed_nothing`), **nothing is changed.**

| Status | Code | When |
| - | - | - |
| `400` | `update_target_required` | `targetDiscountId` is missing. Creating a new discount is `shopify_discount_publish`. |
| `400` | — | Missing or invalid `config`, unsupported template, or the update itself failed. |
| `404` | `target_not_found` | `targetDiscountId` isn't one of this store's discounts. |
| `422` | `saved_rule_unavailable` or `template_not_editable` | The discount couldn't be loaded safely, or its template can't be edited here. Don't retry; the merchant edits it in the AIOD editor. |
| `200` with `ok: false` | — | Validation or simulation rejected it. Read `issues`. |

## What it checks first

The same gate as drafting and creating — shape repair, field policy, empty tier check, then validation and cart simulation. The [rejection codes](https://aiodapp.com/docs/mcp-server/tools.md#rejections-are-useful-not-fatal) are the same too.

## Things people ask that land here

* "Replace the tier ladder on my volume discount with these three tiers."
* "Change the free gift on my summer offer to the tote bag, and update it in Shopify."
* "Raise the spend threshold on my existing discount to \$120."

## Getting it right

Report all three of these, every time:

1. The discount's rule was replaced in Shopify, and it is back in test mode.
2. It only applies for `testModeEmail`. If it was live, real shoppers no longer get it.
3. The merchant must open `url` and switch it to active themselves. No tool can do it for them.

And remember this only covers AIOD's automatic discounts — not discount codes, and not discounts created directly in Shopify or by another app.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.