-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.json
More file actions
1469 lines (1469 loc) · 53.6 KB
/
Copy pathopenapi.json
File metadata and controls
1469 lines (1469 loc) · 53.6 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": "Haldir API — Governance for AI Agents",
"version": "0.1.0",
"description": "Haldir is a security and governance layer for AI agents, composed of three modules:\n\n- **Gate** — Session-scoped permissions. Create short-lived sessions with explicit scopes (read, write, admin, spend:N) and TTLs. Every privileged operation must pass through Gate first.\n- **Vault** — Encrypted secret storage with access control. Secrets are AES-encrypted at rest and only released to sessions that hold the required scope. Vault also manages spend budgets and payment authorization.\n- **Watch** — Tamper-evident audit logging with automatic anomaly detection. Every tool call, payment, and decision is recorded. Suspicious patterns (rapid-fire actions, high-cost operations, unusual tools) are flagged in real time.\n\nAuthenticate with `Authorization: Bearer hld_...` or `X-API-Key: hld_...`. Create your first key via `POST /v1/keys` (no auth required for the bootstrap key).",
"contact": {
"name": "0xN0rD",
"url": "https://haldir.xyz"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"servers": [
{
"url": "https://haldir.xyz",
"description": "Production"
}
],
"security": [
{ "BearerAuth": [] },
{ "ApiKeyAuth": [] }
],
"tags": [
{ "name": "gate", "description": "Session management and permission checks" },
{ "name": "vault", "description": "Encrypted secret storage and retrieval" },
{ "name": "watch", "description": "Audit logging and spend tracking" },
{ "name": "proxy", "description": "Governance proxy for upstream MCP servers" },
{ "name": "audit", "description": "Query audit trail and spend summaries" },
{ "name": "approvals", "description": "Human-in-the-loop approval workflows" },
{ "name": "webhooks", "description": "Webhook registration for real-time alerts" }
],
"paths": {
"/v1/keys": {
"post": {
"operationId": "createApiKey",
"summary": "Create an API key",
"description": "Create a new API key. The very first key requires no authentication. Subsequent keys require either a valid API key or the HALDIR_BOOTSTRAP_TOKEN.",
"tags": ["gate"],
"security": [
{},
{ "BearerAuth": [] },
{ "ApiKeyAuth": [] }
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"default": "default",
"description": "Human-readable name for this key"
},
"tier": {
"type": "string",
"enum": ["free", "pro", "enterprise"],
"default": "free",
"description": "Pricing tier (affects rate limits)"
},
"bootstrap_token": {
"type": "string",
"description": "HALDIR_BOOTSTRAP_TOKEN value, required when creating additional keys without an existing API key"
}
}
}
}
}
},
"responses": {
"201": {
"description": "API key created",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"key": { "type": "string", "description": "Full API key (shown only once)" },
"prefix": { "type": "string", "description": "Key prefix for identification" },
"name": { "type": "string" },
"tier": { "type": "string" },
"message": { "type": "string" }
},
"required": ["key", "prefix", "name", "tier", "message"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" }
}
}
},
"/v1/sessions": {
"post": {
"operationId": "createSession",
"summary": "Create an agent session",
"description": "Create a scoped session for an AI agent with explicit permissions, TTL, and optional spend budget.",
"tags": ["gate"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["agent_id"],
"properties": {
"agent_id": { "type": "string", "description": "Unique agent identifier" },
"scopes": {
"type": "array",
"items": { "type": "string" },
"default": ["read", "browse"],
"description": "Permission scopes to grant"
},
"ttl": {
"type": "integer",
"default": 3600,
"description": "Session time-to-live in seconds"
},
"spend_limit": {
"type": "number",
"nullable": true,
"description": "Maximum USD spend for this session"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Session created",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/SessionCreated" }
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/sessions/{session_id}": {
"get": {
"operationId": "getSession",
"summary": "Get session info",
"description": "Retrieve the current state of a session including scopes, spend, remaining budget, and validity.",
"tags": ["gate"],
"parameters": [
{ "$ref": "#/components/parameters/SessionIdPath" }
],
"responses": {
"200": {
"description": "Session details",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/SessionDetail" }
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/NotFound" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
},
"delete": {
"operationId": "revokeSession",
"summary": "Revoke a session",
"description": "Immediately revoke a session, permanently disabling all permissions.",
"tags": ["gate"],
"parameters": [
{ "$ref": "#/components/parameters/SessionIdPath" }
],
"responses": {
"200": {
"description": "Session revoked",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"revoked": { "type": "boolean", "const": true },
"session_id": { "type": "string" }
},
"required": ["revoked", "session_id"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/NotFound" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/sessions/{session_id}/check": {
"post": {
"operationId": "checkPermission",
"summary": "Check a session permission",
"description": "Check whether a session holds a specific scope. Use before sensitive operations to avoid 403 errors.",
"tags": ["gate"],
"parameters": [
{ "$ref": "#/components/parameters/SessionIdPath" }
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["scope"],
"properties": {
"scope": { "type": "string", "description": "The scope to check (e.g. read, write, admin)" }
}
}
}
}
},
"responses": {
"200": {
"description": "Permission check result",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"allowed": { "type": "boolean" },
"session_id": { "type": "string" },
"scope": { "type": "string" }
},
"required": ["allowed", "session_id", "scope"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/secrets": {
"post": {
"operationId": "storeSecret",
"summary": "Store an encrypted secret",
"description": "Store a secret in the Vault, encrypted at rest with AES. Optionally require a specific scope for retrieval.",
"tags": ["vault"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["name", "value"],
"properties": {
"name": { "type": "string", "description": "Unique secret name" },
"value": { "type": "string", "description": "Secret value to encrypt" },
"scope_required": {
"type": "string",
"default": "read",
"description": "Minimum scope a session must hold to read this secret"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Secret stored",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"stored": { "type": "boolean", "const": true },
"name": { "type": "string" }
},
"required": ["stored", "name"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
},
"get": {
"operationId": "listSecrets",
"summary": "List secret names",
"description": "List all stored secret names (never values).",
"tags": ["vault"],
"responses": {
"200": {
"description": "List of secret names",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"secrets": {
"type": "array",
"items": { "type": "string" }
},
"count": { "type": "integer" }
},
"required": ["secrets", "count"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/secrets/{name}": {
"get": {
"operationId": "getSecret",
"summary": "Retrieve a secret",
"description": "Retrieve a decrypted secret. Pass X-Session-ID header or session_id query param for scope-based access control.",
"tags": ["vault"],
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": { "type": "string" },
"description": "Secret name"
},
{
"name": "session_id",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "Session ID for scope enforcement"
},
{
"name": "X-Session-ID",
"in": "header",
"required": false,
"schema": { "type": "string" },
"description": "Session ID for scope enforcement (alternative to query param)"
}
],
"responses": {
"200": {
"description": "Secret value",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"value": { "type": "string" }
},
"required": ["name", "value"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"403": { "$ref": "#/components/responses/Forbidden" },
"404": { "$ref": "#/components/responses/NotFound" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
},
"delete": {
"operationId": "deleteSecret",
"summary": "Delete a secret",
"description": "Permanently delete a secret from the Vault.",
"tags": ["vault"],
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": { "type": "string" },
"description": "Secret name"
}
],
"responses": {
"200": {
"description": "Secret deleted",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"deleted": { "type": "boolean", "const": true },
"name": { "type": "string" }
},
"required": ["deleted", "name"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/NotFound" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/payments/authorize": {
"post": {
"operationId": "authorizePayment",
"summary": "Authorize a payment",
"description": "Authorize a payment against a session's spend budget. Denied if insufficient budget remains.",
"tags": ["vault"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["session_id", "amount"],
"properties": {
"session_id": { "type": "string" },
"amount": { "type": "number", "description": "Amount to authorize" },
"currency": { "type": "string", "default": "USD", "description": "ISO 4217 currency code" },
"description": { "type": "string", "default": "", "description": "What the payment is for" }
}
}
}
}
},
"responses": {
"200": {
"description": "Payment authorized",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/PaymentResult" }
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"403": {
"description": "Payment denied (budget exceeded)",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/PaymentResult" }
}
}
},
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/audit": {
"post": {
"operationId": "logAction",
"summary": "Log an agent action",
"description": "Log an action to the tamper-evident audit trail. Watch automatically flags anomalous patterns.",
"tags": ["watch", "audit"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["session_id", "action"],
"properties": {
"session_id": { "type": "string" },
"tool": { "type": "string", "default": "", "description": "Tool or service name" },
"action": { "type": "string", "description": "Description of the action" },
"details": { "type": "string", "nullable": true, "description": "Additional context" },
"cost_usd": { "type": "number", "default": 0, "description": "Cost in USD" }
}
}
}
}
},
"responses": {
"201": {
"description": "Action logged",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"logged": { "type": "boolean", "const": true },
"entry_id": { "type": "string" },
"flagged": { "type": "boolean", "description": "Whether the action was flagged as anomalous" },
"flag_reason": { "type": "string", "nullable": true }
},
"required": ["logged", "entry_id", "flagged", "flag_reason"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
},
"get": {
"operationId": "getAuditTrail",
"summary": "Query the audit trail",
"description": "Retrieve audit log entries with optional filters by session, agent, tool, or flagged status.",
"tags": ["watch", "audit"],
"parameters": [
{ "name": "session_id", "in": "query", "schema": { "type": "string" }, "description": "Filter by session" },
{ "name": "agent_id", "in": "query", "schema": { "type": "string" }, "description": "Filter by agent" },
{ "name": "tool", "in": "query", "schema": { "type": "string" }, "description": "Filter by tool name" },
{ "name": "flagged", "in": "query", "schema": { "type": "string", "enum": ["true", "false"] }, "description": "Only flagged entries" },
{ "name": "limit", "in": "query", "schema": { "type": "integer", "default": 100 }, "description": "Max entries to return" }
],
"responses": {
"200": {
"description": "Audit entries",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"count": { "type": "integer" },
"entries": {
"type": "array",
"items": { "$ref": "#/components/schemas/AuditEntry" }
}
},
"required": ["count", "entries"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/audit/spend": {
"get": {
"operationId": "getSpend",
"summary": "Get spend summary",
"description": "Get aggregated spend data, optionally filtered by session or agent.",
"tags": ["watch", "audit"],
"parameters": [
{ "name": "session_id", "in": "query", "schema": { "type": "string" }, "description": "Filter by session" },
{ "name": "agent_id", "in": "query", "schema": { "type": "string" }, "description": "Filter by agent" }
],
"responses": {
"200": {
"description": "Spend summary",
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "Spend breakdown returned by Watch.get_spend()",
"additionalProperties": true
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/usage": {
"get": {
"operationId": "getUsage",
"summary": "Get usage stats",
"description": "Get API usage count for the current tenant, optionally for a specific month.",
"tags": ["watch"],
"parameters": [
{ "name": "month", "in": "query", "schema": { "type": "string", "pattern": "^\\d{4}-\\d{2}$" }, "description": "Month in YYYY-MM format (defaults to current month)" }
],
"responses": {
"200": {
"description": "Usage data",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"tenant_id": { "type": "string" },
"month": { "type": "string" },
"action_count": { "type": "integer" },
"tier": { "type": "string" }
},
"required": ["tenant_id", "month", "action_count"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/approvals/rules": {
"post": {
"operationId": "addApprovalRule",
"summary": "Add an approval rule",
"description": "Add a rule that triggers human-in-the-loop approval for matching actions.",
"tags": ["approvals"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"enum": ["spend_over", "tool_blocked", "destructive", "all"],
"description": "Rule type"
},
"threshold": { "type": "number", "default": 0, "description": "Threshold for spend_over rules (USD)" },
"tools": {
"type": "array",
"items": { "type": "string" },
"nullable": true,
"description": "Tool names for tool_blocked rules"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Rule added",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"added": { "type": "boolean", "const": true },
"type": { "type": "string" }
},
"required": ["added", "type"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/approvals/request": {
"post": {
"operationId": "requestApproval",
"summary": "Request human approval",
"description": "Submit an action for human approval. The agent polls the approval status until it is approved or denied.",
"tags": ["approvals"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["session_id"],
"properties": {
"session_id": { "type": "string" },
"tool": { "type": "string", "default": "" },
"action": { "type": "string", "default": "" },
"amount": { "type": "number", "default": 0 },
"reason": { "type": "string", "default": "" },
"details": { "type": "string", "nullable": true },
"ttl": { "type": "integer", "default": 3600, "description": "Time before the request expires (seconds)" }
}
}
}
}
},
"responses": {
"201": {
"description": "Approval requested",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"request_id": { "type": "string" },
"status": { "type": "string" },
"expires_at": { "type": "number" }
},
"required": ["request_id", "status", "expires_at"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/approvals/{request_id}": {
"get": {
"operationId": "checkApproval",
"summary": "Check approval status",
"description": "Poll the status of a pending approval request.",
"tags": ["approvals"],
"parameters": [
{
"name": "request_id",
"in": "path",
"required": true,
"schema": { "type": "string" }
}
],
"responses": {
"200": {
"description": "Approval status",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ApprovalDetail" }
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"404": { "$ref": "#/components/responses/NotFound" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/approvals/{request_id}/approve": {
"post": {
"operationId": "approveRequest",
"summary": "Approve a pending request",
"description": "Approve a pending approval request, allowing the agent to proceed.",
"tags": ["approvals"],
"parameters": [
{
"name": "request_id",
"in": "path",
"required": true,
"schema": { "type": "string" }
}
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"decided_by": { "type": "string", "default": "", "description": "Who approved (e.g. human operator name)" },
"note": { "type": "string", "default": "", "description": "Optional note on the decision" }
}
}
}
}
},
"responses": {
"200": {
"description": "Request approved",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"approved": { "type": "boolean", "const": true },
"request_id": { "type": "string" }
},
"required": ["approved", "request_id"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/approvals/{request_id}/deny": {
"post": {
"operationId": "denyRequest",
"summary": "Deny a pending request",
"description": "Deny a pending approval request, blocking the agent's action.",
"tags": ["approvals"],
"parameters": [
{
"name": "request_id",
"in": "path",
"required": true,
"schema": { "type": "string" }
}
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"decided_by": { "type": "string", "default": "" },
"note": { "type": "string", "default": "" }
}
}
}
}
},
"responses": {
"200": {
"description": "Request denied",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"denied": { "type": "boolean", "const": true },
"request_id": { "type": "string" }
},
"required": ["denied", "request_id"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/approvals/pending": {
"get": {
"operationId": "listPendingApprovals",
"summary": "List pending approvals",
"description": "List all approval requests that are still pending a decision.",
"tags": ["approvals"],
"parameters": [
{ "name": "agent_id", "in": "query", "schema": { "type": "string" }, "description": "Filter by agent" }
],
"responses": {
"200": {
"description": "Pending approval requests",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"count": { "type": "integer" },
"requests": {
"type": "array",
"items": { "$ref": "#/components/schemas/PendingApproval" }
}
},
"required": ["count", "requests"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/webhooks": {
"post": {
"operationId": "registerWebhook",
"summary": "Register a webhook",
"description": "Register a URL to receive real-time event notifications (anomaly, approval_requested, budget_exhausted).",
"tags": ["webhooks"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["url"],
"properties": {
"url": { "type": "string", "format": "uri", "description": "Webhook endpoint URL" },
"name": { "type": "string", "default": "", "description": "Human-readable name" },
"events": {
"type": "array",
"items": { "type": "string", "enum": ["all", "anomaly", "approval_requested", "budget_exhausted"] },
"nullable": true,
"description": "Events to subscribe to (defaults to all)"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Webhook registered",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"registered": { "type": "boolean", "const": true },
"url": { "type": "string" },
"events": {
"type": "array",
"items": { "type": "string" },
"nullable": true
}
},
"required": ["registered", "url", "events"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
},
"get": {
"operationId": "listWebhooks",
"summary": "List registered webhooks",
"description": "List all webhooks registered for this account.",
"tags": ["webhooks"],
"responses": {
"200": {
"description": "Webhook list",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"webhooks": { "type": "array", "items": { "type": "object" } }
},
"required": ["webhooks"]
}
}
}
},
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
}
},
"/v1/proxy/upstreams": {
"post": {
"operationId": "registerUpstream",
"summary": "Register an upstream MCP server",
"description": "Register an upstream MCP server to proxy through Haldir. Haldir discovers the server's tools automatically.",
"tags": ["proxy"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["name", "url"],
"properties": {
"name": { "type": "string", "description": "Unique name for this upstream" },
"url": { "type": "string", "format": "uri", "description": "MCP server URL" }
}
}
}
}
},
"responses": {
"201": {
"description": "Upstream registered",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"registered": { "type": "boolean", "const": true },
"name": { "type": "string" },
"url": { "type": "string" },
"healthy": { "type": "boolean" },
"tools_discovered": { "type": "integer" },
"tool_names": { "type": "array", "items": { "type": "string" } },
"error": { "type": "string", "description": "Present if upstream had errors during discovery" },
"upstream_status": { "type": "integer", "description": "HTTP status from upstream (debug)" },
"upstream_body": { "type": "string", "description": "Truncated response body from upstream (debug)" }
},
"required": ["registered", "name", "url", "healthy", "tools_discovered", "tool_names"]
}
}
}
},
"400": { "$ref": "#/components/responses/BadRequest" },
"401": { "$ref": "#/components/responses/Unauthorized" },
"429": { "$ref": "#/components/responses/RateLimited" }
}
},
"get": {
"operationId": "listUpstreams",
"summary": "List upstream servers",
"description": "List all registered upstream MCP servers and their health status.",
"tags": ["proxy"],
"responses": {
"200": {
"description": "Upstream server stats",
"content": {
"application/json": {
"schema": {