Skip to content

Tổng quan API ​

Tài liệu tham khảo cho 25+ REST API endpoints của Haravan Invoice MVP, bao gồm authentication, request/response format, và examples.

Tóm tắt

Haravan Invoice API xây dựng trên Hono framework, chạy trên Cloudflare Workers. Tất cả endpoints yêu cầu Bearer token authentication (trừ health và login). Base URL: /api/v1.

Base URL ​

Development: http://localhost:8787/api/v1
Production: https://your-worker.workers.dev/api/v1

Authentication ​

Tất cả endpoints (trừ /health và /auth/login) yêu cầu Bearer token:

Authorization: Bearer <jwt_token>

Lấy token từ POST /auth/login.

Response Format ​

Success response ​

json
{
  "success": true,
  "data": { ... }
}

Paginated response ​

json
{
  "success": true,
  "data": {
    "items": [...],
    "total": 100,
    "page": 1,
    "pageSize": 20,
    "totalPages": 5
  }
}

Error response ​

json
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Tên người mua không được để trống"
  }
}

Endpoints Summary ​

ResourceEndpointsTài liệu
AuthPOST /loginAuth
InvoicesPOST, GET, GET/:id, POST/:id/replace, POST/:id/adjust, POST/:id/one-clickInvoices
PDFGET /:id/pdfPDF
AuditGET /:id/auditInvoices
CustomersGET, GET/:id, GET/:id/analyticsCustomers
ProductsGETProducts
ReportsGET /summary, GET /monthlyReports
AnalyticsGET /channels, /top-customers, /top-skusAnalytics
SettingsGET/PATCH /templates, /automation, GET /planSettings
NotificationsGET, PATCH/:id/read, POST /read-all, GET /unread-countNotifications
AggregateGETAggregate
MST LookupGET /lookupMST Lookup
ConfigGET, PATCHHealth & Config
HealthGET /Health & Config

Idempotency ​

Hỗ trợ idempotency key cho POST requests:

X-Idempotency-Key: unique-key-here

Key được cache trong KV với TTL 24 giờ.

Liên kết liên quan ​

Phát hành theo giấy phép MIT.