Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1882 lines (1767 loc) · 57.5 KB
/
Copy pathopenapi.yaml
File metadata and controls
1882 lines (1767 loc) · 57.5 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.0.3
info:
title: ELMS — Electronic Locker Management System
version: 1.0.0
description: |
Contract for the ELMS backend. This document is the source of truth: it
generates the Go server interface (oapi-codegen) and the TypeScript client
(openapi-typescript), so the SPA and the API cannot drift apart.
Three audiences share one API:
- **Agents** store packages and read locker availability.
- **Admins** manage stations, lockers and pricing, and read the dashboard.
- **Customers** use the kiosk. They have no account: the locker label plus
the 6-digit pickup code *is* the credential, which is why `/pickup/*` is
unauthenticated and rate-limited instead (TDD §9).
Conventions:
- Money is always an integer count of **minor units** (cents) in the named
currency. No floating point appears anywhere in this contract.
- Timestamps are RFC 3339 in UTC.
- Every failure is an RFC 7807 `application/problem+json` document.
- Operations that need a session carry `x-required-role`. `agent` means any
logged-in operator (admins included); `admin` means admins only.
servers:
- url: /api/v1
# Session by default. Public endpoints opt out with `security: []` — an explicit
# decision each time, never an omission.
security:
- sessionCookie: []
tags:
- name: auth
description: Login, logout and the current principal (FR-13).
- name: stations
description: Station management (FR-1).
- name: lockers
description: Locker management, availability, maintenance and fit preview (FR-2..4, FR-16).
- name: catalogs
description: The cell sizes and box templates everything else measures against (FR-15).
- name: packages
description: Storing packages (FR-5..7).
- name: pickup
description: Public kiosk retrieval — quote, pay, open (FR-8..10).
- name: admin
description: Pricing and the occupancy dashboard (FR-11, FR-14).
- name: system
description: Liveness.
paths:
## -------------------------------------------------------------- auth
/auth/login:
post:
operationId: login
tags: [auth]
summary: Exchange credentials for a session cookie
description: |
A failed login never says which half was wrong (FR-13), and an unknown
username costs the same time as a wrong password.
security: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LoginRequest'
responses:
'200':
description: Signed in. The session cookie is set on this response.
headers:
Set-Cookie:
description: '`elms_session=<token>; HttpOnly; SameSite=Lax; Secure; Path=/` (TDD §8.2).'
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'400':
$ref: '#/components/responses/BadRequest'
'401':
description: Invalid credentials — deliberately not saying which field.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
default:
$ref: '#/components/responses/Unexpected'
/auth/logout:
post:
operationId: logout
tags: [auth]
summary: Destroy the current session
description: The session is deleted server-side; the cookie is cleared.
x-required-role: agent
responses:
'204':
description: Signed out.
headers:
Set-Cookie:
description: Expired `elms_session` cookie.
schema:
type: string
'401':
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Unexpected'
/auth/me:
get:
operationId: getCurrentUser
tags: [auth]
summary: The principal behind the current session
description: The SPA's route guards are built on this (TDD §10).
x-required-role: agent
responses:
'200':
description: The signed-in operator.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'401':
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Unexpected'
## -------------------------------------------------------------- stations
/stations:
get:
operationId: listStations
tags: [stations]
summary: List stations
description: |
Public, like the rest of the kiosk path. A customer has no account and
must still choose which locker bank they are standing at (US-C1), so
this is the one station operation that carries no role.
Nothing here is a secret: a station's name and address are painted on
the building. Knowing a station id buys nothing on its own — a pickup
still needs the locker label and the 6-digit code, rate-limited to five
attempts (FR-8). Creating, changing and deleting stations stay admin.
security: []
responses:
'200':
description: All stations, ordered by name — this is a list a person reads.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Station'
'401':
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Unexpected'
post:
operationId: createStation
tags: [stations]
summary: Create a station
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/StationInput'
responses:
'201':
description: Station created.
content:
application/json:
schema:
$ref: '#/components/schemas/Station'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
default:
$ref: '#/components/responses/Unexpected'
/stations/{stationId}:
parameters:
- $ref: '#/components/parameters/StationId'
patch:
operationId: updateStation
tags: [stations]
summary: Rename or re-address a station
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/StationInput'
responses:
'200':
description: Station updated.
content:
application/json:
schema:
$ref: '#/components/schemas/Station'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Unexpected'
delete:
operationId: deleteStation
tags: [stations]
summary: Delete an empty station
description: A station that still has lockers cannot be deleted (FR-1).
x-required-role: admin
responses:
'204':
description: Station deleted.
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
## -------------------------------------------------------------- lockers
/stations/{stationId}/lockers:
parameters:
- $ref: '#/components/parameters/StationId'
get:
operationId: listLockers
tags: [lockers]
summary: List a station's lockers with live status
description: |
Powers the agent's availability grid and the admin's locker table
(FR-3). Filters combine.
x-required-role: agent
parameters:
- name: status
in: query
required: false
description: Only lockers in this status.
schema:
$ref: '#/components/schemas/LockerStatus'
- name: locker_type_id
in: query
required: false
description: Only lockers of this cell type.
schema:
type: string
format: uuid
responses:
'200':
description: Lockers, ordered by label.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Locker'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Unexpected'
post:
operationId: createLocker
tags: [lockers]
summary: Add a locker to a station
description: |
Labels are unique within a station (FR-2); a duplicate is a 409. The
admin UI proposes `<first letter of the type name>-<seq>` (`M-03`) and
the operator may type anything else — the label is what a customer reads
off the door, so the server never invents one.
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LockerCreate'
responses:
'201':
description: Locker created, available for allocation.
content:
application/json:
schema:
$ref: '#/components/schemas/Locker'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
/stations/{stationId}/fit:
parameters:
- $ref: '#/components/parameters/StationId'
get:
operationId: previewFit
tags: [lockers]
summary: Ask what this station would do with a package of these measurements
description: |
The agent's form calls this while the numbers are still being typed
(FR-16). It claims nothing: the fit rule lives on the server so it is
not reimplemented in the browser, where no cross-check test can reach
it, and the binding decision still happens when the store is submitted.
x-required-role: agent
parameters:
- name: length_mm
in: query
required: true
schema: { type: integer, minimum: 1, maximum: 5000 }
- name: width_mm
in: query
required: true
schema: { type: integer, minimum: 1, maximum: 5000 }
- name: height_mm
in: query
required: true
schema: { type: integer, minimum: 1, maximum: 5000 }
responses:
'200':
description: What the station would do right now.
content:
application/json:
schema:
$ref: '#/components/schemas/FitPreview'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Unexpected'
/lockers/{lockerId}:
parameters:
- $ref: '#/components/parameters/LockerId'
patch:
operationId: updateLocker
tags: [lockers]
summary: Relabel a locker, change its type, or move it in and out of service
description: |
The maintenance toggle lives here: `status: out_of_service` removes the
locker from allocation. An occupied locker cannot be taken out of
service, relabelled or retyped — that would strand a stored package
(FR-4), so it answers 409.
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LockerUpdate'
responses:
'200':
description: Locker updated.
content:
application/json:
schema:
$ref: '#/components/schemas/Locker'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
delete:
operationId: deleteLocker
tags: [lockers]
summary: Delete an empty locker
x-required-role: admin
responses:
'204':
description: Locker deleted.
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
## -------------------------------------------------------------- catalogs
/locker-types:
get:
operationId: listLockerTypes
tags: [catalogs]
summary: The cell sizes lockers are built from
description: |
Ordered by interior volume, smallest first — the same order allocation
reasons in, so a Tower XL sits between Medium and Large whatever its
name suggests. Agents may read it: the availability grid names types.
x-required-role: agent
responses:
'200':
description: The catalog.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/LockerType'
'401':
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Unexpected'
post:
operationId: createLockerType
tags: [catalogs]
summary: Add a cell size
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LockerTypeInput'
responses:
'201':
description: Type created.
content:
application/json:
schema:
$ref: '#/components/schemas/LockerType'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
/locker-types/{lockerTypeId}:
parameters:
- $ref: '#/components/parameters/LockerTypeId'
patch:
operationId: updateLockerType
tags: [catalogs]
summary: Correct a cell size
description: |
Editing is unrestricted: a package's dimensions are frozen when it is
stored, so no correction here can rewrite history, and allocation asks
the fit question afresh on every store (US-A7).
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LockerTypeUpdate'
responses:
'200':
description: Type updated.
content:
application/json:
schema:
$ref: '#/components/schemas/LockerType'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
delete:
operationId: deleteLockerType
tags: [catalogs]
summary: Delete a cell size no locker is built from
description: |
A type the estate references answers 409: it is not the admin's to
remove while lockers depend on it (US-A7).
x-required-role: admin
responses:
'204':
description: Type deleted.
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
/package-templates:
get:
operationId: listPackageTemplates
tags: [catalogs]
summary: The standard boxes the agent picks from
description: Ordered by volume, smallest first.
x-required-role: agent
parameters:
- name: active
in: query
required: false
description: |
`true` returns only the offered templates — what the agent's form
asks for. Omitted, the whole catalog comes back, which is what the
admin screen needs.
schema:
type: boolean
responses:
'200':
description: The catalog.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PackageTemplate'
'401':
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Unexpected'
post:
operationId: createPackageTemplate
tags: [catalogs]
summary: Add a box template
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PackageTemplateInput'
responses:
'201':
description: Template created, and offered.
content:
application/json:
schema:
$ref: '#/components/schemas/PackageTemplate'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
/package-templates/{packageTemplateId}:
parameters:
- $ref: '#/components/parameters/PackageTemplateId'
patch:
operationId: updatePackageTemplate
tags: [catalogs]
summary: Correct or retire a box template
description: |
`active: false` retires it: the template leaves the agent's form and the
packages measured from it keep their dimensions and their name (FR-15).
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PackageTemplateUpdate'
responses:
'200':
description: Template updated.
content:
application/json:
schema:
$ref: '#/components/schemas/PackageTemplate'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Unexpected'
delete:
operationId: deletePackageTemplate
tags: [catalogs]
summary: Delete a box template nothing was measured from
description: |
A template a stored package names answers 409 — retire it instead, which
is what keeps a receipt readable a year later (FR-15).
x-required-role: admin
responses:
'204':
description: Template deleted.
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
default:
$ref: '#/components/responses/Unexpected'
## -------------------------------------------------------------- packages
/packages:
post:
operationId: storePackage
tags: [packages]
summary: Store a package in the smallest fitting locker
description: |
Allocates the smallest available locker at the station that fits the
package, lowest label first (FR-5), and returns the pickup code **once**
(FR-6). The code is bcrypt-hashed before it is stored; nothing can show
it again.
A station with no fitting free locker answers 409 with no side effects
(FR-7). Concurrent stores each get a different locker or a clean 409 —
never the same locker twice (FR-12).
x-required-role: agent
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/StorePackageRequest'
responses:
'201':
description: Stored. This response is the only place the code appears.
content:
application/json:
schema:
$ref: '#/components/schemas/StoredPackage'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'409':
description: |
No available locker at that station fits the package — including
the case of a station that does not exist, which is indistinguishable
from a station with nothing free.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
default:
$ref: '#/components/responses/Unexpected'
## -------------------------------------------------------------- pickup
/pickup/quotes:
post:
operationId: quotePickup
tags: [pickup]
summary: Price a pickup and hold the quote
description: |
Public: the locker label plus the pickup code is the credential.
Every failure — unknown station, unknown label, wrong code, package
already collected — answers the same 404 (FR-8). After 5 failed
attempts against one package, further attempts are refused with 429 for
15 minutes.
The quote freezes the amount for 15 minutes; a later rate change does
not rewrite it (FR-11). Re-quoting while a pending payment exists
returns that same quote rather than a second one.
security: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/QuoteRequest'
responses:
'200':
description: The charge, its per-tier breakdown, and the payment to confirm.
content:
application/json:
schema:
$ref: '#/components/schemas/Quote'
'400':
$ref: '#/components/responses/BadRequest'
'404':
description: |
Invalid pickup. Intentionally identical for every cause — the kiosk
must never reveal whether the label or the code was wrong (§9).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
'429':
$ref: '#/components/responses/PickupBlocked'
default:
$ref: '#/components/responses/Unexpected'
/pickup/payments/{paymentId}/confirm:
parameters:
- $ref: '#/components/parameters/PaymentId'
post:
operationId: confirmPickup
tags: [pickup]
summary: Pay the quote and open the locker
description: |
Mock payment. One transaction marks the payment paid, the package
retrieved and the locker available again (FR-9).
Confirming twice replays the receipt with `already_paid: true` instead
of charging again — kiosk buttons get double-tapped. An expired quote
answers 409 and is closed on the way out, so the customer can re-quote
immediately.
security: []
responses:
'200':
description: Paid. The locker is open and the package is released.
content:
application/json:
schema:
$ref: '#/components/schemas/Receipt'
'400':
$ref: '#/components/responses/BadRequest'
'404':
description: No such payment, or the package is no longer collectable.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
'409':
description: The quote expired before it was paid — quote again (FR-9).
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
default:
$ref: '#/components/responses/Unexpected'
## -------------------------------------------------------------- admin
/admin/dashboard:
get:
operationId: getDashboard
tags: [admin]
summary: Occupancy, dwell time and accrued charges for a station
description: |
Accrued amounts are what a pickup would cost right now, at the current
rate — they are live figures, not quotes, and nothing here is frozen
(FR-14).
x-required-role: admin
parameters:
- name: station_id
in: query
required: true
description: The station to report on.
schema:
type: string
format: uuid
responses:
'200':
description: The station's current state.
content:
application/json:
schema:
$ref: '#/components/schemas/Dashboard'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Unexpected'
/admin/audit-events:
get:
operationId: listAuditEvents
tags: [admin]
summary: The audit log, newest first
description: |
Every state-changing action, recorded in the transaction of the change
itself (FR-17): stores, retrievals, failed and blocked pickup attempts,
and every admin mutation. Newest first; insertion order breaks
same-instant ties, so pages never flap. Both time bounds are inclusive
— they arrive as day boundaries, and a boundary event belongs to the
range. Pickup codes never appear in `details`, attempted or real.
x-required-role: admin
parameters:
- name: event_type
in: query
required: false
description: Only events of this type, e.g. `package_stored`.
schema:
type: string
- name: station_id
in: query
required: false
description: Only events concerning this station.
schema:
type: string
format: uuid
- name: from
in: query
required: false
description: Only events at or after this instant.
schema:
type: string
format: date-time
- name: to
in: query
required: false
description: Only events at or before this instant.
schema:
type: string
format: date-time
- name: limit
in: query
required: false
description: Page size; the server default is 50.
schema:
type: integer
minimum: 1
maximum: 200
- name: offset
in: query
required: false
schema:
type: integer
minimum: 0
responses:
'200':
description: One page of the log, with the filtered total for paging.
content:
application/json:
schema:
$ref: '#/components/schemas/AuditEventPage'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
default:
$ref: '#/components/responses/Unexpected'
/pricing-config:
get:
operationId: getPricingConfig
tags: [admin]
summary: Read the base daily rate
x-required-role: admin
responses:
'200':
description: The single pricing row.
content:
application/json:
schema:
$ref: '#/components/schemas/PricingConfig'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
default:
$ref: '#/components/responses/Unexpected'
put:
operationId: setPricingConfig
tags: [admin]
summary: Change the base daily rate X
description: |
Tiers stay fixed at 1×/2×/3×; only X and the currency are editable
(FR-11). Quotes already issued keep the amount they were given.
x-required-role: admin
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PricingConfigUpdate'
responses:
'200':
description: Pricing updated; the next quote uses it.
content:
application/json:
schema:
$ref: '#/components/schemas/PricingConfig'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
default:
$ref: '#/components/responses/Unexpected'
## -------------------------------------------------------------- system
/healthz:
get:
operationId: getHealth
tags: [system]
summary: Liveness and database reachability
security: []
responses:
'200':
description: The API is up and the database answered a ping.
content:
application/json:
schema:
$ref: '#/components/schemas/Health'
'503':
description: The database did not answer.
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
default:
$ref: '#/components/responses/Unexpected'
components:
securitySchemes:
sessionCookie:
type: apiKey
in: cookie
name: elms_session
description: |
Server-side session: a random 256-bit token whose SHA-256 hash is what
the database holds, valid 24 hours. Set by `POST /auth/login`, cleared
by `POST /auth/logout` (TDD §8.2).
parameters:
StationId:
name: stationId
in: path
required: true
description: Station identifier.
schema:
type: string
format: uuid