-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.yaml
More file actions
1803 lines (1715 loc) · 59.3 KB
/
Copy pathopenapi.yaml
File metadata and controls
1803 lines (1715 loc) · 59.3 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: Portwing Agent API
version: 0.9.17
description: |
Portwing is a lightweight remote Docker agent for the Drydock container
monitoring platform. This specification covers the **Standard Mode** HTTP API
only (Edge Mode communicates over a WebSocket multiplexed protocol documented
separately in SPEC.md §3).
## Authentication
All protected endpoints require the agent token, supplied via one of:
- `Authorization: Bearer <token>` (standard, checked first)
- `X-Portwing-Token` header
- `X-Dd-Agent-Secret` header (Drydock agent secret header)
Raw-token verification hashes each presented value and compares a
fixed-size SHA-256 digest with `crypto/subtle.ConstantTimeCompare`.
Standard mode fails closed when no token, token hash, or authorized-keys
registry is configured. Unauthenticated development requires explicit
opt-in and an additional acknowledgement for non-loopback binds.
**Rate limiting:** 10 failed attempts per IP per rolling minute. Exceeding
the threshold returns HTTP 429 until the window expires.
## Docker Engine API Proxy
Any path not matched by a named route is transparently proxied to the local
Docker daemon (Unix socket). This includes every endpoint in the
[Docker Engine API](https://docs.docker.com/engine/api/) — streaming
endpoints (`/logs`, `/attach`, `/exec/*/start`, `/events`, `/build`,
`/images/create`, `/images/{name}/push`, `/containers/{id}/stats` (streaming is disabled when `stream` is empty, `0`, `no`, `false`, or `none`)), interactive exec hijacking
(`Upgrade: tcp`), and binary responses. Paths are forwarded verbatim; the
agent negotiates the API version on startup (fallback: `v1.44`).
A representative proxy path is shown below under `/v1.44/{path}`.
contact:
email: security@codeswhat.com
license:
name: AGPL-3.0
url: https://www.gnu.org/licenses/agpl-3.0.html
servers:
- url: http://{host}:{port}
description: Standard mode (HTTP)
variables:
host:
default: localhost
port:
default: "3000"
- url: https://{host}:{port}
description: Standard mode (HTTPS/TLS 1.2+)
variables:
host:
default: localhost
port:
default: "3000"
components:
securitySchemes:
bearerToken:
type: http
scheme: bearer
description: >
Agent token via Authorization: Bearer. Also accepted in the
`X-Portwing-Token` header, or Drydock's `X-Dd-Agent-Secret` header.
portwingToken:
type: apiKey
in: header
name: X-Portwing-Token
description: Agent token via the X-Portwing-Token header.
ed25519Signature:
type: apiKey
in: header
name: X-Portwing-Signature
description: |
Ed25519 per-request signature (base64url, no padding). When this header
is present the agent verifies the request via Ed25519 instead of the
shared token.
Signature version 2 requires five headers together:
| Header | Format | Example |
|--------|--------|---------|
| `X-Portwing-Key-ID` | hex(SHA-256(raw 32-byte pubkey)[:8]) | `4a3f2b1c9d8e7f6a` |
| `X-Portwing-Timestamp` | Unix epoch, seconds, decimal | `1749600000` |
| `X-Portwing-Nonce` | 32 random hex chars (128-bit) | `a1b2c3d4e5f6...` |
| `X-Portwing-Signature` | base64url (no padding) Ed25519 signature | `d2hh...` |
| `X-Portwing-Signature-Version` | canonical format version | `2` |
The signed canonical string is:
```
METHOD\nREQUEST-TARGET\nbody-sha256-hex\nunix-timestamp\nnonce
```
`REQUEST-TARGET` is the escaped path plus the exact raw query string.
Unversioned legacy signatures are accepted only on query-free requests.
For an empty body, `body-sha256-hex` is the full SHA-256 of the empty
string: `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`.
On failure, the response includes `X-Portwing-Reason` with one of:
`timestamp-skew`, `replay`, `unknown-key`, `invalid-signature`.
schemas:
HealthResponse:
type: object
required: [status, live, ready, mode, version, uptimeSeconds, docker, controller]
properties:
status:
type: string
enum: [ok, healthy, unhealthy]
example: healthy
live:
type: boolean
description: Whether the Portwing process is running.
ready:
type: boolean
description: Whether the dependencies required by the current mode are connected.
mode:
type: string
enum: [standard, edge]
version:
type: string
description: Portwing agent version.
example: "0.9.17"
uptimeSeconds:
type: number
minimum: 0
description: Seconds since the agent process started.
docker:
type: string
enum: [connected, disconnected, unknown]
example: connected
controller:
type: string
enum: [connected, disconnected, not_applicable]
description: Edge controller state, or `not_applicable` in standard mode.
InfoResponse:
type: object
required: [version, dockerVersion, mode, uptime, hostname, agentId, agentName, capabilities]
properties:
version:
type: string
description: Portwing agent version
example: "0.9.17"
dockerVersion:
type: string
description: Docker Engine version string
example: "27.0.3"
mode:
type: string
enum: [standard]
description: Connection mode (always "standard" in HTTP API)
uptime:
type: string
description: Agent uptime as a Go duration string
example: "2h34m56.789s"
hostname:
type: string
example: "my-server"
agentId:
type: string
format: uuid
example: "550e8400-e29b-41d4-a716-446655440000"
agentName:
type: string
example: "my-server"
capabilities:
type: array
description: >
Adapter namespace and transport capabilities. Unsupported legacy
dd:watch and dd:trigger capabilities are omitted. Use the watcher
descriptor and empty trigger list to discover the v0.9.0
controller-owned execution contract; the corresponding wire message
types remain reserved but unadvertised.
items:
type: string
example: ["compose", "exec", "metrics", "events", "dd:container-sync", "dd:logs"]
ComposeRequest:
type: object
required: [operation, stackName]
properties:
operation:
type: string
enum: [up, down, pull, ps, logs, restart, stop, start]
description: Compose sub-command to execute.
stackName:
type: string
description: >
Stack name. Used as the subdirectory under `STACKS_DIR`
when `stackDir` is not supplied.
example: "myapp"
stackDir:
type: string
description: >
Explicit subdirectory within `STACKS_DIR`. Overrides the
`stackName`-derived path. Must not escape the stacks directory
(path-traversal protected).
example: "myapp/v2"
services:
type: array
items:
type: string
description: >
Optional list of service names to scope the operation.
Names starting with `-` are rejected (flag-injection guard).
example: ["web", "worker"]
build:
type: boolean
description: Pass `--build` to `compose up`.
default: false
forceRecreate:
type: boolean
description: Pass `--force-recreate` to `compose up`.
default: false
removeVolumes:
type: boolean
description: Pass `--volumes` to `compose down`.
default: false
noDeps:
type: boolean
description: Pass `--no-deps` to `compose up`.
default: false
tail:
type: integer
minimum: 1
description: Number of log lines to tail (`logs` operation only).
example: 100
envVars:
type: object
additionalProperties:
type: string
description: >
Environment variables written to `.env.drydock` before execution.
Keys must match `^[a-zA-Z_][a-zA-Z0-9_]*$`. The following keys
are denied: `LD_PRELOAD`, `LD_LIBRARY_PATH`, `PATH`,
`DOCKER_HOST`, `DOCKER_CONFIG`, `DOCKER_CERT_PATH`,
`DOCKER_TLS_VERIFY`, `DOCKER_CONTEXT`, `HOME`, `SHELL`,
`BASH_ENV`, `ENV`, `CDPATH`, `IFS`.
example:
DATABASE_URL: "postgres://..."
APP_PORT: "8080"
files:
type: object
additionalProperties:
type: string
description: >
Files to write into the stack directory before execution.
Keys are paths relative to the stack directory; values are
file content (plain text) or base64-encoded content prefixed
with `base64:`. Paths are resolved and verified within the
stacks directory (path-traversal protected).
example:
"docker-compose.yml": "version: '3'\nservices:\n web:\n image: nginx\n"
registryAuth:
$ref: '#/components/schemas/RegistryAuth'
RegistryAuth:
type: object
required: [server, username, password]
properties:
server:
type: string
description: Registry hostname (e.g. `ghcr.io`).
example: "ghcr.io"
username:
type: string
example: "myuser"
password:
type: string
format: password
description: >
Registry password or token. Passed via `--password-stdin`
to `docker login`; never appears in process argument list.
example: "ghp_..."
ComposeResponse:
type: object
required: [success]
properties:
success:
type: boolean
output:
type: string
description: Combined stdout + stderr from the Compose command.
example: "Container myapp-web-1 Started\n"
error:
type: string
description: Error message if `success` is false.
example: "exit status 1"
Container:
type: object
description: Drydock container model with update metadata.
properties:
id:
type: string
example: "abc123def456"
name:
type: string
example: "myapp-web-1"
displayName:
type: string
example: "My App Web"
displayIcon:
type: string
example: "docker"
status:
type: string
example: "running"
watcher:
type: string
example: "docker"
agent:
type: string
health:
type: string
description: >
Docker health-check state, present only when the container
declares a health check.
enum: [starting, healthy, unhealthy]
example: "healthy"
image:
$ref: '#/components/schemas/ContainerImage'
result:
$ref: '#/components/schemas/ContainerResult'
error:
$ref: '#/components/schemas/ContainerError'
updateAvailable:
type: boolean
updateKind:
$ref: '#/components/schemas/ContainerUpdateKind'
includeTags:
type: string
excludeTags:
type: string
transformTags:
type: string
labels:
type: object
additionalProperties:
type: string
details:
$ref: '#/components/schemas/RuntimeDetails'
ContainerImage:
type: object
description: >
Drydock's image model. `registry`, `tag` and `digest` are objects, not
strings: Drydock's AgentClient stores this shape verbatim, so the
nesting is the wire contract rather than an encoding detail.
required: [id, registry, name, tag, digest, architecture, os]
properties:
id:
type: string
example: "sha256:0f2c1a2f"
registry:
$ref: '#/components/schemas/ContainerImageRegistry'
name:
type: string
example: "library/nginx"
tag:
$ref: '#/components/schemas/ContainerImageTag'
digest:
$ref: '#/components/schemas/ContainerImageDigest'
architecture:
type: string
description: Image architecture, falling back to the agent's own.
example: "arm64"
os:
type: string
description: Image OS, falling back to the agent's own.
example: "linux"
created:
type: string
description: Image creation timestamp, when the daemon reports one.
ContainerImageRegistry:
type: object
description: >
Registry component assignment. Portwing reports the URL it parsed from
the image reference and leaves `name` as `unknown`, because the
registry component is named by the Drydock controller's own config.
required: [name, url]
properties:
name:
type: string
example: "unknown"
url:
type: string
example: "docker.io"
ContainerImageTag:
type: object
required: [value, semver]
properties:
value:
type: string
example: "1.27.0"
semver:
type: boolean
description: >
Whether Drydock should treat `value` as a semver range. Portwing
reports false; semver classification is controller-owned.
example: false
ContainerImageDigest:
type: object
required: [watch]
properties:
watch:
type: boolean
description: >
Whether Drydock should watch the digest for changes. Portwing
reports false; digest watching is controller-owned.
example: false
value:
type: string
description: Image digest (`sha256:...`) when the daemon reports one.
repo:
type: string
description: Digest repository, set by the Drydock controller.
ContainerUpdateKind:
type: object
description: >
Update classification. Portwing's raw inventory always reports
`{"kind":"unknown"}`; the Drydock controller fills in the real kind
from its own watcher result.
required: [kind]
properties:
kind:
type: string
example: "unknown"
ContainerResult:
type: object
properties:
tag:
type: string
digest:
type: string
description: Image digest (`sha256:...`) when resolved.
created:
type: string
format: date-time
link:
type: string
description: Optional link to the image/registry page.
ContainerError:
type: object
properties:
message:
type: string
RuntimeDetails:
type: object
description: Runtime container details (ports, mounts, environment, etc.).
additionalProperties: true
WatcherComponent:
type: object
description: >
Drydock watcher component descriptor. Portwing v0.9.0's `docker`
descriptor marks Docker API transport and watcher/update execution as
controller-owned while retaining Portwing lifecycle events. Drydock
v1.6.0-rc.11+ consumes this complete feature contract.
required: [type, name, configuration]
properties:
type:
type: string
example: docker
name:
type: string
example: docker
configuration:
type: object
additionalProperties: true
example:
description: Watches Docker containers for updates via Docker Engine API
capabilities: [container-sync, labels]
transport: docker-api
execution: controller
events: portwing
TriggerComponent:
type: object
description: >
Drydock trigger component descriptor. Portwing v0.9.0 advertises an
empty trigger list because update execution is controller-owned.
additionalProperties: true
NotImplementedResponse:
type: object
required: [error, message]
properties:
error:
type: string
example: "not implemented in v1.0"
message:
type: string
example: "registry checking is performed by the Drydock controller"
ErrorResponse:
type: object
properties:
error:
type: string
GenericVersionResponse:
type: object
required: [agentVersion, protocolName, protocolVersion, adapter]
description: Generic adapter version and protocol metadata.
properties:
agentVersion:
type: string
example: "0.9.17"
protocolName:
type: string
example: "portwing"
protocolVersion:
type: string
example: "1.0"
adapter:
type: string
example: "generic"
GenericEvent:
type: object
required: [ts, type, action, containerId, name, image]
description: Generic Docker lifecycle event envelope (ADAPTER=generic SSE stream).
properties:
ts:
type: string
format: date-time
description: Event timestamp in RFC 3339 UTC.
example: "2026-06-11T10:00:00Z"
type:
type: string
description: Docker object type (always "container" for this stream).
example: "container"
action:
type: string
description: Docker event action (create, start, stop, die, kill, etc.).
example: "start"
containerId:
type: string
description: Container ID from the Docker actor.
example: "abc123def456"
name:
type: string
description: Container name from event attributes.
example: "my-container"
image:
type: string
description: Image name from event attributes.
example: "nginx:latest"
labels:
type: object
additionalProperties:
type: string
description: >
User-defined container labels from event attributes. Synthetic
Docker keys (name, image, exitCode, etc.) are stripped.
AuditRecord:
type: object
required: [cursor, ts, event]
description: >
A single structured audit event from the in-memory ring buffer. Field
names match the stable on-wire JSON schema; optional fields are omitted
when empty. This ring-buffer schema differs from the streamed slog log
line, which uses `time`/`level`/`msg` keys.
properties:
cursor:
type: integer
format: int64
minimum: 1
description: Monotonic cursor scoped to the current agent process.
ts:
type: string
format: date-time
description: Event timestamp (RFC3339 UTC).
event:
type: string
description: Event type.
example: "exec_start"
actor:
type: string
description: Authenticated principal (token label or key ID).
method:
type: string
description: HTTP method (api_request / auth_failure / rate_limited events only).
path:
type: string
description: HTTP path (api_request / auth_failure / rate_limited events only).
outcome:
type: string
example: "allowed"
status:
type: integer
example: 200
duration_ms:
type: number
operation:
type: string
stack:
type: string
container:
type: string
exec_id:
type: string
key_id:
type: string
description: hex(SHA-256(pubkey)[:8]).
AuditResponse:
type: object
required: [records, count]
properties:
records:
type: array
items:
$ref: '#/components/schemas/AuditRecord'
count:
type: integer
description: Number of records returned.
MCPRequest:
type: object
required: [jsonrpc, method]
description: JSON-RPC 2.0 request envelope.
properties:
jsonrpc:
type: string
enum: ["2.0"]
id:
description: Request ID (string, number, or null). Absent for notifications.
method:
type: string
example: "tools/list"
params:
type: object
additionalProperties: true
MCPResponse:
type: object
required: [jsonrpc, id]
description: JSON-RPC 2.0 response envelope.
properties:
jsonrpc:
type: string
enum: ["2.0"]
id:
description: Echoes the request ID.
result:
type: object
additionalProperties: true
error:
type: object
properties:
code:
type: integer
message:
type: string
paths:
/health:
get:
operationId: getHealth
summary: Process liveness
description: >
Returns HTTP 200 while the Portwing process is running. No auth
required. This route does not probe Docker or the edge controller;
use `/ready` for dependency readiness.
tags: [Health]
responses:
"200":
description: Agent is running.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/ready:
get:
operationId: getReadiness
summary: Agent readiness
description: >
Probes Docker connectivity and, in edge mode, the controller
WebSocket. No auth required. Returns HTTP 503 until all dependencies
required by the active mode are connected.
tags: [Health]
responses:
"200":
description: Agent dependencies are ready.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
"503":
description: Docker or the edge controller is unavailable.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/_portwing/health:
get:
operationId: getPortwingHealth
summary: Agent health check with Docker connectivity
description: >
Compatibility alias for `/ready`. Returns mode, version, uptime,
Docker state, and edge-controller state. No auth required.
tags: [Health]
responses:
"200":
description: Agent healthy and Docker connected.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
status: healthy
docker: connected
"503":
description: Docker daemon unreachable.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
status: unhealthy
docker: disconnected
/_portwing/info:
get:
operationId: getPortwingInfo
summary: Agent metadata
description: >
Returns agent version, Docker version, connection mode, uptime,
hostname, and capability list. Bearer auth required.
tags: [Agent]
security:
- bearerToken: []
- portwingToken: []
responses:
"200":
description: Agent metadata.
content:
application/json:
schema:
$ref: '#/components/schemas/InfoResponse'
"401":
description: Missing or invalid token.
"429":
description: Rate limit exceeded (10 failures/min/IP).
/_portwing/metrics:
get:
operationId: getPortwingMetrics
summary: Prometheus metrics (namespaced)
description: >
Exposes Portwing agent metrics in Prometheus text exposition format
(version 0.0.4), including HTTP, host, container, audit, and edge
connection/backpressure series. Metrics are prefixed with `portwing_`
or `container_`. Bearer auth is required in standard mode.
Scrape this endpoint rather than `/metrics` when you want only
agent-specific metrics without Docker daemon metrics.
tags: [Metrics]
security:
- bearerToken: []
- portwingToken: []
responses:
"200":
description: Prometheus text format metrics.
content:
text/plain; version=0.0.4:
schema:
type: string
example: |
# HELP portwing_cpu_usage_percent Host CPU usage percentage.
# TYPE portwing_cpu_usage_percent gauge
portwing_cpu_usage_percent 23.5
# HELP portwing_memory_used_bytes Host memory used in bytes.
# TYPE portwing_memory_used_bytes gauge
portwing_memory_used_bytes 4294967296
"401":
description: Missing or invalid token.
"429":
description: Rate limit exceeded.
/metrics:
get:
operationId: getMetrics
summary: Prometheus metrics (root)
description: >
Alias for `/_portwing/metrics`. Exposes Portwing agent metrics in
Prometheus text exposition format (version 0.0.4). Bearer auth
required.
Provided for compatibility with default Prometheus scrape configs
that expect metrics at `/metrics`.
tags: [Metrics]
security:
- bearerToken: []
- portwingToken: []
responses:
"200":
description: Prometheus text format metrics.
content:
text/plain; version=0.0.4:
schema:
type: string
"401":
description: Missing or invalid token.
"429":
description: Rate limit exceeded.
/_portwing/compose:
post:
operationId: postPortwingCompose
summary: Docker Compose operations
description: >
Executes a Docker Compose sub-command within the managed stacks
directory (`STACKS_DIR`, default `/data/stacks`). The request body
specifies the operation, stack, optional files to write, and optional
env vars.
**Security controls applied before execution:**
- Stack path resolved to absolute and verified within `STACKS_DIR`
(path-traversal protection).
- Env var keys validated against `^[a-zA-Z_][a-zA-Z0-9_]*$` and
checked against the denylist.
- Service names must not start with `-` (flag-injection prevention).
- Registry auth passed via `--password-stdin` (never in argv).
tags: [Compose]
security:
- bearerToken: []
- portwingToken: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ComposeRequest'
examples:
up:
summary: Bring up a stack
value:
operation: up
stackName: myapp
build: false
forceRecreate: false
down-with-volumes:
summary: Remove a stack including volumes
value:
operation: down
stackName: myapp
removeVolumes: true
deploy-with-files:
summary: Write compose file then bring up
value:
operation: up
stackName: myapp
files:
"docker-compose.yml": "version: '3'\nservices:\n web:\n image: nginx:latest\n"
envVars:
APP_PORT: "8080"
responses:
"200":
description: Compose command executed (check `success` field for result).
content:
application/json:
schema:
$ref: '#/components/schemas/ComposeResponse'
examples:
success:
value:
success: true
output: "Container myapp-web-1 Started\n"
failure:
value:
success: false
output: "Error response from daemon: ..."
error: "exit status 1"
"400":
description: Invalid or malformed request body.
"401":
description: Missing or invalid token.
"429":
description: Rate limit exceeded.
"500":
description: Internal server error.
/_portwing/audit:
get:
operationId: getPortwingAudit
summary: Recent audit records
description: >
Returns recent structured audit records from the in-memory ring
buffer, newest-first. Bearer auth required.
tags: [Agent]
security:
- bearerToken: []
- portwingToken: []
parameters:
- name: limit
in: query
schema:
type: integer
description: >
Maximum number of records to return (newest-first). Omit or use a
non-positive value to return all currently buffered records.
example: 100
responses:
"200":
description: Buffered audit records.
content:
application/json:
schema:
$ref: '#/components/schemas/AuditResponse'
"401":
description: Missing or invalid token.
"429":
description: Rate limit exceeded.
/_portwing/audit/export:
get:
operationId: exportPortwingAudit
summary: Cursor-based NDJSON audit export
description: >
Streams retained audit records oldest-first as newline-delimited JSON.
On the first request, omit `cursor` to bootstrap from the oldest
retained record. Persist `X-Portwing-Next-Cursor` and provide it on the
next request. A 409 response detects overwritten history or an agent
restart instead of silently skipping records. Standard mode requires
Bearer or Portwing-token authentication. Edge mode exposes this route
without inbound authentication on its private operations listener;
restrict listener access because records may contain sensitive
operational metadata.
tags: [Agent]
security:
- bearerToken: []
- portwingToken: []
parameters:
- name: cursor
in: query
schema:
type: integer
format: int64
minimum: 0
description: Last successfully consumed cursor. Omit for initial bootstrap.
- name: limit
in: query
schema:
type: integer
minimum: 0
description: Maximum records to return; zero or omitted returns all retained matches.
responses:
"200":
description: Retained records after the supplied cursor.
headers:
X-Portwing-Oldest-Cursor:
schema:
type: integer
X-Portwing-Latest-Cursor:
schema:
type: integer
X-Portwing-Next-Cursor:
schema:
type: integer
description: Cursor to persist after consuming the response.
X-Portwing-Record-Count:
schema:
type: integer
content:
application/x-ndjson:
schema:
type: string
example: |
{"cursor":41,"ts":"2026-07-28T19:00:00Z","event":"auth_failure","actor":"203.0.113.9","method":"GET","path":"/_portwing/info","outcome":"denied"}
{"cursor":42,"ts":"2026-07-28T19:00:01Z","event":"api_request","actor":"203.0.113.42","method":"GET","path":"/metrics","outcome":"allowed","status":200}
"400":
description: Invalid cursor or limit.
"409":
description: >
Cursor is outside the current retained window. Reset to the
`X-Portwing-Next-Cursor` response header and surface the gap.
"401":
description: Missing or invalid token (Standard mode only).
"429":
description: Rate limit exceeded.