This document describes the backend HTTP API for the AutoHub application. It includes every public route implemented under the routes/ folder, required authentication, request shapes, query parameters, and example responses.
Notes:
token) or Authorization header Bearer <token>.Admin./api (unless explicitly served at /uploads which is static).200 or 201 with a JSON body. Errors use 4xx or 5xx with { error: "message" }.?page and ?limit query params. Defaults: page=1, limit varies (usually 10).Base path: /api/auth
token and returns user objecttoken cookie and returns { message: "Logged out successfully" }Base path: /api/users (requires authentication + admin role)
GET /api/users
GET /api/users/:id
PUT /api/users/:id
DELETE /api/users/:id
Base path: /api/car-intake (authenticated)
Endpoints:
POST /api/car-intake
upload.any().sellerData provided, the flow will create Seller, CarIntake and optionally Transaction if payment info included.GET /api/car-intake
GET /api/car-intake/:id
PUT /api/car-intake/:id
PATCH /api/car-intake/:id/status
scraped, also sets scrapedBy and scrapDateDELETE /api/car-intake/:id
GET /api/car-intake/stats
POST /api/car-intake/bulk-upload
/uploads/ directoryPOST /api/car-intake/bulk-upload-scraped
GONE and maps custom columnsNotes and validation details:
Base path: /api/transactions (authenticated)
POST /api/transactions
GET /api/transactions
GET /api/transactions/:id
PUT /api/transactions/:id
PATCH /api/transactions/:id/status
DELETE /api/transactions/:id
GET /api/transactions/car-intake/:carIntakeId
GET /api/transactions/seller/:sellerId
GET /api/transactions/stats
Base path: /api/upload (authenticated for most actions)
POST /api/upload/image
image (images and Excel allowed)POST /api/upload/multiple
images (limit 10)DELETE /api/upload/:filename
/uploads directoryGET /api/upload/:filename
Notes:
uploads/ and served statically at /uploads by the server.Base path: /api/vin (authenticated)
source (database or MarketCheck/NHTSA) and timestampError cases include invalid VIN format, service timeout/unavailable, or VIN not decoded.
These endpoints typically require authentication (admin-level in controllers).
Base path: /api/make (controller uses paths like /api/make)
POST /api/make
GET /api/make
?page, ?limit, ?searchGET /api/make/:id
PUT /api/make/:id
DELETE /api/make/:id
Base path: /api/model
POST /api/model
GET /api/model
GET /api/model/:id
PUT /api/model/:id
Base path: /api/trim
POST /api/trim
GET /api/trim
?make and ?model filtersGET /api/trim/:id
PUT /api/trim/:id
Base path: /api/part
POST /api/part
GET /api/part
GET /api/part/:id
PUT /api/part/:id
DELETE /api/part/:id
Base path: /api/element
POST /api/element
GET /api/element
GET /api/element/:id
PUT /api/element/:id
Base path: /api/scrap-element
POST /api/scrap-element
elementName and vin (unit optional)GET /api/scrap-element/vin/:vin
Base path: /api/inventory (authenticated)
POST /api/inventory
tag computed server-sideGET /api/inventory/parts
GET /api/inventory/vin/:vin
GET /api/inventory
Base path: /api/buyers (authenticated)
POST /api/buyers
GET /api/buyers
GET /api/buyers/:id
PUT /api/buyers/:id
DELETE /api/buyers/:id
Note: Buyer documents include isDeleted (Boolean) and deletedAt (Date). List and GET endpoints exclude soft-deleted buyers by default.
Base path: /api/waivers (authenticated)
POST /api/waivers
customerType.sellerId or sellerData (or buyerId/buyerData when customerType is buyer). Optionally transactionData to create a payment transaction.customerType in ["seller","buyer"]GET /api/waivers
GET /api/waivers/:id
PUT /api/waivers/:id
DELETE /api/waivers/:id
isDeleted=true and deletedAt)Note: The Waiver model now includes isDeleted (Boolean) and deletedAt (Date). GET/list endpoints exclude soft-deleted waivers by default.
GET /api/waivers/seller/:sellerId
GET /api/waivers/buyer/:buyerId
GET /api/waivers/stats
The backend uses soft deletes for most user-visible resources. This section summarizes the current behavior, fields added to schemas, which endpoints perform soft deletes vs hard deletes, and recommendations for standardization.
Fields added / in-use across models:
isDeleted (Boolean) — preferred canonical flag for soft-deleted documents. When true the document is considered deleted and should be excluded from normal list/get responses.deletedAt (Date) — timestamp set when a document is soft-deleted.deleted (Boolean) — legacy flag used by the Part model and some older code paths. New deletions on parts set both deleted and isDeleted for compatibility.isActive (Boolean) — used in many models to indicate active/inactive status; controllers sometimes set isActive=false when soft-deleting.Endpoints using soft-delete (controller sets isDeleted=true, deletedAt=Date.now() and often isActive=false):
isDeleted for future alignmentEndpoints that currently perform hard deletes (consider converting to soft-delete if you want recoverability):
Querying and controller notes:
isDeleted: { $ne: true } or checking isActive). Some older endpoints/models still rely on deleted or isActive for compatibility.deleted and isDeleted to avoid breaking older clients.Recommendations:
isDeleted + deletedAt as the single soft-delete contract across all models and update controllers to use them consistently.findByIdAndDelete, findOneAndDelete, etc.) with a shared soft-delete helper or Mongoose plugin that sets isDeleted, deletedAt, and optionally isActive=false and updatedBy.Model.findActive() or a global query filter) or a small plugin to reduce duplication and prevent accidental hard-deletes./uploads are served statically at /uploads/*.cd backend
npm install
npm run dev
If you want this rendered to OpenAPI/Swagger format, I can generate an OpenAPI v3 YAML/JSON from these endpoints and types — tell me which format you prefer (JSON/YAML) and whether you want it added as /api-docs with Swagger UI.