Alert the warehouse when a paid order is edited

An automation that tags a paid order and emails the warehouse when its items or shipping address change after payment. A validated definition using order.edited@1 and a live financial-status check.

When someone changes the items or the shipping address of an order that is already paid, tag it and email the person who packs. Trigger: order.edited@1 with a live filter. Actions: add_order_tags@1, send_internal_email@1.

Model background: Automations.

The definition

{
  "schemaVersion": 1,
  "trigger": {
    "type": "order.edited@1",
    "origins": [
      "USER",
      "API",
      "MCP",
      "ASSISTANT",
      "BULK",
      "IMPORT",
      "DUPLICATE",
      "SYSTEM",
      "AUTOMATION"
    ],
    "filter": {
      "op": "all",
      "rules": [
        {
          "path": "current.order.financialStatus",
          "op": "eq",
          "value": "paid"
        }
      ]
    }
  },
  "steps": [
    {
      "id": "tag",
      "type": "action",
      "contract": "add_order_tags@1",
      "input": {
        "orderId": {
          "$ref": "event.entityId"
        },
        "tags": ["edited-after-payment"]
      }
    },
    {
      "id": "tell",
      "type": "action",
      "contract": "send_internal_email@1",
      "input": {
        "recipientUserIds": ["user_REPLACE_WITH_WAREHOUSE_MEMBER_ID"],
        "subject": "Paid order {{order.number}} was edited",
        "body": "The items or the shipping address of order {{order.number}} changed after it was paid. Check it before you pack.",
        "includeEntityLink": true
      }
    }
  ]
}

Replace before saving: recipientUserIds (1 to 5 team member user ids, never an email address) and the tag.

How it works

  • order.edited@1 fires when the items or the shipping address of an order really changed after it was placed, one event per edit. Its facts are the order facts without the status transition, plus event.facts.changed.items and event.facts.changed.shippingAddress (true or false) and event.facts.change.at. A status, notes or payment method edit, and a save that changes nothing, fire nothing. No address or line value is ever in the facts.
  • The filter uses the live value current.order.financialStatus (eq paid). Live values work in the trigger filter as well as in conditions: they are read from the database when the run evaluates, so the rule sees the order's payment state now, not the state when it was edited. To alert only on one kind of edit, add { "path": "event.facts.changed.shippingAddress", "op": "eq", "value": true } or the same for changed.items.
  • send_internal_email@1 writes to your own team only. Texts under an order trigger may use the order variables, for example {{order.number}}. includeEntityLink: true puts a link to the order in the email. The email says to check the order because the facts carry no address or item to print.

What it does not do

  • It does not say what changed beyond items versus address. The recipient opens the order.
  • It does not stop the edit or hold the order. To hold it as well, add set_order_hold@1 (a guarded action, satisfied by the filter above), remembering that only PENDING and PROCESSING orders can be held.
  • It does not email the customer. The recipients must still be allowed to receive the email at send time, or the run ends SKIPPED with NO_RECIPIENTS.

Create it

With the Admin MCP:

  1. get_automation_guide with topic: "triggers", then "live-values".
  2. validate_automation_definition. Fix every finding.
  3. test_automation with entity: { "type": "Order", "id": "<a paid order id>" }. The filter is judged on the order's current data and marked as such, and the email text is shown with how many people it would reach.
  4. create_automation_draft with name: "Paid order edited".
  5. Tell the merchant to approve it in the dashboard.

With the SDK:

const check = await admin.validateAutomationDefinition(storeId, { definition });
if (!check.ok) throw new Error(JSON.stringify(check.errors));

const draft = await admin.createAutomation(storeId, {
  name: 'Paid order edited',
  definition,
});

What the merchant sees

A draft in Settings, then Automations. Once on, an edit to a paid order adds the edited-after-payment tag and sends the warehouse an email "Paid order 1042 was edited" with a link to the order. An edit to an order that is not paid is left alone: no tag and no email.