forked from StellarGateLabs/StellarGate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1934 lines (1857 loc) · 66.2 KB
/
Copy pathopenapi.yaml
File metadata and controls
1934 lines (1857 loc) · 66.2 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: StellarGate
description: |-
Payment gateway API built on Stellar for accepting and managing payments in
XLM and USDC.
## Versioning
`/v1` is the canonical, versioned surface — use it for all new integrations.
The same operations are also served **unprefixed** (`POST /payments`, …) for
backward compatibility (issue #121); those paths are **deprecated** and every
response on them carries, per RFC 8594 / RFC 8288:
```
Deprecation: true
Link: </v1/…>; rel="successor-version"
```
The deprecated operations are documented below and marked `deprecated: true`
so a generated client surfaces the move. Operational endpoints (`/health`,
`/ready`, `/metrics`, `/dashboard`) are infrastructure rather than contract
and are intentionally unversioned.
Every response also carries an `x-request-id` header — echoed from the
caller's or generated server-side — worth quoting in a support request.
version: 0.1.0
license:
name: MIT
url: https://github.com/StellarGateLabs/StellarGate/blob/main/LICENSE
servers:
- url: http://localhost:3000
description: Local development
paths:
/:
get:
operationId: root
summary: Service root
description: >-
Content-negotiated on `Accept`, not User-Agent: a browser (`Accept:
text/html`) is redirected to the operator dashboard, and every other
caller — `fetch()`, `curl`, the dashboard's own version lookup, an
uptime check — gets the plain-text version string. This exists so a
hosting platform's "open in browser" link lands somewhere useful
instead of a bare line of text with no hint that a UI exists one path
away.
security: []
responses:
"200":
description: Not a browser request (or no Accept header) — plain-text version string
content:
text/plain:
schema:
type: string
example: StellarGate API v0.1.0
"307":
description: >-
Browser request (`Accept` contains `text/html`) — temporary
redirect to /dashboard
headers:
Location:
schema:
type: string
example: /dashboard
/health:
get:
operationId: health
summary: Health check
# Explicitly unauthenticated. Stating this is not redundant: without it a
# reader cannot tell "no credential required" from "the spec forgot to
# say", which is the ambiguity this whole block exists to remove.
security: []
responses:
"200":
description: Service is up
headers:
X-Request-Id:
$ref: "#/components/headers/XRequestId"
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
/ready:
get:
operationId: ready
summary: Readiness probe
description: >-
Distinct from /health: this is what an orchestrator's readiness probe
should target, not /health, which returns 200 unconditionally as long
as the process is up (#103). Returns 200 only when the database
responds AND (if a Horizon gateway is configured) Horizon is reachable
AND the payment-detection cursor has advanced recently. A pod that
cannot detect on-chain payments should not receive traffic even though
the process itself is alive.
security: []
responses:
"200":
description: Database reachable, and Horizon + cursor freshness checks pass (or no gateway is configured)
content:
application/json:
schema:
$ref: "#/components/schemas/ReadyResponse"
"503":
description: Not ready — the database is unreachable, Horizon is unreachable, or the detection cursor has stalled
content:
application/json:
schema:
$ref: "#/components/schemas/ReadyResponse"
examples:
database_unreachable:
summary: Database unreachable
value:
status: unavailable
reason: database unreachable
cursor_stalled:
summary: Payment detection stalled
value:
status: unavailable
reason: >-
payment detection stalled: no successful poll or stream
event in 900s (limit 300s)
/metrics:
get:
operationId: metrics
summary: Prometheus-compatible metrics snapshot
description: >-
Text-exposition-format counters and gauges covering webhook delivery,
authentication, and background task health. Currently unauthenticated
— see issue #250 for the access-control decision tracked against that.
security: []
responses:
"200":
description: Metrics snapshot
content:
text/plain; version=0.0.4:
schema:
type: string
/merchants:
post:
operationId: provisionMerchant
summary: Provision a new merchant
description: >-
There is no self-service signup; minting a merchant and its first
credential is an operator action gated by the X-Admin-Secret header.
The response's `api_key` is shown exactly once — the server stores
only a hash, so this is the only time the raw key is ever recoverable.
An unset ADMIN_PROVISIONING_SECRET disables this route entirely
(every request gets 401), rather than leaving it open.
security:
- adminSecret: []
requestBody:
required: false
content:
application/json:
schema:
$ref: "#/components/schemas/ProvisionMerchantRequest"
responses:
"201":
description: Merchant provisioned
content:
application/json:
schema:
$ref: "#/components/schemas/ProvisionMerchantResponse"
"400":
description: rate_limit_per_sec is not a positive integer, or the body has an unrecognised field
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_rate_limit:
summary: Non-positive rate limit
value:
error: rate_limit_per_sec must be positive
code: invalid_rate_limit
"401":
$ref: "#/components/responses/AdminUnauthorized"
/merchants/{id}/keys:
post:
operationId: issueApiKey
summary: Issue an additional API key
description: >-
Rotation is issue-then-revoke, not replace-in-place: the new key is
live immediately while the old one keeps working, so a merchant can
deploy the new credential and never has a window with no valid key.
The response's `api_key` is shown exactly once, the same as
provisioning.
security:
- adminSecret: []
parameters:
- name: id
in: path
required: true
description: Merchant ID
schema:
type: string
format: uuid
requestBody:
required: false
content:
application/json:
schema:
$ref: "#/components/schemas/IssueKeyRequest"
responses:
"201":
description: Key issued
content:
application/json:
schema:
$ref: "#/components/schemas/IssueKeyResponse"
"400":
description: Label exceeds 100 characters (or 400 bytes), contains a control character, or the request body has an unrecognised field
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_label:
summary: Label too long
value:
error: label must be at most 100 characters
code: invalid_label
"401":
$ref: "#/components/responses/AdminUnauthorized"
"404":
description: No merchant with that ID
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
merchant_not_found:
summary: Merchant not found
value:
error: merchant not found
code: merchant_not_found
get:
operationId: listApiKeys
summary: List a merchant's API keys
description: >-
Metadata only — never the secret, which is unrecoverable by design.
`prefix` is enough for an operator to identify which key to revoke.
Keyset (cursor) paginated with the same conventions as `GET
/payments`: revoked keys are kept forever as an audit trail, so a
merchant that rotates regularly accumulates rows without bound, and
this endpoint used to return every one of them in a single unbounded
response (issue #262).
security:
- adminSecret: []
parameters:
- name: id
in: path
required: true
description: Merchant ID
schema:
type: string
format: uuid
- name: active
in: query
schema:
type: boolean
description: >-
`true` returns only usable keys, `false` only revoked ones.
Omitted (the default) returns both, including the revoked audit
trail.
- name: limit
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 20
description: Page size
- name: cursor
in: query
schema:
type: string
description: Opaque cursor for keyset pagination (returned as next_cursor)
responses:
"200":
description: A page of the merchant's keys
content:
application/json:
schema:
$ref: "#/components/schemas/ListApiKeysResponse"
"400":
description: Invalid query parameter
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_cursor:
summary: Invalid cursor
value:
error: invalid cursor
code: invalid_cursor
invalid_limit:
summary: limit outside 1..=100
value:
error: "limit must be between 1 and 100 (got 5000)"
code: invalid_limit
"401":
$ref: "#/components/responses/AdminUnauthorized"
"404":
description: No merchant with that ID
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
merchant_not_found:
summary: Merchant not found
value:
error: merchant not found
code: merchant_not_found
/merchants/{id}/keys/{key_id}:
delete:
operationId: revokeApiKey
summary: Revoke an API key
description: >-
Refuses to revoke a merchant's last active key — this API has no
self-service recovery, so that would turn a routine revocation into an
incident. Issue a replacement first.
security:
- adminSecret: []
parameters:
- name: id
in: path
required: true
description: Merchant ID
schema:
type: string
format: uuid
- name: key_id
in: path
required: true
schema:
type: string
format: uuid
responses:
"200":
description: Key revoked
content:
application/json:
schema:
$ref: "#/components/schemas/RevokeApiKeyResponse"
"400":
description: This is the merchant's only active key
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
last_active_key:
summary: Only active key
value:
error: >-
cannot revoke a merchant's only active key — issue a
replacement first
code: last_active_key
"401":
$ref: "#/components/responses/AdminUnauthorized"
"404":
description: No such merchant, or no active key with that ID for this merchant
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
merchant_not_found:
summary: Merchant not found
value:
error: merchant not found
code: merchant_not_found
key_not_found:
summary: Key not found
value:
error: no active key with that id for this merchant
code: key_not_found
/merchants/{id}/rate-limit:
put:
operationId: setMerchantRateLimit
summary: Set or clear a merchant's per-second rate-limit override
description: >-
Sets (or clears) an individual per-merchant quota on the authenticated
rate limiter, independent of the global `RATE_LIMIT_REQUESTS_PER_SEC`
default. Passing `null` for `rate_limit_per_sec` removes the override
and returns the merchant to the configured default. Admin only.
security:
- adminSecret: []
parameters:
- name: id
in: path
required: true
description: Merchant ID
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SetRateLimitRequest"
responses:
"200":
description: Rate limit updated (or cleared)
content:
application/json:
schema:
$ref: "#/components/schemas/SetRateLimitResponse"
"400":
description: rate_limit_per_sec is not a positive integer, or the request body has an unrecognised field
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_rate_limit:
summary: Non-positive rate limit
value:
error: rate_limit_per_sec must be positive
code: invalid_rate_limit
"401":
$ref: "#/components/responses/AdminUnauthorized"
"404":
description: No merchant with that ID
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
merchant_not_found:
summary: Merchant not found
value:
error: merchant not found
code: merchant_not_found
/payments:
post:
operationId: createPayment
summary: Create a payment intent
description: >-
The merchant that owns the intent is taken from the bearer token, not
from the request body — there is no way to create a payment on behalf
of a different merchant. `CreatePaymentRequest` has no `merchant_id`
property, and the server rejects any body containing one with `400
unknown_field` rather than silently ignoring it.
security:
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/IdempotencyKey"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreatePaymentRequest"
responses:
"201":
description: Payment intent created
headers:
X-RateLimit-Limit:
$ref: "#/components/headers/XRateLimitLimit"
X-RateLimit-Remaining:
$ref: "#/components/headers/XRateLimitRemaining"
X-RateLimit-Reset:
$ref: "#/components/headers/XRateLimitReset"
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"
"200":
description: >-
Idempotent replay — a prior request carrying the same
`Idempotency-Key` (for this merchant) already created this intent,
so the original is returned rather than a duplicate.
headers:
X-Request-Id:
$ref: "#/components/headers/XRequestId"
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"
"401":
$ref: "#/components/responses/Unauthorized"
"409":
description: >-
The request carried an `Idempotency-Key` that another in-flight
request for the same merchant is already creating a payment for,
and that request had not committed yet. Transient: retry after
the interval in `Retry-After`.
headers:
Retry-After:
$ref: "#/components/headers/RetryAfter"
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
idempotency_conflict:
summary: Concurrent create raced on the same idempotency key
value:
error: concurrent request conflict, please retry
code: idempotency_conflict
"429":
description: >-
Rate limit exceeded. The request fell into the `payments` bucket,
whose quota is RATE_LIMIT_REQUESTS_PER_SEC × 1. See the Rate
Limiting section of the README for the full bucket/quota model.
headers:
Retry-After:
$ref: "#/components/headers/RetryAfter"
X-RateLimit-Limit:
$ref: "#/components/headers/XRateLimitLimit"
X-RateLimit-Remaining:
$ref: "#/components/headers/XRateLimitRemaining"
X-RateLimit-Reset:
$ref: "#/components/headers/XRateLimitReset"
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
rate_limit_exceeded:
summary: Rate limit exceeded
value:
error: rate limit exceeded
code: rate_limit_exceeded
"503":
description: >-
The gateway account currently has no trustline for the requested
asset, confirmed by the recurring trustline checker (see the
Trustlines section of the README) — an intent minted now could
only bounce on-chain. An asset that has never been checked yet,
or whose last check failed to reach Horizon, is not rejected on
that basis alone.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
trustline_missing:
summary: No trustline for this asset
value:
error: >-
the gateway account currently has no trustline for
USDC; payments in this asset cannot be received until
one is established
code: trustline_missing
get:
operationId: listPayments
summary: List payments
description: >-
Scoped to the merchant that owns the API key. There is no parameter for
selecting a different merchant.
The parameter set is closed: a query parameter not listed below is
rejected with `400 unknown_parameter` naming it, rather than ignored.
A discarded filter would otherwise be returned as an unfiltered `200`
page, so `?stauts=completed` listed every payment including pending
ones.
security:
- bearerAuth: []
parameters:
- name: status
in: query
schema:
$ref: "#/components/schemas/PaymentStatus"
description: Filter by status
- name: limit
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 20
description: Page size
- name: offset
in: query
schema:
type: integer
minimum: 0
maximum: 10000
default: 0
description: >-
Rows to skip (offset pagination, deprecated in favour of
`cursor`). SQLite implements OFFSET by producing and discarding
every skipped row, so cost grows with depth; values above 10000
are rejected with `400 invalid_offset` rather than answered.
Mutually exclusive with `cursor`: sending both is
`400 conflicting_pagination`, decided on presence rather than
value, so even `offset=0` alongside a cursor is rejected.
- name: cursor
in: query
schema:
type: string
description: >-
Opaque cursor for keyset pagination (returned as next_cursor).
Selects keyset mode, whose response carries `payments`, `limit` and
`next_cursor` but no `offset` or `total`. Mutually exclusive with
`offset`: sending both is `400 conflicting_pagination`.
- name: include_total
in: query
schema:
type: boolean
default: false
description: >-
Offset pagination only; has no effect with cursor set. `total`
costs a full COUNT(*) scan over every matching row — SQLite has no
cached row count — so it is computed only when this is `true`,
and the `total` field is otherwise absent from the response
entirely (not `null`). Keyset (cursor) pagination is the
recommended approach and has never returned `total`.
responses:
"200":
description: Paginated list of payments
headers:
X-Request-Id:
$ref: "#/components/headers/XRequestId"
content:
application/json:
schema:
$ref: "#/components/schemas/ListPaymentsResponse"
"400":
description: Invalid query parameter
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_status:
summary: Invalid status filter
value:
error: "invalid status 'foo'; valid: pending, completed, underpaid, expired"
code: invalid_status
invalid_cursor:
summary: Invalid cursor
value:
error: invalid cursor
code: invalid_cursor
invalid_offset:
summary: Offset beyond the maximum
value:
error: "offset exceeds maximum of 10000; use cursor pagination instead (see the `cursor` parameter and `next_cursor` in the response)"
code: invalid_offset
conflicting_pagination:
summary: Both cursor and offset supplied
value:
error: "cursor and offset are mutually exclusive; use cursor for keyset pagination"
code: conflicting_pagination
invalid_limit:
summary: limit outside 1..=100
value:
error: "limit must be between 1 and 100 (got 5000)"
code: invalid_limit
unknown_parameter:
summary: Unrecognised query parameter
value:
error: "invalid query string: Failed to deserialize query string: unknown field `stauts`, expected one of `status`, `limit`, `offset`, `cursor`, `include_total`"
code: unknown_parameter
"401":
$ref: "#/components/responses/Unauthorized"
/v1/payments/webhooks:
get:
operationId: listMerchantWebhooks
summary: Dead-letter view — all failed deliveries across a merchant's payments
description: >-
Returns webhook deliveries across **all** of the authenticated
merchant's payments, defaulting to `status=failed`. This is the
endpoint to reach for when a merchant says they are missing events,
because that question arrives without a payment id —
`GET /v1/payments/{id}/webhooks` can only answer it if you already
know where to look.
The parameter set is closed: an unrecognised query parameter is
rejected with `400 unknown_parameter`. This matters most here where
`status` defaults to `failed`: a typo'd filter would otherwise return
the full dead-letter list and look entirely plausible.
security:
- bearerAuth: []
parameters:
- name: status
in: query
schema:
type: string
enum: [pending, delivered, failed]
default: failed
description: Filter deliveries by status. Defaults to failed.
- name: limit
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 20
description: Page size
- name: cursor
in: query
schema:
type: string
description: Opaque cursor for keyset pagination (returned as next_cursor)
responses:
"200":
description: A page of the merchant's webhook deliveries
headers:
X-Request-Id:
$ref: "#/components/headers/XRequestId"
content:
application/json:
schema:
$ref: "#/components/schemas/ListMerchantDeliveriesResponse"
"400":
description: Invalid query parameter
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_status:
summary: Invalid status filter
value:
error: "invalid delivery status 'foo'; valid: pending, delivered, failed"
code: invalid_status
invalid_cursor:
summary: Invalid cursor
value:
error: invalid cursor
code: invalid_cursor
invalid_limit:
summary: limit outside 1..=100
value:
error: "limit must be between 1 and 100 (got 5000)"
code: invalid_limit
unknown_parameter:
summary: Unrecognised query parameter
value:
error: "invalid query string: Failed to deserialize query string: unknown field `staus`, expected one of `status`, `limit`, `cursor`"
code: unknown_parameter
"401":
$ref: "#/components/responses/Unauthorized"
/v1/payments/webhooks/redeliver:
post:
operationId: redeliverWebhooksBulk
summary: Bulk-requeue failed webhook deliveries for retry
description: >-
Requeues failed deliveries so the background redrive worker retries
them. Omit `delivery_ids` (or send an empty body) to requeue every
failed delivery for this merchant; supply a list to requeue specific
ones (max 100 per request).
**This endpoint sends nothing itself.** It resets matching rows to
`pending` with `attempts = 0` and hands them to the redrive worker,
whose `WEBHOOK_REDRIVE_CONCURRENCY` and exponential backoff already
bound the outbound rate. Requeueing thousands of deliveries therefore
costs one `UPDATE` and cannot stampede a receiver that has only just
come back up.
Requeueing also acknowledges the deliveries, returning them to ordinary
retention.
security:
- bearerAuth: []
requestBody:
required: false
content:
application/json:
schema:
$ref: "#/components/schemas/RedeliverBulkRequest"
responses:
"200":
description: Deliveries requeued for the redrive worker
headers:
X-Request-Id:
$ref: "#/components/headers/XRequestId"
content:
application/json:
schema:
$ref: "#/components/schemas/RedeliverBulkResponse"
"400":
description: More than 100 delivery_ids supplied, or the body has an unrecognised field
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
too_many_delivery_ids:
summary: Delivery id list exceeds the cap
value:
error: "at most 100 delivery_ids per request; omit the field to requeue every failed delivery"
code: too_many_delivery_ids
"401":
$ref: "#/components/responses/Unauthorized"
/v1/payments/{id}:
get:
operationId: getPayment
summary: Get a payment by ID
description: >-
Authentication is optional here and changes what comes back, so this is
the one operation whose security requirement is genuinely a choice
rather than a gate. It stays reachable without a credential so a
checkout page can poll it directly.
**No credential** returns a minimal public projection — `id`, `status`
and `expires_at`. Enough to answer "has this been paid yet", and
nothing else. It deliberately omits `merchant_id`, every amount and
`tx_hash`: payment ids travel through logs, referrers and browser
history, so anything on this response should be treated as effectively
public.
**The owning merchant's key** returns the full record.
**Another merchant's key** returns `404`, the same answer an unknown id
gets. A `403` would confirm the payment exists and belongs to someone
else.
**An invalid or revoked key** returns `401` rather than silently
falling back to the public view, so a typo'd credential says so instead
of leaving the caller wondering why fields are missing.
security:
# An empty requirement alongside the scheme is how OpenAPI expresses
# "auth optional, but it changes the response". Flattening this to a
# single requirement would misdocument the endpoint most likely to be
# integrated against.
- {} # anonymous -> PublicPaymentView
- bearerAuth: [] # owner -> Payment
parameters:
- $ref: "#/components/parameters/PaymentId"
responses:
"200":
description: >-
Payment found. The schema depends on the credential: the full
Payment for the owning merchant, PublicPaymentView for an
anonymous caller.
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/Payment"
- $ref: "#/components/schemas/PublicPaymentView"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
description: >-
No such payment, or it belongs to another merchant — the two are
deliberately indistinguishable.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/v1/payments/{id}/webhooks:
get:
operationId: listWebhookDeliveries
summary: List webhook deliveries for a payment
security:
- bearerAuth: []
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: status
in: query
schema:
type: string
enum: [pending, delivered, failed]
description: Filter deliveries by status
- name: limit
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 20
description: Page size
- name: cursor
in: query
schema:
type: string
description: Opaque cursor for keyset pagination (returned as next_cursor)
responses:
"200":
description: Webhook delivery history
headers:
X-Request-Id:
$ref: "#/components/headers/XRequestId"
content:
application/json:
schema:
$ref: "#/components/schemas/ListWebhookDeliveriesResponse"
"400":
description: Invalid query parameter
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
examples:
invalid_cursor:
summary: Invalid cursor
value:
error: invalid cursor
code: invalid_cursor
invalid_limit:
summary: limit outside 1..=100
value:
error: "limit must be between 1 and 100 (got 5000)"
code: invalid_limit
unknown_parameter:
summary: Unrecognised query parameter
value:
error: "invalid query string: Failed to deserialize query string: unknown field `staus`, expected one of `status`, `limit`, `cursor`"
code: unknown_parameter
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
/v1/payments/{id}/webhooks/{delivery_id}/redeliver:
post:
operationId: redeliverWebhook
summary: Re-attempt a webhook delivery
security:
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/PaymentId"
- $ref: "#/components/parameters/DeliveryId"
responses:
"200":
description: Redelivery succeeded
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"502":
$ref: "#/components/responses/WebhookBadGateway"
# ---------------------------------------------------------------------------
# Deprecated unprefixed mount. These are aliases of the /v1 operations above,
# kept served for backward compatibility (issue #121). Every response carries
# `Deprecation` and `Link: rel="successor-version"` headers. New integrations
# must use /v1.
# ---------------------------------------------------------------------------
/payments:
post:
operationId: createPaymentLegacy
summary: Create a payment intent (deprecated)
description: Deprecated alias of `POST /v1/payments`.
deprecated: true
parameters:
- $ref: "#/components/parameters/IdempotencyKey"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreatePaymentRequest"
responses:
"201":
description: Payment intent created
headers:
X-Request-Id:
$ref: "#/components/headers/XRequestId"
Deprecation:
$ref: "#/components/headers/Deprecation"
Link:
$ref: "#/components/headers/Link"
content:
application/json:
schema:
$ref: "#/components/schemas/Payment"
"200":
description: Idempotent replay — see `POST /v1/payments`.
headers:
X-Request-Id: