Shopify integration
Turn any Shopify store into a live frida-protocol/1 merchant agent in two minutes — backed by your real inventory and unit costs, settling via single-use Draft Orders instead of leakable coupon codes.
1. Scaffold your agent
npx --package=https://protocol.frida.chat/sdk/frida-protocol-1.8.2.tgz frida-protocol init my-store --shopify --shop my-store.myshopify.com cd my-store npm install
2. Create a Shopify Admin API token
- In Shopify Admin, open Settings → Apps and sales channels → Develop apps → Create an app.
- Under Configuration → Admin API integration, enable three scopes:
read_products— active products, variants, prices, barcodes (GTIN) and optionsread_inventory— liveinventoryQuantityandinventoryItem.unitCost(COGS)write_draft_orders— single-use, price-locked Draft Order checkout links with inventory reservation
- Install the app, copy the Admin API access token (
shpat_…), and put it in.envasSHOPIFY_ACCESS_TOKEN.
3. Start, verify and haggle
npm start # serves Agent Card, JWKS, /a2a and /healthz on :8787 npm run verify # runs the frida-protocol/1 conformance suite against your store npm run try # negotiates with your live Shopify catalog as a buyer agent
Why Draft Orders instead of discount codes
Reusable coupon codes leak to browser extensions within hours and destroy private pricing. createShopifySettlement() creates a Shopify Draft Order tagged frida-order:<order_id> with the exact variant, quantity, line-level appliedDiscount, agreed shipping perk, and a 30-minute inventory reservation. Retrying accept reuses the same Draft Order and returns the same single-use invoiceUrl.
Programmatic usage
import { loadSigningKey, memoryRateLimit } from 'frida-protocol';
import { listen } from 'frida-protocol/node';
import { createShopifyMerchantAgent } from 'frida-protocol/shopify';
const agent = createShopifyMerchantAgent({
url: process.env.AGENT_URL ?? 'http://127.0.0.1:8787',
name: 'Harbor & Pine',
key: await loadSigningKey(process.env.FRIDA_MERCHANT_KEY),
shop: process.env.SHOPIFY_SHOP, // e.g. harbor-and-pine.myshopify.com
accessToken: process.env.SHOPIFY_ACCESS_TOKEN,
policy: {
marginFloor: 0.35, // never below 35% gross margin on Shopify unitCost
perks: [{ code: 'free_express', label: '2-day courier', value: 1600, cost: 600, per: 'order' }],
},
reserveInventoryMinutes: 30, // holds stock on the Draft Order until checkout
rateLimit: memoryRateLimit({ limit: 120 }),
});
await listen(agent.fetch, { port: 8787, shutdownSignals: true });
Mount agent.shopify.catalog.handleWebhook(request, process.env.SHOPIFY_WEBHOOK_SECRET) at POST /webhooks/shopify and subscribe to inventory_levels/update and products/update so stock changes invalidate the in-memory cache immediately.