-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.yaml
More file actions
6122 lines (5747 loc) · 252 KB
/
Copy pathopenapi.yaml
File metadata and controls
6122 lines (5747 loc) · 252 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: "3.1.0"
info:
title: FoodFlow API
description: |
FoodFlow -- Food Delivery Platform REST API.
**Base path:** `/api`. The production origin is the verified Railway API domain.
**Conventions:**
- All monetary values are in **VND**, represented as integers.
- All datetime values use ISO 8601 `date-time` with timezone.
- Successful web/admin/restaurant endpoints return `{ success: true, data, meta? }`.
- List endpoints put the collection in `data` and pagination in `meta`.
- Errors use the shared `ProblemDetail` schema (RFC 7807) and are not success-wrapped.
- Idempotency is supported via `Idempotency-Key` header (UUID v4).
- Inbound HMAC: SePay webhooks are verified with `x-sepay-signature`.
- Outbound HMAC: generic outbound webhooks use `X-Signature-SHA256` when configured.
**Versioning:** Batch 4 currently uses the `/api` base without a `/v1` prefix. A future version prefix requires an updated server contract and migration policy.
version: "1.0.0"
contact:
name: FoodFlow Team
email: support@foodflow.vn
servers:
- url: https://replace-with-foodflow-api.up.railway.app/api
description: Production placeholder; replace with the verified Railway public domain before publishing external client configuration
- url: http://localhost:3001/api
description: Local development
tags:
- name: auth
description: Authentication (register, login, refresh, logout, forgot/reset password, verify email, OTP)
- name: users
description: User profiles, address book, wallet
- name: restaurants
description: Restaurant discovery (nearby, search, detail, menu, reviews)
- name: restaurant-profile
description: Restaurant owner profile, opening hours, and special closure dates
- name: menu
description: Menu management (categories, items, options, availability) -- restaurant owner only
- name: restaurant-staff
description: Restaurant tenant staff invitations, permissions, and shift schedules
- name: restaurant-reviews
description: Restaurant tenant review inbox and merchant replies
- name: orders
description: Order lifecycle (place, status transitions, cancel, refund, assign driver, tracking)
- name: drivers
description: Driver operations (online/offline, location, earnings, trip history, withdrawals)
- name: payments
description: Wallet topup, payment methods, SePay webhook, refund, withdrawal
- name: promotions
description: Promotion CRUD, validation, overlap check, scheduler, audience targeting (admin)
- name: notifications
description: Push notifications (FCM), email templates (vi/en/ja), SMS
- name: support
description: Support tickets, replies, SLA, macros, bulk actions, CSAT (admin)
- name: audit
description: Audit log (search tsvector, export, retention) -- admin only
- name: settings
description: Platform settings and degraded integration state -- admin only
- name: ai
description: FoodFlow AI chatbot and service integration
- name: analytics
description: KPI aggregations, business dashboards, heat maps -- admin only
- name: realtime
description: Short-lived Supabase Realtime authorization for authenticated private channels
- name: jobs
description: Secured PostgreSQL outbox drain used for Railway recovery and approved worker invocations
- name: health
description: Public platform liveness and strict dependency readiness probes
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: JWT bearer access token. Obtain via `POST /auth/login`; the signing algorithm follows the active JWT cutover phase.
cronBearer:
type: http
scheme: bearer
bearerFormat: opaque
description: Exact server-side CRON_SECRET value. Never expose this credential to browser or mobile clients.
parameters:
PageParam:
name: page
in: query
schema: { type: integer, minimum: 1, default: 1 }
description: Page number (1-indexed)
LimitParam:
name: limit
in: query
schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
description: Items per page
IdempotencyKeyHeader:
name: Idempotency-Key
in: header
required: false
schema: { type: string, format: uuid }
description: UUID v4 for idempotent request deduplication
schemas:
# ── Shared ──
SuccessEnvelope:
type: object
properties:
success: { type: boolean, const: true }
data: { description: "Endpoint-specific payload" }
meta: { description: "Optional pagination or aggregation metadata" }
required: [success, data]
ProblemDetail:
type: object
properties:
type: { type: string, description: "URI to problem type documentation" }
title: { type: string, description: "Short human-readable summary" }
status: { type: integer, description: "HTTP status code" }
detail: { type: string, description: "Human-readable explanation" }
instance: { type: string, description: "URI to the specific occurrence" }
code: { type: string, description: "Application-specific error code (e.g. AUTH_INVALID_CREDENTIALS)" }
required: [type, title, status, detail]
example:
type: "about:blank"
title: "Validation Error"
status: 422
detail: "Email is not valid"
code: "VALIDATION_INVALID_EMAIL"
HealthComponentStatus:
type: object
additionalProperties: false
properties:
status: { type: string, enum: [up, down] }
latencyMs: { type: integer, minimum: 0 }
required: [status, latencyMs]
StorageHealthComponentStatus:
type: object
additionalProperties: false
properties:
provider: { type: string, enum: [minio, supabase] }
status: { type: string, enum: [up, down] }
latencyMs: { type: integer, minimum: 0 }
required: [provider, status, latencyMs]
HealthComponents:
type: object
additionalProperties: false
properties:
db: { $ref: '#/components/schemas/HealthComponentStatus' }
redis: { $ref: '#/components/schemas/HealthComponentStatus' }
storage: { $ref: '#/components/schemas/StorageHealthComponentStatus' }
required: [db, redis, storage]
HealthResponse:
type: object
additionalProperties: false
properties:
status: { type: string, enum: [ok, degraded] }
uptime: { type: number, minimum: 0 }
timestamp: { type: string, format: date-time }
components: { $ref: '#/components/schemas/HealthComponents' }
required: [status, uptime, timestamp, components]
ReadinessResponse:
type: object
additionalProperties: false
properties:
status: { type: string, enum: [ready, not_ready] }
ready: { type: boolean }
timestamp: { type: string, format: date-time }
components: { $ref: '#/components/schemas/HealthComponents' }
required: [status, ready, timestamp, components]
PaginationMeta:
type: object
properties:
total: { type: integer, description: "Total items across all pages" }
page: { type: integer, description: "Current page number" }
limit: { type: integer, description: "Items per page" }
hasMore: { type: boolean, description: "Whether more pages exist" }
required: [total, page, limit, hasMore]
RealtimeTokenRequest:
type: object
additionalProperties: false
properties:
orderId:
type: string
format: uuid
description: Optional order scope; the actor must be an authorized participant or admin.
restaurantId:
type: string
format: uuid
description: Optional restaurant scope; the actor must have an active profile for this tenant.
RealtimeTokenData:
type: object
additionalProperties: false
properties:
provider:
type: string
const: supabase
token:
type: string
minLength: 1
description: Five-minute Supabase-compatible JWT carrying explicit realtime_channels claims.
expiresAt:
type: string
format: date-time
channels:
type: array
minItems: 1
uniqueItems: true
items:
type: string
pattern: '^private:'
required: [provider, token, expiresAt, channels]
RealtimeTokenEnvelope:
type: object
additionalProperties: false
properties:
success:
type: boolean
const: true
data:
$ref: '#/components/schemas/RealtimeTokenData'
required: [success, data]
JobDrainStats:
type: object
additionalProperties: false
properties:
claimed: { type: integer, minimum: 0 }
completed: { type: integer, minimum: 0 }
failed: { type: integer, minimum: 0 }
retried: { type: integer, minimum: 0 }
required: [claimed, completed, failed, retried]
JobDrainEnvelope:
type: object
additionalProperties: false
properties:
success:
type: boolean
const: true
data:
$ref: '#/components/schemas/JobDrainStats'
required: [success, data]
# ── Auth ──
RegisterRequest:
type: object
properties:
email: { type: string, format: email }
password: { type: string, minLength: 8, maxLength: 72, description: "Must include uppercase, lowercase, digit" }
fullName: { type: string, minLength: 2, maxLength: 100 }
phone: { type: string, pattern: '^\+?[1-9]\d{6,14}$', description: "e.g. +84123456789" }
required: [email, password, fullName]
additionalProperties: false
example:
email: "nguyenvana@example.com"
password: "REPLACE_WITH_STRONG_PASSWORD"
fullName: "Nguyễn Văn A"
phone: "+84987654321"
LoginRequest:
type: object
properties:
email: { type: string, format: email }
password: { type: string }
required: [email, password]
example:
email: "customer1@foodflow.vn"
password: "REPLACE_WITH_TEST_PASSWORD"
RefreshRequest:
type: object
properties:
refreshToken: { type: string }
required: [refreshToken]
example:
refreshToken: "REPLACE_WITH_OPAQUE_REFRESH_TOKEN"
LogoutRequest:
type: object
properties:
refreshToken: { type: string }
example:
refreshToken: "REPLACE_WITH_OPAQUE_REFRESH_TOKEN"
ForgotPasswordRequest:
type: object
properties:
email: { type: string, format: email }
required: [email]
example:
email: "nguyenvana@example.com"
ResetPasswordRequest:
type: object
properties:
token: { type: string, description: "Reset token from email" }
password: { type: string, minLength: 8, maxLength: 72 }
required: [token, password]
example:
token: "REPLACE_WITH_RESET_TOKEN"
password: "REPLACE_WITH_NEW_STRONG_PASSWORD"
AuthResult:
type: object
properties:
accessToken: { type: string, description: "JWT access token (15 min TTL; algorithm follows the active backend cutover phase)" }
refreshToken: { type: string, description: "Rotating refresh JWT (7 day TTL; invalidated through the server-side blocklist)" }
expiresAt: { type: string, format: date-time }
user:
$ref: "#/components/schemas/UserProfile"
required: [accessToken, refreshToken, expiresAt, user]
# ── Users ──
UserProfile:
type: object
properties:
id: { type: string, format: uuid }
email: { type: string, format: email }
fullName: { type: string }
phone: { type: string }
role: { type: string, enum: [customer, driver, restaurant, admin] }
avatarUrl: { type: string }
isActive: { type: boolean }
createdAt: { type: string, format: date-time }
updatedAt: { type: string, format: date-time }
required: [id, email, fullName, role, isActive, createdAt, updatedAt]
example:
id: "550e8400-e29b-41d4-a716-446655440000"
email: "nguyenvana@example.com"
fullName: "Nguyễn Văn A"
phone: "+84987654321"
role: "customer"
avatarUrl: "https://cdn.foodflow.vn/avatars/default.png"
isActive: true
createdAt: "2026-01-15T08:30:00Z"
updatedAt: "2026-07-11T08:30:00Z"
UpdateUserRequest:
type: object
properties:
fullName: { type: string, minLength: 1, maxLength: 100 }
phone: { type: string }
avatarUrl: { type: string, format: uri }
example:
fullName: "Nguyễn Văn A (đã sửa)"
phone: "+84988888888"
AvatarUploadResponse:
type: object
properties:
url: { type: string }
required: [url]
example:
url: "https://cdn.foodflow.vn/avatars/550e8400-e29b-41d4-a716-446655440000.jpg"
Address:
type: object
properties:
id: { type: string, format: uuid }
label: { type: string, description: "e.g. Nhà riêng, Công ty" }
addressLine: { type: string }
latitude: { type: number, minimum: 3.8, maximum: 23.5 }
longitude: { type: number, minimum: 102.0, maximum: 117.5 }
isDefault: { type: boolean }
createdAt: { type: string, format: date-time }
required: [id, label, addressLine, latitude, longitude, isDefault, createdAt]
example:
id: "11111111-1111-4111-8111-111111111111"
label: "Nhà riêng"
addressLine: "123 Nguyễn Huệ, Quận 1, TP. Hồ Chí Minh"
latitude: 10.7769
longitude: 106.7009
isDefault: true
createdAt: "2026-07-06T00:00:00Z"
CreateAddressRequest:
type: object
properties:
label: { type: string }
addressLine: { type: string }
latitude: { type: number, minimum: 3.8, maximum: 23.5 }
longitude: { type: number, minimum: 102.0, maximum: 117.5 }
isDefault: { type: boolean, default: false }
required: [label, addressLine, latitude, longitude]
example:
label: "Công ty"
addressLine: "456 Lê Lợi, Quận 1, TP. Hồ Chí Minh"
latitude: 10.7730
longitude: 106.6984
isDefault: false
UpdateAddressRequest:
type: object
properties:
label: { type: string }
addressLine: { type: string }
latitude: { type: number, minimum: 3.8, maximum: 23.5 }
longitude: { type: number, minimum: 102.0, maximum: 117.5 }
isDefault: { type: boolean }
example:
label: "Nhà mới"
addressLine: "789 Võ Văn Kiệt, Quận 1, TP. Hồ Chí Minh"
WalletSnapshot:
type: object
properties:
balance: { type: integer, description: "Available balance in VND" }
transactions:
type: array
items: { $ref: "#/components/schemas/WalletTransaction" }
required: [balance, transactions]
example:
balance: 350000
transactions:
- id: "22222222-2222-4222-8222-222222222222"
amountDelta: 200000
type: credit
reason: order_refund
refId: "11111111-1111-4111-8111-111111111111"
createdAt: "2026-06-09T10:30:00Z"
WalletTransaction:
type: object
properties:
id: { type: string, format: uuid }
amountDelta: { type: integer, description: "Signed wallet ledger delta in VND" }
type: { type: string, enum: [credit, debit] }
reason: { type: string, description: "Ledger reason such as order_refund, referral_bonus, or order_payment" }
refId: { type: string, format: uuid, nullable: true }
createdAt: { type: string, format: date-time }
required: [id, amountDelta, type, reason, createdAt]
example:
id: "22222222-2222-4222-8222-222222222222"
amountDelta: 200000
type: credit
reason: order_refund
refId: "11111111-1111-4111-8111-111111111111"
createdAt: "2026-06-09T10:30:00Z"
# ── Restaurants ──
RestaurantSummary:
type: object
properties:
id: { type: string, format: uuid }
name: { type: string }
slug: { type: string }
logoUrl: { type: string }
coverUrl: { type: string }
cuisineTypes: { type: array, items: { type: string } }
priceRange: { type: string, enum: ["$", "$$", "$$$"] }
rating: { type: number }
totalReviews: { type: integer }
distanceKm: { type: number, description: "Distance from query point (nearby only)" }
isOpen: { type: boolean }
prepTimeAvg: { type: integer, description: "Average preparation time in minutes" }
minOrderAmount: { type: integer, description: "Minimum order amount in VND" }
required: [id, name, slug, cuisineTypes, priceRange, rating, totalReviews, isOpen]
example:
id: "33333333-3333-4333-8333-333333333333"
name: "Phở 24"
slug: "pho-24"
logoUrl: "https://cdn.foodflow.vn/restaurants/pho24-logo.png"
coverUrl: "https://cdn.foodflow.vn/restaurants/pho24-cover.png"
cuisineTypes: ["Phở", "Món Việt"]
priceRange: "$$"
rating: 4.5
totalReviews: 128
distanceKm: 1.2
isOpen: true
prepTimeAvg: 15
minOrderAmount: 50000
RestaurantOpeningHour:
type: object
properties:
dayOfWeek: { type: integer, minimum: 0, maximum: 6, description: "0=Sunday, 6=Saturday" }
openTime: { type: string, pattern: "^\\d{2}:\\d{2}$", description: "HH:mm" }
closeTime: { type: string, pattern: "^\\d{2}:\\d{2}$", description: "HH:mm" }
isClosed: { type: boolean }
required: [dayOfWeek, openTime, closeTime, isClosed]
RestaurantHolidayClosure:
type: object
properties:
id: { type: string, format: uuid, readOnly: true }
date: { type: string, format: date, description: "Full-day closure date in YYYY-MM-DD format" }
reason: { type: string, nullable: true, maxLength: 200 }
required: [date]
RestaurantDetail:
allOf:
- $ref: "#/components/schemas/RestaurantSummary"
- type: object
properties:
description: { type: string }
addressLine: { type: string }
city: { type: string }
district: { type: string }
phone: { type: string }
openingHours:
type: array
items: { $ref: "#/components/schemas/RestaurantOpeningHour" }
RestaurantProfile:
allOf:
- $ref: "#/components/schemas/RestaurantDetail"
- type: object
properties:
holidayClosures:
type: array
items: { $ref: "#/components/schemas/RestaurantHolidayClosure" }
membership:
type: object
properties:
id: { type: string, format: uuid }
role: { type: string }
permissions: { type: array, items: { type: string } }
onboardingCompletedAt: { type: string, format: date-time, nullable: true }
required: [id, role, permissions]
UpdateRestaurantProfileRequest:
type: object
properties:
name: { type: string, maxLength: 200 }
description: { type: string, maxLength: 2000 }
phone: { type: string, maxLength: 20 }
addressLine: { type: string, maxLength: 300 }
cuisineTypes: { type: array, items: { type: string } }
logoUrl: { type: string, maxLength: 500 }
coverUrl: { type: string, maxLength: 500 }
minOrderAmount: { type: number, minimum: 0 }
isOpen: { type: boolean }
openingHours:
type: array
items: { $ref: "#/components/schemas/RestaurantOpeningHour" }
holidayClosures:
type: array
description: Replaces the authenticated restaurant's full special closure list when provided.
items: { $ref: "#/components/schemas/RestaurantHolidayClosure" }
ImageUploadResult:
type: object
properties:
url: { type: string, format: uri }
required: [url]
MenuCategory:
type: object
properties:
id: { type: string, format: uuid }
name: { type: string }
sortOrder: { type: integer }
items:
type: array
items: { $ref: "#/components/schemas/MenuItem" }
required: [id, name, sortOrder, items]
MenuItem:
type: object
properties:
id: { type: string, format: uuid }
restaurantId: { type: string, format: uuid }
name: { type: string }
description: { type: string }
imageUrl: { type: string }
basePrice: { type: integer, description: "VND" }
isAvailable: { type: boolean }
isPopular: { type: boolean }
options:
type: array
items: { $ref: "#/components/schemas/MenuItemOption" }
required: [id, restaurantId, name, description, imageUrl, basePrice, isAvailable, isPopular, options]
example:
id: "44444444-4444-4444-8444-444444444444"
restaurantId: "33333333-3333-4333-8333-333333333333"
name: "Phở bò tái chín"
description: "Phở bò với thịt tái và chín, kèm rau thơm"
imageUrl: "https://cdn.foodflow.vn/menu/pho-bo-tai-chin.jpg"
basePrice: 65000
isAvailable: true
isPopular: true
options: []
MenuItemOption:
type: object
properties:
id: { type: string, format: uuid }
name: { type: string }
isRequired: { type: boolean }
isMultiple: { type: boolean }
values:
type: array
items:
type: object
properties:
value: { type: string }
priceModifier: { type: integer, description: "Additional VND" }
required: [value, priceModifier]
required: [id, name, isRequired, isMultiple, values]
example:
id: "55555555-5555-4555-8555-555555555555"
name: "Size"
isRequired: true
isMultiple: false
values:
- { value: "Nhỏ", priceModifier: 0 }
- { value: "Vừa", priceModifier: 15000 }
- { value: "Lớn", priceModifier: 25000 }
Review:
type: object
properties:
id: { type: string, format: uuid }
foodRating: { type: integer, minimum: 1, maximum: 5 }
deliveryRating: { type: integer, minimum: 1, maximum: 5 }
comment: { type: string }
customerName: { type: string }
createdAt: { type: string, format: date-time }
required: [id, foodRating, deliveryRating, customerName, createdAt]
example:
id: "ffffffff-ffff-4fff-8fff-ffffffffffff"
foodRating: 5
deliveryRating: 4
comment: "Phở ngon, nước dùng đậm đà"
customerName: "Nguyễn Văn A"
createdAt: "2026-06-08T12:00:00Z"
# ── Orders ──
PlaceOrderRequest:
type: object
properties:
addressId: { type: string, format: uuid }
paymentMethod: { type: string, enum: [cash, wallet, sepay], default: cash, description: "Public payment method. Wallet payments debit the confirmed wallet ledger; no mock wallet request value is accepted." }
promotionCode: { type: string }
notes: { type: string, maxLength: 500 }
required: [addressId]
example:
addressId: "11111111-1111-4111-8111-111111111111"
paymentMethod: "wallet"
promotionCode: "WELCOME2026"
notes: "Không hành, thêm ớt"
DeliveryPricingResponse:
type: object
description: Configured checkout delivery pricing returned by the backend so clients do not invent local delivery-fee business rules.
properties:
baseDeliveryFeeVnd: { type: integer, minimum: 0, description: "Configured base delivery fee in VND" }
required: [baseDeliveryFeeVnd]
example:
baseDeliveryFeeVnd: 15000
OrderDetail:
type: object
properties:
id: { type: string, format: uuid }
status: { type: string, enum: [created, pending_payment, paid, restaurant_pending, restaurant_accepted, preparing, ready_for_pickup, driver_assigned, driver_arriving_restaurant, picked_up, delivering, delivered, completed, cancelled, refunded] }
subtotal: { type: integer, description: "VND" }
deliveryFee: { type: integer, description: "VND" }
discount: { type: integer, description: "VND" }
total: { type: integer, description: "VND" }
paymentMethod: { type: string, enum: [cash, wallet, sepay] }
notes: { type: string }
items:
type: array
items:
type: object
properties:
id: { type: string, format: uuid }
menuItemId: { type: string, format: uuid }
name: { type: string }
nameSnapshot: { type: string }
quantity: { type: integer }
unitPrice: { type: integer, description: "VND" }
price: { type: integer, description: "Alias of unitPrice for legacy clients" }
options: { type: array, items: { type: string }, description: "Selected option values" }
selectedOptions: { type: array, items: { type: object, additionalProperties: true }, description: "Persisted selected option JSON" }
totalPrice: { type: integer, description: "VND" }
lineTotal: { type: integer, description: "VND" }
required: [menuItemId, name, quantity, unitPrice, lineTotal]
restaurant:
type: object
properties:
id: { type: string, format: uuid }
name: { type: string }
deliveryAddress:
$ref: "#/components/schemas/Address"
driver:
type: object
properties:
id: { type: string, format: uuid }
fullName: { type: string }
phone: { type: string }
rating: { type: number }
lat: { type: number }
lng: { type: number }
timeline:
type: array
items:
type: object
properties:
status: { type: string }
timestamp: { type: string, format: date-time }
note: { type: string }
createdAt: { type: string, format: date-time }
estimatedDelivery: { type: string, format: date-time }
required: [id, status, subtotal, deliveryFee, total, paymentMethod, items, restaurant, createdAt]
example:
id: "66666666-6666-4666-8666-666666666666"
status: "preparing"
subtotal: 130000
deliveryFee: 15000
discount: 20000
total: 125000
paymentMethod: "wallet"
notes: "Không hành, thêm ớt"
items:
- { menuItemId: "44444444-4444-4444-8444-444444444444", name: "Phở bò tái chín", nameSnapshot: "Phở bò tái chín", quantity: 2, unitPrice: 65000, price: 65000, selectedOptions: [{ groupName: "Size", optionName: "Lớn", price: 15000 }], lineTotal: 130000, totalPrice: 130000 }
restaurant: { id: "33333333-3333-4333-8333-333333333333", name: "Phở 24" }
deliveryAddress:
id: "11111111-1111-4111-8111-111111111111"
addressLine: "123 Nguyen Hue, Quan 1, TP. Ho Chi Minh"
label: "Nhà riêng"
street: "123 Nguyễn Huệ"
ward: "Phường Bến Nghé"
district: "Quận 1"
city: "TP. Hồ Chí Minh"
latitude: 10.7769
longitude: 106.7009
lat: 10.7769
lng: 106.7009
isDefault: true
createdAt: "2026-07-06T00:00:00Z"
createdAt: "2026-06-09T11:00:00Z"
estimatedDelivery: "2026-06-09T11:35:00Z"
timeline:
- { status: "created", timestamp: "2026-06-09T11:00:00Z" }
- { status: "paid", timestamp: "2026-06-09T11:00:05Z" }
- { status: "restaurant_accepted", timestamp: "2026-06-09T11:02:00Z" }
- { status: "preparing", timestamp: "2026-06-09T11:05:00Z" }
OrderTrackingDriverLocation:
type: object
description: Last real GPS position recorded for the driver currently assigned to the order.
properties:
lat: { type: number, minimum: -90, maximum: 90 }
lng: { type: number, minimum: -180, maximum: 180 }
lastUpdated: { type: string, format: date-time }
required: [lat, lng, lastUpdated]
OrderTrackingResponse:
type: object
description: Order-participant-scoped tracking snapshot. Nullable fields remain null until real telemetry exists.
properties:
orderId: { type: string, format: uuid }
status: { type: string, enum: [created, pending_payment, paid, restaurant_pending, restaurant_accepted, preparing, ready_for_pickup, driver_assigned, driver_arriving_restaurant, picked_up, delivering, delivered, completed, cancelled, refunded] }
driverLocation:
oneOf:
- $ref: "#/components/schemas/OrderTrackingDriverLocation"
- type: "null"
etaMinutes: { type: [integer, "null"], minimum: 1 }
routePolyline: { type: [string, "null"] }
routePhase: { type: string, enum: [pickup, dropoff] }
required: [orderId, status, driverLocation, etaMinutes, routePolyline, routePhase]
RestaurantOrderChatMessage:
type: object
description: Persisted order-room message used by restaurant staff and assigned driver.
properties:
id: { type: string, format: uuid }
senderType: { type: string, enum: [customer, driver, restaurant, ai, system] }
senderId: { type: string, format: uuid, nullable: true }
content: { type: string, minLength: 1, maxLength: 1000 }
createdAt: { type: string, format: date-time }
required: [id, senderType, content, createdAt]
RestaurantOrderChatMessagesPayload:
type: object
properties:
messages:
type: array
items: { $ref: "#/components/schemas/RestaurantOrderChatMessage" }
canReply:
type: boolean
description: False until a driver is assigned to the order.
required: [messages, canReply]
CreateRestaurantOrderChatMessageRequest:
type: object
properties:
content: { type: string, minLength: 1, maxLength: 1000 }
required: [content]
CancelOrderRequest:
type: object
properties:
reason: { type: string, maxLength: 500 }
example:
reason: "Đổi ý, muốn đặt món khác"
UpdateOrderStatusRequest:
type: object
properties:
status: { type: string }
note: { type: string }
required: [status]
example:
status: "preparing"
note: "Bắt đầu chế biến món"
AdminOrderStatusRequest:
type: object
properties:
status: { type: string, description: "Target order status accepted by the backend order state machine." }
note: { type: string }
required: [status]
RestaurantReviewRequest:
type: object
properties:
notes: { type: string }
reason: { type: string }
RestaurantMenuAvailabilityRequest:
type: object
properties:
available: { type: boolean }
required: [available]
KycReviewRequest:
type: object
additionalProperties: false
properties:
submissionId: { type: string, format: uuid }
status: { type: string, enum: [approved, rejected] }
reason: { type: string, minLength: 1, maxLength: 1000, description: "Required when status is rejected." }
required: [submissionId, status]
DriverKycUploadRequest:
type: object
additionalProperties: false
properties:
documentType: { type: string, enum: [idCardFront, idCardBack, driverLicense, vehicleRegistration] }
contentType: { type: string, enum: [image/jpeg, image/png, image/webp] }
sizeBytes: { type: integer, minimum: 1024, maximum: 4194304 }
required: [documentType, contentType, sizeBytes]
DriverKycUploadGrant:
type: object
additionalProperties: false
description: Short-lived upload capability for one private KYC object. Clients must not derive or persist a public URL.
properties:
uploadUrl: { type: string, format: uri, description: "Provider-signed PUT URL. HTTPS is mandatory in release clients." }
objectKey: { type: string, minLength: 1, maxLength: 512, description: "Opaque private object key returned unchanged in the final KYC submission." }
headers:
type: object
description: Exact non-credential headers that the client must include in the signed PUT request.
additionalProperties: { type: string }
required: [uploadUrl, objectKey, headers]
DriverKycDocumentObjects:
type: object
additionalProperties: false
description: Private storage object keys owned by the authenticated driver; URI values are rejected.
properties:
idCardFront: { type: string, minLength: 1, maxLength: 512 }
idCardBack: { type: string, minLength: 1, maxLength: 512 }
driverLicense: { type: string, minLength: 1, maxLength: 512 }
vehicleRegistration: { type: string, minLength: 1, maxLength: 512 }
required: [idCardFront, idCardBack, driverLicense, vehicleRegistration]
SubmitDriverKycRequest:
type: object
additionalProperties: false
properties:
licenseNumber: { type: string, minLength: 5, maxLength: 50, pattern: "^[A-Z0-9./-]+$" }
vehicleType: { type: string, enum: [motorbike, car, bicycle] }
vehiclePlate: { type: string, minLength: 5, maxLength: 20, pattern: "^[A-Z0-9.-]+$" }
documents: { $ref: "#/components/schemas/DriverKycDocumentObjects" }
required: [licenseNumber, vehicleType, vehiclePlate, documents]
example:
licenseNumber: "A1-123456789"
vehicleType: "motorbike"
vehiclePlate: "59-F1-12345"
documents:
idCardFront: "kyc/9c8a7a32-6f2d-4c7d-a40f-7de8629f84a9/1730000000000-0123456789abcdef01234567-idCardFront.jpg"
idCardBack: "kyc/9c8a7a32-6f2d-4c7d-a40f-7de8629f84a9/1730000000001-0123456789abcdef01234567-idCardBack.jpg"
driverLicense: "kyc/9c8a7a32-6f2d-4c7d-a40f-7de8629f84a9/1730000000002-0123456789abcdef01234567-driverLicense.jpg"
vehicleRegistration: "kyc/9c8a7a32-6f2d-4c7d-a40f-7de8629f84a9/1730000000003-0123456789abcdef01234567-vehicleRegistration.jpg"
DriverKycSubmissionReceipt:
type: object
additionalProperties: false
properties:
submissionId: { type: string, format: uuid }
status: { type: string, enum: [pending] }
submittedAt: { type: string, format: date-time }
required: [submissionId, status, submittedAt]
DriverKycLatestSubmission:
type: object
additionalProperties: false
properties:
id: { type: string, format: uuid }
status: { type: string, enum: [pending, approved, rejected] }
rejectionReason: { type: [string, "null"] }
submittedAt: { type: string, format: date-time }
reviewedAt: { type: [string, "null"], format: date-time }
required: [id, status, rejectionReason, submittedAt, reviewedAt]
DriverKycStatusResponse:
type: object
additionalProperties: false
properties:
isVerified: { type: boolean }
status: { type: string, enum: [not_submitted, pending, approved, rejected] }
licenseNumber: { type: [string, "null"] }
vehicleType: { type: string, enum: [motorbike, car, bicycle] }
vehiclePlate: { type: [string, "null"] }
termsAcceptedAt: { type: [string, "null"], format: date-time }
termsVersion: { type: [string, "null"] }
latestSubmission:
oneOf:
- $ref: "#/components/schemas/DriverKycLatestSubmission"
- type: "null"
attemptsRemaining: { type: integer, minimum: 0 }
required: [isVerified, status, licenseNumber, vehicleType, vehiclePlate, termsAcceptedAt, termsVersion, latestSubmission, attemptsRemaining]
AdminKycSignedDocuments:
type: object
additionalProperties: false
description: Five-minute signed read URLs generated only for authorized admin review.
properties:
idCardFront: { type: string, format: uri }
idCardBack: { type: string, format: uri }
driverLicense: { type: string, format: uri }
vehicleRegistration: { type: string, format: uri }
required: [idCardFront, idCardBack, driverLicense, vehicleRegistration]
AdminKycSubmission:
type: object
additionalProperties: false
properties:
id: { type: string, format: uuid }
status: { type: string, enum: [pending, approved, rejected] }
rejectionReason: { type: [string, "null"] }
reviewedById: { type: [string, "null"], format: uuid }
reviewedAt: { type: [string, "null"], format: date-time }
createdAt: { type: string, format: date-time }
updatedAt: { type: string, format: date-time }
documentsAvailable: { type: boolean }
documentUrls:
oneOf:
- $ref: "#/components/schemas/AdminKycSignedDocuments"
- type: "null"
required: [id, status, rejectionReason, reviewedById, reviewedAt, createdAt, updatedAt, documentsAvailable, documentUrls]
AdminKycReviewResponse:
type: object
additionalProperties: false
properties:
id: { type: string, format: uuid }
status: { type: string, enum: [approved, rejected] }
rejectionReason: { type: [string, "null"] }
reviewedById: { type: string, format: uuid }
reviewedAt: { type: string, format: date-time }
updatedAt: { type: string, format: date-time }
required: [id, status, rejectionReason, reviewedById, reviewedAt, updatedAt]
CreateReviewRequest:
type: object
properties:
foodRating: { type: integer, minimum: 1, maximum: 5 }
deliveryRating: { type: integer, minimum: 1, maximum: 5 }
comment: { type: string, maxLength: 500 }
required: [foodRating, deliveryRating]
example:
foodRating: 5
deliveryRating: 4
comment: "Phở ngon, giao nhanh"
# ── Drivers ──