openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: Telegram Shop Admin API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: dashboard description: Dashboard statistics - name: categories description: Category management - name: products description: Product management - name: stocks description: Stock management - name: orders description: Order management - name: transactions description: Transaction management - name: customers description: Customer management - name: promotions description: Promotion management - name: bot description: Telegram bot configuration - name: bot-logs description: Bot activity logs - name: payments description: Payment configuration - name: i18n description: Internationalization strings management paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # ─── Auth ──────────────────────────────────────────────────────────────────── /auth/login: post: operationId: login tags: [auth] summary: Admin login requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginRequest" responses: "200": description: Login successful content: application/json: schema: $ref: "#/components/schemas/AdminUser" "401": description: Invalid credentials content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/logout: post: operationId: logout tags: [auth] summary: Admin logout responses: "200": description: Logged out content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /auth/me: get: operationId: getMe tags: [auth] summary: Get current admin responses: "200": description: Current admin content: application/json: schema: $ref: "#/components/schemas/AdminUser" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── Dashboard ─────────────────────────────────────────────────────────────── /dashboard/stats: get: operationId: getDashboardStats tags: [dashboard] summary: Get dashboard statistics responses: "200": description: Dashboard stats content: application/json: schema: $ref: "#/components/schemas/DashboardStats" # ─── Categories ────────────────────────────────────────────────────────────── /categories: get: operationId: listCategories tags: [categories] summary: List all categories responses: "200": description: List of categories content: application/json: schema: $ref: "#/components/schemas/CategoryList" post: operationId: createCategory tags: [categories] summary: Create a category requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateCategoryRequest" responses: "201": description: Category created content: application/json: schema: $ref: "#/components/schemas/Category" /categories/{id}: get: operationId: getCategory tags: [categories] summary: Get a category parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Category content: application/json: schema: $ref: "#/components/schemas/Category" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updateCategory tags: [categories] summary: Update a category parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateCategoryRequest" responses: "200": description: Updated category content: application/json: schema: $ref: "#/components/schemas/Category" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: operationId: deleteCategory tags: [categories] summary: Delete a category parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── Products ──────────────────────────────────────────────────────────────── /products: get: operationId: listProducts tags: [products] summary: List products parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 - name: search in: query schema: type: string - name: categoryId in: query schema: type: integer - name: isActive in: query schema: type: boolean - name: orderBy in: query schema: type: string enum: [createdAt, stockRequestCount] responses: "200": description: Product list with pagination content: application/json: schema: $ref: "#/components/schemas/ProductListResponse" post: operationId: createProduct tags: [products] summary: Create a product requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateProductRequest" responses: "201": description: Product created content: application/json: schema: $ref: "#/components/schemas/Product" /products/{id}: get: operationId: getProduct tags: [products] summary: Get a product parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Product content: application/json: schema: $ref: "#/components/schemas/ProductDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updateProduct tags: [products] summary: Update a product parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateProductRequest" responses: "200": description: Updated product content: application/json: schema: $ref: "#/components/schemas/Product" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: operationId: deleteProduct tags: [products] summary: Delete a product parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── Stocks ────────────────────────────────────────────────────────────────── /products/{id}/stocks: get: operationId: listProductStocks tags: [stocks] summary: List stocks for a product parameters: - name: id in: path required: true schema: type: integer - name: status in: query schema: type: string responses: "200": description: Stock list content: application/json: schema: $ref: "#/components/schemas/StockList" post: operationId: addProductStocks tags: [stocks] summary: Add stock lines to a product parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AddStocksRequest" responses: "201": description: Stocks added content: application/json: schema: $ref: "#/components/schemas/AddStocksResponse" /products/{id}/stock-requests: get: operationId: listProductStockRequests tags: [products] summary: List unique customers who requested restock for a product parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Stock requesters content: application/json: schema: $ref: "#/components/schemas/StockRequestListResponse" "404": description: Product not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /products/{id}/notify: post: operationId: notifyProductRestocked tags: [stocks] summary: Broadcast a restock notification to all registered Telegram users parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Broadcast result content: application/json: schema: $ref: "#/components/schemas/NotifyProductResponse" "404": description: Product not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /stocks/{id}: delete: operationId: deleteStock tags: [stocks] summary: Delete a stock line parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── Orders ────────────────────────────────────────────────────────────────── /orders: get: operationId: listOrders tags: [orders] summary: List orders parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 - name: status in: query schema: type: string - name: customerId in: query schema: type: integer - name: hasRetries in: query description: When true, only return orders with retry_count > 0. schema: type: boolean responses: "200": description: Order list content: application/json: schema: $ref: "#/components/schemas/OrderListResponse" /orders/{id}: get: operationId: getOrder tags: [orders] summary: Get order detail parameters: - name: id in: path required: true schema: type: integer 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" /admin/restock-queue: get: operationId: getRestockQueue tags: [orders] summary: List orders waiting for restock (needs_manual_action), oldest first responses: "200": description: Restock queue content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/RestockQueueItem" required: - data /admin/retry-sweep/status: get: operationId: getRetrySweepStatus tags: [orders] summary: Get last retry sweep timestamp responses: "200": description: Last sweep status content: application/json: schema: $ref: "#/components/schemas/RetrySweepStatus" /admin/retry-sweep: post: operationId: triggerRetrySweep tags: [orders] summary: Trigger a stuck-order retry sweep immediately responses: "200": description: Sweep result content: application/json: schema: $ref: "#/components/schemas/RetrySweepResult" "409": description: Sweep already running content: application/json: schema: $ref: "#/components/schemas/RetrySweepResult" # ─── Transactions ───────────────────────────────────────────────────────────── /transactions: get: operationId: listTransactions tags: [transactions] summary: List transactions parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 - name: type in: query schema: type: string - name: status in: query schema: type: string - name: search in: query schema: type: string responses: "200": description: Transaction list content: application/json: schema: $ref: "#/components/schemas/TransactionListResponse" /transactions/{id}: get: operationId: getTransaction tags: [transactions] summary: Get transaction detail parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Transaction detail content: application/json: schema: $ref: "#/components/schemas/Transaction" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── Customers ──────────────────────────────────────────────────────────────── /customers: get: operationId: listCustomers tags: [customers] summary: List customers parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 - name: search in: query schema: type: string responses: "200": description: Customer list content: application/json: schema: $ref: "#/components/schemas/CustomerListResponse" /customers/{id}: get: operationId: getCustomer tags: [customers] summary: Get customer detail parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Customer detail content: application/json: schema: $ref: "#/components/schemas/Customer" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /customers/{id}/orders: get: operationId: getCustomerOrders tags: [customers] summary: Get customer order history parameters: - name: id in: path required: true schema: type: integer - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 responses: "200": description: Customer orders content: application/json: schema: $ref: "#/components/schemas/OrderListResponse" /customers/{id}/transactions: get: operationId: getCustomerTransactions tags: [customers] summary: Get customer transaction history parameters: - name: id in: path required: true schema: type: integer - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 responses: "200": description: Customer transactions content: application/json: schema: $ref: "#/components/schemas/TransactionListResponse" /customers/{id}/disable: post: operationId: disableCustomer tags: [customers] summary: Disable a customer parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Customer disabled content: application/json: schema: $ref: "#/components/schemas/Customer" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /customers/{id}/add-balance: post: operationId: addCustomerBalance tags: [customers] summary: Add balance to customer parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AddBalanceRequest" responses: "200": description: Balance added content: application/json: schema: $ref: "#/components/schemas/Customer" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── Promotions ─────────────────────────────────────────────────────────────── /promotions: get: operationId: listPromotions tags: [promotions] summary: List promotions responses: "200": description: Promotion list content: application/json: schema: $ref: "#/components/schemas/PromotionList" post: operationId: createPromotion tags: [promotions] summary: Create a promotion requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreatePromotionRequest" responses: "201": description: Promotion created content: application/json: schema: $ref: "#/components/schemas/Promotion" /promotions/{id}: get: operationId: getPromotion tags: [promotions] summary: Get a promotion parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Promotion content: application/json: schema: $ref: "#/components/schemas/Promotion" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: operationId: updatePromotion tags: [promotions] summary: Update a promotion parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdatePromotionRequest" responses: "200": description: Updated promotion content: application/json: schema: $ref: "#/components/schemas/Promotion" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: operationId: deletePromotion tags: [promotions] summary: Delete a promotion parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── System Settings ────────────────────────────────────────────────────────── /admin/system-settings: get: operationId: getSystemSettings tags: [system-settings] summary: Get system settings (retry limits, etc.) responses: "200": description: System settings content: application/json: schema: $ref: "#/components/schemas/SystemSettings" put: operationId: updateSystemSettings tags: [system-settings] summary: Update system settings requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateSystemSettingsRequest" responses: "200": description: Updated settings content: application/json: schema: $ref: "#/components/schemas/SystemSettings" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" # ─── Bot Config ─────────────────────────────────────────────────────────────── /bot/config: get: operationId: getBotConfig tags: [bot] summary: Get bot configuration responses: "200": description: Bot config content: application/json: schema: $ref: "#/components/schemas/BotConfig" post: operationId: saveBotConfig tags: [bot] summary: Save bot configuration requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SaveBotConfigRequest" responses: "200": description: Config saved content: application/json: schema: $ref: "#/components/schemas/BotConfig" /bot/test-token: post: operationId: testBotToken tags: [bot] summary: Test bot token with Telegram API requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TestTokenRequest" responses: "200": description: Token test result content: application/json: schema: $ref: "#/components/schemas/TestTokenResponse" /bot/set-webhook: post: operationId: setBotWebhook tags: [bot] summary: Set Telegram webhook responses: "200": description: Webhook set content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /bot/register-commands: post: operationId: registerBotCommands tags: [bot] summary: Re-register bot commands with Telegram responses: "200": description: Commands registered content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /bot/disconnect: post: operationId: disconnectBot tags: [bot] summary: Disconnect and clear bot config responses: "200": description: Bot disconnected content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /bot/webhook: post: operationId: handleBotWebhook tags: [bot] summary: Telegram webhook handler requestBody: required: true content: application/json: schema: type: object responses: "200": description: Webhook received content: application/json: schema: $ref: "#/components/schemas/MessageResponse" # ─── Bot Logs ───────────────────────────────────────────────────────────────── /bot-logs: get: operationId: listBotLogs tags: [bot-logs] summary: List bot logs parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 50 - name: search in: query schema: type: string - name: action in: query schema: type: string - name: level in: query schema: type: string responses: "200": description: Bot log list content: application/json: schema: $ref: "#/components/schemas/BotLogListResponse" # ─── Payment Config ─────────────────────────────────────────────────────────── /payments/config: get: operationId: getPaymentConfig tags: [payments] summary: Get payment configuration (sensitive fields masked) responses: "200": description: Payment config content: application/json: schema: $ref: "#/components/schemas/PaymentConfig" post: operationId: savePaymentConfig tags: [payments] summary: Save payment configuration requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SavePaymentConfigRequest" responses: "200": description: Config saved content: application/json: schema: $ref: "#/components/schemas/PaymentConfig" /payments/sepay/webhook: post: operationId: handleSepayWebhook tags: [payments] summary: SePay payment webhook requestBody: required: true content: application/json: schema: type: object responses: "200": description: Webhook processed content: application/json: schema: $ref: "#/components/schemas/MessageResponse" # ─── i18n ──────────────────────────────────────────────────────────────────── /i18n/strings: get: operationId: listI18nStrings tags: [i18n] summary: List all i18n strings responses: "200": description: All i18n strings content: application/json: schema: $ref: "#/components/schemas/I18nStringListResponse" patch: operationId: bulkUpdateI18nStrings tags: [i18n] summary: Bulk update i18n strings requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BulkUpdateI18nStringsRequest" responses: "200": description: Updated strings content: application/json: schema: $ref: "#/components/schemas/BulkUpdateI18nStringsResponse" /i18n/flush-cache: post: operationId: flushI18nCache tags: [i18n] summary: Flush the in-memory i18n cache so the bot picks up changes immediately responses: "200": description: Cache flushed content: application/json: schema: type: object properties: ok: type: boolean required: - ok /i18n/strings/{key}: patch: operationId: updateI18nString tags: [i18n] summary: Update a single i18n string by key parameters: - name: key in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateI18nStringRequest" responses: "200": description: Updated string content: application/json: schema: $ref: "#/components/schemas/I18nString" "404": description: Key not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" components: schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object properties: error: type: string required: - error MessageResponse: type: object properties: message: type: string required: - message FailedOrderRef: type: object properties: id: type: integer orderCode: type: string required: - id - orderCode RetrySweepResult: type: object properties: alreadyRunning: type: boolean swept: type: integer delivered: type: integer failed: type: integer errored: type: integer exhausted: type: integer failedOrders: type: array items: $ref: "#/components/schemas/FailedOrderRef" erroredOrders: type: array items: $ref: "#/components/schemas/FailedOrderRef" lastSweepAt: type: string format: date-time nullable: true required: - alreadyRunning - swept - delivered - failed - errored - exhausted - failedOrders - erroredOrders - lastSweepAt RestockQueueItem: type: object properties: id: type: integer orderCode: type: string status: type: string totalAmount: type: string retryCount: type: integer createdAt: type: string format: date-time customer: nullable: true type: object properties: id: type: integer firstName: type: string nullable: true lastName: type: string nullable: true username: type: string nullable: true chatId: type: string required: [id, chatId] items: type: array items: type: object properties: id: type: integer productId: type: integer quantity: type: integer productName: type: string nullable: true required: [id, productId, quantity] required: - id - orderCode - status - totalAmount - retryCount - createdAt - customer - items RetrySweepStatus: type: object properties: lastSweepAt: type: string format: date-time nullable: true required: - lastSweepAt LoginRequest: type: object properties: username: type: string password: type: string required: - username - password AdminUser: type: object properties: id: type: integer username: type: string displayName: type: string nullable: true createdAt: type: string format: date-time required: - id - username - createdAt DashboardStats: type: object properties: totalProducts: type: integer totalOrders: type: integer totalCustomers: type: integer totalRevenue: type: string recentOrders: type: array items: $ref: "#/components/schemas/OrderSummary" newCustomers: type: array items: $ref: "#/components/schemas/Customer" required: - totalProducts - totalOrders - totalCustomers - totalRevenue - recentOrders - newCustomers Category: type: object properties: id: type: integer name: type: string icon: type: string nullable: true isActive: type: boolean createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - name - isActive - createdAt - updatedAt CategoryList: type: object properties: data: type: array items: $ref: "#/components/schemas/Category" required: - data CreateCategoryRequest: type: object properties: name: type: string icon: type: string isActive: type: boolean required: - name UpdateCategoryRequest: type: object properties: name: type: string icon: type: string isActive: type: boolean Product: type: object properties: id: type: integer name: type: string description: type: string nullable: true categoryId: type: integer nullable: true categoryIcon: type: string nullable: true productIcon: type: string nullable: true price: type: string originalPrice: type: string nullable: true productType: type: string minQuantity: type: integer maxQuantity: type: integer isActive: type: boolean stockCount: type: integer stockRequestCount: type: integer createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - name - price - productType - minQuantity - maxQuantity - isActive - stockCount - stockRequestCount - createdAt - updatedAt ProductDetail: type: object properties: id: type: integer name: type: string description: type: string nullable: true categoryId: type: integer nullable: true categoryIcon: type: string nullable: true productIcon: type: string nullable: true price: type: string originalPrice: type: string nullable: true productType: type: string minQuantity: type: integer maxQuantity: type: integer isActive: type: boolean stockCount: type: integer stockRequestCount: type: integer category: $ref: "#/components/schemas/Category" nullable: true createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - name - price - productType - minQuantity - maxQuantity - isActive - stockCount - stockRequestCount - createdAt - updatedAt ProductListResponse: type: object properties: data: type: array items: $ref: "#/components/schemas/Product" total: type: integer page: type: integer limit: type: integer required: - data - total - page - limit CreateProductRequest: type: object properties: name: type: string description: type: string categoryId: type: integer categoryIcon: type: string productIcon: type: string price: type: string originalPrice: type: string productType: type: string minQuantity: type: integer maxQuantity: type: integer isActive: type: boolean required: - name - price UpdateProductRequest: type: object properties: name: type: string description: type: string categoryId: type: integer categoryIcon: type: string productIcon: type: string price: type: string originalPrice: type: string productType: type: string minQuantity: type: integer maxQuantity: type: integer isActive: type: boolean Stock: type: object properties: id: type: integer productId: type: integer content: type: string status: type: string orderId: type: integer nullable: true createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - productId - content - status - createdAt - updatedAt StockList: type: object properties: data: type: array items: $ref: "#/components/schemas/Stock" availableCount: type: integer totalCount: type: integer required: - data - availableCount - totalCount AddStocksRequest: type: object properties: lines: type: array items: type: string required: - lines AddStocksResponse: type: object properties: added: type: integer message: type: string required: - added - message NotifyProductResponse: type: object properties: sent: type: integer description: Number of users successfully notified total: type: integer description: Total number of users attempted message: type: string required: - sent - total - message StockRequester: type: object properties: customerId: type: integer nullable: true firstName: type: string nullable: true lastName: type: string nullable: true username: type: string nullable: true chatId: type: string nullable: true requestedAt: type: string format: date-time required: - requestedAt StockRequestListResponse: type: object properties: data: type: array items: $ref: "#/components/schemas/StockRequester" total: type: integer required: - data - total Order: type: object properties: id: type: integer orderCode: type: string customerId: type: integer totalAmount: type: string promotionId: type: integer nullable: true discountAmount: type: string nullable: true description: Discount applied to this order in VND (string representation of numeric). promotionCode: type: string nullable: true description: Promo code that was applied to this order, if any. status: type: string retryCount: type: integer nullable: true retryExhaustedAt: type: string format: date-time nullable: true paymentReference: type: string nullable: true paidAt: type: string format: date-time nullable: true deliveredAt: type: string format: date-time nullable: true notes: type: string nullable: true createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - orderCode - customerId - totalAmount - status - createdAt - updatedAt OrderSummary: type: object properties: id: type: integer orderCode: type: string totalAmount: type: string status: type: string customerName: type: string nullable: true createdAt: type: string format: date-time required: - id - orderCode - totalAmount - status - createdAt OrderItem: type: object properties: id: type: integer orderId: type: integer productId: type: integer productName: type: string quantity: type: integer unitPrice: type: string totalPrice: type: string createdAt: type: string format: date-time required: - id - orderId - productId - productName - quantity - unitPrice - totalPrice - createdAt OrderDetail: type: object properties: id: type: integer orderCode: type: string customerId: type: integer totalAmount: type: string promotionId: type: integer nullable: true discountAmount: type: string nullable: true description: Discount applied to this order in VND. promotion: nullable: true type: object description: The promotion that was applied, if any. properties: id: type: integer code: type: string nullable: true name: type: string required: - id - name status: type: string paymentReference: type: string nullable: true paidAt: type: string format: date-time nullable: true deliveredAt: type: string format: date-time nullable: true notes: type: string nullable: true customer: $ref: "#/components/schemas/Customer" nullable: true items: type: array items: $ref: "#/components/schemas/OrderItem" transaction: $ref: "#/components/schemas/Transaction" nullable: true retryCount: type: integer description: Number of retry attempts made for this order (excludes the initial delivery attempt) retryLogs: type: array items: $ref: "#/components/schemas/RetryLog" description: Chronological log of delivery attempts and retry events for this order createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - orderCode - customerId - totalAmount - status - items - retryCount - retryLogs - createdAt - updatedAt RetryLog: type: object properties: id: type: integer action: type: string customerId: type: integer nullable: true chatId: type: string nullable: true content: type: string nullable: true metadata: nullable: true level: type: string createdAt: type: string format: date-time required: - id - action - level - createdAt OrderListResponse: type: object properties: data: type: array items: $ref: "#/components/schemas/Order" total: type: integer page: type: integer limit: type: integer required: - data - total - page - limit Transaction: type: object properties: id: type: integer transactionCode: type: string paymentReference: type: string nullable: true type: type: string orderId: type: integer nullable: true customerId: type: integer nullable: true amount: type: string status: type: string provider: type: string nullable: true rawPayload: type: string nullable: true notes: type: string nullable: true confirmedAt: type: string format: date-time nullable: true createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - transactionCode - type - amount - status - createdAt - updatedAt TransactionListResponse: type: object properties: data: type: array items: $ref: "#/components/schemas/Transaction" total: type: integer page: type: integer limit: type: integer required: - data - total - page - limit Customer: type: object properties: id: type: integer chatId: type: string firstName: type: string nullable: true lastName: type: string nullable: true username: type: string nullable: true balance: type: string totalSpent: type: string totalOrders: type: integer lastActiveAt: type: string format: date-time nullable: true isActive: type: boolean createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - chatId - balance - totalSpent - totalOrders - isActive - createdAt - updatedAt CustomerListResponse: type: object properties: data: type: array items: $ref: "#/components/schemas/Customer" total: type: integer page: type: integer limit: type: integer required: - data - total - page - limit AddBalanceRequest: type: object properties: amount: type: string note: type: string required: - amount Promotion: type: object properties: id: type: integer name: type: string description: type: string nullable: true code: type: string nullable: true type: type: string discountValue: type: string nullable: true usageLimit: type: integer nullable: true useCount: type: integer appliesTo: type: string categoryId: type: integer nullable: true productId: type: integer nullable: true customerTarget: type: string customerId: type: integer nullable: true tiers: nullable: true startDate: type: string format: date-time nullable: true endDate: type: string format: date-time nullable: true priority: type: integer isActive: type: boolean createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - name - type - appliesTo - customerTarget - useCount - priority - isActive - createdAt - updatedAt PromotionList: type: object properties: data: type: array items: $ref: "#/components/schemas/Promotion" required: - data CreatePromotionRequest: type: object properties: name: type: string description: type: string code: type: string type: type: string discountValue: type: string usageLimit: type: integer appliesTo: type: string categoryId: type: integer productId: type: integer customerTarget: type: string customerId: type: integer tiers: type: object startDate: type: string format: date-time endDate: type: string format: date-time priority: type: integer isActive: type: boolean required: - name - type UpdatePromotionRequest: type: object properties: name: type: string description: type: string code: type: string type: type: string discountValue: type: string usageLimit: type: integer appliesTo: type: string categoryId: type: integer productId: type: integer customerTarget: type: string customerId: type: integer tiers: type: object startDate: type: string format: date-time endDate: type: string format: date-time priority: type: integer isActive: type: boolean BotConfig: type: object properties: id: type: integer nullable: true botToken: type: string nullable: true botUsername: type: string nullable: true webhookUrl: type: string nullable: true isConnected: type: boolean webhookStatus: type: string nullable: true adminChatId: type: string nullable: true warrantyText: type: string nullable: true supportText: type: string nullable: true infoText: type: string nullable: true shopName: type: string nullable: true welcomeMessage: type: string nullable: true updatedAt: type: string format: date-time nullable: true required: - isConnected SaveBotConfigRequest: type: object properties: botToken: type: string adminChatId: type: string nullable: true warrantyText: type: string nullable: true supportText: type: string nullable: true infoText: type: string nullable: true shopName: type: string nullable: true welcomeMessage: type: string nullable: true required: - botToken TestTokenRequest: type: object properties: token: type: string required: - token TestTokenResponse: type: object properties: valid: type: boolean username: type: string nullable: true firstName: type: string nullable: true error: type: string nullable: true required: - valid BotLog: type: object properties: id: type: integer action: type: string customerId: type: integer nullable: true chatId: type: string nullable: true content: type: string nullable: true metadata: nullable: true level: type: string createdAt: type: string format: date-time required: - id - action - level - createdAt BotLogListResponse: type: object properties: data: type: array items: $ref: "#/components/schemas/BotLog" total: type: integer page: type: integer limit: type: integer required: - data - total - page - limit PaymentConfig: type: object properties: id: type: integer nullable: true provider: type: string bankName: type: string nullable: true bankCode: type: string nullable: true accountNumber: type: string nullable: true accountHolder: type: string nullable: true webhookSecret: type: string nullable: true apiKey: type: string nullable: true webhookUrl: type: string nullable: true description: Public URL admins should configure in SePay's webhook settings. Computed from REPLIT_DOMAINS at request time. isActive: type: boolean updatedAt: type: string format: date-time nullable: true required: - provider - isActive SavePaymentConfigRequest: type: object properties: bankName: type: string bankCode: type: string accountNumber: type: string accountHolder: type: string webhookSecret: type: string apiKey: type: string isActive: type: boolean SystemSettings: type: object properties: maxRetryCount: type: integer maxOrderAgeDays: type: integer updatedAt: type: string format: date-time nullable: true required: - maxRetryCount - maxOrderAgeDays UpdateSystemSettingsRequest: type: object properties: maxRetryCount: type: integer minimum: 1 maximum: 1000 maxOrderAgeDays: type: integer minimum: 1 maximum: 365 required: - maxRetryCount - maxOrderAgeDays I18nString: type: object properties: id: type: integer key: type: string vi: type: string en: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - key - vi - en - createdAt - updatedAt I18nStringListResponse: type: object properties: data: type: array items: $ref: "#/components/schemas/I18nString" required: - data UpdateI18nStringRequest: type: object properties: vi: type: string en: type: string BulkUpdateI18nStringsRequest: type: object properties: updates: type: array items: type: object properties: key: type: string vi: type: string en: type: string required: - key required: - updates BulkUpdateI18nStringsResponse: type: object properties: updated: type: integer data: type: array items: $ref: "#/components/schemas/I18nString" required: - updated - data