# Private cart recovery (Phase 4E) Authenticated customers can resume their persisted cart after at least 24 hours without a successful cart edit, recovery, or checkout. Cart reads and failed commands do not refresh activity. A cart must contain at least one line and have a known activity timestamp. This milestone provides in-app recovery; outbound reminders require the later consent-aware messaging milestone. All routes use the caller's live active session and own organization/user scope. No staff permission, user ID parameter, public token, customer directory, or new provider is involved. Existing access rate limits apply. | Method | Route | Behavior | | ------ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | GET | `/api/v1/cart/recovery` | Returns `version`, nullable `lastActivityAt`, `recoverable`, and current lines; does not create a cart or change activity. | | POST | `/api/v1/cart/recovery` | Strict body `{ "version": 1 }`; resumes the eligible cart at its current version. Returns 201 with the next `version` and `removedVariantIds`. | Each preview line contains `variantId`, `quantity`, `available`, and `variant`. Available variants expose current name, SKU, decimal price, currency, and product name. Inactive variants and unpublished products return `available: false, variant: null`; their private catalog details are redacted. The response contains no user profile or contact details. The customer explicitly confirms removal of unavailable lines when posting recovery. Resumption rechecks catalog availability, preserves all available quantities, removes unavailable lines atomically, refreshes activity, increments the cart version once, and appends `cart.recovered` to the audit trail. A competing edit, checkout, or recovery is serialized by the existing organization lock. Stale versions return `CART_CHANGED` (409); empty, undated, or recently active carts return `CART_NOT_RECOVERABLE` (409). Invalid bodies return 400; missing/inactive sessions are rejected by the existing access guard. A lost successful response is resolved by reading the new version, rather than blindly retrying the old command. Availability means currently active and published merchandise, not a stock reservation. Recovery neither freezes prices nor copies coupons from earlier orders. Checkout remains authoritative for current prices, currency consistency, campaign/coupon eligibility, stock, and immutable order snapshots. Customers can edit the recovered cart with the existing versioned cart endpoints. Deploy the additive nullable `last_activity_at` migration before the application. Existing carts retain all lines but have unknown historical activity; they become eligible only after a new successful cart edit followed by 24 idle hours. This avoids inventing old activity timestamps. No historical migrations are edited. Older code ignores the new column; if rolling back and later re-enabling recovery, clear timestamps for carts that may have been edited by the older code before enabling recovery again. Preserve cart lines, orders, and audit history. Acceptance covers the exact 24-hour boundary, empty/unknown/future activity, current prices, read-only activity semantics, customer and organization isolation, schema validation, stale and concurrent commands, audit uniqueness, inactive/unpublished redaction and removal, and edit/checkout reset. Native PostgreSQL concurrency checks remain subject to the project's existing CI database setup.