-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathopenapi.json
More file actions
531 lines (531 loc) · 17.9 KB
/
openapi.json
File metadata and controls
531 lines (531 loc) · 17.9 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
{
"openapi": "3.1.0",
"info": {
"title": "StreamPay API",
"version": "2.0.0",
"description": "REST API for the StreamPay payment-streaming platform on Stellar.\n\nAll error responses use the canonical envelope:\n```json\n{ \"error\": { \"code\": \"ERROR_CODE\", \"message\": \"Human-readable detail.\", \"request_id\": \"req_...\" } }\n```\n\nv1 stream paths are deprecated and will be removed. Use `/api/v2/streams`."
},
"servers": [
{ "url": "http://localhost:3000", "description": "Local development" }
],
"security": [
{ "bearerAuth": [] }
],
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "opaque",
"description": "Obtain a token via POST /api/auth/wallet, then pass it as `Authorization: Bearer <token>`."
}
},
"schemas": {
"ErrorEnvelope": {
"type": "object",
"required": ["error"],
"properties": {
"error": {
"type": "object",
"required": ["code", "message", "request_id"],
"properties": {
"code": {
"type": "string",
"description": "Machine-readable error code.",
"example": "NOT_FOUND"
},
"message": {
"type": "string",
"description": "Human-readable description safe to display to clients.",
"example": "The requested stream does not exist."
},
"request_id": {
"type": "string",
"description": "Opaque identifier for this request, useful for log correlation.",
"example": "req_01HZ9ABCDEF"
}
}
}
}
},
"StreamV2": {
"type": "object",
"required": ["id", "recipient", "rate", "status", "allowed_actions", "created_at", "settlement"],
"properties": {
"id": {
"type": "string",
"description": "Unique stream identifier.",
"example": "stream_lf3k9z"
},
"recipient": {
"type": "string",
"description": "Stellar public key of the payment recipient.",
"example": "GABC1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ234567890ABCDEFG"
},
"rate": {
"type": "string",
"description": "Human-readable payment rate.",
"example": "120 XLM/month"
},
"status": {
"type": "string",
"enum": ["draft", "active", "paused", "ended"],
"description": "Current lifecycle state of the stream."
},
"allowed_actions": {
"type": "array",
"items": { "type": "string" },
"description": "Actions the authenticated user may perform on this stream. Replaces v1 `actions`.",
"example": ["pause", "stop"]
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "ISO-8601 creation timestamp. Replaces v1 `createdAt`.",
"example": "2024-01-15T10:00:00.000Z"
},
"settlement": {
"oneOf": [
{
"type": "object",
"required": ["settled_at", "amount", "currency"],
"properties": {
"settled_at": {
"type": "string",
"format": "date-time",
"example": "2024-02-01T12:00:00.000Z"
},
"amount": {
"type": "string",
"example": "360 XLM"
},
"currency": {
"type": "string",
"example": "XLM"
}
}
},
{ "type": "null" }
],
"description": "Settlement details once the stream has been settled, otherwise `null`. Clients must handle `null` explicitly."
}
}
},
"WalletChallenge": {
"type": "object",
"required": ["challenge", "expires_at"],
"properties": {
"challenge": {
"type": "string",
"description": "One-time nonce the client must sign with their Stellar private key.",
"example": "streampay_auth_1716000000000_x7k2m"
},
"expires_at": {
"type": "string",
"format": "date-time",
"description": "Challenge expiry (5 minutes from issuance).",
"example": "2024-01-15T10:05:00.000Z"
}
}
},
"WalletToken": {
"type": "object",
"required": ["token", "expires_at"],
"properties": {
"token": {
"type": "string",
"description": "Opaque bearer token. Pass as `Authorization: Bearer <token>`.",
"example": "tok_R0FCQzEyMzQ1Njc4OTA"
},
"expires_at": {
"type": "string",
"format": "date-time",
"description": "Token expiry (24 hours from issuance).",
"example": "2024-01-16T10:00:00.000Z"
}
}
}
},
"responses": {
"400": {
"description": "Bad request — invalid input.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorEnvelope" },
"example": {
"error": {
"code": "BAD_REQUEST",
"message": "Request body must include 'recipient' and 'rate'.",
"request_id": "req_01HZ9ABCDEF"
}
}
}
}
},
"401": {
"description": "Unauthorized — missing or invalid bearer token.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorEnvelope" },
"example": {
"error": {
"code": "UNAUTHORIZED",
"message": "Bearer token required.",
"request_id": "req_01HZ9ABCDEF"
}
}
}
}
},
"403": {
"description": "Forbidden.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorEnvelope" },
"example": {
"error": {
"code": "FORBIDDEN",
"message": "This endpoint is not available in production.",
"request_id": "req_01HZ9ABCDEF"
}
}
}
}
},
"500": {
"description": "Internal server error.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ErrorEnvelope" },
"example": {
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "An unexpected error occurred.",
"request_id": "req_01HZ9ABCDEF"
}
}
}
}
}
}
},
"paths": {
"/api/auth/wallet": {
"get": {
"operationId": "getWalletChallenge",
"summary": "Issue a wallet authentication challenge",
"description": "Returns a one-time nonce the client must sign with their Stellar private key, then submit to `POST /api/auth/wallet`.",
"security": [],
"tags": ["Auth"],
"parameters": [
{
"name": "address",
"in": "query",
"required": true,
"description": "Stellar public key (G…, 56 characters).",
"schema": {
"type": "string",
"pattern": "^G[A-Z2-7]{55}$",
"example": "GABC1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ234567890ABCDEFG"
}
}
],
"responses": {
"200": {
"description": "Challenge issued.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/WalletChallenge" }
}
}
},
"400": { "$ref": "#/components/responses/400" },
"500": { "$ref": "#/components/responses/500" }
}
},
"post": {
"operationId": "verifyWalletSignature",
"summary": "Verify a signed challenge and issue a bearer token",
"security": [],
"tags": ["Auth"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["address", "challenge", "signature"],
"properties": {
"address": {
"type": "string",
"description": "Stellar public key.",
"example": "GABC1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ234567890ABCDEFG"
},
"challenge": {
"type": "string",
"description": "The nonce returned by GET /api/auth/wallet.",
"example": "streampay_auth_1716000000000_x7k2m"
},
"signature": {
"type": "string",
"description": "Base64-encoded Ed25519 signature of the challenge.",
"example": "dGVzdHNpZ25hdHVyZQ=="
}
}
}
}
}
},
"responses": {
"200": {
"description": "Token issued.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/WalletToken" }
}
}
},
"400": { "$ref": "#/components/responses/400" },
"401": { "$ref": "#/components/responses/401" },
"500": { "$ref": "#/components/responses/500" }
}
}
},
"/api/v2/streams": {
"get": {
"operationId": "listStreamsV2",
"summary": "List payment streams (v2)",
"description": "Returns all streams owned by the authenticated user in the v2 shape (`allowed_actions`, `created_at`, `settlement`).",
"tags": ["Streams"],
"security": [{ "bearerAuth": [] }],
"responses": {
"200": {
"description": "Stream list.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["streams"],
"properties": {
"streams": {
"type": "array",
"items": { "$ref": "#/components/schemas/StreamV2" }
}
}
},
"example": {
"streams": [
{
"id": "stream_lf3k9z",
"recipient": "GABC1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ234567890ABCDEFG",
"rate": "120 XLM/month",
"status": "active",
"allowed_actions": ["pause", "stop"],
"created_at": "2024-01-15T10:00:00.000Z",
"settlement": null
}
]
}
}
}
},
"401": { "$ref": "#/components/responses/401" },
"500": { "$ref": "#/components/responses/500" }
}
},
"post": {
"operationId": "createStreamV2",
"summary": "Create a payment stream (v2)",
"tags": ["Streams"],
"security": [{ "bearerAuth": [] }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["recipient", "rate"],
"properties": {
"recipient": {
"type": "string",
"description": "Stellar public key of the recipient.",
"example": "GABC1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ234567890ABCDEFG"
},
"rate": {
"type": "string",
"description": "Payment rate string.",
"example": "120 XLM/month"
},
"currency": {
"type": "string",
"description": "Asset code (optional, defaults to XLM).",
"example": "XLM"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Stream created. Initial status is `draft`.",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/StreamV2" },
"example": {
"id": "stream_lf3k9z",
"recipient": "GABC1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ234567890ABCDEFG",
"rate": "120 XLM/month",
"status": "draft",
"allowed_actions": ["start"],
"created_at": "2024-01-15T10:00:00.000Z",
"settlement": null
}
}
}
},
"400": { "$ref": "#/components/responses/400" },
"401": { "$ref": "#/components/responses/401" },
"500": { "$ref": "#/components/responses/500" }
}
}
},
"/api/webhooks/dlq": {
"post": {
"operationId": "receiveDlqWebhook",
"summary": "Receive a dead-letter-queue webhook event",
"description": "Accepts failed webhook events for reprocessing. No authentication required (secured at the network/gateway level).",
"security": [],
"tags": ["Webhooks"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "Arbitrary webhook event payload.",
"example": { "event": "payment.failed", "id": "evt_001" }
}
}
}
},
"responses": {
"200": {
"description": "Event accepted.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["received"],
"properties": {
"received": { "type": "boolean", "example": true }
}
}
}
}
},
"400": { "$ref": "#/components/responses/400" },
"500": { "$ref": "#/components/responses/500" }
}
}
},
"/api/webhooks/deliveries": {
"get": {
"operationId": "listWebhookDeliveries",
"summary": "List webhook delivery attempts",
"security": [],
"tags": ["Webhooks"],
"parameters": [
{
"name": "limit",
"in": "query",
"description": "Number of records to return (1–100, default 20).",
"schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 }
},
{
"name": "cursor",
"in": "query",
"description": "Opaque pagination cursor from a previous response.",
"schema": { "type": "string" }
}
],
"responses": {
"200": {
"description": "Delivery list.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["deliveries", "cursor", "limit"],
"properties": {
"deliveries": { "type": "array", "items": { "type": "object" } },
"cursor": { "type": ["string", "null"] },
"limit": { "type": "integer" }
}
}
}
}
},
"400": { "$ref": "#/components/responses/400" },
"500": { "$ref": "#/components/responses/500" }
}
}
},
"/api/debug/kms-sign": {
"post": {
"operationId": "debugKmsSign",
"summary": "Sign a payload via KMS (debug only)",
"description": "**Non-production only.** Returns a base64-encoded signature for the given payload. Returns 403 in production.",
"security": [],
"tags": ["Debug"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["payload"],
"properties": {
"payload": {
"type": "string",
"description": "Base64-encoded data to sign.",
"example": "aGVsbG8="
}
}
}
}
}
},
"responses": {
"200": {
"description": "Signature produced.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["signature"],
"properties": {
"signature": {
"type": "string",
"description": "Base64-encoded signature.",
"example": "c2lnbmVkOmFHVnNiRzg9"
}
}
}
}
}
},
"400": { "$ref": "#/components/responses/400" },
"403": { "$ref": "#/components/responses/403" },
"500": { "$ref": "#/components/responses/500" }
}
}
}
},
"tags": [
{ "name": "Auth", "description": "Wallet-based authentication flow" },
{ "name": "Streams", "description": "Payment stream management (v2)" },
{ "name": "Webhooks", "description": "Webhook ingestion and delivery history" },
{ "name": "Debug", "description": "Non-production debugging utilities" }
]
}