-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1842 lines (1790 loc) · 75.3 KB
/
Copy pathopenapi.yaml
File metadata and controls
1842 lines (1790 loc) · 75.3 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: C++ REST API Template
description: |
Infrastructure endpoints for the C++ REST API template: health probes
and a background-job API. Authentication is opt-in (auth.mode=jwt|bearer|none).
Rate-limiting and idempotency are driven by headers.
version: 1.0.0
contact:
name: Platform team
servers:
- url: http://localhost:8080
description: Local dev
- url: https://api.example.com
description: Production
# Global security — attached per-operation below where needed.
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
# Browser-SPA session: the access JWT travels in an HttpOnly
# __Host- cookie set by POST /api/auth/login (auth.cookies.* in
# config/config.json). Same-origin only — the SPA never reads it
# from JS; fetch sends it via credentials: 'include'.
cookieAuth:
type: apiKey
in: cookie
name: __Host-access
parameters:
IdempotencyKey:
name: Idempotency-Key
in: header
required: false
description: |
Opaque client-generated key. First request with this key + body hash
is executed and its response cached; subsequent requests replay it.
Conflicting body with the same key returns 422.
schema:
type: string
maxLength: 256
Traceparent:
name: traceparent
in: header
required: false
description: W3C Trace Context header.
schema:
type: string
pattern: '^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$'
schemas:
# Mirrors ErrorResponse::make in src/utils/ErrorResponse.cpp — every
# error body carries `error` AND the numeric `status` (message/extras
# optional). The schema used to omit `status`; the e2e schema validation
# surfaced the drift.
Error:
type: object
required: [error, status]
properties:
error: { type: string }
status: { type: integer, description: "HTTP status code, duplicated into the body" }
message: { type: string }
code: { type: string }
ValidationError:
type: object
required: [error, status, errors]
properties:
error:
type: string
enum: [validation_failed]
status: { type: integer }
errors:
type: array
items:
type: object
required: [field, code, message]
properties:
field: { type: string }
code: { type: string }
message: { type: string }
# Mirrors Jobs::Job::to_json() in src/jobs/Jobs.hpp.
Job:
type: object
required: [id, type, status, created_at]
properties:
id: { type: string, format: uuid }
type: { type: string }
payload: { type: object, additionalProperties: true }
status:
type: string
enum: [pending, processing, completed, failed, dead]
result: { nullable: true }
error: { type: string }
worker_id: { type: string }
trace_id: { type: string, description: W3C trace id of the submitting request — deep-link into Jaeger }
retry_count: { type: integer }
max_retries: { type: integer }
created_at: { type: integer, format: int64, description: Epoch seconds }
updated_at: { type: integer, format: int64, description: Epoch seconds }
# Mirrors Domain::to_json(Role) in src/domain/Role.hpp.
Role:
type: object
required: [id, name, permissions, is_default]
properties:
id: { type: integer }
name: { type: string }
permissions: { type: integer, description: Bitmask — Domain::Permission::k* }
is_default: { type: boolean }
# Mirrors Domain::to_json(User) in src/domain/User.hpp.
# `role` is only present when the row was loaded with its role joined.
User:
type: object
required: [id, email, full_name, confirmed, role_id, created_at, updated_at]
properties:
id: { type: string, format: uuid }
email: { type: string, format: email }
first_name: { type: ['string', 'null'] }
last_name: { type: ['string', 'null'] }
full_name: { type: string }
confirmed: { type: boolean }
role_id: { type: integer }
role: { $ref: '#/components/schemas/Role' }
created_at: { type: string }
updated_at: { type: string }
UserListResponse:
type: object
required: [data, total, limit, offset]
properties:
data:
type: array
items: { $ref: '#/components/schemas/User' }
total: { type: integer }
limit: { type: integer }
offset: { type: integer }
JobListResponse:
type: object
required: [data, total, limit, offset]
properties:
data:
type: array
items: { $ref: '#/components/schemas/Job' }
total: { type: integer }
limit: { type: integer }
offset: { type: integer }
DlqListResponse:
type: object
required: [data, count, depth]
properties:
data:
type: array
items: { $ref: '#/components/schemas/Job' }
count: { type: integer, description: Number of jobs returned (after type filter + limit) }
depth: { type: integer, description: Total DLQ depth (unfiltered) }
AuditEntry:
type: object
required: [id, action, target_type, details, created_at]
properties:
id: { type: integer, format: int64 }
actor_id: { type: string, nullable: true, description: Acting principal subject (uuid), or null for a system action }
action: { type: string, description: 'Dotted verb, e.g. user.create' }
target_type: { type: string, description: 'Affected entity kind, e.g. user / role' }
target_id: { type: string, nullable: true, description: Affected entity id (uuid or int as text) }
details: { type: object, additionalProperties: true, description: Action-specific context }
created_at: { type: string, format: date-time }
AuditListResponse:
type: object
required: [data, total, limit, offset]
properties:
data:
type: array
items: { $ref: '#/components/schemas/AuditEntry' }
total: { type: integer }
limit: { type: integer }
offset: { type: integer }
JobCreate:
type: object
required: [type]
properties:
type: { type: string, minLength: 1 }
payload: { type: object, additionalProperties: true }
max_retries: { type: integer, minimum: 0, maximum: 20 }
# GET /api/auth/me, POST /api/auth/login, POST /api/auth/refresh.
# Mirrors AuthController::me/login/refresh — Response::ok({{"user", user}}).
MeResponse:
type: object
required: [user]
properties:
user: { $ref: '#/components/schemas/User' }
# GET/PATCH /api/admin/users/{id}, POST /api/admin/users.
# Mirrors AdminController::getUser/updateUser/createUser —
# Response::ok/created({{"data", user}}).
UserDetailResponse:
type: object
required: [data]
properties:
data: { $ref: '#/components/schemas/User' }
# POST /api/admin/invite. Mirrors AdminController::inviteUser —
# Response::created({{"data", user}, {"message", "Invitation sent"}}).
InviteResponse:
type: object
required: [data]
properties:
data: { $ref: '#/components/schemas/User' }
message: { type: string }
# GET /api/admin/roles. Mirrors AdminController::listRoles —
# Response::list({{"data", [...roles]}}).
RolesResponse:
type: object
required: [data]
properties:
data:
type: array
items: { $ref: '#/components/schemas/Role' }
# POST/PATCH /api/admin/roles[/{id}]. Mirrors AdminController::createRole/
# updateRole — Response::ok({{"data", role}}).
RoleDetailResponse:
type: object
required: [data]
properties:
data: { $ref: '#/components/schemas/Role' }
# Generic "{message: ...}" envelope: logout, delete user/role, etc.
MessageResponse:
type: object
properties:
message: { type: string }
# POST /api/v1/auth/register. Mirrors AuthController::registerUser —
# Response::created({{"user", user}, {"message", ...}}).
RegisterResponse:
type: object
required: [user, message]
properties:
user: { $ref: '#/components/schemas/User' }
message: { type: string }
# Mirrors Domain::to_json(Post) in src/domain/Post.hpp — the full admin
# shape (includes the raw Markdown body). The public index serves the
# lighter PostCard projection documented inline on /api/v1/public/posts.
Post:
type: object
required: [id, slug, title, summary, body, status, topic, tags, published_at, created_at, updated_at]
properties:
id: { type: string, format: uuid }
slug: { type: string }
title: { type: string }
summary: { type: string }
body: { type: string }
status: { type: string, enum: [draft, published] }
topic: { type: string }
tags: { type: array, items: { type: string } }
published_at: { type: ['string', 'null'], format: date-time }
created_at: { type: string }
updated_at: { type: string }
# GET/POST/PATCH /api/v1/posts[/{id}]. Mirrors PostsController —
# Response::ok/created({{"data", post}}).
PostDetailResponse:
type: object
required: [data]
properties:
data: { $ref: '#/components/schemas/Post' }
# Mirrors Domain::to_json(Package) in src/domain/Billing.hpp.
BillingPackage:
type: object
required: [id, title, amount_cents, credits, active, sort, created_at, updated_at]
properties:
id: { type: string, format: uuid }
title: { type: string }
amount_cents: { type: integer, format: int64 }
credits: { type: integer, format: int64 }
active: { type: boolean }
sort: { type: integer }
created_at: { type: string }
updated_at: { type: string }
# GET /api/v1/billing/packages also surfaces the current per-unit rate and
# the custom-amount bounds — a custom-amount input validates
# against these client-side, and a package's own price/credits ratio can
# legitimately differ from the generic rate (a bonus/discount package),
# so they aren't derivable from the package list alone.
BillingPackageListResponse:
type: object
required: [data, credits_per_unit, min_amount_cents, max_amount_cents]
properties:
data:
type: array
items: { $ref: '#/components/schemas/BillingPackage' }
credits_per_unit: { type: integer, format: int64, description: "billing.credits_per_unit — credits per 100 cents" }
min_amount_cents: { type: integer, format: int64, description: Minimum accepted amount_cents for a custom top-up }
max_amount_cents: { type: integer, format: int64, description: Maximum accepted amount_cents for a custom top-up }
# Mirrors Domain::to_json(WalletEntry) in src/domain/Billing.hpp — the
# full internal/admin shape, INCLUDING created_by. Not used by the
# user-facing GET /api/v1/billing/wallet response — see PublicWalletEntry.
WalletEntry:
type: object
required: [id, user_id, delta_credits, kind, reference, note, created_at]
properties:
id: { type: string, format: uuid }
user_id: { type: string, format: uuid }
delta_credits: { type: integer, format: int64 }
kind: { type: string, enum: [topup, spend, adjustment, refund] }
reference: { type: string }
note: { type: string }
created_by: { type: ['string', 'null'], format: uuid }
created_at: { type: string }
# GET /api/v1/billing/wallet's ledger rows. Deliberately OMITS
# created_by (an admin's raw UUID on adjustment rows) — that's
# internal/admin-only information, not something an end user's own
# wallet view should ever leak. See BillingController::public_wallet_entry.
PublicWalletEntry:
type: object
required: [id, user_id, delta_credits, kind, reference, note, created_at]
properties:
id: { type: string, format: uuid }
user_id: { type: string, format: uuid }
delta_credits: { type: integer, format: int64 }
kind: { type: string, enum: [topup, spend, adjustment, refund] }
reference: { type: string }
note: { type: string }
created_at: { type: string }
# GET /api/v1/billing/wallet. Mirrors BillingController::getWallet.
WalletResponse:
type: object
required: [data, limit, offset]
properties:
data:
type: object
required: [balance, history]
properties:
balance: { type: integer, format: int64 }
history:
type: array
items: { $ref: '#/components/schemas/PublicWalletEntry' }
limit: { type: integer }
offset: { type: integer }
# POST /api/v1/billing/topup. Mirrors BillingController::topup — the
# approve URL only; no credit count is ever present here.
TopupResponse:
type: object
required: [data]
properties:
data:
type: object
required: [order_id, approve_url]
properties:
order_id: { type: string, description: PayPal order id — pass back to POST .../capture }
approve_url: { type: string, format: uri, description: Redirect the buyer here to approve the order on PayPal }
# POST /api/v1/billing/capture. Mirrors BillingController::capture.
CaptureResponse:
type: object
required: [data]
properties:
data:
type: object
required: [credited, balance, status]
properties:
credited: { type: boolean, description: "false on an idempotent replay, or when PayPal has not yet COMPLETED the capture" }
balance: { type: integer, format: int64, description: Wallet balance AFTER this call (unchanged if not credited) }
status:
type: string
description: >
"captured" once this or an earlier call credited the wallet;
otherwise PayPal's own capture status verbatim (e.g.
"PENDING", "DECLINED") — PayPal answers 2xx for both, so this
is how a caller tells a settled capture from one still in
flight.
pending:
type: boolean
description: Present (true) only when PayPal's capture has not reached COMPLETED yet — the payment is left uncaptured for the webhook to resolve.
# POST /api/v1/billing/paypal/webhook. `handled` distinguishes "this event
# type applies real ledger logic" (PAYMENT.CAPTURE.COMPLETED/REFUNDED/
# REVERSED — see BillingController::handleCaptureRefunded's doc comment
# for why REVERSED shares REFUNDED's handling) from "acknowledged but
# deliberately not acted on" (an unrelated event type) — both answer 200
# either way, since PayPal retries any non-2xx for days.
WebhookAckResponse:
type: object
required: [data]
properties:
data:
type: object
required: [handled]
properties:
handled: { type: boolean, description: "true if this event type drives real crediting/refund logic (whether or not it was a no-op replay); false for an ignored/unrecognized event type" }
# GET/POST/PATCH /api/v1/admin/billing/packages[/{id}]. Same shape as the
# user-facing BillingPackage — the admin view just isn't filtered to
# active=true.
AdminPackageResponse:
type: object
required: [data]
properties:
data: { $ref: '#/components/schemas/BillingPackage' }
AdminPackageListResponse:
type: object
required: [data]
properties:
data:
type: array
items: { $ref: '#/components/schemas/BillingPackage' }
# GET /api/v1/admin/billing/payments. Mirrors Domain::to_json(Payment).
AdminPaymentListResponse:
type: object
required: [data, total, limit, offset]
properties:
data:
type: array
items: { $ref: '#/components/schemas/Payment' }
total: { type: integer }
limit: { type: integer }
offset: { type: integer }
Payment:
type: object
required:
- id
- user_id
- provider
- provider_order_id
- amount_cents
- currency
- credits_expected
- rate_snapshot
- status
- created_at
- updated_at
properties:
id: { type: string, format: uuid }
user_id: { type: string, format: uuid }
provider: { type: string }
provider_order_id: { type: string }
provider_capture_id: { type: ['string', 'null'] }
amount_cents: { type: integer, format: int64 }
currency: { type: string }
credits_expected: { type: integer, format: int64 }
rate_snapshot: { type: integer, format: int64 }
package_id: { type: ['string', 'null'], format: uuid }
status: { type: string, enum: [created, approved, captured, failed, refunded] }
failure_reason: { type: ['string', 'null'] }
created_at: { type: string }
updated_at: { type: string }
# GET/PUT /api/v1/admin/billing/settings. Mirrors Domain::to_json(BillingSettings).
BillingSettings:
type: object
required: [credits_per_unit, min_amount_cents, max_amount_cents, updated_at]
properties:
credits_per_unit: { type: integer, format: int64, description: Credits granted per 100 cents on a custom-amount top-up }
min_amount_cents: { type: integer, format: int64 }
max_amount_cents: { type: integer, format: int64 }
updated_at: { type: string }
BillingSettingsResponse:
type: object
required: [data]
properties:
data: { $ref: '#/components/schemas/BillingSettings' }
# POST /api/v1/admin/billing/users/{id}/adjust. Mirrors
# AdminBillingController::adjustWallet — deliberately does NOT echo the
# ledger row's full shape (no reference/kind/note round-trip needed by a
# caller that already knows what it just sent).
AdjustResponse:
type: object
required: [data]
properties:
data:
type: object
required: [balance, credited]
properties:
balance: { type: integer, format: int64, description: Wallet balance AFTER this adjustment }
credited: { type: boolean, description: "false only if this exact adjustment somehow no-op'd (not expected in normal use — adjust() has no idempotency key)" }
# GET /api/v1/admin/billing/metrics. Mirrors AdminBillingController::metrics
# / BillingMetricsRepository::get. All money in integer cents, all credits
# integers — no floating point except conversion.rate.
BillingMetricsResponse:
type: object
required: [data]
properties:
data:
type: object
required:
- period
- revenue_cents
- payments_count
- avg_payment_cents
- conversion
- refunds_cents
- refunds_count
- outstanding_credits
- outstanding_value_cents
- series
- top_packages
- top_users
properties:
period: { type: string, enum: [day, week, month] }
revenue_cents: { type: integer, format: int64, description: "Sum of amount_cents over captured payments in-window" }
payments_count: { type: integer, format: int64, description: "Count of captured payments in-window" }
avg_payment_cents: { type: integer, format: int64, description: "revenue_cents / payments_count (integer division; 0 if payments_count is 0)" }
conversion:
type: object
required: [created, captured, rate]
properties:
created: { type: integer, format: int64, description: Every payment (any status) created in-window }
captured: { type: integer, format: int64, description: Of those, how many reached captured }
rate: { type: number, format: double, description: "captured / created as a float ratio; 0 if created is 0" }
refunds_cents: { type: integer, format: int64, description: "Sum of billing_refunds.amount_cents in-window, outcome='applied' only" }
refunds_count: { type: integer, format: int64, description: "Count of billing_refunds rows in-window, outcome='applied' only" }
outstanding_credits: { type: integer, format: int64, description: "SUM(wallet_balances.credits) — all-time liability, NOT windowed" }
outstanding_value_cents: { type: integer, format: int64, description: "outstanding_credits * 100 / credits_per_unit (integer math, current billing_settings rate)" }
series:
type: array
description: "Calendar-bucketed (hourly for period=day, daily otherwise); every bucket in range is present, zero-filled if no captured payments landed in it"
items:
type: object
required: [bucket_start, revenue_cents, payments_count]
properties:
bucket_start: { type: string, description: ISO-8601 UTC bucket start }
revenue_cents: { type: integer, format: int64 }
payments_count: { type: integer, format: int64 }
top_packages:
type: array
description: "Top 5 packages by revenue among captured payments in-window"
items:
type: object
required: [package_id, title, revenue_cents, payments_count]
properties:
package_id: { type: string, format: uuid }
title: { type: string }
revenue_cents: { type: integer, format: int64 }
payments_count: { type: integer, format: int64 }
top_users:
type: array
description: "Top 5 users by top-up credits among captured payments in-window"
items:
type: object
required: [user_id, email, topup_credits, revenue_cents]
properties:
user_id: { type: string, format: uuid }
email: { type: string, format: email }
topup_credits: { type: integer, format: int64 }
revenue_cents: { type: integer, format: int64 }
# -----------------------------------------------------------------------------
paths:
/:
get:
summary: Endpoint discovery — list every registered route
tags: [health]
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
message: { type: string }
version: { type: string }
endpoints:
type: array
items:
type: object
required: [method, path, description]
properties:
method: { type: string }
path: { type: string }
description: { type: string }
/healthz:
get:
summary: Liveness probe
tags: [health]
responses:
'200':
description: Process is alive
content:
application/json:
schema:
type: object
required: [status, timestamp]
properties:
status: { type: string, enum: [alive] }
timestamp: { type: integer, format: int64, description: Epoch seconds }
/ready:
get:
summary: Readiness probe
tags: [health]
responses:
'200': { description: Ready }
'503': { description: Draining or dependency unhealthy }
/health:
get:
summary: Detailed component health
tags: [health]
responses:
'200': { description: All components healthy }
'503': { description: One or more components unhealthy }
# ── Auth ───────────────────────────────────────────────────────────────────
/api/v1/auth/register:
post:
summary: Register a new user
tags: [auth]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email, password]
properties:
email: { type: string, format: email }
password: { type: string, minLength: 8, maxLength: 128 }
first_name: { type: string }
last_name: { type: string }
responses:
'201':
description: User created — confirmation email queued
content:
application/json:
schema: { $ref: '#/components/schemas/RegisterResponse' }
'400': { description: Validation failed }
'409': { description: Email already registered }
'422':
description: Idempotency-Key conflict — same key, different body (idempotency middleware)
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
/api/v1/auth/login:
post:
summary: Log in
tags: [auth]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email, password]
properties:
email: { type: string, format: email }
password: { type: string }
responses:
'200':
description: Logged in — Set-Cookie access + refresh
headers:
Set-Cookie:
schema: { type: string }
content:
application/json:
schema: { $ref: '#/components/schemas/MeResponse' }
'401':
description: Invalid email or password
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
'415':
description: Body content type is not application/json (content-type middleware — applies to every JSON API endpoint)
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
/api/v1/auth/logout:
post:
summary: Log out (clears cookies + revokes refresh token)
tags: [auth]
security: [{ BearerAuth: [] }]
responses:
'200':
description: Logged out
content:
application/json:
schema: { $ref: '#/components/schemas/MessageResponse' }
/api/v1/auth/refresh:
post:
summary: Rotate access + refresh tokens
tags: [auth]
responses:
'200':
description: New cookies issued
headers:
Set-Cookie:
schema: { type: string }
content:
application/json:
schema: { $ref: '#/components/schemas/MeResponse' }
'401':
description: Refresh token missing / expired / revoked
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
/api/v1/auth/me:
get:
summary: Get the authenticated user
tags: [auth]
security: [{ BearerAuth: [] }]
responses:
'200':
description: Current user
content:
application/json:
schema: { $ref: '#/components/schemas/MeResponse' }
'401': { description: Not authenticated }
# ── Account self-service ───────────────────────────────────────────────────
/api/v1/account/confirm-resend:
post:
summary: Resend the email-confirmation link to the current user
tags: [account]
security: [{ BearerAuth: [] }]
responses:
'200': { description: Confirmation email queued }
'401': { description: Not authenticated }
/api/v1/account/confirm/{token}:
post:
summary: Confirm an account from an email link
tags: [account]
parameters:
- name: token
in: path
required: true
schema: { type: string }
responses:
'200': { description: Account confirmed }
'400': { description: Invalid or expired token }
'404': { description: User not found }
/api/v1/account/reset-password-request:
post:
summary: Start a password reset (email-based)
tags: [account]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email]
properties:
email: { type: string, format: email }
responses:
'200': { description: "If the email is registered, a reset link is on its way" }
/api/v1/account/reset-password/{token}:
post:
summary: Apply a password reset using an email-link token
tags: [account]
parameters:
- name: token
in: path
required: true
schema: { type: string }
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [new_password]
properties:
new_password: { type: string, minLength: 8, maxLength: 128 }
responses:
'200': { description: Password updated }
'400':
description: Invalid or expired token
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
/api/v1/account/change-email-request:
post:
summary: Start an email-change flow (verifies password, mails a link to new address)
tags: [account]
security: [{ BearerAuth: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [new_email, password]
properties:
new_email: { type: string, format: email }
password: { type: string }
responses:
'200': { description: Confirmation email sent to the new address }
'401': { description: Wrong password or not authenticated }
/api/v1/account/change-email/{token}:
post:
summary: Apply a pending email change from token
tags: [account]
parameters:
- name: token
in: path
required: true
schema: { type: string }
responses:
'200': { description: Email updated }
'400': { description: Invalid or expired token }
'409': { description: Email already in use }
/api/v1/account/join-from-invite/{token}:
post:
summary: Set password and confirm account from an invite token
tags: [account]
parameters:
- name: token
in: path
required: true
schema: { type: string }
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [new_password]
properties:
new_password: { type: string, minLength: 8, maxLength: 128 }
responses:
'200': { description: Account ready — the invitee can now sign in }
'400': { description: Invalid or expired invitation token }
/api/v1/account/change-password:
post:
summary: Change password while logged in (verifies old password)
tags: [account]
security: [{ BearerAuth: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [old_password, new_password]
properties:
old_password: { type: string }
new_password: { type: string, minLength: 8, maxLength: 128 }
responses:
'200': { description: Password updated }
'401': { description: Wrong current password or not authenticated }
/api/v1/account/api-keys:
get:
summary: List your API keys (metadata only; never the secret)
tags: [account]
security: [{ BearerAuth: [] }]
responses:
'200': { description: "Array of API key metadata under data[]" }
'401': { description: Not authenticated }
post:
summary: Create an API key — the secret is returned ONCE in this response
tags: [account]
security: [{ BearerAuth: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name]
properties:
name: { type: string }
responses:
'201': { description: Key created; `key` field holds the one-time secret }
'401': { description: Not authenticated }
/api/v1/account/api-keys/{id}:
delete:
summary: Revoke one of your API keys
tags: [account]
security: [{ BearerAuth: [] }]
parameters:
- { name: id, in: path, required: true, schema: { type: string, format: uuid } }
responses:
'200': { description: Key revoked }
'401': { description: Not authenticated }
'404': { description: No such key (or not yours) }
# ── Admin (require Permission::ADMINISTER) ────────────────────────────────
/api/v1/admin/users:
get:
summary: List users (admin)
tags: [admin]
security: [{ BearerAuth: [] }]
parameters:
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 200, default: 50 } }
- { name: offset, in: query, schema: { type: integer, minimum: 0, default: 0 } }
responses:
'200':
description: User page
content:
application/json:
schema: { $ref: '#/components/schemas/UserListResponse' }
'403':
description: Not an admin
content:
application/json:
schema: { $ref: '#/components/schemas/Error' }
post:
summary: Create a confirmed user (admin)
tags: [admin]
security: [{ BearerAuth: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email, password]
properties:
email: { type: string, format: email }
password: { type: string, minLength: 8, maxLength: 128 }
first_name: { type: string }
last_name: { type: string }
role_id: { type: integer }
responses:
'201':
description: Created
content:
application/json:
schema: { $ref: '#/components/schemas/UserDetailResponse' }
'400': { description: Validation failed }
'403': { description: Not an admin }
'409': { description: Email already registered }
/api/v1/admin/invite:
post:
summary: Invite a user via email (admin)
tags: [admin]
security: [{ BearerAuth: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email]
properties:
email: { type: string, format: email }
first_name: { type: string }
last_name: { type: string }
role_id: { type: integer }
responses:
'201':
description: Invited
content:
application/json:
schema: { $ref: '#/components/schemas/InviteResponse' }
'403': { description: Not an admin }
'409': { description: Email already registered }
/api/v1/admin/users/{id}:
parameters:
- { name: id, in: path, required: true, schema: { type: string, format: uuid } }
get:
summary: User detail (admin)
tags: [admin]
security: [{ BearerAuth: [] }]
responses:
'200':
description: User row with role
content:
application/json:
schema: { $ref: '#/components/schemas/UserDetailResponse' }
'403': { description: Not an admin }
'404': { description: User not found }
patch:
summary: Update user — email / role_id / first_name / last_name (admin)
tags: [admin]
security: [{ BearerAuth: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
properties: