Nano Store - Ecommerce Docs
Developer ResourcesProduct Gallery, Delete and Preview

Product Gallery, Delete and Preview API

Contract changes to the admin product restore, bulk restore and product response, with error codes and integration notes.

Audience: Admin and other consumers of /api/admin/products Scope: Only what this feature changed. The full endpoint list is on the products API page. The storefront gallery has no API surface.

Product Gallery, Delete and Preview API

1. Route Surfaces

SurfacePrefixAuth
Admin/api/admin/productsJWT + role, Products_* permission

2. Endpoint Reference

MethodPathAuthDescription
DELETE/api/admin/products/:publicIdProducts_DELETESoft delete (unchanged)
POST/api/admin/products/:publicId/restoreProducts_RESTORERestore; can now return 409 for a deleted referent
POST/api/admin/products/bulk/restoreProducts_RESTOREBulk restore; per-row failures include the new codes
GET/api/admin/productsProducts_READList; the admin sends deletedOnly, onSale and featured

3. Key Contracts

3.1 Admin product timestamps.deletedAt

Returned by every admin route that returns ProductResponseDto (get, create, update, facet updates, restore). Admin surface only; the customer response never carries the key.

{
  "timestamps": {
    "createdAt": "2026-09-01T10:00:00.000Z",
    "updatedAt": "2026-10-07T08:30:00.000Z",
    "publishedAt": null,
    "deletedAt": "2026-10-07T08:30:00.000Z"
  }
}

deletedAt is null for a live product. Consumers must treat an absent key (older backend) and null as not deleted.

3.2 Restore refused: 409

POST /api/admin/products/:publicId/restore, one error per call.

{
  "message": "Category is deleted.",
  "errorCode": "PRODUCT_CATEGORY_DELETED"
}

A refused restore writes nothing and triggers no cache invalidation.

3.3 Bulk restore: per-row failures

ProductBulkResultDto is unchanged: { succeeded: string[]; failures: { publicId: string; errorCode: string }[] }. failures[].errorCode may now also be PRODUCT_CATEGORY_DELETED, PRODUCT_BRAND_DELETED or PRODUCT_SERIES_DELETED. Other rows in the batch still restore.

{
  "message": "Bulk restore processed",
  "errorCode": null,
  "data": {
    "succeeded": ["0192f3a0-0000-7000-8000-000000000001"],
    "failures": [
      { "publicId": "0192f3a0-0000-7000-8000-000000000002", "errorCode": "PRODUCT_BRAND_DELETED" }
    ]
  }
}

3.4 Catalog restore (consumed by the admin)

The admin catalog screens call these existing restore routes. They are unchanged by this feature.

MethodPathPermission
POST/api/admin/catalog/categories/:publicId/restoreCategories_RESTORE
POST/api/admin/catalog/brands/:publicId/restoreBrands_RESTORE
POST/api/admin/catalog/brand-series/:publicId/restoreBrandSeries_RESTORE

The admin list calls send deletedOnly=true for categories (one tree level, scoped to the parent) and includeDeleted=true for brands and series (live plus deleted). Restoring the referent is how an operator clears a product restore 409 (PRODUCT_CATEGORY_DELETED, PRODUCT_BRAND_DELETED, PRODUCT_SERIES_DELETED). Category restore does not check that the parent category is live.

4. Error Reference

StatuserrorCodeRouteWhen
404PRODUCT_NOT_FOUNDrestore, deleteno product has this public id
409PRODUCT_NOT_DELETEDrestorethe product is not deleted; checked first
409PRODUCT_CATEGORY_DELETEDrestorecategory is soft-deleted ("Category is deleted.")
409PRODUCT_BRAND_DELETEDrestorebrand set and soft-deleted, category live ("Brand is deleted.")
409PRODUCT_SERIES_DELETEDrestoreseries set and soft-deleted, category and brand live ("Brand series is deleted.")
409PRODUCT_ALREADY_DELETEDdeletealready soft-deleted

Precedence on restore is category, then brand, then series.

5. Integration Notes

  • Branch on errorCode, never on message.
  • Admin consumer type: timestamps.deletedAt?: string | null (lib/mobile-api/admin/products.types.ts).
  • The admin maps the three referent codes to "Can't restore: its category|brand|series is deleted. Restore that first."
  • Admin GET still returns soft-deleted products; use deletedAt to detect them.
  • Admin list: deletedOnly=true combines with the other filters. The backend coerces any onSale or featured string other than "true" to false, so send only true or false.

6. Guardrail Summary

  • Deploy the backend before the admin.
  • Never expect deletedAt on a customer response.
  • Never assume one refused restore reports every deleted referent; fix the reported one and retry.
  • Do not rely on the referent check being atomic with the restore.

See Also