{
  "openapi": "3.1.0",
  "info": {
    "title": "PacketGrid Customer API",
    "version": "1.1.0",
    "description": "Scoped API for one owned active game server or VPS per key. Billing and account management are not API operations."
  },
  "servers": [
    {
      "url": "{dashboardOrigin}",
      "variables": {
        "dashboardOrigin": {
          "default": "https://localhost",
          "description": "Set this to the address of your PacketGrid dashboard."
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/v1/server": {
      "get": {
        "summary": "Read the key's server",
        "operationId": "getServer",
        "x-packetgrid-scope": "server.read",
        "responses": {
          "200": {
            "description": "Server identity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Server"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/server/resources": {
      "get": {
        "summary": "Read live resources",
        "operationId": "getResources",
        "x-packetgrid-scope": "server.read",
        "responses": {
          "200": {
            "description": "Live panel resource readings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Resources"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/api/v1/server/console": {
      "get": {
        "summary": "Read game console output",
        "description": "Recent and live output as server-sent events. Connections last up to 15 minutes.",
        "x-packetgrid-scope": "console.read",
        "responses": {
          "200": {
            "description": "Read game console output",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid key"
          },
          "403": {
            "description": "Permission denied"
          },
          "429": {
            "description": "Console rate or connection limit reached"
          },
          "502": {
            "description": "Console unavailable"
          }
        }
      }
    },
    "/api/v1/server/power": {
      "post": {
        "summary": "Start, stop, or restart",
        "operationId": "power",
        "description": "The signal selects the required scope. Start or restart may require a dashboard video; paid starts may require a Cloudflare check. Power is limited to 10 requests per server in two minutes.",
        "x-packetgrid-scope": "power.start | power.stop | power.restart",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "signal"
                ],
                "properties": {
                  "signal": {
                    "type": "string",
                    "enum": [
                      "start",
                      "stop",
                      "restart"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/api/v1/server/command": {
      "post": {
        "summary": "Send a game console command",
        "operationId": "sendCommand",
        "description": "This is input to the game process, not an operating-system shell.",
        "x-packetgrid-scope": "console.command",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "command"
                ],
                "properties": {
                  "command": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/Ok"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/api/v1/server/files": {
      "get": {
        "summary": "List a directory",
        "operationId": "listFiles",
        "x-packetgrid-scope": "files.read",
        "parameters": [
          {
            "name": "directory",
            "in": "query",
            "description": "Absolute directory path; defaults to /",
            "schema": {
              "$ref": "#/components/schemas/AbsolutePath"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Panel file listing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      },
      "delete": {
        "summary": "Delete one entry",
        "operationId": "deleteFile",
        "x-packetgrid-scope": "files.delete",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NamedEntry"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/api/v1/server/files/content": {
      "get": {
        "summary": "Read text file",
        "operationId": "readFile",
        "x-packetgrid-scope": "files.read",
        "parameters": [
          {
            "$ref": "#/components/parameters/FilePath"
          }
        ],
        "responses": {
          "200": {
            "description": "Raw text file",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      },
      "put": {
        "summary": "Replace text file",
        "operationId": "writeFile",
        "description": "Replaces the full text file. Maximum 1 MiB.",
        "x-packetgrid-scope": "files.write",
        "parameters": [
          {
            "$ref": "#/components/parameters/FilePath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Written"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/api/v1/server/files/directory": {
      "post": {
        "summary": "Create a directory",
        "operationId": "createDirectory",
        "x-packetgrid-scope": "files.write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NamedEntry"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Created"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/api/v1/server/files/rename": {
      "put": {
        "summary": "Rename one entry",
        "operationId": "renameFile",
        "x-packetgrid-scope": "files.write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "root",
                  "from",
                  "to"
                ],
                "properties": {
                  "root": {
                    "$ref": "#/components/schemas/AbsolutePath"
                  },
                  "from": {
                    "$ref": "#/components/schemas/EntryName"
                  },
                  "to": {
                    "$ref": "#/components/schemas/EntryName"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/api/v1/vps": {
      "get": {
        "summary": "Read the key's VPS",
        "operationId": "getVps",
        "x-packetgrid-scope": "server.read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Vps"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          }
        }
      }
    },
    "/api/v1/vps/resources": {
      "get": {
        "summary": "Read VPS usage without internal connection details",
        "operationId": "getVpsResources",
        "x-packetgrid-scope": "server.read",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VpsResources"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          }
        }
      }
    },
    "/api/v1/vps/console": {
      "get": {
        "summary": "Capture the VPS console screen",
        "description": "Read-only PNG snapshot of the current screen. Requires a running VPS.",
        "x-packetgrid-scope": "console.read",
        "responses": {
          "200": {
            "description": "Capture the VPS console screen",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid key"
          },
          "403": {
            "description": "Permission denied"
          },
          "429": {
            "description": "Console rate or connection limit reached"
          },
          "502": {
            "description": "Console unavailable"
          }
        }
      }
    },
    "/api/v1/vps/power": {
      "post": {
        "summary": "Confirm VPS start, graceful stop/restart, or Force Off",
        "operationId": "vpsPower",
        "x-packetgrid-scope": "power.start | power.stop | power.restart | power.force-stop",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          }
        },
        "description": "Each signal requires its matching scope. force-stop requires confirm=true. Subscription checks apply to start/restart. Shared dashboard/API cooldown is ten attempts per account/VPS in two minutes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "signal"
                ],
                "additionalProperties": false,
                "properties": {
                  "signal": {
                    "enum": [
                      "start",
                      "stop",
                      "restart",
                      "force-stop"
                    ]
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vps/files": {
      "get": {
        "summary": "List a directory",
        "operationId": "vpsListfiles",
        "x-packetgrid-scope": "files.read",
        "parameters": [
          {
            "name": "directory",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "/"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "entries",
                    "hasMore",
                    "nextOffset"
                  ],
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "isDirectory": {
                            "type": "boolean"
                          },
                          "size": {
                            "type": "integer"
                          },
                          "modifiedAt": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "nextOffset": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          }
        },
        "description": "Linux guest files as root; running guest agent required. Metadata/directory operations require Python 3 and glibc. UTF-8 file content is limited to 1 MiB. Deleting directories requires an empty directory. Rename refuses existing destinations."
      },
      "delete": {
        "summary": "Delete one entry",
        "operationId": "vpsDeletefile",
        "x-packetgrid-scope": "files.delete",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NamedEntry"
              }
            }
          }
        },
        "responses": {
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          },
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          }
        },
        "description": "Linux guest files as root; running guest agent required. Metadata/directory operations require Python 3 and glibc. UTF-8 file content is limited to 1 MiB. Deleting directories requires an empty directory. Rename refuses existing destinations."
      }
    },
    "/api/v1/vps/files/content": {
      "get": {
        "summary": "Read text file",
        "operationId": "vpsReadfile",
        "x-packetgrid-scope": "files.read",
        "parameters": [
          {
            "$ref": "#/components/parameters/FilePath"
          }
        ],
        "responses": {
          "200": {
            "description": "Raw text file",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          }
        },
        "description": "Linux guest files as root; running guest agent required. Metadata/directory operations require Python 3 and glibc. UTF-8 file content is limited to 1 MiB. Deleting directories requires an empty directory. Rename refuses existing destinations."
      },
      "put": {
        "summary": "Replace text file",
        "operationId": "vpsWritefile",
        "description": "Linux guest files as root; running guest agent required. Metadata/directory operations require Python 3 and glibc. UTF-8 file content is limited to 1 MiB. Deleting directories requires an empty directory. Rename refuses existing destinations.",
        "x-packetgrid-scope": "files.write",
        "parameters": [
          {
            "$ref": "#/components/parameters/FilePath"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          },
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vps/files/directory": {
      "post": {
        "summary": "Create a directory",
        "operationId": "vpsCreatedirectory",
        "x-packetgrid-scope": "files.write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NamedEntry"
              }
            }
          }
        },
        "responses": {
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          },
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          }
        },
        "description": "Linux guest files as root; running guest agent required. Metadata/directory operations require Python 3 and glibc. UTF-8 file content is limited to 1 MiB. Deleting directories requires an empty directory. Rename refuses existing destinations."
      }
    },
    "/api/v1/vps/files/rename": {
      "put": {
        "summary": "Rename one entry",
        "operationId": "vpsRenamefile",
        "x-packetgrid-scope": "files.write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "root",
                  "from",
                  "to"
                ],
                "properties": {
                  "root": {
                    "$ref": "#/components/schemas/AbsolutePath"
                  },
                  "from": {
                    "$ref": "#/components/schemas/EntryName"
                  },
                  "to": {
                    "$ref": "#/components/schemas/EntryName"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          },
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          }
        },
        "description": "Linux guest files as root; running guest agent required. Metadata/directory operations require Python 3 and glibc. UTF-8 file content is limited to 1 MiB. Deleting directories requires an empty directory. Rename refuses existing destinations."
      }
    },
    "/api/v1/vps/exec": {
      "post": {
        "summary": "Start a root command inside the selected VPS",
        "operationId": "startVpsCommand",
        "x-packetgrid-scope": "guest.exec",
        "responses": {
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          },
          "202": {
            "description": "Command started. Poll GET /api/v1/vps/exec?pid=...",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "pid"
                  ],
                  "properties": {
                    "pid": {
                      "type": "integer",
                      "minimum": 1
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "command"
                ],
                "additionalProperties": false,
                "properties": {
                  "command": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 64,
                    "items": {
                      "type": "string",
                      "maxLength": 4096
                    }
                  }
                }
              }
            }
          }
        },
        "description": "The executable must be non-empty; NUL bytes are refused. Runs as root in this guest, not on the hosting system. Key revocation does not cancel an already-started process. Combined command JSON is limited to 256 KiB."
      },
      "get": {
        "summary": "Read the result of a guest command",
        "operationId": "getVpsCommandResult",
        "x-packetgrid-scope": "guest.exec",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GuestExecution"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/GuestMissing"
          },
          "409": {
            "$ref": "#/components/responses/GuestConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "504": {
            "$ref": "#/components/responses/GuestTimeout"
          }
        },
        "parameters": [
          {
            "name": "pid",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "PacketGrid API key"
      }
    },
    "parameters": {
      "FilePath": {
        "name": "path",
        "in": "query",
        "required": true,
        "description": "Absolute path to a text file",
        "schema": {
          "$ref": "#/components/schemas/AbsolutePath"
        }
      }
    },
    "schemas": {
      "AbsolutePath": {
        "type": "string",
        "maxLength": 1024,
        "pattern": "^/",
        "description": "Absolute path with no parent traversal, backslash, or control characters."
      },
      "EntryName": {
        "type": "string",
        "minLength": 1,
        "maxLength": 255,
        "description": "One name with no slash, backslash, control character, . or .."
      },
      "NamedEntry": {
        "type": "object",
        "required": [
          "root",
          "name"
        ],
        "properties": {
          "root": {
            "$ref": "#/components/schemas/AbsolutePath"
          },
          "name": {
            "$ref": "#/components/schemas/EntryName"
          }
        }
      },
      "Server": {
        "type": "object",
        "required": [
          "id",
          "name",
          "status",
          "plan"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "plan": {
            "type": "string"
          }
        }
      },
      "Resources": {
        "type": "object",
        "required": [
          "currentState",
          "cpuAbsolute",
          "memoryBytes",
          "memoryLimitBytes",
          "diskBytes",
          "networkRxBytes",
          "networkTxBytes",
          "uptimeMs"
        ],
        "properties": {
          "currentState": {
            "type": "string"
          },
          "cpuAbsolute": {
            "type": "number"
          },
          "memoryBytes": {
            "type": "number"
          },
          "memoryLimitBytes": {
            "type": "number"
          },
          "diskBytes": {
            "type": "number"
          },
          "networkRxBytes": {
            "type": "number"
          },
          "networkTxBytes": {
            "type": "number"
          },
          "uptimeMs": {
            "type": "number"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "VpsResources": {
        "type": "object",
        "properties": {
          "cpuPercent": {
            "type": [
              "number",
              "null"
            ]
          },
          "memoryBytes": {
            "type": [
              "number",
              "null"
            ]
          },
          "maxMemoryBytes": {
            "type": [
              "number",
              "null"
            ]
          },
          "diskUsedBytes": {
            "type": [
              "number",
              "null"
            ]
          },
          "diskTotalBytes": {
            "type": [
              "number",
              "null"
            ]
          },
          "uptimeSeconds": {
            "type": [
              "number",
              "null"
            ]
          },
          "networkInBytes": {
            "type": [
              "number",
              "null"
            ]
          },
          "networkOutBytes": {
            "type": [
              "number",
              "null"
            ]
          },
          "power": {
            "type": "string"
          }
        },
        "required": [
          "cpuPercent",
          "memoryBytes",
          "maxMemoryBytes",
          "diskUsedBytes",
          "diskTotalBytes",
          "uptimeSeconds",
          "networkInBytes",
          "networkOutBytes",
          "power"
        ]
      },
      "Vps": {
        "type": "object",
        "required": [
          "id",
          "name",
          "status",
          "operatingSystem",
          "vcpu",
          "memoryMb",
          "storageMb"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "operatingSystem": {
            "type": "string"
          },
          "vcpu": {
            "type": "integer"
          },
          "memoryMb": {
            "type": "integer"
          },
          "storageMb": {
            "type": "integer"
          }
        }
      },
      "GuestExecution": {
        "type": "object",
        "required": [
          "exited",
          "exitCode",
          "stdout",
          "stderr",
          "truncated"
        ],
        "properties": {
          "exited": {
            "type": "boolean"
          },
          "exitCode": {
            "type": [
              "integer",
              "null"
            ]
          },
          "stdout": {
            "type": "string",
            "maxLength": 65536
          },
          "stderr": {
            "type": "string",
            "maxLength": 65536
          },
          "truncated": {
            "type": "boolean"
          }
        }
      }
    },
    "responses": {
      "Ok": {
        "description": "Action accepted",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "ok"
              ],
              "properties": {
                "ok": {
                  "const": true
                }
              }
            }
          }
        }
      },
      "BadRequest": {
        "description": "Invalid request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Permission or dashboard check required",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooLarge": {
        "description": "Request exceeds 1 MiB",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit reached",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "UpstreamError": {
        "description": "Panel request failed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "GuestConflict": {
        "description": "Guest unavailable, filesystem conflict, unconfirmed power state or power cooldown",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "GuestMissing": {
        "description": "Guest file or directory not found"
      },
      "GuestTimeout": {
        "description": "The guest file operation is still running; inspect before retrying"
      }
    }
  }
}
