agentspay 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/.env.example +40 -0
  2. package/README.md +35 -4
  3. package/VERIFICATION_SUMMARY.txt +151 -0
  4. package/dist/api/server.d.ts.map +1 -1
  5. package/dist/api/server.js +530 -74
  6. package/dist/api/server.js.map +1 -1
  7. package/dist/bsv/crypto.d.ts +65 -0
  8. package/dist/bsv/crypto.d.ts.map +1 -0
  9. package/dist/bsv/crypto.js +158 -0
  10. package/dist/bsv/crypto.js.map +1 -0
  11. package/dist/bsv/mnee.d.ts +88 -0
  12. package/dist/bsv/mnee.d.ts.map +1 -0
  13. package/dist/bsv/mnee.js +173 -0
  14. package/dist/bsv/mnee.js.map +1 -0
  15. package/dist/bsv/opreturn.d.ts +22 -0
  16. package/dist/bsv/opreturn.d.ts.map +1 -0
  17. package/dist/bsv/opreturn.js +117 -0
  18. package/dist/bsv/opreturn.js.map +1 -0
  19. package/dist/bsv/whatsonchain.d.ts +46 -0
  20. package/dist/bsv/whatsonchain.d.ts.map +1 -0
  21. package/dist/bsv/whatsonchain.js +98 -0
  22. package/dist/bsv/whatsonchain.js.map +1 -0
  23. package/dist/config.d.ts +38 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +85 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/currency/currency.d.ts +70 -0
  28. package/dist/currency/currency.d.ts.map +1 -0
  29. package/dist/currency/currency.js +137 -0
  30. package/dist/currency/currency.js.map +1 -0
  31. package/dist/disputes/dispute.d.ts +50 -0
  32. package/dist/disputes/dispute.d.ts.map +1 -0
  33. package/dist/disputes/dispute.js +162 -0
  34. package/dist/disputes/dispute.js.map +1 -0
  35. package/dist/docs/openapi.yaml +1079 -0
  36. package/dist/docs/swagger.d.ts +12 -0
  37. package/dist/docs/swagger.d.ts.map +1 -0
  38. package/dist/docs/swagger.js +104 -0
  39. package/dist/docs/swagger.js.map +1 -0
  40. package/dist/middleware/auth.d.ts +20 -0
  41. package/dist/middleware/auth.d.ts.map +1 -0
  42. package/dist/middleware/auth.js +32 -0
  43. package/dist/middleware/auth.js.map +1 -0
  44. package/dist/middleware/rateLimit.d.ts +25 -0
  45. package/dist/middleware/rateLimit.d.ts.map +1 -0
  46. package/dist/middleware/rateLimit.js +61 -0
  47. package/dist/middleware/rateLimit.js.map +1 -0
  48. package/dist/payment/payment.d.ts +79 -9
  49. package/dist/payment/payment.d.ts.map +1 -1
  50. package/dist/payment/payment.js +387 -47
  51. package/dist/payment/payment.js.map +1 -1
  52. package/dist/registry/db.d.ts.map +1 -1
  53. package/dist/registry/db.js +110 -3
  54. package/dist/registry/db.js.map +1 -1
  55. package/dist/registry/registry.d.ts +1 -1
  56. package/dist/registry/registry.d.ts.map +1 -1
  57. package/dist/registry/registry.js +12 -4
  58. package/dist/registry/registry.js.map +1 -1
  59. package/dist/types/index.d.ts +34 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/types/index.js.map +1 -1
  62. package/dist/utils/validation.d.ts +27 -0
  63. package/dist/utils/validation.d.ts.map +1 -0
  64. package/dist/utils/validation.js +164 -0
  65. package/dist/utils/validation.js.map +1 -0
  66. package/dist/verification/receipt.d.ts +42 -0
  67. package/dist/verification/receipt.d.ts.map +1 -0
  68. package/dist/verification/receipt.js +10 -0
  69. package/dist/verification/receipt.js.map +1 -0
  70. package/dist/verification/verification.d.ts +41 -0
  71. package/dist/verification/verification.d.ts.map +1 -0
  72. package/dist/verification/verification.js +217 -0
  73. package/dist/verification/verification.js.map +1 -0
  74. package/dist/wallet/providerManager.d.ts +32 -0
  75. package/dist/wallet/providerManager.d.ts.map +1 -0
  76. package/dist/wallet/providerManager.js +118 -0
  77. package/dist/wallet/providerManager.js.map +1 -0
  78. package/dist/wallet/providers/handcash.d.ts +22 -0
  79. package/dist/wallet/providers/handcash.d.ts.map +1 -0
  80. package/dist/wallet/providers/handcash.js +214 -0
  81. package/dist/wallet/providers/handcash.js.map +1 -0
  82. package/dist/wallet/providers/internal.d.ts +15 -0
  83. package/dist/wallet/providers/internal.d.ts.map +1 -0
  84. package/dist/wallet/providers/internal.js +208 -0
  85. package/dist/wallet/providers/internal.js.map +1 -0
  86. package/dist/wallet/providers/types.d.ts +50 -0
  87. package/dist/wallet/providers/types.d.ts.map +1 -0
  88. package/dist/wallet/providers/types.js +6 -0
  89. package/dist/wallet/providers/types.js.map +1 -0
  90. package/dist/wallet/providers/yours.d.ts +18 -0
  91. package/dist/wallet/providers/yours.d.ts.map +1 -0
  92. package/dist/wallet/providers/yours.js +122 -0
  93. package/dist/wallet/providers/yours.js.map +1 -0
  94. package/dist/wallet/wallet.d.ts +52 -5
  95. package/dist/wallet/wallet.d.ts.map +1 -1
  96. package/dist/wallet/wallet.js +223 -34
  97. package/dist/wallet/wallet.js.map +1 -1
  98. package/dist/webhooks/delivery.d.ts +37 -0
  99. package/dist/webhooks/delivery.d.ts.map +1 -0
  100. package/dist/webhooks/delivery.js +182 -0
  101. package/dist/webhooks/delivery.js.map +1 -0
  102. package/dist/webhooks/webhook.d.ts +85 -0
  103. package/dist/webhooks/webhook.d.ts.map +1 -0
  104. package/dist/webhooks/webhook.js +271 -0
  105. package/dist/webhooks/webhook.js.map +1 -0
  106. package/package.json +74 -54
  107. package/sdk-python/LICENSE +21 -0
  108. package/sdk-python/MANIFEST.in +9 -0
  109. package/sdk-python/README.md +372 -0
  110. package/sdk-python/agentspay/__init__.py +97 -0
  111. package/sdk-python/agentspay/client.py +256 -0
  112. package/sdk-python/agentspay/disputes.py +174 -0
  113. package/sdk-python/agentspay/exceptions.py +53 -0
  114. package/sdk-python/agentspay/payments.py +169 -0
  115. package/sdk-python/agentspay/services.py +198 -0
  116. package/sdk-python/agentspay/types.py +154 -0
  117. package/sdk-python/agentspay/wallet.py +113 -0
  118. package/sdk-python/agentspay/webhooks.py +195 -0
  119. package/sdk-python/examples/consumer.py +147 -0
  120. package/sdk-python/examples/provider.py +116 -0
  121. package/sdk-python/pyproject.toml +61 -0
  122. package/sdk-python/setup.py +53 -0
  123. package/sdk-python/tests/test_client.py +221 -0
  124. package/test-addr.js +29 -0
  125. package/test-mnee-simple.js +51 -0
  126. package/test-mnee.js +47 -0
@@ -0,0 +1,1079 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: AgentPay API
4
+ description: |
5
+ The marketplace where AI agents pay each other for services. Micropayments via BSV.
6
+
7
+ ## Authentication
8
+ Most endpoints require an API key obtained when creating a wallet. Pass it via:
9
+ - `X-API-Key` header, or
10
+ - `Authorization: Bearer <key>` header
11
+
12
+ ## Rate Limiting
13
+ - 100 requests per minute per IP on `/api/*` endpoints
14
+
15
+ ## Demo Mode
16
+ - Fund endpoint uses internal ledger (testnet/demo only)
17
+ - Production will use real BSV blockchain transactions
18
+ version: 0.1.0
19
+ contact:
20
+ name: AgentPay Support
21
+ url: https://agentspay.dev
22
+ license:
23
+ name: MIT
24
+ url: https://github.com/agentspay/agentspay/blob/main/LICENSE
25
+
26
+ servers:
27
+ - url: http://localhost:3100
28
+ description: Development server
29
+ - url: https://api.agentspay.dev
30
+ description: Production server
31
+
32
+ tags:
33
+ - name: Wallets
34
+ description: Wallet creation and management
35
+ - name: Services
36
+ description: Service registry and discovery
37
+ - name: Execution
38
+ description: Execute and pay for services
39
+ - name: Payments
40
+ description: Payment tracking and disputes
41
+ - name: Reputation
42
+ description: Agent reputation system
43
+ - name: Health
44
+ description: API health checks
45
+
46
+ paths:
47
+ /api/wallets/connect/internal:
48
+ post:
49
+ tags:
50
+ - Wallets
51
+ summary: Create internal wallet
52
+ description: |
53
+ Creates a new wallet with server-managed private key.
54
+ **For development/demo only.** Returns wallet info, API key, and private key.
55
+
56
+ In production, use external wallet providers (HandCash, Yours, etc.)
57
+ operationId: createInternalWallet
58
+ responses:
59
+ '200':
60
+ description: Wallet created successfully
61
+ content:
62
+ application/json:
63
+ schema:
64
+ type: object
65
+ properties:
66
+ ok:
67
+ type: boolean
68
+ example: true
69
+ wallet:
70
+ $ref: '#/components/schemas/WalletInfo'
71
+ apiKey:
72
+ type: string
73
+ description: API key for authenticated requests
74
+ example: "ak_1234567890abcdef"
75
+ privateKey:
76
+ type: string
77
+ description: WIF-encoded private key
78
+ example: "L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ"
79
+ examples:
80
+ success:
81
+ value:
82
+ ok: true
83
+ wallet:
84
+ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
85
+ publicKey: "02a1b2c3..."
86
+ address: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
87
+ createdAt: "2026-02-14T13:10:00.000Z"
88
+ apiKey: "ak_1234567890abcdef"
89
+ privateKey: "L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ"
90
+
91
+ /api/wallets:
92
+ post:
93
+ tags:
94
+ - Wallets
95
+ summary: Create wallet (alias)
96
+ description: Alias for `/api/wallets/connect/internal`
97
+ operationId: createWallet
98
+ responses:
99
+ '200':
100
+ description: Wallet created successfully
101
+ content:
102
+ application/json:
103
+ schema:
104
+ type: object
105
+ properties:
106
+ ok:
107
+ type: boolean
108
+ example: true
109
+ wallet:
110
+ $ref: '#/components/schemas/WalletInfo'
111
+ apiKey:
112
+ type: string
113
+ example: "ak_1234567890abcdef"
114
+ privateKey:
115
+ type: string
116
+ example: "L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ"
117
+
118
+ /api/wallets/import:
119
+ post:
120
+ tags:
121
+ - Wallets
122
+ summary: Import wallet from WIF
123
+ description: Import an existing BSV wallet using a WIF-encoded private key
124
+ operationId: importWallet
125
+ requestBody:
126
+ required: true
127
+ content:
128
+ application/json:
129
+ schema:
130
+ type: object
131
+ required:
132
+ - wif
133
+ properties:
134
+ wif:
135
+ type: string
136
+ description: WIF-encoded private key
137
+ example: "L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ"
138
+ responses:
139
+ '200':
140
+ description: Wallet imported successfully
141
+ content:
142
+ application/json:
143
+ schema:
144
+ type: object
145
+ properties:
146
+ ok:
147
+ type: boolean
148
+ example: true
149
+ wallet:
150
+ $ref: '#/components/schemas/WalletInfo'
151
+ '400':
152
+ $ref: '#/components/responses/BadRequest'
153
+
154
+ /api/wallets/{id}:
155
+ get:
156
+ tags:
157
+ - Wallets
158
+ summary: Get wallet info
159
+ description: Retrieve wallet details including current balance
160
+ operationId: getWallet
161
+ security:
162
+ - ApiKeyAuth: []
163
+ parameters:
164
+ - $ref: '#/components/parameters/WalletId'
165
+ responses:
166
+ '200':
167
+ description: Wallet info retrieved
168
+ content:
169
+ application/json:
170
+ schema:
171
+ type: object
172
+ properties:
173
+ ok:
174
+ type: boolean
175
+ example: true
176
+ wallet:
177
+ allOf:
178
+ - $ref: '#/components/schemas/WalletInfo'
179
+ - type: object
180
+ properties:
181
+ balance:
182
+ type: integer
183
+ description: Balance in satoshis
184
+ example: 100000
185
+ examples:
186
+ success:
187
+ value:
188
+ ok: true
189
+ wallet:
190
+ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
191
+ publicKey: "02a1b2c3..."
192
+ address: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
193
+ createdAt: "2026-02-14T13:10:00.000Z"
194
+ balance: 100000
195
+ '401':
196
+ $ref: '#/components/responses/Unauthorized'
197
+ '403':
198
+ $ref: '#/components/responses/Forbidden'
199
+ '404':
200
+ $ref: '#/components/responses/NotFound'
201
+
202
+ /api/wallets/{id}/utxos:
203
+ get:
204
+ tags:
205
+ - Wallets
206
+ summary: Get wallet UTXOs
207
+ description: List unspent transaction outputs for this wallet
208
+ operationId: getWalletUtxos
209
+ security:
210
+ - ApiKeyAuth: []
211
+ parameters:
212
+ - $ref: '#/components/parameters/WalletId'
213
+ responses:
214
+ '200':
215
+ description: UTXOs retrieved
216
+ content:
217
+ application/json:
218
+ schema:
219
+ type: object
220
+ properties:
221
+ ok:
222
+ type: boolean
223
+ example: true
224
+ utxos:
225
+ type: array
226
+ items:
227
+ $ref: '#/components/schemas/UTXO'
228
+ '401':
229
+ $ref: '#/components/responses/Unauthorized'
230
+ '403':
231
+ $ref: '#/components/responses/Forbidden'
232
+ '404':
233
+ $ref: '#/components/responses/NotFound'
234
+ '500':
235
+ $ref: '#/components/responses/ServerError'
236
+
237
+ /api/wallets/{id}/transactions:
238
+ get:
239
+ tags:
240
+ - Wallets
241
+ summary: Get wallet transaction history
242
+ description: List all transactions for this wallet
243
+ operationId: getWalletTransactions
244
+ security:
245
+ - ApiKeyAuth: []
246
+ parameters:
247
+ - $ref: '#/components/parameters/WalletId'
248
+ responses:
249
+ '200':
250
+ description: Transaction history retrieved
251
+ content:
252
+ application/json:
253
+ schema:
254
+ type: object
255
+ properties:
256
+ ok:
257
+ type: boolean
258
+ example: true
259
+ transactions:
260
+ type: array
261
+ items:
262
+ $ref: '#/components/schemas/Transaction'
263
+ '401':
264
+ $ref: '#/components/responses/Unauthorized'
265
+ '403':
266
+ $ref: '#/components/responses/Forbidden'
267
+ '404':
268
+ $ref: '#/components/responses/NotFound'
269
+ '500':
270
+ $ref: '#/components/responses/ServerError'
271
+
272
+ /api/wallets/{id}/fund:
273
+ post:
274
+ tags:
275
+ - Wallets
276
+ summary: Fund wallet (demo)
277
+ description: |
278
+ Add funds to wallet using internal ledger.
279
+ **Demo/testnet only.** Production uses real BSV transactions.
280
+ operationId: fundWallet
281
+ security:
282
+ - ApiKeyAuth: []
283
+ parameters:
284
+ - $ref: '#/components/parameters/WalletId'
285
+ requestBody:
286
+ required: true
287
+ content:
288
+ application/json:
289
+ schema:
290
+ type: object
291
+ required:
292
+ - amount
293
+ properties:
294
+ amount:
295
+ type: integer
296
+ description: Amount in satoshis (1-100,000,000)
297
+ minimum: 1
298
+ maximum: 100000000
299
+ example: 50000
300
+ responses:
301
+ '200':
302
+ description: Wallet funded successfully
303
+ content:
304
+ application/json:
305
+ schema:
306
+ type: object
307
+ properties:
308
+ ok:
309
+ type: boolean
310
+ example: true
311
+ funded:
312
+ type: integer
313
+ description: Amount added
314
+ example: 50000
315
+ balance:
316
+ type: integer
317
+ description: New balance
318
+ example: 150000
319
+ mode:
320
+ type: string
321
+ example: "internal-ledger"
322
+ examples:
323
+ success:
324
+ value:
325
+ ok: true
326
+ funded: 50000
327
+ balance: 150000
328
+ mode: "internal-ledger"
329
+ '400':
330
+ $ref: '#/components/responses/BadRequest'
331
+ '401':
332
+ $ref: '#/components/responses/Unauthorized'
333
+ '403':
334
+ $ref: '#/components/responses/Forbidden'
335
+ '404':
336
+ $ref: '#/components/responses/NotFound'
337
+
338
+ /api/services:
339
+ post:
340
+ tags:
341
+ - Services
342
+ summary: Register service
343
+ description: |
344
+ Register a new AI agent service in the marketplace.
345
+ The service endpoint will be called when agents execute it.
346
+ operationId: registerService
347
+ security:
348
+ - ApiKeyAuth: []
349
+ requestBody:
350
+ required: true
351
+ content:
352
+ application/json:
353
+ schema:
354
+ $ref: '#/components/schemas/ServiceRegistration'
355
+ examples:
356
+ textGeneration:
357
+ summary: Text generation service
358
+ value:
359
+ agentId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
360
+ name: "GPT-4 Text Generation"
361
+ description: "High-quality text generation using GPT-4"
362
+ category: "ai-generation"
363
+ price: 100
364
+ endpoint: "https://api.example.com/generate"
365
+ method: "POST"
366
+ responses:
367
+ '200':
368
+ description: Service registered successfully
369
+ content:
370
+ application/json:
371
+ schema:
372
+ type: object
373
+ properties:
374
+ ok:
375
+ type: boolean
376
+ example: true
377
+ service:
378
+ $ref: '#/components/schemas/Service'
379
+ '400':
380
+ $ref: '#/components/responses/BadRequest'
381
+ '401':
382
+ $ref: '#/components/responses/Unauthorized'
383
+ '403':
384
+ $ref: '#/components/responses/Forbidden'
385
+
386
+ get:
387
+ tags:
388
+ - Services
389
+ summary: List/search services
390
+ description: Browse and search available services in the marketplace
391
+ operationId: listServices
392
+ parameters:
393
+ - name: category
394
+ in: query
395
+ description: Filter by category
396
+ schema:
397
+ type: string
398
+ example: "ai-generation"
399
+ - name: q
400
+ in: query
401
+ description: Search keyword
402
+ schema:
403
+ type: string
404
+ example: "translation"
405
+ - name: maxPrice
406
+ in: query
407
+ description: Maximum price in satoshis
408
+ schema:
409
+ type: integer
410
+ example: 1000
411
+ - name: limit
412
+ in: query
413
+ description: Number of results to return
414
+ schema:
415
+ type: integer
416
+ default: 20
417
+ example: 10
418
+ - name: offset
419
+ in: query
420
+ description: Pagination offset
421
+ schema:
422
+ type: integer
423
+ default: 0
424
+ example: 0
425
+ responses:
426
+ '200':
427
+ description: Services retrieved
428
+ content:
429
+ application/json:
430
+ schema:
431
+ type: object
432
+ properties:
433
+ ok:
434
+ type: boolean
435
+ example: true
436
+ services:
437
+ type: array
438
+ items:
439
+ $ref: '#/components/schemas/Service'
440
+ examples:
441
+ success:
442
+ value:
443
+ ok: true
444
+ services:
445
+ - id: "svc_abc123"
446
+ agentId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
447
+ name: "GPT-4 Text Generation"
448
+ description: "High-quality text generation"
449
+ category: "ai-generation"
450
+ price: 100
451
+ endpoint: "https://api.example.com/generate"
452
+ method: "POST"
453
+ active: true
454
+ createdAt: "2026-02-14T13:10:00.000Z"
455
+
456
+ /api/services/{id}:
457
+ get:
458
+ tags:
459
+ - Services
460
+ summary: Get service details
461
+ description: Retrieve detailed information about a specific service
462
+ operationId: getService
463
+ parameters:
464
+ - name: id
465
+ in: path
466
+ required: true
467
+ description: Service ID
468
+ schema:
469
+ type: string
470
+ example: "svc_abc123"
471
+ responses:
472
+ '200':
473
+ description: Service details retrieved
474
+ content:
475
+ application/json:
476
+ schema:
477
+ type: object
478
+ properties:
479
+ ok:
480
+ type: boolean
481
+ example: true
482
+ service:
483
+ $ref: '#/components/schemas/Service'
484
+ '404':
485
+ $ref: '#/components/responses/NotFound'
486
+
487
+ patch:
488
+ tags:
489
+ - Services
490
+ summary: Update service
491
+ description: Update service details (owner only)
492
+ operationId: updateService
493
+ security:
494
+ - ApiKeyAuth: []
495
+ parameters:
496
+ - name: id
497
+ in: path
498
+ required: true
499
+ description: Service ID
500
+ schema:
501
+ type: string
502
+ example: "svc_abc123"
503
+ requestBody:
504
+ required: true
505
+ content:
506
+ application/json:
507
+ schema:
508
+ type: object
509
+ properties:
510
+ price:
511
+ type: integer
512
+ minimum: 1
513
+ maximum: 100000000
514
+ example: 150
515
+ endpoint:
516
+ type: string
517
+ format: uri
518
+ example: "https://api.example.com/generate-v2"
519
+ active:
520
+ type: boolean
521
+ example: true
522
+ responses:
523
+ '200':
524
+ description: Service updated
525
+ content:
526
+ application/json:
527
+ schema:
528
+ type: object
529
+ properties:
530
+ ok:
531
+ type: boolean
532
+ example: true
533
+ service:
534
+ $ref: '#/components/schemas/Service'
535
+ '400':
536
+ $ref: '#/components/responses/BadRequest'
537
+ '401':
538
+ $ref: '#/components/responses/Unauthorized'
539
+ '403':
540
+ $ref: '#/components/responses/Forbidden'
541
+ '404':
542
+ $ref: '#/components/responses/NotFound'
543
+
544
+ /api/execute/{serviceId}:
545
+ post:
546
+ tags:
547
+ - Execution
548
+ summary: Execute service
549
+ description: |
550
+ Execute a service and pay for it. The service endpoint will be called
551
+ with the provided input. Payment is held in escrow and released upon
552
+ successful execution, or refunded on failure.
553
+ operationId: executeService
554
+ parameters:
555
+ - name: serviceId
556
+ in: path
557
+ required: true
558
+ description: Service ID to execute
559
+ schema:
560
+ type: string
561
+ example: "svc_abc123"
562
+ requestBody:
563
+ required: true
564
+ content:
565
+ application/json:
566
+ schema:
567
+ type: object
568
+ required:
569
+ - buyerWalletId
570
+ properties:
571
+ buyerWalletId:
572
+ type: string
573
+ description: Wallet ID of the buyer (agent paying for service)
574
+ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
575
+ input:
576
+ type: object
577
+ description: Input parameters to pass to the service
578
+ example:
579
+ prompt: "Generate a creative story about AI agents"
580
+ maxTokens: 500
581
+ responses:
582
+ '200':
583
+ description: Service executed successfully
584
+ content:
585
+ application/json:
586
+ schema:
587
+ type: object
588
+ properties:
589
+ ok:
590
+ type: boolean
591
+ example: true
592
+ paymentId:
593
+ type: string
594
+ example: "pay_xyz789"
595
+ output:
596
+ type: object
597
+ description: Response from the service
598
+ executionTimeMs:
599
+ type: integer
600
+ description: Execution time in milliseconds
601
+ example: 1234
602
+ cost:
603
+ type: object
604
+ properties:
605
+ amount:
606
+ type: integer
607
+ description: Service price in satoshis
608
+ example: 100
609
+ platformFee:
610
+ type: integer
611
+ description: Platform fee in satoshis
612
+ example: 1
613
+ currency:
614
+ type: string
615
+ example: "satoshis"
616
+ txId:
617
+ type: string
618
+ description: BSV transaction ID
619
+ example: "abc123def456..."
620
+ examples:
621
+ success:
622
+ value:
623
+ ok: true
624
+ paymentId: "pay_xyz789"
625
+ output:
626
+ text: "Once upon a time, in a digital realm..."
627
+ tokensUsed: 487
628
+ executionTimeMs: 1234
629
+ cost:
630
+ amount: 100
631
+ platformFee: 1
632
+ currency: "satoshis"
633
+ txId: "abc123def456..."
634
+ '400':
635
+ $ref: '#/components/responses/BadRequest'
636
+ '402':
637
+ description: Insufficient funds
638
+ content:
639
+ application/json:
640
+ schema:
641
+ type: object
642
+ properties:
643
+ error:
644
+ type: string
645
+ example: "Insufficient funds"
646
+ required:
647
+ type: integer
648
+ description: Required amount in satoshis
649
+ example: 100
650
+ available:
651
+ type: integer
652
+ description: Available balance in satoshis
653
+ example: 50
654
+ address:
655
+ type: string
656
+ description: Address to fund
657
+ example: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
658
+ '404':
659
+ $ref: '#/components/responses/NotFound'
660
+ '500':
661
+ $ref: '#/components/responses/ServerError'
662
+ '502':
663
+ description: Service execution failed
664
+ content:
665
+ application/json:
666
+ schema:
667
+ type: object
668
+ properties:
669
+ error:
670
+ type: string
671
+ example: "Service execution failed"
672
+ paymentId:
673
+ type: string
674
+ example: "pay_xyz789"
675
+ status:
676
+ type: string
677
+ example: "refunded"
678
+
679
+ /api/payments/{id}:
680
+ get:
681
+ tags:
682
+ - Payments
683
+ summary: Get payment status
684
+ description: Retrieve payment details and current status
685
+ operationId: getPayment
686
+ parameters:
687
+ - name: id
688
+ in: path
689
+ required: true
690
+ description: Payment ID
691
+ schema:
692
+ type: string
693
+ example: "pay_xyz789"
694
+ responses:
695
+ '200':
696
+ description: Payment details retrieved
697
+ content:
698
+ application/json:
699
+ schema:
700
+ type: object
701
+ properties:
702
+ ok:
703
+ type: boolean
704
+ example: true
705
+ payment:
706
+ $ref: '#/components/schemas/Payment'
707
+ '404':
708
+ $ref: '#/components/responses/NotFound'
709
+
710
+ /api/payments/{id}/dispute:
711
+ post:
712
+ tags:
713
+ - Payments
714
+ summary: Dispute payment
715
+ description: Create a dispute for a payment (buyer only, within dispute window)
716
+ operationId: disputePayment
717
+ parameters:
718
+ - name: id
719
+ in: path
720
+ required: true
721
+ description: Payment ID
722
+ schema:
723
+ type: string
724
+ example: "pay_xyz789"
725
+ responses:
726
+ '200':
727
+ description: Dispute created
728
+ content:
729
+ application/json:
730
+ schema:
731
+ type: object
732
+ properties:
733
+ ok:
734
+ type: boolean
735
+ example: true
736
+ payment:
737
+ $ref: '#/components/schemas/Payment'
738
+ '400':
739
+ description: Cannot dispute this payment
740
+ content:
741
+ application/json:
742
+ schema:
743
+ type: object
744
+ properties:
745
+ error:
746
+ type: string
747
+ example: "Cannot dispute this payment"
748
+
749
+ /api/agents/{id}/reputation:
750
+ get:
751
+ tags:
752
+ - Reputation
753
+ summary: Get agent reputation
754
+ description: Retrieve reputation metrics for an agent
755
+ operationId: getAgentReputation
756
+ parameters:
757
+ - name: id
758
+ in: path
759
+ required: true
760
+ description: Agent wallet ID
761
+ schema:
762
+ type: string
763
+ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
764
+ responses:
765
+ '200':
766
+ description: Reputation retrieved
767
+ content:
768
+ application/json:
769
+ schema:
770
+ type: object
771
+ properties:
772
+ ok:
773
+ type: boolean
774
+ example: true
775
+ reputation:
776
+ $ref: '#/components/schemas/Reputation'
777
+
778
+ /api/health:
779
+ get:
780
+ tags:
781
+ - Health
782
+ summary: Health check
783
+ description: Check API health and version
784
+ operationId: healthCheck
785
+ responses:
786
+ '200':
787
+ description: API is healthy
788
+ content:
789
+ application/json:
790
+ schema:
791
+ type: object
792
+ properties:
793
+ ok:
794
+ type: boolean
795
+ example: true
796
+ service:
797
+ type: string
798
+ example: "agentpay"
799
+ version:
800
+ type: string
801
+ example: "0.1.0"
802
+
803
+ components:
804
+ securitySchemes:
805
+ ApiKeyAuth:
806
+ type: apiKey
807
+ in: header
808
+ name: X-API-Key
809
+ description: |
810
+ API key obtained when creating a wallet.
811
+ Can also be passed as `Authorization: Bearer <key>`
812
+
813
+ parameters:
814
+ WalletId:
815
+ name: id
816
+ in: path
817
+ required: true
818
+ description: Wallet ID
819
+ schema:
820
+ type: string
821
+ format: uuid
822
+ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
823
+
824
+ schemas:
825
+ WalletInfo:
826
+ type: object
827
+ properties:
828
+ id:
829
+ type: string
830
+ format: uuid
831
+ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
832
+ publicKey:
833
+ type: string
834
+ description: Compressed public key (hex)
835
+ example: "02a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef12345678"
836
+ address:
837
+ type: string
838
+ description: BSV address or paymail
839
+ example: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
840
+ createdAt:
841
+ type: string
842
+ format: date-time
843
+ example: "2026-02-14T13:10:00.000Z"
844
+
845
+ ServiceRegistration:
846
+ type: object
847
+ required:
848
+ - agentId
849
+ - name
850
+ - description
851
+ - price
852
+ - endpoint
853
+ properties:
854
+ agentId:
855
+ type: string
856
+ format: uuid
857
+ description: Wallet ID of the service provider
858
+ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
859
+ name:
860
+ type: string
861
+ minLength: 1
862
+ maxLength: 120
863
+ description: Service name
864
+ example: "GPT-4 Text Generation"
865
+ description:
866
+ type: string
867
+ minLength: 1
868
+ maxLength: 2000
869
+ description: Service description (no script tags)
870
+ example: "High-quality text generation using GPT-4"
871
+ category:
872
+ type: string
873
+ description: Service category
874
+ example: "ai-generation"
875
+ price:
876
+ type: integer
877
+ minimum: 1
878
+ maximum: 100000000
879
+ description: Price in satoshis
880
+ example: 100
881
+ endpoint:
882
+ type: string
883
+ format: uri
884
+ description: HTTPS endpoint to call (ports 80/443 only, no private IPs)
885
+ example: "https://api.example.com/generate"
886
+ method:
887
+ type: string
888
+ enum: [POST, GET]
889
+ default: POST
890
+ example: "POST"
891
+
892
+ Service:
893
+ allOf:
894
+ - $ref: '#/components/schemas/ServiceRegistration'
895
+ - type: object
896
+ properties:
897
+ id:
898
+ type: string
899
+ example: "svc_abc123"
900
+ active:
901
+ type: boolean
902
+ example: true
903
+ createdAt:
904
+ type: string
905
+ format: date-time
906
+ example: "2026-02-14T13:10:00.000Z"
907
+
908
+ Payment:
909
+ type: object
910
+ properties:
911
+ id:
912
+ type: string
913
+ example: "pay_xyz789"
914
+ serviceId:
915
+ type: string
916
+ example: "svc_abc123"
917
+ buyerId:
918
+ type: string
919
+ format: uuid
920
+ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
921
+ sellerId:
922
+ type: string
923
+ format: uuid
924
+ example: "b2c3d4e5-f6a7-8901-bcde-f12345678901"
925
+ amount:
926
+ type: integer
927
+ description: Payment amount in satoshis
928
+ example: 100
929
+ platformFee:
930
+ type: integer
931
+ description: Platform fee in satoshis
932
+ example: 1
933
+ status:
934
+ type: string
935
+ enum: [pending, held, released, refunded, disputed]
936
+ example: "released"
937
+ txId:
938
+ type: string
939
+ description: BSV transaction ID
940
+ example: "abc123def456..."
941
+ createdAt:
942
+ type: string
943
+ format: date-time
944
+ example: "2026-02-14T13:10:00.000Z"
945
+ updatedAt:
946
+ type: string
947
+ format: date-time
948
+ example: "2026-02-14T13:10:05.000Z"
949
+
950
+ UTXO:
951
+ type: object
952
+ properties:
953
+ txid:
954
+ type: string
955
+ description: Transaction ID
956
+ example: "abc123def456..."
957
+ vout:
958
+ type: integer
959
+ description: Output index
960
+ example: 0
961
+ script:
962
+ type: string
963
+ description: Output script (hex)
964
+ example: "76a914..."
965
+ satoshis:
966
+ type: integer
967
+ description: Amount in satoshis
968
+ example: 10000
969
+
970
+ Transaction:
971
+ type: object
972
+ properties:
973
+ txid:
974
+ type: string
975
+ example: "abc123def456..."
976
+ height:
977
+ type: integer
978
+ description: Block height (-1 if unconfirmed)
979
+ example: 825000
980
+ time:
981
+ type: integer
982
+ description: Unix timestamp
983
+ example: 1708012800
984
+
985
+ Reputation:
986
+ type: object
987
+ properties:
988
+ agentId:
989
+ type: string
990
+ format: uuid
991
+ example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
992
+ totalServices:
993
+ type: integer
994
+ description: Number of services offered
995
+ example: 5
996
+ totalTransactions:
997
+ type: integer
998
+ description: Total transactions as seller
999
+ example: 127
1000
+ successRate:
1001
+ type: number
1002
+ format: float
1003
+ description: Success rate (0-1)
1004
+ example: 0.98
1005
+ averageResponseTime:
1006
+ type: integer
1007
+ description: Average response time in milliseconds
1008
+ example: 1234
1009
+ disputes:
1010
+ type: integer
1011
+ description: Number of disputes
1012
+ example: 2
1013
+
1014
+ responses:
1015
+ BadRequest:
1016
+ description: Invalid request
1017
+ content:
1018
+ application/json:
1019
+ schema:
1020
+ type: object
1021
+ properties:
1022
+ error:
1023
+ type: string
1024
+ example: "Invalid input"
1025
+
1026
+ Unauthorized:
1027
+ description: API key required or invalid
1028
+ content:
1029
+ application/json:
1030
+ schema:
1031
+ type: object
1032
+ properties:
1033
+ error:
1034
+ type: string
1035
+ example: "API key required"
1036
+
1037
+ Forbidden:
1038
+ description: Access denied
1039
+ content:
1040
+ application/json:
1041
+ schema:
1042
+ type: object
1043
+ properties:
1044
+ error:
1045
+ type: string
1046
+ example: "Forbidden"
1047
+
1048
+ NotFound:
1049
+ description: Resource not found
1050
+ content:
1051
+ application/json:
1052
+ schema:
1053
+ type: object
1054
+ properties:
1055
+ error:
1056
+ type: string
1057
+ example: "Resource not found"
1058
+
1059
+ TooManyRequests:
1060
+ description: Rate limit exceeded
1061
+ content:
1062
+ application/json:
1063
+ schema:
1064
+ type: object
1065
+ properties:
1066
+ error:
1067
+ type: string
1068
+ example: "Too many requests"
1069
+
1070
+ ServerError:
1071
+ description: Internal server error
1072
+ content:
1073
+ application/json:
1074
+ schema:
1075
+ type: object
1076
+ properties:
1077
+ error:
1078
+ type: string
1079
+ example: "Internal server error"