# Hold Shopify orders

Connect a Shopify store, choose which orders ask the buyer, see who reaches the cart, work from Shopify's admin, and pay through Shopify.

Connect a Shopify store and its orders run through your checkout rules. An order a rule names is held in Shopify while the buyer approves it on the approval page; approved, the hold lifts and the order ships as usual. The checkout itself doesn't change, so this works on every Shopify plan.

**Before you begin:** you need the console's Owner or Admin role to connect a store, and the Provenance app installed on the Shopify store. Every plan; each order your rules check counts as one checked order, as an assessment does.

1. **Shopify takes the order**: and the payment, as usual
2. **Your rules check it**: Orders from AI agents, or your own
3. **The buyer approves**: the hold lifts and the order ships

## 1. Connect the store

In the console, open **Authorize › Stores** and choose **Connect a Shopify store**. Enter the shop's name (`saltmarsh-goods` or `saltmarsh-goods.myshopify.com`), approve the app's access in Shopify, and you're back on the Stores page with the shop listed. The app asks Shopify for orders, risk assessments and cancels (`read_orders`, `write_orders`) and fulfillment holds (`write_merchant_managed_fulfillment_orders`).

Installing the app from Shopify lands on the same page with the shop filled in. One shop connects to one Provenance account; an account connects any number of shops.

Your shops are listed by [`GET /v1/authorize/store_connections`](https://provenanceauth.com/docs/api/store-integrations.md#get-v1-authorize-store-connections):

```json
{
  "object": "list",
  "data": [
    {
      "object": "store_connection",
      "id": "stc_01M7V7QYRYH5TA9E3H2GV0VT1Y",
      "platform": "shopify",
      "shop_domain": "saltmarsh-goods.myshopify.com",
      "status": "active",
      "billing_source": "shopify",
      "settings": { "auto_cancel_on_decline": false, "agent_channels": [] }
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## 2. Choose which orders are asked

By default only orders placed by AI agents are asked. The first shop you connect adds one rule, **Orders from AI agents**, at the top of your checkout rules when you have none of your own yet. With rules of your own already, add it in one call, [`POST /v1/authorize/store_connections/{id}/default_rule`](https://provenanceauth.com/docs/api/store-integrations.md#post-v1-authorize-store-connections-id-default-rule), or write your own rules on these fields.

An order is placed by an AI agent (`store.agent_order`) when it came through an agent sales channel, or when the storefront check (step 6) classed the cart's visitor as an agent, a declared bot or an automated browser.

A verified card network agent signature on that visit counts too, and `agent.order_signals` names why. A shared payment token or a card network agent token will count once Shopify carries one on the order; today a Shopify order carries no agent payment credential, so its `payment_signals` is null.

Agent sales channels come from two lists. Provenance keeps a list of AI shopping agents' channels and adds to it as they appear; [`GET /v1/authorize/store_agent_channels`](https://provenanceauth.com/docs/api/store-integrations.md#get-v1-authorize-store-agent-channels) returns it with its `version`. Add your own (a Shopify app ID or source name) in `agent_channels` with [`PATCH /v1/authorize/store_connections/{id}`](https://provenanceauth.com/docs/api/store-integrations.md#patch-v1-authorize-store-connections-id).

Pass `store_connection_id` to the list and it also returns the channels your shop's last 90 days of orders carried that neither list names (`seen`). That's what **Add channel** offers in the console.

In the console, **Authorize › Stores** shows the rules that decide store orders in the **When to ask** card: one line per rule, with its switch and outcome, then **Every other order · Not asked**. **Add rule** opens the store templates in Policies:

| Template | Rule |
| --- | --- |
| Orders from AI agents | `store.agent_order` is true |
| Orders through agent channels | `store.agent_channel` is true |
| Orders over an amount | The order total is over an amount you set |
| First orders over an amount | `store.customer_order_count` is 0 and the total is over an amount you set |
| Products | `store.products` contains products you name |
| Ships to countries | `store.ship_country` is one you name |
| Automated browser at checkout | The visitor was an automated browser or headless |
| High automation score | `agent.automation_score` is 70 or more (needs field timing) |
| Fast checkout | `agent.checkout_fill_seconds` is under 10 (needs field timing) |
| All fields pasted | `agent.fields_all_pasted` is true (needs field timing) |
| Outside hours | The order arrived before 7 or after 22 (UTC) |

The three field-timing templates ask the buyer and say "Turn on field timing in Traffic" until a shop has it on. A change saves as a draft; **Review changes** publishes it with Manage policies and a passkey.

Store orders run your checkout rules with these fields, as Shopify reports them. Each is absent on a checkout assessment, so a rule on them only ever matches a store order:

| Field | Type | What it is |
| --- | --- | --- |
| `store.agent_order` | boolean | Placed by an AI agent |
| `store.agent_channel` | boolean | Sold through one of your agent sales channels |
| `store.customer_order_count` | number | The customer's orders before this one (0 is a first order) |
| `store.products` | list | The order's Shopify product IDs |
| `store.ship_country` | string | The shipping country (ISO 3166-1 alpha-2) |
| `store.sales_channel` | string | Shopify's source name (`web`, `pos`, an app) |
| `store.shop` | string | The shop's domain, for accounts with several shops |
| `store.platform` | string | `shopify` |

The order fields work too: the order total, its currency and its item count. A rule has one of these outcomes on a store order:

| Outcome | What happens |
| --- | --- |
| Ask the buyer (`require.approval`) | The order is held and the buyer gets the approval by email or text |
| Hold for review (`require.deny`) | The order is held for you, with no message to the buyer |
| No rule matches | The order goes on as Shopify handles it (`state: "not_challenged"`) |

## 3. What the buyer and your team see

When a rule asks, Provenance puts a fulfillment hold on the order (reason "High risk of fraud", from the Provenance app) and writes a risk assessment ("Waiting for the buyer's approval"). Your team sees both on the order in the Shopify admin; the order can't be fulfilled while the hold stands. The buyer gets the cart approval at the email or phone on the order, as a store's own customer.

The orders waiting on a buyer are listed by [`GET /v1/authorize/store_orders`](https://provenanceauth.com/docs/api/store-integrations.md#get-v1-authorize-store-orders) with `state=challenged`:

```json
{
  "object": "list",
  "data": [
    {
      "object": "store_order",
      "id": "sto_01M7V7QYS7FQ9HETWF1HF5SM2H",
      "platform_order_id": "5512345678901",
      "order_name": "#1002",
      "state": "challenged",
      "reason": "policy_rule",
      "checkout_approval_id": "coap_01M7V7QYS8H2SM4X31ME688ZWN",
      "approval_status": "pending",
      "held": true,
      "risk": "pending"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## 4. When the buyer decides

- **Approved:** the hold is released and the risk level goes to low. The order ships as usual (`state: "released"`, `reason: "store_buyer_approved"`).
- **Declined or expired:** the hold stays and the risk level goes to high (`state: "held"`). Cancel and refund the order in one call with [`POST /v1/authorize/store_orders/{id}/cancel`](https://provenanceauth.com/docs/api/store-integrations.md#post-v1-authorize-store-orders-id-cancel), or release it after you've spoken to the buyer with [`POST /v1/authorize/store_orders/{id}/release`](https://provenanceauth.com/docs/api/store-integrations.md#post-v1-authorize-store-orders-id-release). Both work in the Shopify admin too.

To cancel and refund every declined order at once, turn on **Cancel automatically on decline** (`auto_cancel_on_decline: true`; Manage policies, with a second-factor check in the console). It's off by default.

Shopify captures card payments at checkout by default, so a cancelled order is refunded. A store that captures payment by hand never charges a declined order: cancelling voids the authorization. Shopify keeps a card authorization for 7 days, longer than an approval waits (1 hour).

## 5. Uninstalling and privacy requests

Removing the app in Shopify deletes the shop's access at once (`status: "uninstalled"`), with its storefront visits; its orders change nothing from then on. Provenance keeps ids, the cart's binding hash and each order's state, never the order itself.

Shopify's privacy webhooks are handled: a customer's redaction deletes the order records it names and the storefront visits those orders carried, and the shop's redaction, 48 hours after uninstall, deletes the connection and its records.

To stop on Provenance's side without uninstalling, disconnect the shop with [`DELETE /v1/authorize/store_connections/{id}`](https://provenanceauth.com/docs/api/store-integrations.md#delete-v1-authorize-store-connections-id). Holds already placed stay in Shopify for you to release there.

## 6. See who reaches the cart

The storefront check classes each visitor on your shop's pages: a person, a signed agent, an unsigned agent or an automated browser. It runs through the Provenance app embed, which Shopify leaves off after install. Turn it on from the theme editor: [`GET /v1/authorize/store_connections/{id}`](https://provenanceauth.com/docs/api/store-integrations.md#get-v1-authorize-store-connections-id) returns the link as `storefront.theme_editor_url`, and the console's Traffic rows open it.

On the cart page the check writes the visit to the cart attribute `provenance_visit`, and the order carries it into your rules: the visitor's kind as `agent.class`, and `store.agent_order` true for an agent or an automated browser. Each cart page view is one hosted check; other page views are free. Shopify doesn't let an app's script run on its checkout steps, so the check reads the cart page.

The same read returns the Traffic card's counts, your shop's visits over the last 7 days:

```json
{
  "object": "store_connection",
  "id": "stc_01M7V7QYRYH5TA9E3H2GV0VT1Y",
  "settings": { "storefront_check": true, "storefront_category": "security", "field_timing": false },
  "storefront": {
    "theme_editor_url": "https://saltmarsh-goods.myshopify.com/admin/themes/current/editor?context=apps&activateAppId=4c2d9a7e4b1f3a5c6e8d0b2f4a6c8e1d%2Fstorefront-check",
    "traffic": { "window": "7d", "humans": 412, "signed_agents": 9, "unsigned_agents": 31, "automated_browsers": 17, "unknown": 6 }
  }
}
```

Change the check with [`PATCH /v1/authorize/store_connections/{id}`](https://provenanceauth.com/docs/api/store-integrations.md#patch-v1-authorize-store-connections-id) (Manage policies):

| Setting | Default | What it does |
| --- | --- | --- |
| `storefront_check` | `true` | Runs the check on your shop's pages once the app embed is on |
| `storefront_category` | `security` | `analytics` makes the whole check wait for the visitor's analytics consent |
| `field_timing` | `false` | Adds how the cart form is filled in, never what is typed; runs only for visitors who allow analytics, through Shopify's customer privacy setting |

With field timing on, the order's rules also read the visit's automation score and its parts, under the same names your checkout rules use:

| Field | Type | What it is |
| --- | --- | --- |
| `agent.automation_score` | number | Field timing's score, 0 to 100 |
| `agent.fields_all_pasted` | boolean | Every filled field was pasted |
| `agent.checkout_fill_seconds` | number | First focus to submit, in seconds |
| `agent.pointer_seen` | boolean | A pointer moved, clicked or touched |
| `agent.typed` | boolean | A field was typed in |

The score never makes an order an agent order. A rule on field timing alone may **Ask the buyer**, never **Hold for review**: add another condition, such as a first order or an agent channel, and the hold saves. How field timing measures, and its limits, is in [Check storefront visitors](https://provenanceauth.com/docs/identify/guides/storefront-check.md#4-turn-on-field-timing).

## 7. Answer chargebacks

With dispute access granted, Provenance answers Shopify Payments chargebacks on the orders it checked, with staged text Shopify sends on the due date. See [chargeback responses](https://provenanceauth.com/docs/authorize/guides/chargeback-responses.md#shopify-payments).

Each connected shop has Chargebacks rows on **Authorize → Stores**: its dispute access, the response mode and the reasons answered. A shop connected before dispute access was asked for shows **Grant dispute access**: select it, approve the new access in Shopify, and you're sent back to Stores.

Where the shop can read disputes but we can't write evidence, the chargeback waits with our text ready: copy it from the Chargebacks page or the Provenance app in Shopify's admin and paste it into the dispute.

## 8. Work from Shopify's admin

The Provenance app opens inside Shopify's admin. It shows the orders waiting on a buyer or held, with **Release** and **Cancel and refund**; your shop's chargebacks, with **Copy our text**; your shop's Traffic rows; and your plan. **When to ask**, field timing and Cancel automatically on decline need Manage policies and a passkey, so their links open the console in a new window.

The app signs each request with the session token Shopify issues for it, and reaches only that shop's orders. A shop that isn't connected yet shows **Connect to Provenance**, which signs you in to the console and connects it.

## 9. Billing through Shopify

A shop's plan is billed through Shopify. Every plan fee and usage price there is the [normal price](https://provenanceauth.com/pricing) plus 20%, and a plan renews every 30 days.

Choose a plan in the app's **Plan** row and approve it on Shopify's page. Usage past the plan's included amounts goes on the same Shopify bill, posted as totals rounded down to the cent, up to the usage cap you approve: your spend cap, or the default cap if you have none.

When the cap is spent, orders that arrive go on as Shopify handles them (`store_usage_cap_reached`) until the next cycle. Shopify tells you at 90%.

- **Trial.** A new plan starts with the days left in your account's free trial, once per account.
- **Several shops.** Your shops share one plan, billed through the first one you connected; the others show "Billed through". If that shop uninstalls the app, the plan stays to the end of its paid period and the next shop asks you to approve it there.
- **Moving from Stripe.** If your Stripe plan is only for your shops (no API key used in 30 days), the Shopify plan starts when the Stripe period ends and the Stripe plan ends then. If you also use the API, both plans run, and your account gets the higher one's features.

[`GET /v1/account/billing/sources`](https://provenanceauth.com/docs/api/billing.md#get-v1-account-billing-sources) lists each bill, and **Settings › Plan & usage** shows a card for the Shopify one.

## 10. Agent orders through Shopify's agent checkout

Shopify runs its own Universal Commerce Protocol (UCP) checkout for every store, so agents can shop your store through Shopify's agent checkout. Those orders arrive one of two ways, and your **When to ask** rules check both:

| How the agent finishes | What reaches your rules |
| --- | --- |
| Hands the shopper to your store's checkout | The order, with the cart page visit the storefront check saw (step 6) |
| Completes the purchase through Shopify's API | The order, without a cart page visit |

Shopify serves the store's UCP endpoints itself, so a Shopify store can't add Provenance's UCP approval step. If you run your own UCP server, see [Approve UCP checkouts](https://provenanceauth.com/docs/authorize/guides/ucp.md).

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `store_integration_unconfigured` (503) | This deployment has no Shopify app credentials | Use the checkout approvals API from your own checkout, or add the Shopify app's credentials to a [self-hosted deployment](https://provenanceauth.com/docs/self-host/configuration.md). |
| `store_connection_conflict` (409) | The shop is connected to another Provenance account | Disconnect it there (or uninstall the app), then connect it here. |
| `store_oauth_state_invalid` (400) | The connect link was used, is over 10 minutes old, or came back to another browser | Start again from Connect a Shopify store, in the same browser. |
| `store_order_not_held` (409) | The order isn't held by Provenance | Read the order and act on it in the Shopify admin. |
| `store_platform_unavailable` (503) | Shopify didn't take the release or cancel | Retry in a minute; nothing changed on the order. |
| An order reads `not_challenged` with `store_platform_unavailable` | Shopify didn't answer when the order arrived, so nothing was held | Review the order in the Shopify admin. |
| An order reads `not_challenged` with `store_usage_cap_reached` | This cycle's usage cap in Shopify is spent | Raise the cap from the app in Shopify, or wait for the next cycle. |
| `shopify_session_token_invalid` (401) | The app's request carried no session token, or an expired one | Reload the app in Shopify's admin. |
| `store_shop_not_connected` (409) | The shop the app is open in isn't connected | Choose **Connect to Provenance** in the app. |
| `store_billing_elsewhere` (409) | Your plan is billed through another of your shops | Change it from the app in that shop. |

## See also

- [Ask your own customer](https://provenanceauth.com/docs/authorize/guides/ask-your-own-customer.md): the cart approval a store order sends
- [Check storefront visitors](https://provenanceauth.com/docs/identify/guides/storefront-check.md): the storefront check and field timing
- [Assess an agent checkout](https://provenanceauth.com/docs/authorize/guides/assess-checkouts.md): the checkout rules both paths share
- [Approve UCP checkouts](https://provenanceauth.com/docs/authorize/guides/ucp.md): your own UCP server
- [Store integrations API](https://provenanceauth.com/docs/api/store-integrations.md)
- [Reason codes](https://provenanceauth.com/docs/platform/reason-codes.md): every `store_*` reason
