Skip to main content
The response contract is published as the npm package @depict-ai/v4-types. It has TypeScript types and zod schemas for every request and response, and a JSON Schema for other languages. Your store’s merchant attributes differ from other stores’, so the package can also build your store’s own card type from GET /v4/{merchant}/schema.

Install

The package is ESM only and depends on zod 4. It is MIT licensed.

Response types

Each endpoint has a request and a response schema, named after it: BrowseRequest and BrowseResponse, ProductsResponse, ContextResponse, RecommendationsResponse, SuggestResponse, ListingResponse, ListingTreeResponse, SchemaResponse and EventsResponse. Errors are ErrorResponse. Each schema is also a type of the same name.
  • Product and Variant are the product card and its variants.
  • endpoints lists every endpoint’s method, path, and request and response schemas.
  • CONTRACT_VERSION is the contract version the package follows. The package’s major and minor version match it, so 6.1.x follows contract 6.1.
  • Response schemas accept fields they don’t know, so a client built on 6.1 keeps working when the API adds fields.
  • Without TypeScript, use the JSON Schema (draft 2020-12) in the package: import schema from "@depict-ai/v4-types/schema.json" with { type: "json" }. Every request and response is under $defs.

Store schema

GET /v4/{merchant}/schema lists your store’s declared attributes. These are the attributes your cards are built with. It takes no parameters.
  • attributes is [] when your store has no declared attributes. Its cards are then the plain Product.
  • The list changes only when Depict changes your store’s attributes. Call this endpoint when you build your storefront or generate code, not on every page load.
  • An unknown store is a 404 unknown_merchant, as on every endpoint.

productSchemaFor

productSchemaFor(attributes) returns your store’s card schema. It is the Product schema with your declared attributes added, and it fails a card that lacks a required attribute or has a value that breaks its pattern:
responseSchemasFor(attributes) returns every endpoint’s response schema with your card in browse, products and recommendations. productSchemaFor checks values while your code runs, but its type is the plain Product. To have your attributes typed too, generate a module.

Generate a typed module

From @depict-ai/v4-types 6.1.0.
The package’s command line tool reads GET /v4/{merchant}/schema and writes a TypeScript module for your store:
For the store above, src/depict/acme.ts is:
Use it in place of Product:
  • The tool needs Node 18 or later. It installs nothing besides the package and zod.
  • Commit the generated file, and run the command again when Depict changes your store’s attributes.
  • When the store is unknown, the API can’t be reached or the answer isn’t a schema, the tool prints one line saying what the API answered and exits with code 1.