{
  "openapi": "3.1.0",
  "info": {
    "title": "revsheller API",
    "version": "1.0.0",
    "summary": "Hosted reverse and forward shell relay and HTTP tunnels.",
    "description": "REST API for revsheller. Shell sessions give you a hosted listener for machines you are authorized to test (your own systems, CTFs, training labs, engagements with written permission). Tunnels expose a local web server at a public https URL. Shell I/O runs over a WebSocket, not over this REST API; see https://revsheller.com/api-docs#websocket-protocol. AI agents that speak MCP can use the remote MCP server at https://revsheller.com/mcp instead. Free for registered accounts during the beta.",
    "termsOfService": "https://revsheller.com/terms",
    "contact": { "name": "revsheller", "url": "https://revsheller.com/feedback" }
  },
  "externalDocs": { "description": "API documentation", "url": "https://revsheller.com/api-docs" },
  "servers": [{ "url": "https://revsheller.com" }],
  "tags": [
    { "name": "sessions", "description": "Shell sessions (reverse and forward)" },
    { "name": "tunnels", "description": "HTTP tunnels to a local web server" },
    { "name": "meta", "description": "Service configuration" }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from https://revsheller.com/account. Starts with rsh_."
      },
      "operatorSecret": {
        "type": "http",
        "scheme": "bearer",
        "description": "The session's operatorSecret (op_...) returned when the session was created."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": { "error": { "type": "string" } },
        "required": ["error"]
      },
      "Session": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "examples": ["abc12345"] },
          "operatorSecret": { "type": "string", "description": "op_... Keep it out of logs and prompts." },
          "targetSecret": { "type": "string", "description": "tgt_... Embedded in the target payload." },
          "operatorConnected": { "type": "boolean" },
          "targetConnected": { "type": "boolean" },
          "createdAt": { "type": "integer", "description": "Unix ms" },
          "idleTimeoutMs": { "type": "integer" },
          "mode": { "type": "string", "enum": ["reverse", "forward"] },
          "targetHost": { "type": "string" },
          "targetPort": { "type": "integer" }
        }
      },
      "CreateSessionRequest": {
        "type": "object",
        "properties": {
          "mode": { "type": "string", "enum": ["reverse", "forward"], "default": "reverse" },
          "targetHost": { "type": "string", "description": "Forward mode only. Must be a public host; private and reserved ranges are rejected." },
          "targetPort": { "type": "integer", "minimum": 1, "maximum": 65535, "description": "Forward mode only. Port 25 is blocked." }
        }
      },
      "CreateSessionResponse": {
        "type": "object",
        "properties": {
          "session": { "$ref": "#/components/schemas/Session" },
          "payloads": {
            "type": "object",
            "description": "Target commands for reverse sessions. Empty for forward sessions.",
            "properties": {
              "auto": { "type": "string", "description": "Unix one-liner" },
              "auto_windows": { "type": "string", "description": "Windows one-liner" }
            }
          },
          "operatorUrl": { "type": "string", "examples": ["wss://abc12345.revsheller.com/ws/operator"] },
          "httpBase": { "type": "string" },
          "wsBase": { "type": "string" },
          "pathPrefix": { "type": "string" },
          "plan": { "type": "string" },
          "limits": {
            "type": "object",
            "properties": {
              "maxSessions": { "type": ["integer", "null"] },
              "idleTimeoutMs": { "type": "integer" }
            }
          }
        }
      },
      "Tunnel": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "examples": ["tn-k3v9q2m7xa"] },
          "hostname": { "type": "string" },
          "url": { "type": "string" },
          "kind": { "type": "string" },
          "createdAt": { "type": "integer" },
          "expiresAt": { "type": ["integer", "null"] },
          "limits": { "type": "object" }
        }
      }
    }
  },
  "paths": {
    "/api/session": {
      "post": {
        "tags": ["sessions"],
        "operationId": "createSession",
        "summary": "Create a reverse or forward shell session",
        "description": "Reverse is the default and returns target payloads. Forward sessions connect out to targetHost:targetPort when the operator WebSocket connects.",
        "security": [{ "apiKey": [] }],
        "requestBody": {
          "required": false,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateSessionRequest" } } }
        },
        "responses": {
          "200": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateSessionResponse" } } } },
          "400": { "description": "Invalid input, such as a private target host", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "403": { "description": "Plan does not allow this", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Session limit or rate limit", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/session/{id}": {
      "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
      "get": {
        "tags": ["sessions"],
        "operationId": "getSession",
        "summary": "Get session state",
        "security": [{ "operatorSecret": [] }],
        "responses": {
          "200": { "description": "Session state", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Session" } } } },
          "404": { "description": "Unknown session or wrong secret", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      },
      "delete": {
        "tags": ["sessions"],
        "operationId": "deleteSession",
        "summary": "Tear down a session and free its slot",
        "security": [{ "operatorSecret": [] }],
        "responses": {
          "200": { "description": "Deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } } } } } },
          "404": { "description": "Unknown session or wrong secret", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/payload/generate": {
      "post": {
        "tags": ["sessions"],
        "operationId": "generatePayload",
        "summary": "Generate a target command for a session",
        "security": [{ "apiKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["type", "slug", "token"],
                "properties": {
                  "type": { "type": "string", "default": "auto" },
                  "slug": { "type": "string", "description": "Session id" },
                  "token": { "type": "string", "description": "The session's targetSecret" },
                  "variant": { "type": "string", "enum": ["posix", "windows"], "default": "posix" },
                  "encoding": { "type": "string", "examples": ["base64"] }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Payload", "content": { "application/json": { "schema": { "type": "object", "properties": { "payload": { "type": "string" } } } } } },
          "400": { "description": "Invalid input", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/tunnels": {
      "post": {
        "tags": ["tunnels"],
        "operationId": "createTunnel",
        "summary": "Create a tunnel",
        "description": "Returns the public URL and a connectUrl for the client: curl -fsSL https://revsheller.com/tn | RSH_API_KEY=rsh_... node - http 3000 --tunnel <id>",
        "security": [{ "apiKey": [] }],
        "requestBody": {
          "required": false,
          "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string", "description": "A reserved name you own" } } } } }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "tunnel": { "$ref": "#/components/schemas/Tunnel" }, "connectUrl": { "type": "string" } }
                }
              }
            }
          },
          "403": { "description": "No account, or a reserved name you don't own", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "409": { "description": "Name taken", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Tunnel limit or rate limit; body includes limitHit", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "503": { "description": "Tunnels switched off", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      },
      "get": {
        "tags": ["tunnels"],
        "operationId": "listTunnels",
        "summary": "List your tunnels with live status, this month's usage and your limits",
        "security": [{ "apiKey": [] }],
        "responses": { "200": { "description": "Tunnels", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    },
    "/api/tunnels/{id}": {
      "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
      "delete": {
        "tags": ["tunnels"],
        "operationId": "deleteTunnel",
        "summary": "Disconnect the client, stop serving the URL and free the slot",
        "security": [{ "apiKey": [] }],
        "responses": {
          "200": { "description": "Deleted" },
          "404": { "description": "Unknown tunnel", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/tunnel-names": {
      "get": {
        "tags": ["tunnels"],
        "operationId": "listTunnelNames",
        "summary": "Your reserved tunnel names and maxReservedNames",
        "security": [{ "apiKey": [] }],
        "responses": { "200": { "description": "Names", "content": { "application/json": { "schema": { "type": "object" } } } } }
      },
      "post": {
        "tags": ["tunnels"],
        "operationId": "reserveTunnelName",
        "summary": "Reserve a tunnel name",
        "security": [{ "apiKey": [] }],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "type": "object", "required": ["name"], "properties": { "name": { "type": "string" } } } } }
        },
        "responses": {
          "201": { "description": "Reserved", "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" } } } } } },
          "409": { "description": "Name taken", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Name limit", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/tunnel-names/{name}": {
      "parameters": [{ "name": "name", "in": "path", "required": true, "schema": { "type": "string" } }],
      "delete": {
        "tags": ["tunnels"],
        "operationId": "releaseTunnelName",
        "summary": "Release a name and close its open tunnel",
        "security": [{ "apiKey": [] }],
        "responses": { "200": { "description": "Released" } }
      }
    },
    "/api/config": {
      "get": {
        "tags": ["meta"],
        "operationId": "getConfig",
        "summary": "Service flags: beta and billingEnabled",
        "security": [],
        "responses": { "200": { "description": "Config", "content": { "application/json": { "schema": { "type": "object", "properties": { "beta": { "type": "boolean" }, "billingEnabled": { "type": "boolean" } } } } } } }
      }
    }
  }
}
