{
  "openapi": "3.1.0",
  "info": {
    "title": "SocksProxy API",
    "version": "0.1.0",
    "description": "查询套餐、开通代理和管理订单。API 使用 Bearer Token 鉴权，网页使用登录会话。注册与登录需要 Turnstile 验证。正式充值支持 TRON 主网 USDT，最低 1 USDT，按 1 USDT = 1 美元入账。时间戳采用 Unix 毫秒。\n\n线路带宽最高 1 Gbps。单连接没有保底速率，实际速度取决于网络路径和线路负载。不限流量，适用公平使用政策。持续高负载影响其他用户时，连接可能被临时限速。"
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "paths": {
    "/api/auth/config": {
      "get": {
        "summary": "Public Turnstile configuration",
        "responses": {
          "200": {
            "description": "Challenge configuration",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "required": {
                      "type": "boolean"
                    },
                    "site_key": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "summary": "Health and database readiness",
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "demo": {
                      "type": "boolean"
                    },
                    "provider": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalog": {
      "get": {
        "summary": "Available plans, countries and protocols",
        "parameters": [
          {
            "in": "query",
            "name": "product_type",
            "schema": {
              "type": "string"
            },
            "description": "Get the available regions and regional term prices for this product using its configured default."
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog, or product pricing when filtered",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "required": [
                        "plans"
                      ],
                      "type": "object",
                      "properties": {
                        "plans": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "supplier_id": {
                                "type": "string",
                                "description": "Supplier bound to this plan and its renewals."
                              },
                              "is_default": {
                                "type": "boolean",
                                "description": "Preferred supplier for this product type."
                              },
                              "product_type": {
                                "type": "string",
                                "examples": [
                                  "dedicated_datacenter_ipv4"
                                ],
                                "description": "Product category independent of supplier. dedicated_datacenter_ipv4 identifies a dedicated datacenter IP; dedicated_isp_ipv4 identifies static dedicated ISP proxies. Dedicated residential and dynamic products are separate categories. Availability is determined by the returned plans."
                              },
                              "duration_days": {
                                "type": "integer"
                              },
                              "price_cents": {
                                "type": "integer",
                                "description": "Minimum new purchase price in USD cents"
                              },
                              "prices_by_country": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "integer"
                                },
                                "description": "Country-specific new purchase price in USD cents"
                              },
                              "renewal_price_status": {
                                "enum": [
                                  "unverified",
                                  "live_quote"
                                ]
                              }
                            }
                          }
                        },
                        "countries": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "protocols": {
                          "type": "array",
                          "items": {
                            "enum": [
                              "http",
                              "socks5"
                            ]
                          }
                        },
                        "demo": {
                          "type": "boolean"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "product_type",
                        "countries",
                        "terms",
                        "currency"
                      ],
                      "properties": {
                        "product_type": {
                          "type": "string"
                        },
                        "currency": {
                          "const": "USD"
                        },
                        "countries": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "terms": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "duration_days": {
                                "type": "integer"
                              },
                              "prices_by_country": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "integer",
                                  "description": "USD cents"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/register": {
      "post": {
        "summary": "Register a user and start a cookie session",
        "description": "Requires a same-origin Origin header and a Turnstile token with action=register. Password length: 12–128. New wallets start with a zero balance.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password",
                  "name"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 12,
                    "maxLength": 128
                  },
                  "turnstile_token": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Single-use Turnstile token; required outside explicit loopback development mode."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 60
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account and session created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/login": {
      "post": {
        "summary": "Sign in with email and password",
        "description": "Requires a same-origin Origin header and a Turnstile token with action=login.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "maxLength": 128
                  },
                  "turnstile_token": {
                    "type": "string",
                    "maxLength": 2048,
                    "description": "Single-use Turnstile token; required outside explicit loopback development mode."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/me": {
      "get": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Current web account and wallet",
        "responses": {
          "200": {
            "description": "Account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/logout": {
      "post": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Revoke the current browser session",
        "responses": {
          "200": {
            "description": "Signed out"
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proxies/{id}/renew": {
      "post": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Request renewal of an owned Geonix proxy",
        "description": "Renews an owned active proxy at the published regional plan price after an upstream renewal quote check. Supply Idempotency-Key and poll the returned order.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "plan_id"
                ],
                "properties": {
                  "plan_id": {
                    "type": "string",
                    "examples": [
                      "geonix-30"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed renewal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "202": {
            "description": "Accepted renewal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proxies": {
      "post": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Purchase one proxy resource",
        "description": "Reserve funds and durably enqueue provisioning. Reuse Idempotency-Key when retrying. Cookie sessions can also call this endpoint with a same-origin Origin header.",
        "parameters": [
          {
            "name": "If-Price-Cents",
            "in": "header",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Expected USD cents; mismatch returns 409 before reserving funds."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9_.:-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Purchase"
              },
              "examples": {
                "dedicated": {
                  "summary": "独享 IP · 美国 7 天 SOCKS5",
                  "value": {
                    "product_type": "dedicated_datacenter_ipv4",
                    "country": "US",
                    "duration_days": 7,
                    "protocol": "socks5"
                  }
                },
                "isp": {
                  "summary": "静态独享 ISP · 美国 7 天 SOCKS5",
                  "value": {
                    "product_type": "dedicated_isp_ipv4",
                    "country": "US",
                    "duration_days": 7,
                    "protocol": "socks5"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Previously completed idempotent request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "202": {
            "description": "Order accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List the latest 100 owned proxies without passwords",
        "responses": {
          "200": {
            "description": "Resources",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Proxy"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proxies/{id}": {
      "get": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "summary": "Read owned proxy credentials",
        "responses": {
          "200": {
            "description": "Proxy credentials",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Proxy"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "password": {
                          "type": "string"
                        },
                        "notice": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders": {
      "get": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List the latest 100 owned orders",
        "responses": {
          "200": {
            "description": "Orders",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Order"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/{id}": {
      "get": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "summary": "Poll provisioning state and retrieve proxy_id",
        "responses": {
          "200": {
            "description": "Order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order": {
                      "$ref": "#/components/schemas/Order"
                    },
                    "proxy_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys": {
      "get": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "List own API keys without secret values",
        "responses": {
          "200": {
            "description": "Keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Create an API key; secret shown only once",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 60
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "proxies:read",
                        "proxies:write"
                      ]
                    },
                    "default": [
                      "proxies:read",
                      "proxies:write"
                    ]
                  },
                  "expires_in_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 365,
                    "default": 90
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    },
                    "expires_at": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{id}": {
      "delete": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "summary": "Revoke an owned API key",
        "responses": {
          "200": {
            "description": "Revoked"
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/topups": {
      "get": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "List own latest 50 top-ups and current payment mode",
        "responses": {
          "200": {
            "description": "Top-ups",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Create a USDT-TRC20 top-up quoted in USD",
        "description": "TRON mainnet USDT at 1 USD per USDT. A direct transfer can pay memo_usdt_units with payment_memo in the on-chain TRON memo. Without a memo pay expected_usdt_units exactly. Both amounts are micro-USDT. Requires a same-origin Origin header.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_cents",
                  "currency"
                ],
                "additionalProperties": false,
                "properties": {
                  "currency": {
                    "const": "USD"
                  },
                  "amount_cents": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 1000000,
                    "description": "USD cents. The minimum is 100 cents (1 USDT)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Durable top-up intent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/topups/{id}": {
      "get": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "summary": "Get own top-up quote and settlement state",
        "responses": {
          "200": {
            "description": "Top-up",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/payments/gmpay/webhook": {
      "post": {
        "summary": "Signed GMPay Edge callback",
        "description": "HMAC-SHA256 signature required. Persisted before acknowledgment; authoritative gateway query determines settlement.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pid",
                  "trade_id",
                  "order_id",
                  "status",
                  "signature"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged",
            "content": {
              "text/plain": {
                "schema": {
                  "const": "ok"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/wallet": {
      "get": {
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Wallet and latest 100 ledger entries",
        "responses": {
          "200": {
            "description": "Wallet and ledger",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API token; requires proxies:read or proxies:write."
      },
      "sessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "portlane_session",
        "description": "Web session. Unsafe requests require a same-origin Origin header."
      }
    },
    "schemas": {
      "Purchase": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "country",
          "protocol"
        ],
        "oneOf": [
          {
            "required": [
              "product_type",
              "duration_days"
            ],
            "not": {
              "required": [
                "plan_id"
              ]
            }
          },
          {
            "required": [
              "plan_id"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "product_type"
                  ]
                },
                {
                  "required": [
                    "duration_days"
                  ]
                }
              ]
            }
          }
        ],
        "properties": {
          "product_type": {
            "type": "string",
            "examples": [
              "dedicated_datacenter_ipv4",
              "dedicated_isp_ipv4"
            ]
          },
          "duration_days": {
            "type": "integer",
            "minimum": 1,
            "description": "Choose an available term from the product catalog."
          },
          "plan_id": {
            "type": "string",
            "deprecated": true,
            "description": "Legacy new-order format. The plan must be offered by the current default supplier."
          },
          "country": {
            "type": "string",
            "pattern": "^[A-Z]{2}$",
            "examples": [
              "US",
              "SG"
            ]
          },
          "protocol": {
            "enum": [
              "http",
              "socks5"
            ]
          }
        }
      },
      "Accepted": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "pending",
              "active",
              "failed",
              "review"
            ]
          },
          "replayed": {
            "type": "boolean"
          },
          "poll_url": {
            "type": "string"
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "plan_id": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "protocol": {
            "enum": [
              "http",
              "socks5"
            ]
          },
          "status": {
            "enum": [
              "pending",
              "active",
              "failed",
              "review"
            ]
          },
          "price_cents": {
            "type": "integer"
          },
          "currency": {
            "const": "USD"
          },
          "created_at": {
            "type": "integer"
          },
          "completed_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Proxy": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "order_id": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "protocol": {
            "enum": [
              "http",
              "socks5"
            ]
          },
          "host": {
            "type": "string",
            "description": "Reserved .invalid domain for mock allocations"
          },
          "port": {
            "type": "integer"
          },
          "username": {
            "type": "string"
          },
          "created_at": {
            "type": "integer"
          },
          "expires_at": {
            "type": "integer"
          },
          "is_mock": {
            "type": "integer",
            "enum": [
              0,
              1
            ]
          },
          "supplier_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "product_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "enum": [
              "active",
              "expired"
            ]
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "user": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "available_cents": {
                "type": "integer"
              },
              "reserved_cents": {
                "type": "integer"
              }
            }
          },
          "demo": {
            "type": "boolean"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
