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/productsScope: 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
| Surface | Prefix | Auth |
|---|---|---|
| Admin | /api/admin/products | JWT + role, Products_* permission |
2. Endpoint Reference
| Method | Path | Auth | Description |
|---|---|---|---|
DELETE | /api/admin/products/:publicId | Products_DELETE | Soft delete (unchanged) |
POST | /api/admin/products/:publicId/restore | Products_RESTORE | Restore; can now return 409 for a deleted referent |
POST | /api/admin/products/bulk/restore | Products_RESTORE | Bulk restore; per-row failures include the new codes |
GET | /api/admin/products | Products_READ | List; 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.
| Method | Path | Permission |
|---|---|---|
POST | /api/admin/catalog/categories/:publicId/restore | Categories_RESTORE |
POST | /api/admin/catalog/brands/:publicId/restore | Brands_RESTORE |
POST | /api/admin/catalog/brand-series/:publicId/restore | BrandSeries_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
| Status | errorCode | Route | When |
|---|---|---|---|
| 404 | PRODUCT_NOT_FOUND | restore, delete | no product has this public id |
| 409 | PRODUCT_NOT_DELETED | restore | the product is not deleted; checked first |
| 409 | PRODUCT_CATEGORY_DELETED | restore | category is soft-deleted ("Category is deleted.") |
| 409 | PRODUCT_BRAND_DELETED | restore | brand set and soft-deleted, category live ("Brand is deleted.") |
| 409 | PRODUCT_SERIES_DELETED | restore | series set and soft-deleted, category and brand live ("Brand series is deleted.") |
| 409 | PRODUCT_ALREADY_DELETED | delete | already soft-deleted |
Precedence on restore is category, then brand, then series.
5. Integration Notes
- Branch on
errorCode, never onmessage. - 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
deletedAtto detect them. - Admin list:
deletedOnly=truecombines with the other filters. The backend coerces anyonSaleorfeaturedstring other than"true"tofalse, so send onlytrueorfalse.
6. Guardrail Summary
- Deploy the backend before the admin.
- Never expect
deletedAton 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
Product Gallery, Delete and Preview Backend Architecture
Backend changes for the feature — the restore referent guard, the admin-only deletedAt timestamp, and their error contract.
Catalog Integrity and Client IP Feature Guide
Delete protection for categories, brands and series, safe restore rules, constraint errors that no longer surface as 500, and the real client IP in audit and session records.