{
  "openapi": "3.1.0",
  "info": {
    "title": "CDNShark Customer API \u2014 Cloud VPS & Valkey",
    "version": "2026-11-27",
    "description": "Manage your Cloud VPS servers and Valkey caches. Same actions as the portal. Ordering, plan changes, cancel and terminate are portal-only. Full docs: https://cdnshark.com/wiki/api. Rate limit: 120 requests/minute per account."
  },
  "servers": [
    {
      "url": "https://cdnshark.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Cloud VPS"
    },
    {
      "name": "Valkey Cache"
    }
  ],
  "paths": {
    "/api/vps": {
      "get": {
        "operationId": "listVps",
        "summary": "List your servers",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:read`.",
        "responses": {
          "200": {
            "description": "Your servers (terminated ones excluded).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Vps"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/vps/{id}": {
      "get": {
        "operationId": "getVps",
        "summary": "Show a server",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:read`.",
        "responses": {
          "200": {
            "description": "The server.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/VpsDetail"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ]
      }
    },
    "/api/vps/{id}/metrics": {
      "get": {
        "operationId": "getVpsMetrics",
        "summary": "CPU, memory, network and disk metrics",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:read`.",
        "responses": {
          "200": {
            "description": "Time series.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Metrics"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          },
          {
            "name": "timeframe",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "hour",
                "day",
                "week",
                "month"
              ],
              "default": "hour"
            }
          }
        ]
      }
    },
    "/api/vps/{id}/images": {
      "get": {
        "operationId": "listVpsImages",
        "summary": "OS images this server can be rebuilt with",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:read`.",
        "responses": {
          "200": {
            "description": "Images.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Image"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ]
      }
    },
    "/api/vps/{id}/power/{action}": {
      "post": {
        "operationId": "powerVps",
        "summary": "Start, stop (hard) or reboot",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Started. Poll GET /api/vps/{id} until `busy` is false.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          },
          {
            "name": "action",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "start",
                "stop",
                "reboot"
              ]
            }
          }
        ]
      }
    },
    "/api/vps/{id}/rebuild": {
      "post": {
        "operationId": "rebuildVps",
        "summary": "Rebuild (ERASES the disk)",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Reinstalls the server from an image. Limited to 6 per hour.\n\nToken ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Started. Poll GET /api/vps/{id} until `busy` is false.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RebuildRequest"
              }
            }
          }
        }
      }
    },
    "/api/vps/{id}/snapshots": {
      "get": {
        "operationId": "listSnapshots",
        "summary": "List snapshots",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:read`.",
        "responses": {
          "200": {
            "description": "Snapshots.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/SnapshotList"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ]
      },
      "post": {
        "operationId": "createSnapshot",
        "summary": "Take a snapshot",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Started. Poll GET /api/vps/{id} until `busy` is false.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SnapshotRequest"
              }
            }
          }
        }
      }
    },
    "/api/vps/{id}/snapshots/{name}": {
      "delete": {
        "operationId": "deleteSnapshot",
        "summary": "Delete a snapshot",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          },
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ]
      }
    },
    "/api/vps/{id}/snapshots/{name}/rollback": {
      "post": {
        "operationId": "rollbackSnapshot",
        "summary": "Roll back to a snapshot",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Changes made since the snapshot are lost.\n\nToken ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Started. Poll GET /api/vps/{id} until `busy` is false.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          },
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ]
      }
    },
    "/api/vps/{id}/backups": {
      "get": {
        "operationId": "listBackups",
        "summary": "List backups",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:read`.",
        "responses": {
          "200": {
            "description": "Backups.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BackupList"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ]
      },
      "post": {
        "operationId": "createBackup",
        "summary": "Start a backup",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Started. Poll GET /api/vps/{id} until `busy` is false.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ]
      },
      "delete": {
        "operationId": "deleteBackup",
        "summary": "Delete a backup",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VolidRequest"
              }
            }
          }
        }
      }
    },
    "/api/vps/{id}/backups/restore": {
      "post": {
        "operationId": "restoreBackup",
        "summary": "Restore a backup (REPLACES the disk)",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Started. Poll GET /api/vps/{id} until `busy` is false.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VolidRequest"
              }
            }
          }
        }
      }
    },
    "/api/vps/{id}/firewall": {
      "get": {
        "operationId": "getFirewall",
        "summary": "Firewall rules and inbound default",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:read`.",
        "responses": {
          "200": {
            "description": "Firewall.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Firewall"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ]
      }
    },
    "/api/vps/{id}/firewall/rules": {
      "post": {
        "operationId": "addFirewallRule",
        "summary": "Add a firewall rule",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FirewallRuleRequest"
              }
            }
          }
        }
      }
    },
    "/api/vps/{id}/firewall/rules/{pos}": {
      "delete": {
        "operationId": "deleteFirewallRule",
        "summary": "Remove a firewall rule",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Token ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          },
          {
            "name": "pos",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Rule position from GET firewall. Positions shift after a delete."
          }
        ]
      }
    },
    "/api/vps/{id}/firewall/policy": {
      "put": {
        "operationId": "setFirewallPolicy",
        "summary": "Set the inbound default",
        "tags": [
          "Cloud VPS"
        ],
        "description": "Add a rule that keeps your SSH access open before switching to DROP.\n\nToken ability: `vps:write`.",
        "responses": {
          "202": {
            "description": "Changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "VPS id from GET /api/vps."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PolicyRequest"
              }
            }
          }
        }
      }
    },
    "/api/valkey": {
      "get": {
        "operationId": "listCaches",
        "summary": "List your caches",
        "tags": [
          "Valkey Cache"
        ],
        "description": "Token ability: `valkey:read`.",
        "responses": {
          "200": {
            "description": "Caches.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Cache"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/valkey/{id}": {
      "get": {
        "operationId": "getCache",
        "summary": "Show a cache with its connection details",
        "tags": [
          "Valkey Cache"
        ],
        "description": "Token ability: `valkey:read`.",
        "responses": {
          "200": {
            "description": "The cache. `connection` (with the password) is present while the cache is active.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CacheDetail"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Cache id from GET /api/valkey."
          }
        ]
      }
    },
    "/api/valkey/{id}/ips": {
      "post": {
        "operationId": "allowCacheIp",
        "summary": "Allow a client IP",
        "tags": [
          "Valkey Cache"
        ],
        "description": "Up to 20 per cache.\n\nToken ability: `valkey:write`.",
        "responses": {
          "200": {
            "description": "Updated cache.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Cache"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Cache id from GET /api/valkey."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IpRequest"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "removeCacheIp",
        "summary": "Remove a client IP",
        "tags": [
          "Valkey Cache"
        ],
        "description": "Token ability: `valkey:write`.",
        "responses": {
          "200": {
            "description": "Updated cache.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Cache"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "Cache id from GET /api/valkey."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IpRequest"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API token from the portal (Account \u2192 API Tokens) with vps:* / valkey:* permissions."
      }
    },
    "schemas": {
      "Message": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      },
      "Ref": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          }
        }
      },
      "Vps": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "hostname": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "description": "running, stopped, rebuilding, suspended, error, \u2026"
          },
          "provision_status": {
            "type": [
              "string",
              "null"
            ]
          },
          "busy": {
            "type": "boolean"
          },
          "ipv4": {
            "type": [
              "string",
              "null"
            ]
          },
          "ipv6": {
            "type": [
              "string",
              "null"
            ]
          },
          "region": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Ref"
              },
              {
                "type": "null"
              }
            ]
          },
          "plan": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Ref"
              },
              {
                "type": "null"
              }
            ]
          },
          "vcpu": {
            "type": "integer"
          },
          "ram_mb": {
            "type": "integer"
          },
          "disk_gb": {
            "type": "integer"
          },
          "os_key": {
            "type": [
              "string",
              "null"
            ]
          },
          "os": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "VpsDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Vps"
          },
          {
            "type": "object",
            "properties": {
              "auth_method": {
                "type": "string",
                "enum": [
                  "password",
                  "key"
                ]
              },
              "login_user": {
                "type": "string"
              },
              "provisioned_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "limits": {
                "type": "object",
                "properties": {
                  "snapshots": {
                    "type": "integer"
                  },
                  "backups": {
                    "type": "integer"
                  },
                  "firewall_rules": {
                    "type": "integer"
                  }
                }
              },
              "bandwidth": {
                "type": "object",
                "properties": {
                  "used_bytes": {
                    "type": "integer"
                  },
                  "allowance_bytes": {
                    "type": "integer"
                  },
                  "period_ends_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "throttled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        ]
      },
      "Metrics": {
        "type": "object",
        "properties": {
          "timeframe": {
            "type": "string"
          },
          "series": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "t": {
                  "type": "integer",
                  "description": "Unix time"
                },
                "cpu": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "% of all vCPUs"
                },
                "mem": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "maxmem": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "netin": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "bytes/s"
                },
                "netout": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "bytes/s"
                },
                "diskread": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "bytes/s"
                },
                "diskwrite": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "description": "bytes/s"
                }
              }
            }
          }
        }
      },
      "Image": {
        "type": "object",
        "properties": {
          "os_key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "RebuildRequest": {
        "type": "object",
        "required": [
          "os_key",
          "auth_method",
          "confirm"
        ],
        "properties": {
          "os_key": {
            "type": "string",
            "description": "From GET /api/vps/{id}/images"
          },
          "auth_method": {
            "type": "string",
            "enum": [
              "password",
              "key"
            ]
          },
          "password": {
            "type": "string",
            "minLength": 8,
            "maxLength": 128,
            "description": "Optional; blank keeps the current password."
          },
          "ssh_pubkey": {
            "type": "string",
            "maxLength": 4000,
            "description": "OpenSSH public key. With auth_method=key and no key, one is generated."
          },
          "confirm": {
            "type": "string",
            "enum": [
              "REBUILD"
            ]
          }
        }
      },
      "SnapshotRequest": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 40,
            "pattern": "^[a-zA-Z][a-zA-Z0-9_\\-]*$"
          },
          "description": {
            "type": "string",
            "maxLength": 255
          }
        }
      },
      "SnapshotList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "snaptime": {
                  "type": "integer"
                }
              }
            }
          },
          "limit": {
            "type": "integer"
          },
          "used": {
            "type": "integer"
          },
          "canAdd": {
            "type": "boolean"
          }
        }
      },
      "BackupList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "volid": {
                  "type": "string"
                },
                "size": {
                  "type": "integer"
                },
                "ctime": {
                  "type": "integer"
                }
              }
            }
          },
          "limit": {
            "type": "integer"
          },
          "used": {
            "type": "integer"
          },
          "canAdd": {
            "type": "boolean"
          },
          "configured": {
            "type": "boolean"
          }
        }
      },
      "VolidRequest": {
        "type": "object",
        "required": [
          "volid"
        ],
        "properties": {
          "volid": {
            "type": "string",
            "maxLength": 255,
            "description": "From GET backups"
          }
        }
      },
      "Firewall": {
        "type": "object",
        "properties": {
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FirewallRule"
            }
          },
          "policy": {
            "type": "string",
            "enum": [
              "ACCEPT",
              "DROP"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "limit": {
            "type": "integer"
          },
          "used": {
            "type": "integer"
          },
          "canAdd": {
            "type": "boolean"
          }
        }
      },
      "FirewallRule": {
        "type": "object",
        "properties": {
          "pos": {
            "type": "integer"
          },
          "type": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "proto": {
            "type": "string"
          },
          "dport": {
            "type": "string"
          },
          "sport": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "dest": {
            "type": "string"
          },
          "comment": {
            "type": "string"
          },
          "enable": {
            "type": "integer"
          }
        }
      },
      "FirewallRuleRequest": {
        "type": "object",
        "required": [
          "type",
          "action"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "in",
              "out"
            ]
          },
          "action": {
            "type": "string",
            "enum": [
              "ACCEPT",
              "DROP",
              "REJECT"
            ]
          },
          "proto": {
            "type": "string",
            "examples": [
              "tcp",
              "udp",
              "icmp"
            ]
          },
          "dport": {
            "type": "string",
            "examples": [
              "443",
              "8000:8100"
            ]
          },
          "sport": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "examples": [
              "203.0.113.0/24"
            ]
          },
          "dest": {
            "type": "string"
          },
          "comment": {
            "type": "string",
            "maxLength": 255
          },
          "enable": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "PolicyRequest": {
        "type": "object",
        "required": [
          "policy"
        ],
        "properties": {
          "policy": {
            "type": "string",
            "enum": [
              "ACCEPT",
              "DROP"
            ]
          }
        }
      },
      "Cache": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended"
            ]
          },
          "host": {
            "type": "string"
          },
          "port": {
            "type": "integer"
          },
          "cache_mb": {
            "type": "integer"
          },
          "allowed_ips": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "max_allowed_ips": {
            "type": "integer"
          }
        }
      },
      "CacheDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Cache"
          },
          {
            "type": "object",
            "properties": {
              "connection": {
                "type": "object",
                "properties": {
                  "host": {
                    "type": "string"
                  },
                  "port": {
                    "type": "integer"
                  },
                  "user": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  }
                }
              }
            }
          }
        ]
      },
      "IpRequest": {
        "type": "object",
        "required": [
          "ip"
        ],
        "properties": {
          "ip": {
            "type": "string",
            "maxLength": 64,
            "description": "An address, or a range no wider than /16 (IPv4) or /48 (IPv6)."
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The token lacks the ability, or the service isn't available to the account.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found, or not yours.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "Invalid input, or the action can't run now (busy, plan limit reached).",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                },
                "errors": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limited.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            }
          }
        }
      },
      "Unavailable": {
        "description": "The hypervisor couldn't be reached. Retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            }
          }
        }
      }
    }
  }
}
