forked from StellarLend/Stellarlend-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1601 lines (1527 loc) · 50.5 KB
/
Copy pathopenapi.yaml
File metadata and controls
1601 lines (1527 loc) · 50.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.1.0"
info:
title: Stellarlend API
version: "1.0.0"
description: |
Server-side API routes for the Stellarlend DeFi lending platform.
All routes live under `/api/` and are implemented as Next.js App Router
route handlers (`app/api/*/route.ts`).
**Authentication**
Protected routes require a valid session cookie (`session`).
A session is obtained via `POST /api/auth/session` and is stored as an
HttpOnly, SameSite=strict cookie.
**Caching**
Public read routes use an in-memory SWR cache (lib/cache).
Responses include an `X-Cache: HIT | MISS | STALE | BYPASS` header.
Cache is bypassed whenever an `Authorization` header, `session` / `token`
cookie, or `x-user-id` header is present.
**Request correlation**
API clients may send `x-request-id` as a ULID to correlate logs across
Stellarlend and upstream services. If it is omitted or malformed, the
middleware generates a fresh ULID, returns it in the `x-request-id`
response header, and forwards it on outbound service calls.
servers:
- url: http://localhost:3000
description: Local development
tags:
- name: health
description: Platform health check
- name: auth
description: Session management
- name: account
description: Account management including deletion
- name: prices
description: Real-time asset prices
- name: markets
description: Per-asset supply/borrow APR and utilization
- name: positions
description: User lending and borrowing positions
- name: transactions
description: Transaction history and creation
- name: quote
description: Lending / borrowing quote calculations
- name: notifications
description: In-app notifications for the authenticated user
- name: liquidation
description: Liquidation risk assessment for user positions
- name: admin
description: Internal admin-only routes for deployment and maintenance
paths:
# ---------------------------------------------------------------------------
# Health
# ---------------------------------------------------------------------------
/api/health:
get:
operationId: getHealth
tags: [health]
summary: Platform health check
description: |
Checks internal service status and Stellar Horizon reachability.
Returns 200 when healthy, 503 when degraded or unhealthy.
parameters:
- $ref: "#/components/parameters/XRequestId"
responses:
"200":
description: Platform is healthy
headers:
x-request-id:
$ref: "#/components/headers/XRequestId"
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
"503":
description: Platform is degraded or unhealthy
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
# ---------------------------------------------------------------------------
# Auth
# ---------------------------------------------------------------------------
/api/auth/session:
post:
operationId: createSession
tags: [auth]
summary: Create a session
description: Authenticates the user and sets an HttpOnly session cookie.
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email, password]
properties:
email:
type: string
format: email
password:
type: string
format: password
responses:
"200":
description: Session created
headers:
Set-Cookie:
description: HttpOnly session cookie
schema:
type: string
content:
application/json:
schema:
type: object
properties:
message:
type: string
"401":
$ref: "#/components/responses/Unauthorized"
get:
operationId: getSession
tags: [auth]
summary: Check session status
responses:
"200":
description: Session is active
content:
application/json:
schema:
type: object
properties:
authenticated:
type: boolean
"401":
$ref: "#/components/responses/Unauthorized"
delete:
operationId: deleteSession
tags: [auth]
summary: Destroy session (logout)
responses:
"200":
description: Session cleared
content:
application/json:
schema:
type: object
properties:
message:
type: string
/api/auth/logout:
post:
operationId: logout
tags: [auth]
summary: Logout and revoke session
description: |
Revokes the current session server-side and clears the session cookie.
This endpoint ensures that:
- The session token is invalidated immediately
- The cookie is removed from the browser
- Other devices using the same session cannot replay the token
- An audit log entry is recorded for security compliance
Requires an active session cookie. Used by the navbar disconnect action
in wallet-authenticated flows.
security:
- sessionCookie: []
responses:
"200":
description: Successfully logged out
headers:
Set-Cookie:
description: Clears the HttpOnly session cookie
schema:
type: string
content:
application/json:
schema:
type: object
required: [success, message]
properties:
success:
type: boolean
example: true
message:
type: string
example: "Logged out successfully"
walletAddress:
type: string
description: |
The wallet address that was logged out.
Included for navbar UI state management.
example: "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
"401":
description: No active session to logout
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error: "No active session"
"500":
$ref: "#/components/responses/InternalError"
delete:
operationId: logoutDelete
tags: [auth]
summary: Logout and revoke session (alternative endpoint)
description: |
Same as POST /api/auth/logout.
Provided for REST semantics preference.
security:
- sessionCookie: []
responses:
"200":
description: Successfully logged out
headers:
Set-Cookie:
description: Clears the HttpOnly session cookie
schema:
type: string
content:
application/json:
schema:
type: object
required: [success, message]
properties:
success:
type: boolean
example: true
message:
type: string
example: "Logged out successfully"
walletAddress:
type: string
example: "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
"401":
description: No active session to logout
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"500":
$ref: "#/components/responses/InternalError"
# ---------------------------------------------------------------------------
# Admin
# ---------------------------------------------------------------------------
/api/admin/migrate-status:
get:
operationId: getMigrateStatus
tags: [admin]
summary: Check migration drift status
description: |
Compares applied Drizzle migrations to the repository source manifest.
Intended for deploy verification and monitoring.
parameters:
- name: x-server-token
in: header
description: Server token used to authenticate internal admin requests
required: true
schema:
type: string
responses:
"200":
description: Migration status
content:
application/json:
schema:
$ref: "#/components/schemas/MigrationStatusResponse"
"403":
description: Unauthorized admin request
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"500":
$ref: "#/components/responses/InternalError"
# ---------------------------------------------------------------------------
# Prices
# ---------------------------------------------------------------------------
/api/prices:
get:
operationId: getPrices
tags: [prices]
summary: Fetch asset spot prices
description: |
Returns current USD prices for supported assets.
Responses are publicly cached (TTL 5 s, SWR 10 s) unless
authentication credentials are present.
parameters:
- name: assets
in: query
description: >
Comma-separated list of asset symbols to filter
(e.g. `XLM,USDC`). Omit for all assets.
required: false
schema:
type: string
example: XLM,USDC
responses:
"200":
description: Asset prices
headers:
X-Cache:
$ref: "#/components/headers/XCache"
Cache-Control:
$ref: "#/components/headers/CacheControl"
content:
application/json:
schema:
$ref: "#/components/schemas/PricesResponse"
"500":
$ref: "#/components/responses/InternalError"
# ---------------------------------------------------------------------------
# Markets
# ---------------------------------------------------------------------------
/api/markets:
get:
operationId: getMarkets
tags: [markets]
summary: Per-asset supply/borrow APR and utilization
description: |
Returns live market data for each supported asset sourced from the
Stellarlend Soroban lending pool contract.
Responses are publicly cached (TTL 30 s, SWR 60 s) unless
authentication credentials are present.
The lending page (`app/lending/page.tsx`) uses this endpoint to
populate default interest rates instead of hardcoded literals.
parameters:
- name: asset
in: query
description: >
Comma-separated list of AssetSymbol values to filter
(e.g. `?asset=XLM,USDC`). Omit for all assets.
required: false
schema:
type: string
example: XLM,USDC
responses:
"200":
description: Market data for the requested assets
headers:
X-Cache:
$ref: "#/components/headers/XCache"
Cache-Control:
$ref: "#/components/headers/CacheControl"
content:
application/json:
schema:
$ref: "#/components/schemas/MarketsResponse"
"400":
description: Unknown asset symbol(s) in the `asset` query param
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error: "Unknown asset(s): FAKE. Supported: XLM, USDC, BTC, ETH"
"500":
$ref: "#/components/responses/InternalError"
/api/internal/cache/invalidate:
post:
operationId: invalidateCache
tags: [auth]
summary: Invalidate cache namespaces (internal only)
description: |
Internal-only endpoint used by deployment tooling to invalidate
specific cache namespaces (e.g. `prices`, `markets`, `idempotency`).
This route is protected by an internal server token and should only
be invoked from trusted CI/CD workflows.
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [namespaces]
properties:
namespaces:
type: array
items:
type: string
example: ["prices", "markets"]
responses:
"200":
description: Number of cache keys deleted
content:
application/json:
schema:
type: object
properties:
deletedCount:
type: integer
"400":
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"500":
$ref: "#/components/responses/InternalError"
# ---------------------------------------------------------------------------
# Positions
# ---------------------------------------------------------------------------
/api/positions:
get:
operationId: getPositions
tags: [positions]
summary: Fetch user positions
description: |
Returns lending/borrowing position data.
When called without authentication, returns public aggregate data.
When called with `x-user-id` header or session cookie, returns
user-specific positions and bypasses the public cache.
parameters:
- name: userId
in: query
required: false
schema:
type: string
- name: x-user-id
in: header
required: false
schema:
type: string
responses:
"200":
description: Position data
headers:
X-Cache:
$ref: "#/components/headers/XCache"
content:
application/json:
schema:
$ref: "#/components/schemas/PositionsResponse"
"500":
$ref: "#/components/responses/InternalError"
/api/positions/history:
get:
operationId: getPositionsHistory
tags: [positions]
summary: Fetch historical position snapshots
description: |
Returns daily snapshots of user lending/borrowing positions over time,
including supplied/borrowed balances and effective APY.
Data is bucketed by the specified interval (1h, 1d, 7d, 30d) with the
first snapshot of each bucket returned. Responses are cached per wallet
with a 5-minute TTL.
Requires authentication. Returns data only for the authenticated wallet.
security:
- session: []
parameters:
- name: from
in: query
required: false
description: Start timestamp in milliseconds (default 90 days ago)
schema:
type: integer
format: int64
minimum: 0
example: 1700000000000
- name: to
in: query
required: false
description: End timestamp in milliseconds (default now)
schema:
type: integer
format: int64
minimum: 0
example: 1702592000000
- name: interval
in: query
required: false
description: Time bucketing interval
schema:
type: string
enum: [1h, 1d, 7d, 30d]
default: 1d
responses:
"200":
description: Historical position snapshots
headers:
X-Cache:
$ref: "#/components/headers/XCache"
Cache-Control:
description: Cache-Control header
schema:
type: string
example: "max-age=300, public"
content:
application/json:
schema:
$ref: "#/components/schemas/PositionHistoryResponse"
"400":
description: Invalid query parameters
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error: Bad Request
message: time range cannot exceed 365 days
"401":
$ref: "#/components/responses/Unauthorized"
"500":
$ref: "#/components/responses/InternalError"
# ---------------------------------------------------------------------------
# Liquidation
# ---------------------------------------------------------------------------
/api/liquidations:
get:
operationId: getLiquidations
tags: [liquidation]
summary: List user positions ranked by liquidation risk
description: |
Returns all borrowing positions for the authenticated user, ranked by
proximity to liquidation. Each position includes the computed health
factor, the price level at which the position becomes liquidatable, and
a normalized risk score between 0 (safe) and 1 (liquidatable).
Collateral factors are sourced from `lib/markets/registry.ts`.
**Risk score formula:**
```
riskScore = clamp(1 - (healthFactor - 1) / (SAFE_HF - 1), 0, 1)
```
where SAFE_HF = 2.0. A health factor ≤ 1 yields riskScore = 1;
a health factor ≥ 2 yields riskScore = 0.
**Health factor formula:**
```
healthFactor = (collateralAmount × collateralFactor) / borrowedAmount
```
**Liquidation price factor formula:**
```
liquidationPriceFactor = borrowedAmount / (collateralAmount × collateralFactor)
```
This is the fraction of the current price at which the position becomes
liquidatable. A value of 0.8 means a 20% price decline triggers liquidation.
security:
- sessionCookie: []
parameters:
- name: wallet
in: query
required: false
description: >
Override wallet address for admin inspection.
Must be a valid Stellar public key (max 56 chars).
schema:
type: string
maxLength: 56
example: GA-test-address
responses:
"200":
description: Liquidation risk assessment
content:
application/json:
schema:
$ref: "#/components/schemas/LiquidationsResponse"
"400":
description: Invalid wallet address parameter
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error: Invalid wallet address
"401":
$ref: "#/components/responses/Unauthorized"
"500":
$ref: "#/components/responses/InternalError"
# ---------------------------------------------------------------------------
# Transactions
# ---------------------------------------------------------------------------
/api/transactions:
get:
operationId: listTransactions
tags: [transactions]
summary: List transactions with optional filters
description: |
Supports the existing offset pagination (`page` and `pageSize`) and optional cursor pagination (`cursor` and `limit`).
Offset pagination is convenient for jumping to an approximate page and remains backward compatible, but large offsets can become inefficient and may miss or duplicate rows when new transactions are inserted between requests. Cursor pagination uses a stable `(date, id)` keyset ordered by `sortDir`, so forward and reverse iteration stays efficient and consistent for sequential scans. Cursor pagination is intentionally limited to `sortBy=date`; use offset pagination when sorting by amount.
parameters:
- name: asset
in: query
required: false
schema:
$ref: "#/components/schemas/AssetSymbol"
- name: type
in: query
required: false
schema:
$ref: "#/components/schemas/TransactionType"
- name: status
in: query
required: false
schema:
$ref: "#/components/schemas/TransactionStatus"
- name: page
in: query
required: false
description: 1-based offset page number used when cursor/limit is omitted.
schema:
type: integer
minimum: 1
default: 1
- name: pageSize
in: query
required: false
description: Offset page size, capped at 100.
schema:
type: integer
minimum: 1
maximum: 100
default: 6
- name: cursor
in: query
required: false
description: Opaque cursor returned as nextCursor or prevCursor. Supplying cursor or limit enables keyset pagination.
schema:
type: string
- name: limit
in: query
required: false
description: Cursor page size, capped at 100. Supplying limit enables keyset pagination from the beginning of the ordered result set.
schema:
type: integer
minimum: 1
maximum: 100
default: 6
- name: sortBy
in: query
required: false
schema:
type: string
enum: [date, amount]
default: date
- name: sortDir
in: query
required: false
schema:
type: string
enum: [asc, desc]
default: desc
responses:
"200":
description: Transaction list
content:
application/json:
schema:
type: object
required: [transactions, total, nextCursor, prevCursor]
properties:
transactions:
type: array
items:
$ref: "#/components/schemas/Transaction"
total:
type: integer
minimum: 0
nextCursor:
type: string
nullable: true
description: Cursor for the next page when cursor pagination has another page.
prevCursor:
type: string
nullable: true
description: Cursor for the previous page when cursor pagination has an earlier page.
"400":
description: Invalid filter or cursor pagination value
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
post:
operationId: createTransaction
tags: [transactions]
summary: Create a transaction record
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TransactionInput"
responses:
"201":
description: Transaction created
content:
application/json:
schema:
type: object
properties:
transaction:
$ref: "#/components/schemas/Transaction"
"400":
$ref: "#/components/responses/BadRequest"
/api/transactions/{id}:
get:
operationId: getTransactionDetail
tags: [transactions]
summary: Retrieve detailed transaction records with operations
description: |
Returns the normalized transaction record with embedded operation logs, fee, and explorer links.
Accepts mock transaction IDs (TXN\d+) and 64-character hexadecimal Soroban/Stellar transaction hashes.
parameters:
- name: id
in: path
required: true
description: The transaction identifier (either mock TXN\d+ or a 64-character hex hash)
schema:
type: string
pattern: "^(TXN\\d+|[0-9a-fA-F]{64})$"
example: TXN12345
responses:
"200":
description: Detailed transaction found
content:
application/json:
schema:
type: object
required: [transaction]
properties:
transaction:
type: object
required: [id, asset, type, status, amount, date, time, fee, explorerUrl, operations]
properties:
id:
type: string
example: TXN12345
asset:
$ref: "#/components/schemas/AssetSymbol"
type:
$ref: "#/components/schemas/TransactionType"
status:
$ref: "#/components/schemas/TransactionStatus"
amount:
type: number
example: 2000
date:
type: string
format: date
example: "2025-04-12"
time:
type: string
example: "09:32AM"
fee:
type: string
example: "0.0001000 XLM"
explorerUrl:
type: string
format: uri
example: "https://stellar.expert/explorer/testnet/tx/TXN12345"
operations:
type: array
items:
type: object
required: [id, type, source, destination, amount, asset]
properties:
id:
type: string
example: "op_TXN12345_1"
type:
type: string
example: "payment"
source:
type: string
example: "GA2C5RFPE6GCKMY3AA3H6AOF5Q4G5S4GX6TQCGEAAS624JBZ2G2UQHGD"
destination:
type: string
example: "GBXQ2P5Z5U67G6Z66Z66Z66Z66Z66Z66Z66Z66Z66Z66Z66Z66Z66"
amount:
type: string
example: "2000.0000000"
asset:
type: string
example: "XLM"
"400":
description: Invalid transaction ID format
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"404":
description: Transaction not found
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/api/transactions/export:
get:
operationId: exportTransactions
tags: [transactions]
summary: Export transactions as CSV
parameters:
- name: asset
in: query
required: false
schema:
$ref: "#/components/schemas/AssetSymbol"
- name: type
in: query
required: false
schema:
$ref: "#/components/schemas/TransactionType"
- name: status
in: query
required: false
schema:
$ref: "#/components/schemas/TransactionStatus"
responses:
"200":
description: CSV file download
content:
text/csv:
schema:
type: string
format: binary
"400":
$ref: "#/components/responses/BadRequest"
# ---------------------------------------------------------------------------
# Quote
# ---------------------------------------------------------------------------
/api/quote:
post:
operationId: calculateQuote
tags: [quote]
summary: Calculate a lending or borrowing quote
description: |
Accepts lending parameters and returns projected earnings (lend)
or repayment schedule (borrow). Backed by lib/lending/quote.ts.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/QuoteRequest"
responses:
"200":
description: Quote result
content:
application/json:
schema:
$ref: "#/components/schemas/QuoteResponse"
"400":
$ref: "#/components/responses/BadRequest"
# ---------------------------------------------------------------------------
# Admin
# ---------------------------------------------------------------------------
/api/admin/users:
get:
operationId: adminListUsers
tags: [admin]
summary: List all platform users (admin only)
description: |
Returns a paginated, searchable list of platform users.
**Requires** an authenticated session JWT that carries a `role: admin` claim.
Response fields are limited to a safe allow-list; hashed credentials and
session tokens are never included.
Every successful call emits a structured audit event.
security:
- sessionCookie: []
- adminBearerToken: []
parameters:
- name: page
in: query
required: false
description: 1-based page number (default: 1)
schema:
type: integer
minimum: 1
default: 1
example: 1
- name: pageSize
in: query
required: false
description: Records per page, 1-100 (default: 20)
schema:
type: integer
minimum: 1
maximum: 100
default: 20
example: 20
- name: search
in: query
required: false
description: Case-insensitive substring match on email and name (max 100 chars)
schema:
type: string
maxLength: 100
example: alice
responses:
"200":
description: Paginated user list
content:
application/json:
schema:
$ref: "#/components/schemas/AdminUsersResponse"
"400":
description: Invalid query parameters
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"401":
$ref: "#/components/responses/Unauthorized"
"403":
description: Authenticated but does not hold the admin role
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
example:
error: Forbidden
"500":
$ref: "#/components/responses/InternalError"
# ---------------------------------------------------------------------------
# Notifications
# ---------------------------------------------------------------------------
/api/notifications:
get:
operationId: listNotifications
tags: [notifications]
summary: List notifications for the authenticated user
description: |
Returns all notifications scoped to the caller's user ID
along with the current unread count (useful for nav-badge rendering).
Requires an active session cookie.
security:
- sessionCookie: []
responses:
"200":
description: Notification list
content:
application/json:
schema:
$ref: "#/components/schemas/NotificationsResponse"
"401":
$ref: "#/components/responses/Unauthorized"
/api/notifications/{id}:
patch:
operationId: markNotificationRead
tags: [notifications]
summary: Mark a notification as read
description: |
Sets `read: true` on the specified notification.
Only affects notifications owned by the authenticated user.
Requires an active session cookie.
security:
- sessionCookie: []
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
"200":
description: Updated notification
content:
application/json:
schema:
type: object
properties:
notification: