Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Avelero/avelero/llms.txt

Use this file to discover all available pages before exploring further.

Update existing products in your catalog. This endpoint supports both single product updates and bulk operations.

Endpoint

trpc.products.update.mutate(input)
Router location: apps/api/src/trpc/routers/products/index.ts:373

Operation modes

The update endpoint supports two modes based on the input structure:
  1. Single product update: Provide id to update one product with full field access
  2. Bulk update: Provide selection to update multiple products with limited fields

Single product update

Request parameters

id
string
required
UUID of the product to update
brand_id
string
UUID of the brand (must match active brand if provided)
name
string
Product name (1-100 characters)
product_handle
string
URL-friendly identifier. Can be set to null to clear.Format: Lowercase letters, numbers, and dashes only
description
string | null
Product description. Set to null to clear.
category_id
string | null
Category UUID. Set to null to clear.
season_id
string | null
Season UUID. Set to null to clear.
manufacturer_id
string | null
Manufacturer UUID. Set to null to clear.
image_path
string | null
Storage path for product image. Set to null to clear.
status
string | null
Product status ("draft" or "published"). Set to null to clear.
tag_ids
string[]
Array of tag UUIDs
materials
array
Array of material compositions (same structure as create)
journey_steps
array
Array of journey steps (same structure as create)
environment
object
Environmental impact metrics (same structure as create)
weight
object
Product weight (same structure as create)

Response

data
object
The updated product object with all fields

Example

const updated = await trpc.products.update.mutate({
  id: "550e8400-e29b-41d4-a716-446655440000",
  name: "Updated Product Name",
  description: "New description",
  status: "published"
});

console.log(updated.data.name); // "Updated Product Name"

Bulk update

Update multiple products at once. Only specific fields are available for bulk updates.

Request parameters

selection
object
required
Defines which products to update
brand_id
string
Brand UUID (must match active brand if provided)

Available bulk update fields

status
string
Product status to apply to all selected products
category_id
string | null
Category UUID to apply. Set to null to clear category for all selected products.
season_id
string | null
Season UUID to apply. Set to null to clear season for all selected products.
Bulk updates only support status, category_id, and season_id. For updating other fields, use single product updates.

Response

success
boolean
Always true on success
updated
number
Number of products updated

Examples

Update specific products

const result = await trpc.products.update.mutate({
  selection: {
    mode: "explicit",
    ids: [
      "uuid-1",
      "uuid-2",
      "uuid-3"
    ]
  },
  status: "published",
  category_id: "new-category-uuid"
});

console.log(result.updated); // 3

Update all products matching filter

const result = await trpc.products.update.mutate({
  selection: {
    mode: "all",
    filters: {
      groups: [
        {
          id: "group-1",
          conditions: [
            {
              id: "cond-1",
              fieldId: "status",
              operator: "equals",
              value: "draft"
            }
          ]
        }
      ]
    },
    excludeIds: ["uuid-to-keep-draft"]
  },
  status: "published"
});

console.log(result.updated); // Number of products changed from draft to published
const result = await trpc.products.update.mutate({
  selection: {
    mode: "all",
    search: "2024 collection"
  },
  season_id: "spring-2024-uuid"
});

Update with materials and environment

const updated = await trpc.products.update.mutate({
  id: "product-uuid",
  materials: [
    {
      brand_material_id: "material-1",
      percentage: 70
    },
    {
      brand_material_id: "material-2",
      percentage: 30
    }
  ],
  environment: {
    carbon_kg_co2e: "10.2",
    water_liters: "2800"
  }
});

Clear nullable fields

Set fields to null to clear their values:
const updated = await trpc.products.update.mutate({
  id: "product-uuid",
  description: null,
  category_id: null,
  manufacturer_id: null
});

Publishing behavior

When setting status to "published", the system automatically triggers the publish flow to create passport versions. This ensures QR codes become resolvable when the product is published.
For single product updates:
const updated = await trpc.products.update.mutate({
  id: "product-uuid",
  status: "published"
});
// Automatically calls publishProduct() in the background
For bulk updates:
const result = await trpc.products.update.mutate({
  selection: { mode: "explicit", ids: ["uuid-1", "uuid-2"] },
  status: "published"
});
// Automatically calls bulkPublishProducts() in the background

Cache revalidation

For single product updates, the DPP cache is automatically revalidated:
// After update, the DPP page for this product is revalidated
await trpc.products.update.mutate({
  id: "product-uuid",
  name: "Updated Name"
});
// DPP cache cleared for /[brandSlug]/[productHandle]/

Error codes

BAD_REQUEST
error
Invalid input or validation errorCommon causes:
  • Product not found for active brand
  • Active brand does not match provided brand_id
  • Invalid product handle format
  • Product handle already exists for another product
  • Invalid UUID format
  • Empty ids array in explicit mode
INTERNAL_SERVER_ERROR
error
Unexpected error during updateMessage: "Failed to update product"

Validation rules

Single update

  • Only fields explicitly provided in the input are updated
  • Nullable fields can be set to null to clear them
  • All validation rules from create apply (product handle format, string lengths, etc.)

Bulk update

  • At least one product ID required in explicit mode
  • Only status, category_id, and season_id can be bulk updated
  • Filters and search use the same FilterState structure as list queries

Source code reference

  • Schema definition: apps/api/src/schemas/products.ts:355 (unifiedUpdateSchema)
  • Implementation: apps/api/src/trpc/routers/products/index.ts:373
  • Database queries:
    • Single: @v1/db/queries/products (updateProduct)
    • Bulk: bulkUpdateProductsByIds, bulkUpdateProductsByFilter

Build docs developers (and LLMs) love