forked from Lex-Studios/Stellar-Spend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
4170 lines (4149 loc) · 118 KB
/
Copy pathopenapi.yaml
File metadata and controls
4170 lines (4149 loc) · 118 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: Stellar-Spend API
description: |
Stellar-Spend converts Stellar USDC to fiat currency (off-ramp) using the
Allbridge cross-chain bridge and Paycrest fiat settlement layer.
## Authentication
| Route group | Auth method |
|---|---|
| `/api/offramp/*` (legacy) | None — server-side secrets only |
| `/api/v1/*` | API key via `X-API-Key` or `Authorization: Bearer` |
| `/api/api-keys/*` | Admin bearer token via `Authorization: Bearer <API_KEY_ADMIN_TOKEN>` |
| `/api/auth/2fa/*` | Public — user-supplied credentials in body |
| `/api/webhooks/paycrest` | HMAC-SHA256 via `X-Paycrest-Signature` |
## API Key Scopes
| Scope | Endpoints |
|---|---|
| `offramp:read` | GET currencies, institutions, rate, bridge status |
| `offramp:write` | POST quote, build-tx, submit-soroban, paycrest order |
| `webhook:read` | Receive webhook events |
## Rate Limits
`/api/v1/*` endpoints are rate-limited per API key.
Default: **120 requests / 60 seconds**. The following headers are returned on
every response:
| Header | Description |
|---|---|
| `X-RateLimit-Limit` | Maximum requests in the current window |
| `X-RateLimit-Remaining` | Requests remaining in the current window |
| `X-RateLimit-Reset` | Unix timestamp when the window resets |
| `Retry-After` | Seconds to wait (only on `429` responses) |
When the limit is exceeded the server returns `429 Too Many Requests`.
## Versioning
All routes are available under `/api/v1/`. Legacy `/api/` routes are deprecated
(sunset `2026-01-01`) and return `Deprecation`, `Sunset`, and `Link` headers.
Version can also be negotiated with:
- `X-API-Version: 1`
- `Accept: application/vnd.stellarspend.v1+json`
The full lifecycle policy — what forces a new major version, when v2 is cut,
how long a deprecated version keeps working, and the deprecation header
contract — is documented in
[`docs/api-versioning.md`](https://github.com/Lex-Studios/Stellar-Spend/blob/main/docs/api-versioning.md).
Supported versions can be discovered at runtime via `GET /api/versions`.
This document remains the source of truth for the API contract itself; the
policy document is authoritative only for version lifecycle decisions.
## Idempotency
Mutating endpoints support the `Idempotency-Key` header. Replay responses
include `Idempotency-Status: replayed`; conflicts return `409`.
Key lifetime: 24 hours (configurable via `IDEMPOTENCY_TTL_MS`).
## API Changelog
### v1.1.0 — 2026-06-29
- Added `X-RateLimit-*` headers to all `/api/v1/*` responses
- Added `Idempotency-Status` response header documentation
- Added API key scope documentation
- Added interactive Swagger UI at `/api/docs`
- Added `docs/integrator-guide.md` for third-party SDK integrators
### v1.0.0 — 2026-01-01
- Initial public API release
- Versioned routes under `/api/v1/` with API key authentication
- Legacy `/api/offramp/*` routes deprecated (sunset 2026-01-01)
- Idempotency support on all mutating endpoints
- Webhook HMAC-SHA256 signature verification
version: 1.1.0
contact:
name: Stellar-Spend
url: https://github.com/Lex-Studios/Stellar-Spend
servers:
- url: http://localhost:3001
description: Local development
- url: https://your-domain.com
description: Production
tags:
- name: health
description: Service health and version
- name: offramp
description: Off-ramp flow — currencies, quotes, bridge, payout
- name: bridge
description: Allbridge Stellar→Base USDC bridge
- name: paycrest
description: Paycrest fiat payout orders
- name: webhooks
description: Inbound event webhooks
- name: api-keys
description: Programmatic API key management (admin)
- name: auth
description: Two-factor authentication
- name: transactions
description: Transaction history and management
- name: notifications
description: User notification preferences
- name: fx-rates
description: Foreign-exchange rates
- name: versions
description: API version discovery
- name: onramp
description: 'On-ramp operations: fiat to crypto conversion and provider orders'
- name: merchant
description: Merchant accounts, statistics, and payout management
- name: security
description: Security audit logs, signatures, IP whitelist, and session controls
- name: admin
description: Admin operations, dispute resolution, database, and vulnerabilities
- name: sync
description: Client transaction history and settings cloud synchronization
- name: monitoring
description: System telemetry, cache metrics, and web vitals
- name: cron
description: Scheduled jobs, stall scanning, and recurring execution
components:
securitySchemes:
ApiKeyHeader:
type: apiKey
in: header
name: X-API-Key
description: Programmatic API key for `/api/v1/*` endpoints
BearerAuth:
type: http
scheme: bearer
description: >
For `/api/v1/*` endpoints use a programmatic API key. For `/api/api-keys/*` admin endpoints use
`API_KEY_ADMIN_TOKEN`.
PaycrestSignature:
type: apiKey
in: header
name: X-Paycrest-Signature
description: HMAC-SHA256 hex digest of the raw request body (webhook only)
headers:
X-RateLimit-Limit:
description: Maximum number of requests allowed in the current window
schema:
type: integer
example: 120
X-RateLimit-Remaining:
description: Number of requests remaining in the current window
schema:
type: integer
example: 115
X-RateLimit-Reset:
description: Unix timestamp (seconds) when the current rate-limit window resets
schema:
type: integer
example: 1751234567
Retry-After:
description: Seconds to wait before retrying (only present on 429 responses)
schema:
type: integer
example: 12
X-Request-Id:
description: Unique identifier for this request, useful for correlating logs
schema:
type: string
example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
schemas:
Error:
type: object
required:
- error
properties:
error:
type: string
description: Machine-readable error code, stable across releases. Safe to branch client logic on.
enum:
- validation_error
- not_found
- unauthorized
- forbidden
- conflict
- rate_limit_exceeded
- server_error
- external_service_error
example: validation_error
message:
type: string
description: Human-readable description of the error, safe to display to end users.
example: Invalid request parameters
details:
type: object
description: >
Additional machine-readable context (e.g. per-field validation failures). Only populated outside production;
omitted entirely when production hides internals.
additionalProperties: true
ValidationError:
description: Error response for validation_error, with per-field detail messages.
allOf:
- $ref: '#/components/schemas/Error'
- type: object
required:
- error
- details
properties:
error:
type: string
enum:
- validation_error
details:
type: object
additionalProperties:
type: string
example:
amount: amount must be a positive number
recipient.institution: recipient.institution is required
HealthResponse:
type: object
properties:
status:
type: string
example: ok
timestamp:
type: string
format: date-time
example: '2026-04-22T22:30:11.068Z'
version:
type: string
example: 1.0.0
Currency:
type: object
properties:
code:
type: string
example: NGN
name:
type: string
example: Nigerian Naira
symbol:
type: string
example: ₦
Institution:
type: object
properties:
code:
type: string
example: ACCESS
name:
type: string
example: Access Bank
QuoteRequest:
type: object
required:
- amount
- currency
- feeMethod
properties:
amount:
type: string
example: '100'
currency:
type: string
example: NGN
feeMethod:
type: string
enum:
- USDC
- XLM
- stablecoin
- native
example: USDC
QuoteResponse:
type: object
properties:
destinationAmount:
type: string
example: '155000.00'
rate:
type: number
example: 1550
currency:
type: string
example: NGN
expiresIn:
type: integer
example: 300
VerifyAccountRequest:
type: object
required:
- institution
- accountIdentifier
properties:
institution:
type: string
example: ACCESS
accountIdentifier:
type: string
example: '0123456789'
VerifyAccountResponse:
type: object
properties:
accountName:
type: string
example: John Doe
GasFeeOptions:
type: object
properties:
feeOptions:
type: object
properties:
native:
type: object
properties:
int:
type: string
example: '1000000'
float:
type: string
example: '1.0'
stablecoin:
type: object
properties:
int:
type: string
example: '500000'
float:
type: string
example: '0.5'
BuildTxRequest:
type: object
required:
- amount
- fromAddress
- toAddress
properties:
amount:
type: string
example: '99.5'
fromAddress:
type: string
description: Stellar G... sender address
example: GABC123XYZ
toAddress:
type: string
description: Base 0x... recipient address
example: '0xabc123def456'
feePaymentMethod:
type: string
enum:
- stablecoin
- native
default: stablecoin
BuildTxResponse:
type: object
properties:
xdr:
type: string
example: AAAAAgAAAA...
sourceToken:
$ref: '#/components/schemas/TokenInfo'
destinationToken:
$ref: '#/components/schemas/TokenInfo'
TokenInfo:
type: object
properties:
symbol:
type: string
example: USDC
decimals:
type: integer
example: 7
contract:
type: string
example: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75
chain:
type: string
example: SRB
SubmitSorobanRequest:
type: object
required:
- signedXdr
properties:
signedXdr:
type: string
example: AAAAAgAAAA...
TxStatusResponse:
type: object
properties:
status:
type: string
enum:
- PENDING
- SUCCESS
- FAILED
- NOT_FOUND
example: PENDING
hash:
type: string
example: abc123def456
BridgeStatusResponse:
type: object
properties:
data:
type: object
properties:
status:
type: string
enum:
- pending
- processing
- completed
- failed
- expired
example: completed
txHash:
type: string
example: abc123def456
receiveAmount:
type: string
example: '99.0'
Recipient:
type: object
required:
- institution
- accountIdentifier
- accountName
- currency
properties:
institution:
type: string
example: ACCESS
accountIdentifier:
type: string
example: '0123456789'
accountName:
type: string
example: John Doe
currency:
type: string
example: NGN
CreateOrderRequest:
type: object
required:
- amount
- rate
- token
- network
- reference
- returnAddress
- recipient
properties:
amount:
type: number
example: 99
rate:
type: number
example: 1550
token:
type: string
example: USDC
network:
type: string
example: base
reference:
type: string
example: ref-unique-123
returnAddress:
type: string
example: '0xabc123def456'
recipient:
$ref: '#/components/schemas/Recipient'
CreateOrderResponse:
type: object
properties:
data:
type: object
properties:
id:
type: string
example: order-uuid
receiveAddress:
type: string
example: 0xpaycrest-deposit-address
OrderStatusResponse:
type: object
properties:
data:
type: object
properties:
id:
type: string
example: order-uuid
status:
type: string
enum:
- pending
- validated
- settled
- refunded
- expired
example: settled
ApiKey:
type: object
properties:
id:
type: string
example: uuid
name:
type: string
example: Production Partner
keyPrefix:
type: string
example: abc123def456
status:
type: string
enum:
- active
- revoked
- rotated
example: active
rateLimitMaxRequests:
type: integer
example: 120
rateLimitWindowMs:
type: integer
example: 60000
CreateApiKeyRequest:
type: object
required:
- name
properties:
name:
type: string
example: Production Partner
rateLimitMaxRequests:
type: integer
example: 120
rateLimitWindowMs:
type: integer
example: 60000
CreateApiKeyResponse:
type: object
properties:
data:
allOf:
- $ref: '#/components/schemas/ApiKey'
- type: object
properties:
plaintextKey:
type: string
example: ssp_live_abc123def456.very-secret-value
NotificationPreferences:
type: object
properties:
userAddress:
type: string
example: GABC...
email:
type: string
format: email
example: user@example.com
phoneNumber:
type: string
example: '+2348000000000'
emailEnabled:
type: boolean
example: true
smsEnabled:
type: boolean
example: false
notifyOnPending:
type: boolean
example: true
notifyOnCompleted:
type: boolean
example: true
notifyOnFailed:
type: boolean
example: true
TwoFASetupRequest:
type: object
required:
- userId
- method
properties:
userId:
type: string
example: user-wallet-address
method:
type: string
enum:
- totp
- sms
example: totp
TwoFASetupResponse:
type: object
properties:
method:
type: string
example: totp
secret:
type: string
example: JBSWY3DPEHPK3PXP
uri:
type: string
example: otpauth://totp/StellarSpend:user?secret=JBSWY3DPEHPK3PXP&issuer=StellarSpend
backupCodes:
type: array
items:
type: string
example:
- abc123
- def456
TwoFAVerifyRequest:
type: object
required:
- userId
- code
- method
properties:
userId:
type: string
example: user-wallet-address
code:
type: string
example: '123456'
method:
type: string
enum:
- totp
- backup
example: totp
secret:
type: string
description: Required when method is totp
example: JBSWY3DPEHPK3PXP
backupCodes:
type: array
description: Required when method is backup
items:
type: string
Transaction:
type: object
required:
- id
- amount
- currency
- status
- createdAt
properties:
id:
type: string
example: tx_1234567890
userAddress:
type: string
example: GCFX...ABCD
amount:
type: string
example: '100.00'
currency:
type: string
example: NGN
status:
type: string
enum:
- pending
- building
- signed
- submitted
- bridging
- payout_pending
- completed
- failed
- refunded
example: completed
stellarTxHash:
type: string
example: 5d1e...
baseTxHash:
type: string
example: 0x12...
recipient:
$ref: '#/components/schemas/Recipient'
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
Dispute:
type: object
required:
- id
- transactionId
- status
- reason
- createdAt
properties:
id:
type: string
example: disp_12345
transactionId:
type: string
example: tx_1234567890
status:
type: string
enum:
- open
- under_review
- resolved
- rejected
example: open
reason:
type: string
example: Bank account not credited after 24h
evidenceUrl:
type: string
format: uri
createdAt:
type: string
format: date-time
resolvedAt:
type: string
format: date-time
WebhookSubscription:
type: object
required:
- id
- targetUrl
- events
- active
- createdAt
properties:
id:
type: string
example: sub_12345
targetUrl:
type: string
format: uri
example: https://example.com/webhooks
events:
type: array
items:
type: string
example:
- order.completed
- order.failed
active:
type: boolean
example: true
createdAt:
type: string
format: date-time
WebhookDelivery:
type: object
required:
- id
- subscriptionId
- event
- statusCode
- success
- timestamp
properties:
id:
type: string
example: deliv_123
subscriptionId:
type: string
example: sub_12345
event:
type: string
example: order.completed
statusCode:
type: integer
example: 200
success:
type: boolean
example: true
attemptCount:
type: integer
example: 1
durationMs:
type: integer
example: 145
timestamp:
type: string
format: date-time
MerchantProfile:
type: object
required:
- id
- businessName
- email
- status
properties:
id:
type: string
example: merch_123
businessName:
type: string
example: Acme Corp
email:
type: string
format: email
example: finance@acme.com
status:
type: string
enum:
- active
- suspended
- pending_kyc
example: active
webhookUrl:
type: string
format: uri
createdAt:
type: string
format: date-time
SloMetrics:
type: object
required:
- uptime
- p99LatencyMs
- errorRate
properties:
uptime:
type: number
example: 99.98
p99LatencyMs:
type: number
example: 120
errorRate:
type: number
example: 0.001
OfframpStatusResponse:
type: object
required:
- orderId
- status
properties:
orderId:
type: string
example: ord_1234567890
status:
type: string
enum:
- pending
- processing
- completed
- failed
- refunded
example: completed
amount:
type: string
example: '100.00'
currency:
type: string
example: NGN
stellarTxHash:
type: string
example: 5d1e...
payoutTxHash:
type: string
example: 0x12...
updatedAt:
type: string
format: date-time
paths:
/api/health:
get:
tags:
- health
summary: Service health check
operationId: getHealth
responses:
'200':
description: Service is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/api/v1/health:
get:
tags:
- health
summary: Service health check (v1)
operationId: getHealthV1
responses:
'200':
description: Service is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/api/versions:
get:
tags:
- versions
summary: List supported API versions
operationId: getVersions
responses:
'200':
description: Supported versions
content:
application/json:
schema:
type: object
properties:
versions:
type: array
items:
type: object
properties:
version:
type: string
example: v1
status:
type: string
example: supported
prefix:
type: string
example: /api/v1
/api/fx-rates:
get:
tags:
- fx-rates
summary: Get current FX rates
operationId: getFxRates
responses:
'200':
description: FX rate data
content:
application/json:
schema:
type: object
/api/v1/fx-rates:
get:
tags:
- fx-rates
summary: Get current FX rates (v1)
operationId: getFxRatesV1
security:
- ApiKeyHeader: []
- BearerAuth: []
responses:
'200':
description: FX rate data
'401':
description: Invalid or missing API key
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/offramp/currencies:
get:
tags:
- offramp
summary: List supported fiat currencies
operationId: getCurrencies
description: Returns supported currencies. Response is cached for 5 minutes.
responses:
'200':
description: List of currencies
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Currency'
example:
data:
- code: NGN
name: Nigerian Naira
symbol: ₦
- code: KES
name: Kenyan Shilling
symbol: KSh
'500':
description: Paycrest API unreachable
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/offramp/currencies:
get:
tags:
- offramp
summary: List supported fiat currencies (v1)
operationId: getCurrenciesV1
security:
- ApiKeyHeader: []
- BearerAuth: []
responses: