Skip to content
New

Shopify launched Agentic Storefronts. We make AI agents recommend you - not just list you.

See the Shopify integration
Tru Commerce

← Insights

Product data APIs for AI agents: contract design

Design product data APIs for AI agents with variant identity, scoped offers, freshness and useful errors. Validate the contract against real shopping tasks.

Tru Commerce Team · November 26, 2026 · ChatGPT Apps & MCP

A product data API for AI agents should return the facts required for a defined shopping task, at the right product and offer scope. Start with stable identifiers, explicit constraints and authoritative commercial data. A large product response is not necessarily a useful or safe tool response.

Reviewed 26 November 2026. This Tru Commerce implementation guide uses current primary documentation and proposed design examples. The examples are not a production benchmark, universal protocol schema or customer case study.

Design around the question the agent must answer

A shopper asking for a waterproof jacket under a budget needs different evidence from a customer asking whether an existing order has shipped. The first task can often begin with public product data. The second requires an authenticated account relationship and a resource ownership check.

Do not combine these tasks into a general-purpose endpoint that returns whatever the internal commerce system knows. Define the intended consumer, allowed operation and minimum response for each tool. A product lookup should not accidentally expose supplier cost, internal warehouse details or customer records.

Start with a written example of a good answer and mark every factual statement it requires. Then identify the authoritative source and scope of each fact. This exercise exposes missing data before a model makes a plausible guess to fill it.

Separate product identity from the offer

A product family, a purchasable variant and a market-specific offer are related but different objects. Preserve the relationship rather than flattening them into a single title and price.

LayerExample questionContract requirement
Product familyWhich jacket model is this?Stable parent identity and shared description
VariantWhich size and color will be purchased?Exact variant ID and selected options
OfferWhat can this shopper buy now?Currency, price context, availability and conditions
Action resultWas the chosen item added?Returned cart state and meaningful warnings

Shopify's Storefront ProductVariant represents a particular option combination and exposes fields such as selected options, price and availability. Its current documentation warns that availableForSale does not distinguish delivery methods: a variant can be available through local pickup rather than shipping. Shopify ProductVariant reference

The implementation consequence is specific. Do not turn a general availability flag into a delivery promise. Resolve the shopper's actual location and fulfillment requirement through the appropriate authoritative route before stating that an offer can be delivered.

Make the contract small enough to inspect

MCP tools declare an input schema and can provide an output schema for structured results. When an output schema is provided, the server must return results that conform to it. Annotations describe behavior but are not a substitute for trusting and authorizing the server. MCP tools specification

For an illustrative product lookup, the input might contain a merchant-scoped variant identifier and an explicit market. The output could contain that same identifier, the selected options, a factual description, offer context, observation time and a source reference. These are proposed contract fields, not required MCP field names.

Avoid accepting a free-form request and then returning an unbounded internal object. Constrain identifiers, permitted filters and result sizes. If the task needs another data category, create a deliberate extension and review its access boundary rather than allowing the response to grow silently.

The Shopify MCP guide explains why interface choice matters. A merchant administration capability should not be exposed as if it were ordinary public product search.

Represent unknown facts honestly

Missing, false and temporarily unavailable are different states. If a material attribute is absent from the approved source, the response should not silently turn absence into “no.” If the source service failed, it should not look like a valid empty catalog result.

For example, “waterproof rating not supplied” means the system lacks evidence for that attribute. “No matching products” means the query ran successfully and did not find an eligible result under its defined rules. “Availability service unavailable” means the current offer could not be checked.

Give the application enough structured information to distinguish those states. The customer-facing response can remain simple, but it should follow the actual result. A useful integration can say that it found a possible product while explaining that current availability could not be confirmed.

The catalog readiness guide covers upstream product quality. The API should preserve that evidence quality rather than conceal missing facts behind more fluent prose. The four-rung product-data framework helps separate identity, qualification, fit and decision support during that review.

Keep freshness attached to the fact

Different fields change at different rates. A material specification may be stable while availability changes repeatedly. A feed import timestamp cannot establish that every price and stock field is current at the moment of purchase.

Define the freshness meaning for each volatile field. Record when the authoritative source was checked, what context applied and what the caller should do if the result is too old for its task. The required age limit is a business and integration decision; there is no universal number of minutes that makes every catalog safe.

A reasonable retrieval design can find candidate identifiers from an index and obtain current offers for the selected candidates before making a commercial promise. That does not mean every descriptive search needs a synchronous call to every backend. Match the validation boundary to the claim and action.

The out-of-stock recommendation guide gives the deeper failure analysis. This contract should carry the identifiers and source state needed to investigate those failures.

Treat action responses as business results

Shopify's cartLinesAdd accepts merchandise lines for product variants and returns the updated cart together with user errors and warnings. Those outputs need to be inspected before the integration tells the customer the requested change succeeded. Shopify cartLinesAdd reference

For any provider, compare the returned state with the requested state. A successful transport response can contain a warning or a different business outcome. Do not reduce every response to a green “tool succeeded” indicator and then reconstruct the cart from the original request.

Keep a product lookup separate from an order commitment. The agentic checkout overview explains the wider transaction boundary. Product data helps establish the offer; it is not permission to execute any action the model proposes.

Use the right error channel

The reviewed MCP specification distinguishes malformed protocol requests and unknown tools from tool-execution failures such as input validation or business logic errors. Execution failures can return isError: true with actionable feedback. MCP error handling

In your application, define stable error categories and safe customer explanations. An expired account connection, an invalid variant and an unavailable inventory service need different responses. Avoid telling the customer to reconnect when the real issue is a backend outage.

A recoverable error should state what can change without exposing sensitive implementation details. If the offer must be reviewed again, preserve that boundary. If the outcome of a write is uncertain, check authoritative state rather than treating a retry as harmless. The checkout recovery guide maps the resulting state and retry decisions.

Test the contract with a deliberately awkward sample

Test input or source conditionExpected behaviorEvidence to retain
Parent ID supplied where a variant is requiredReject or request an exact selectionValidation result and allowed identifier type
Known product, unsupported marketReturn a scoped refusalMarket rule and customer explanation
Missing material attributePreserve unknown statusSource field and rendered answer
Inventory lookup failsAvoid a current-stock claimFailure category and observation time
Cart returns a warningReflect the returned stateActual response and customer message
Unrelated account identifier suppliedEnforce service-side ownershipAuthorization result without private payloads

Run these as controlled tests with representative data. Do not add test orders or generated answers to a customer adoption report. A passing schema validator proves response shape; it does not prove that the underlying commercial facts are correct.

Decide how the contract will evolve

Changing a field's meaning can break a client even when its type stays the same. Document what the consumer may rely on, maintain representative fixtures and compare the generated customer answer after a change. Preserve a way to identify the deployed contract and source configuration in operational evidence.

Use the PIM tools comparison when the missing capability is product governance. Use the feed-management comparison when the missing capability is distribution. The API contract solves a different problem: making a defined task answerable from the right records.

The Provogue case is a separate implementation example rather than proof of this proposed schema. Book a catalog-to-tool review to map a representative shopping question to the records, permissions and action result your integration can support.

Choose the retrieval service against the product contract

The product-search API buyer guide compares Algolia, Google and Constructor on filtering, identity, personalization and billed units. Use the same approved product records and shopping tasks when evaluating each service.

Carry the product contract into a new launch

The new-product AI discovery checklist separates an approved product record, published page, feed acceptance and observed visibility. Use its dated verification log to find which stage needs correction instead of promising a universal indexing deadline.

FAQ

Sources

  1. 1.Shopify ProductVariant reference - shopify.dev
  2. 2.MCP error handling - modelcontextprotocol.io
  3. 3.Shopify cartLinesAdd reference - shopify.dev

Put this into practice

Walk through your shopper journey, integration requirements and the results you want to measure with Tru Commerce.

Choose a time after the form · 30 minutes · no card

Continue reading