openapi: 3.1.0 info: title: Api version: 0.1.0 description: | Fashion store API. Uses Clerk JWT bearer tokens for authentication. servers: - url: /api description: Base API path tags: - name: health - name: auth description: Authentication and session management - name: products description: Product catalog - name: orders description: Order management - name: payments description: Payment processing (Paystack + Hubtel) - name: wishlist description: User wishlist / saved items - name: discounts description: Discount codes and promotions paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/register: post: operationId: register tags: [auth] summary: Register a new user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterBody" responses: "201": description: User created content: application/json: schema: $ref: "#/components/schemas/UserProfile" "422": description: Account creation failed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/login: post: operationId: login tags: [auth] summary: Validate session and return user profile security: - bearerAuth: [] responses: "200": description: Session valid content: application/json: schema: $ref: "#/components/schemas/UserProfile" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/logout: post: operationId: logout tags: [auth] summary: Sign out (revoke session) security: - bearerAuth: [] responses: "204": description: Session revoked "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/forgot-password: post: operationId: forgotPassword tags: [auth] summary: Initiate password reset requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ForgotPasswordBody" responses: "200": description: Reset initiated content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /users/me: get: operationId: getMe tags: [auth] summary: Get current user security: - bearerAuth: [] responses: "200": description: Current user profile content: application/json: schema: $ref: "#/components/schemas/UserProfile" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updateMe tags: [auth] summary: Update current user profile security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateUserProfileBody" responses: "200": description: Updated user profile content: application/json: schema: $ref: "#/components/schemas/UserProfile" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /products: get: operationId: listProducts tags: [products] summary: List products parameters: - name: category in: query schema: type: string - name: search in: query schema: type: string - name: featured in: query schema: type: string enum: ["true", "false"] - name: sort in: query schema: type: string enum: ["newest", "price_asc", "price_desc", "top_rated"] responses: "200": description: Product list content: application/json: schema: $ref: "#/components/schemas/ProductListResponse" /products/{id}: get: operationId: getProduct tags: [products] summary: Get product by ID parameters: - name: id in: path required: true schema: type: string responses: "200": description: Product content: application/json: schema: $ref: "#/components/schemas/Product" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /products/{id}/reviews: get: operationId: listProductReviews tags: [products] summary: List reviews for a product parameters: - name: id in: path required: true schema: type: string - name: page in: query schema: type: integer minimum: 1 default: 1 - name: limit in: query schema: type: integer minimum: 1 maximum: 50 default: 10 responses: "200": description: Reviews list content: application/json: schema: $ref: "#/components/schemas/ReviewListResponse" post: operationId: createReview tags: [products] summary: Submit a review for a product security: - bearerAuth: [] parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateReviewBody" responses: "201": description: Review created content: application/json: schema: $ref: "#/components/schemas/Review" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Not a verified buyer content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Already reviewed content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /products/{id}/review-eligibility: get: operationId: getReviewEligibility tags: [products] summary: Check if the current user is eligible to review a product security: - bearerAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Eligibility result content: application/json: schema: $ref: "#/components/schemas/ReviewEligibility" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Product not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /wishlist: get: operationId: listWishlist tags: [wishlist] summary: Get current user's wishlist security: - bearerAuth: [] responses: "200": description: Wishlist items content: application/json: schema: $ref: "#/components/schemas/WishlistResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" post: operationId: addToWishlist tags: [wishlist] summary: Add product to wishlist security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AddToWishlistBody" responses: "201": description: Item added to wishlist content: application/json: schema: $ref: "#/components/schemas/WishlistItemResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Already in wishlist content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /wishlist/{productId}: delete: operationId: removeFromWishlist tags: [wishlist] summary: Remove product from wishlist security: - bearerAuth: [] parameters: - name: productId in: path required: true schema: type: string responses: "204": description: Removed from wishlist "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /orders: post: operationId: createOrder tags: [orders] summary: Create an order security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateOrderBody" responses: "201": description: Order created content: application/json: schema: $ref: "#/components/schemas/Order" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" get: operationId: listOrders tags: [orders] summary: List my orders security: - bearerAuth: [] responses: "200": description: Orders list content: application/json: schema: $ref: "#/components/schemas/OrderListResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /orders/{id}: get: operationId: getOrder tags: [orders] summary: Get order by ID security: - bearerAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Order detail content: application/json: schema: $ref: "#/components/schemas/OrderDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /payments/paystack/initialize: post: operationId: initializePaystackPayment tags: [payments] summary: Initialize a Paystack payment for an order security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PaystackInitBody" responses: "200": description: Payment initialized content: application/json: schema: $ref: "#/components/schemas/PaystackInitResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /payments/paystack/verify/{reference}: get: operationId: verifyPaystackPayment tags: [payments] summary: Verify a Paystack transaction security: - bearerAuth: [] parameters: - name: reference in: path required: true schema: type: string responses: "200": description: Payment verification result content: application/json: schema: $ref: "#/components/schemas/PaymentVerifyResponse" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /payments/paystack/webhook: post: operationId: paystackWebhook tags: [payments] summary: Paystack webhook handler responses: "200": description: Webhook received content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /payments/hubtel/initiate: post: operationId: initiateHubtelPayment tags: [payments] summary: Initiate a Hubtel mobile money payment security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/HubtelInitBody" responses: "200": description: Mobile money payment initiated content: application/json: schema: $ref: "#/components/schemas/HubtelInitResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /payments/hubtel/callback: post: operationId: hubtelCallback tags: [payments] summary: Hubtel payment callback responses: "200": description: Callback received content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /payments/hubtel/status/{reference}: get: operationId: getHubtelPaymentStatus tags: [payments] summary: Get Hubtel payment status security: - bearerAuth: [] parameters: - name: reference in: path required: true schema: type: string responses: "200": description: Payment status content: application/json: schema: $ref: "#/components/schemas/PaymentVerifyResponse" /discounts/active: get: operationId: listActivePromotions tags: [discounts] summary: List active flash sale promotions responses: "200": description: Active promotions content: application/json: schema: $ref: "#/components/schemas/PromotionsResponse" /discounts/validate: post: operationId: validateDiscountCode tags: [discounts] summary: Validate a promo code against an order total security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ValidateDiscountRequest" responses: "200": description: Validation result content: application/json: schema: $ref: "#/components/schemas/ValidateDiscountResponse" "400": description: Invalid or expired code content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Code not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /discounts: post: operationId: createDiscountCode tags: [discounts] summary: Create a discount code (admin) security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateDiscountRequest" responses: "201": description: Created discount code content: application/json: schema: $ref: "#/components/schemas/DiscountCode" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /discounts/{code}/deactivate: patch: operationId: deactivateDiscountCode tags: [discounts] summary: Deactivate a discount code (admin) security: - bearerAuth: [] parameters: - name: code in: path required: true schema: type: string responses: "200": description: Deactivated discount code content: application/json: schema: $ref: "#/components/schemas/DiscountCode" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /notifications/register: post: operationId: registerDeviceToken tags: [notifications] summary: Register device push token security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterTokenBody" responses: "201": description: Token registered content: application/json: schema: $ref: "#/components/schemas/RegisterTokenResponse" "200": description: Token updated content: application/json: schema: $ref: "#/components/schemas/RegisterTokenResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /notifications/unregister: delete: operationId: unregisterDeviceToken tags: [notifications] summary: Unregister device push token security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UnregisterTokenBody" responses: "200": description: Token removed content: application/json: schema: type: object properties: unregistered: type: boolean required: [unregistered] "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /notifications/preferences: get: operationId: getNotificationPreferences tags: [notifications] summary: Get notification preferences security: - bearerAuth: [] responses: "200": description: Preferences content: application/json: schema: $ref: "#/components/schemas/NotificationPreferences" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updateNotificationPreferences tags: [notifications] summary: Update notification preferences security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdatePreferencesBody" responses: "200": description: Updated content: application/json: schema: type: object properties: updated: type: boolean required: [updated] "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /notifications/broadcast: post: operationId: broadcastNotification tags: [notifications] summary: Admin broadcast push notification to all users security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BroadcastNotificationBody" responses: "200": description: Broadcast result content: application/json: schema: $ref: "#/components/schemas/BroadcastNotificationResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Forbidden content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: HealthStatus: type: object properties: status: type: string required: [status] DiscountCode: type: object properties: id: type: string code: type: string type: type: string enum: [percentage, fixed, free_shipping] value: type: string description: type: string nullable: true minOrderAmount: type: string nullable: true maxUsage: type: integer nullable: true usageCount: type: integer expiresAt: type: string format: date-time nullable: true isActive: type: boolean isFlashSale: type: boolean flashSaleTitle: type: string nullable: true flashSaleEndsAt: type: string format: date-time nullable: true createdAt: type: string format: date-time required: [id, code, type, value, usageCount, isActive, isFlashSale, createdAt] PromotionsResponse: type: object properties: promotions: type: array items: $ref: "#/components/schemas/DiscountCode" required: [promotions] ValidateDiscountRequest: type: object properties: code: type: string orderTotal: type: number required: [code, orderTotal] ValidateDiscountResponse: type: object properties: valid: type: boolean code: type: string type: type: string enum: [percentage, fixed, free_shipping] value: type: number description: type: string nullable: true discountAmount: type: number finalTotal: type: number freeShipping: type: boolean required: [valid, code, type, value, discountAmount, finalTotal, freeShipping] CreateDiscountRequest: type: object properties: code: type: string type: type: string enum: [percentage, fixed, free_shipping] value: type: number description: type: string minOrderAmount: type: number maxUsage: type: integer expiresAt: type: string format: date-time isFlashSale: type: boolean flashSaleTitle: type: string flashSaleEndsAt: type: string format: date-time required: [code, type] ErrorResponse: type: object properties: error: type: string required: [error] MessageResponse: type: object properties: message: type: string required: [message] RegisterBody: type: object properties: emailAddress: type: string format: email password: type: string minLength: 8 firstName: type: string lastName: type: string required: [emailAddress, password] ForgotPasswordBody: type: object properties: emailAddress: type: string format: email required: [emailAddress] UserProfile: type: object properties: id: type: string email: type: string name: type: string nullable: true firstName: type: string nullable: true lastName: type: string nullable: true imageUrl: type: string nullable: true createdAt: type: string format: date-time required: [id, email, createdAt] UpdateUserProfileBody: type: object properties: firstName: type: string lastName: type: string Product: type: object properties: id: type: string name: type: string description: type: string price: type: string comparePrice: type: string nullable: true category: type: string imageUrl: type: string images: type: array items: type: string stock: type: integer isNew: type: boolean isFeatured: type: boolean sizes: type: array items: type: string colors: type: array items: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time required: [id, name, description, price, category, imageUrl, images, stock, isNew, isFeatured, sizes, colors, createdAt, updatedAt] ProductListResponse: type: object properties: products: type: array items: $ref: "#/components/schemas/Product" total: type: integer required: [products, total] OrderItem: type: object properties: id: type: string productId: type: string productName: type: string productImageUrl: type: string size: type: string nullable: true color: type: string nullable: true quantity: type: integer unitPrice: type: string totalPrice: type: string required: [id, productId, productName, productImageUrl, quantity, unitPrice, totalPrice] Order: type: object properties: id: type: string userId: type: string status: type: string enum: [pending, paid, processing, shipped, delivered, cancelled, refunded] totalAmount: type: string currency: type: string deliveryName: type: string deliveryEmail: type: string deliveryPhone: type: string deliveryAddress: type: string deliveryCity: type: string deliveryRegion: type: string notes: type: string nullable: true discountCode: type: string nullable: true discountAmount: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time required: [id, userId, status, totalAmount, discountAmount, currency, deliveryName, deliveryEmail, deliveryPhone, deliveryAddress, deliveryCity, deliveryRegion, createdAt, updatedAt] OrderDetail: allOf: - $ref: "#/components/schemas/Order" - type: object properties: items: type: array items: $ref: "#/components/schemas/OrderItem" payment: $ref: "#/components/schemas/Payment" nullable: true required: [items] OrderListResponse: type: object properties: orders: type: array items: $ref: "#/components/schemas/Order" required: [orders] CreateOrderBody: type: object properties: deliveryName: type: string deliveryEmail: type: string format: email deliveryPhone: type: string deliveryAddress: type: string deliveryCity: type: string deliveryRegion: type: string notes: type: string discountCode: type: string description: Optional promo/discount code to apply server-side items: type: array items: $ref: "#/components/schemas/OrderItemInput" required: [deliveryName, deliveryEmail, deliveryPhone, deliveryAddress, deliveryCity, items] OrderItemInput: type: object properties: productId: type: string quantity: type: integer minimum: 1 size: type: string color: type: string required: [productId, quantity] Payment: type: object properties: id: type: string orderId: type: string method: type: string enum: [paystack, hubtel_mobile_money] status: type: string enum: [pending, success, failed, cancelled] amount: type: string currency: type: string reference: type: string mobileNetwork: type: string nullable: true mobileNumber: type: string nullable: true createdAt: type: string format: date-time required: [id, orderId, method, status, amount, currency, reference, createdAt] Review: type: object properties: id: type: string productId: type: string userId: type: string rating: type: integer minimum: 1 maximum: 5 title: type: string body: type: string reviewerName: type: string createdAt: type: string format: date-time required: [id, productId, userId, rating, title, body, reviewerName, createdAt] ReviewEligibility: type: object properties: eligible: type: boolean reason: type: string enum: [not_purchased, already_reviewed] nullable: true required: [eligible] ReviewListResponse: type: object properties: reviews: type: array items: $ref: "#/components/schemas/Review" total: type: integer page: type: integer limit: type: integer avgRating: type: number nullable: true ratingCount: type: integer required: [reviews, total, page, limit, ratingCount] CreateReviewBody: type: object properties: rating: type: integer minimum: 1 maximum: 5 title: type: string maxLength: 120 body: type: string maxLength: 2000 required: [rating] WishlistItem: type: object properties: id: type: string productId: type: string createdAt: type: string format: date-time product: $ref: "#/components/schemas/Product" required: [id, productId, createdAt, product] WishlistResponse: type: object properties: items: type: array items: $ref: "#/components/schemas/WishlistItem" required: [items] WishlistItemResponse: type: object properties: item: $ref: "#/components/schemas/WishlistItem" required: [item] AddToWishlistBody: type: object properties: productId: type: string required: [productId] PaystackInitBody: type: object properties: orderId: type: string callbackUrl: type: string required: [orderId] PaystackInitResponse: type: object properties: payment: $ref: "#/components/schemas/Payment" authorizationUrl: type: string nullable: true accessCode: type: string nullable: true reference: type: string testMode: type: boolean required: [payment, reference] HubtelInitBody: type: object properties: orderId: type: string mobileNumber: type: string network: type: string enum: [MTN, Vodafone, AirtelTigo] required: [orderId, mobileNumber, network] HubtelInitResponse: type: object properties: payment: $ref: "#/components/schemas/Payment" reference: type: string testMode: type: boolean required: [payment, reference] PaymentVerifyResponse: type: object properties: status: type: string enum: [pending, success, failed, cancelled] reference: type: string method: type: string nullable: true testMode: type: boolean required: [status, reference] RegisterTokenBody: type: object properties: token: type: string platform: type: string enum: [ios, android, web] required: [token] RegisterTokenResponse: type: object properties: registered: type: boolean id: type: string required: [registered, id] UnregisterTokenBody: type: object properties: token: type: string required: [token] NotificationPreferences: type: object properties: orderUpdates: type: boolean flashSales: type: boolean newArrivals: type: boolean registered: type: boolean required: [orderUpdates, flashSales, newArrivals, registered] UpdatePreferencesBody: type: object properties: orderUpdates: type: boolean flashSales: type: boolean newArrivals: type: boolean BroadcastNotificationBody: type: object properties: title: type: string body: type: string data: type: object additionalProperties: true preferenceKey: type: string enum: [orderUpdates, flashSales, newArrivals] required: [title, body] BroadcastNotificationResponse: type: object properties: sent: type: integer success: type: integer required: [sent, success]