API Documentation
The PawVault REST API is organized around resource-oriented URLs and returns JSON. Most write endpoints require an authenticated session (marked
Authentication
/api/auth/registerCreate an account with email, username, and password. Sends a verification email.
{
"email": "buyer@email.com",
"username": "buyer",
"password": "s3cret!",
"confirmPassword": "s3cret!"
}/api/auth/forgot-passwordSend a password-reset token to the user's email.
/api/auth/reset-passwordComplete a password reset using the emailed token.
/api/auth/verify-email?token=...Verify an email address from the link sent during registration.
/api/auth/logoutEnd the current session and clear the auth cookie.
/api/auth/sessionReturn the current session (NextAuth). Used by the client to know if a user is signed in.
Users & Profile
/api/user/profileGet the authenticated user's profile.
/api/user/profileUpdate display name, bio, social links, and privacy settings.
/api/user/wishlistList the user's wishlisted products.
/api/user/wishlistAdd a product to the wishlist. Body: { productId }.
/api/user/wishlist?productId=...Remove a product from the wishlist.
Products
/api/productsList published products with filters. Query: category, search, sort, page, limit, priceMin, priceMax, rating, tags, free, onSale, creator.
GET /api/products?category=avatars&sort=price-asc&page=1&limit=24
{
"products": [ { "id": "cld...", "title": "Neon Fox", "price": 12.0, "rating": 4.7 } ],
"pagination": { "page": 1, "limit": 24, "total": 318, "totalPages": 14 }
}/api/products/[slug]Get full product details including media, files, reviews, and creator.
/api/productsCreate a product (creator only). Handles slug generation and tag upserts.
/api/products/featuredAdmin-curated featured products for the homepage.
/api/products/[slug]/reviewsPaginated, verified reviews for a product with average rating.
Uploads & Media
/api/media/uploadUpload images/videos. Returns a CDN URL and generates a thumbnail.
/api/products/filesAttach downloadable files to a product (drag-and-drop, resumable).
/api/media/[id]Delete a media asset.
Cart & Checkout
/api/cartGet the current cart (user or guest session).
/api/cartAdd a product to the cart. Body: { productId, quantity }.
/api/cart/items/[id]Update an item's quantity (min 1, max 100).
/api/cart/items/[id]Remove an item from the cart.
/api/cart/couponApply a coupon code. Body: { code }.
/api/checkoutCreate a Stripe Checkout session for the cart. Returns orderId and Stripe URL.
POST /api/checkout
{ "cartId": "cld...", "couponCode": "SUMMER10" }
→ { "orderId": "ord...", "url": "https://checkout.stripe.com/..." }Orders & Refunds
/api/ordersList the user's orders with items, payments, and licenses.
/api/orders/[id]/refundRequest a refund. Body: { reason, items? }. Creates a PENDING refund and notifies the buyer.
Licenses
/api/licensesList the user's (or, for admins, all) license keys with product info.
/api/licenses/generateGenerate a license for a completed order. Body: { productId, orderId, userId?, expiresAt? }.
/api/licenses/validate?key=XXXPublic validation. Checks existence, revocation, and expiry. Rate-limited to 100 req/min.
GET /api/licenses/validate?key=PV-AB12-CD34-EF56
{
"valid": true,
"license": { "key": "PV-AB12-CD34-EF56", "status": "ACTIVE", "product": { "slug": "neon-fox" } }
}Reviews
/api/reviewsCreate a review. Verified flag is set if the user owns the product. Body: { productId, rating, title?, content? }.
/api/reviews/[id]Edit your review (within 30 days).
/api/reviews/[id]Delete your review (within 30 days).
Notifications
/api/notificationsList the user's notifications plus an unreadCount. Add ?unread=true to filter.
/api/notifications/[id]/readMark a notification as read.
/api/notifications/[id]Delete a notification.
Search & Discovery
/api/search?q=...Full-text search across products and creators. Query: q, type (all|products|creators), limit, offset.
GET /api/search?q=fox&limit=5
{
"products": [ { "title": "Neon Fox", "slug": "neon-fox" } ],
"creators": [ { "username": "foxtail" } ]
}/api/creators/trendingTop creators ranked by recent sales and followers.
/api/categoriesAll categories with product counts.
/api/categories/[slug]A single category with its products and subcategories.
/api/stores/[slug]Public storefront data: products, collections, and reviews summary.
Rate limiting
Public endpoints are rate-limited per IP (e.g. license validation at 100 req/min). Authenticated requests include X-RateLimit-Remaining headers.