{
  "openapi": "3.0.3",
  "info": {
    "title": "ProxyLayer API",
    "version": "0.1.0",
    "description": "REST API for ProxyLayer. See the [API Overview](https://docs.proxy-layer.com/api) for authentication, pagination, retries, limits, and errors."
  },
  "servers": [
    {
      "url": "https://app.proxy-layer.com",
      "description": "ProxyLayer API"
    }
  ],
  "tags": [
    {
      "name": "Authenticate",
      "description": "Sign up or sign in via Email OTP and receive a Bearer API key."
    },
    {
      "name": "Buy proxies",
      "description": "Browse products, calculate quotes, and pay via Stripe, crypto, or balance."
    },
    {
      "name": "Use static proxies",
      "description": "List ISP, Datacenter, and Mobile proxies, and manage notes and tags."
    },
    {
      "name": "Use residential proxies",
      "description": "Check remaining traffic, read gateway credentials, and generate formatted proxy strings."
    },
    {
      "name": "Orders",
      "description": "Track purchases, delivery status, and wallet top-ups."
    }
  ],
  "paths": {
    "/api/v1/account": {
      "get": {
        "operationId": "getAccount",
        "tags": [
          "Authenticate"
        ],
        "summary": "Get Account",
        "description": "Returns the connected account ID, name, wallet balance in USD cents, mode, and granted scopes.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:account:read"
            ]
          }
        ],
        "x-required-scope": "account:read",
        "responses": {
          "200": {
            "description": "Connected account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                },
                "example": {
                  "id": "user_01JQ8A",
                  "name": "Alex",
                  "balanceCents": 2500,
                  "mode": "live",
                  "scopes": [
                    "account:read",
                    "orders:read"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "- `API_KEY_SCOPE_MISSING`: Use a key with the account:read permission.\n- `OAUTH_SCOPE_MISSING`: Request the rest:account:read OAuth scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "API_KEY_SCOPE_MISSING": {
                    "summary": "Use a key with the account:read permission.",
                    "value": {
                      "error": {
                        "code": "API_KEY_SCOPE_MISSING",
                        "message": "This API key does not have the account:read permission"
                      }
                    }
                  },
                  "OAUTH_SCOPE_MISSING": {
                    "summary": "Request the rest:account:read OAuth scope.",
                    "value": {
                      "error": {
                        "code": "OAUTH_SCOPE_MISSING",
                        "message": "The OAuth token is missing a required permission"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/auth/otp/request": {
      "post": {
        "operationId": "requestEmailOtp",
        "tags": [
          "Authenticate"
        ],
        "summary": "Request OTP",
        "description": "Sends a sign-in code to the email (valid 30 min). Creates an account on verify if new.",
        "security": [],
        "requestBody": {
          "required": true,
          "x-max-bytes": 8192,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OtpRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "email": "agent@example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Code sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OtpRequestResponse"
                },
                "example": {
                  "sent": true,
                  "email": "agent@example.com",
                  "expiresInSeconds": 1800
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedContentType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/auth/otp/verify": {
      "post": {
        "operationId": "verifyEmailOtp",
        "tags": [
          "Authenticate"
        ],
        "summary": "Verify email OTP and issue an API key",
        "description": "Exchanges an email OTP code for a Bearer API key (shown once). Creates an account if new.",
        "security": [],
        "requestBody": {
          "required": true,
          "x-max-bytes": 8192,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OtpVerifyRequest"
              },
              "examples": {
                "default": {
                  "summary": "Live full-access key",
                  "value": {
                    "email": "agent@example.com",
                    "code": "123456",
                    "keyName": "AI Agent",
                    "access": "full"
                  }
                },
                "scoped": {
                  "summary": "Scoped read-only key",
                  "value": {
                    "email": "agent@example.com",
                    "code": "123456",
                    "keyName": "Inventory Reader",
                    "scopes": [
                      "proxies:read"
                    ]
                  }
                },
                "sandbox": {
                  "summary": "Sandbox test key (pl_test_...)",
                  "value": {
                    "email": "agent@example.com",
                    "code": "123456",
                    "keyName": "CI Sandbox",
                    "mode": "test",
                    "access": "full"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Authenticated user and issued Bearer API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OtpVerifyResponse"
                },
                "example": {
                  "apiKey": "pl_live_example",
                  "mode": "live",
                  "keyId": "key_01JQ8A",
                  "keyPrefix": "pl_live_examp",
                  "scopes": [
                    "account:read",
                    "orders:read"
                  ],
                  "user": {
                    "id": "user_01JQ8A",
                    "email": "agent@example.com"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "description": "Code is invalid or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "INVALID_OTP": {
                    "summary": "Code is invalid or expired.",
                    "value": {
                      "error": {
                        "code": "INVALID_OTP",
                        "message": "Invalid OTP"
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedContentType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/catalog": {
      "get": {
        "operationId": "getCatalog",
        "tags": [
          "Buy proxies"
        ],
        "summary": "List products and prices",
        "description": "Public catalog of products, countries, terms, prices, and purchase limits.",
        "security": [],
        "parameters": [
          {
            "name": "product",
            "in": "query",
            "required": false,
            "example": "residential",
            "description": "Filter by product.",
            "schema": {
              "type": "string",
              "enum": [
                "isp",
                "residential",
                "datacenter",
                "mobile"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Catalog"
                },
                "example": {
                  "currency": "USD",
                  "products": [
                    {
                      "slug": "isp",
                      "type": "ISP",
                      "name": "ISP",
                      "billingMode": "FIXED",
                      "durationsDays": [
                        30,
                        90
                      ],
                      "countries": [
                        {
                          "code": "US",
                          "name": "United States"
                        }
                      ],
                      "prices": [
                        {
                          "ruleType": "BASE",
                          "durationDays": 30,
                          "countryCode": null,
                          "minQuantity": 1,
                          "maxQuantity": null,
                          "minTrafficGb": null,
                          "maxTrafficGb": null,
                          "unitAmountCents": 500,
                          "packageAmountCents": null,
                          "currency": "USD"
                        }
                      ]
                    }
                  ],
                  "limits": {
                    "maxProxyQuantity": 500,
                    "maxResidentialTrafficGb": 5000
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/quotes": {
      "get": {
        "operationId": "getPurchaseQuote",
        "tags": [
          "Buy proxies"
        ],
        "summary": "Check price via GET query",
        "description": "Compact GET quote calculator for a single product. Example: `?product=residential&gb=10` or `?product=isp&country=US&qty=2&days=30`.",
        "security": [
          {},
          {
            "bearerAuth": []
          },
          {
            "oauth2": []
          }
        ],
        "parameters": [
          {
            "name": "product",
            "in": "query",
            "required": true,
            "example": "residential",
            "description": "Product slug: isp, datacenter, mobile, or residential.",
            "schema": {
              "type": "string",
              "enum": [
                "isp",
                "residential",
                "datacenter",
                "mobile"
              ],
              "description": "Product slug: isp, datacenter, mobile, or residential."
            }
          },
          {
            "name": "gb",
            "in": "query",
            "required": false,
            "example": "10",
            "description": "Traffic in GB (required when product=residential).",
            "schema": {
              "description": "Traffic in GB (required when product=residential).",
              "type": "integer",
              "minimum": 0,
              "exclusiveMinimum": true
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "Two-letter ISO country code for static proxies (e.g. US, DE).",
            "schema": {
              "description": "Two-letter ISO country code for static proxies (e.g. US, DE).",
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            }
          },
          {
            "name": "qty",
            "in": "query",
            "required": false,
            "description": "Static proxy quantity (defaults to 1).",
            "schema": {
              "default": 1,
              "description": "Static proxy quantity (defaults to 1).",
              "type": "integer",
              "minimum": 0,
              "exclusiveMinimum": true
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "Static proxy term in days (30, 60, or 90; defaults to 30).",
            "schema": {
              "default": 30,
              "description": "Static proxy term in days (30, 60, or 90; defaults to 30).",
              "type": "integer",
              "minimum": 0,
              "exclusiveMinimum": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                },
                "example": {
                  "productSlug": "residential",
                  "productType": "RESIDENTIAL",
                  "productName": "Residential",
                  "currency": "USD",
                  "amountCents": 1799,
                  "durationDays": null,
                  "quantity": 1,
                  "items": [
                    {
                      "countryCode": null,
                      "quantity": 1,
                      "targetProxyIds": [],
                      "trafficGb": 10,
                      "unitAmountCents": 180,
                      "totalAmountCents": 1799
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "post": {
        "operationId": "createPurchaseQuote",
        "tags": [
          "Buy proxies"
        ],
        "summary": "Check the price",
        "description": "Validates a purchase or renewal and returns the total price. Renewal quotes with `targetProxyIds` require authentication.",
        "security": [
          {},
          {
            "bearerAuth": []
          },
          {
            "oauth2": []
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Static proxy purchase, renewal, or Residential traffic purchase.",
          "x-max-bytes": 32768,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              },
              "examples": {
                "isp": {
                  "summary": "ISP",
                  "value": {
                    "purchase": {
                      "productSlug": "isp",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "US",
                          "quantity": 2
                        }
                      ]
                    }
                  }
                },
                "datacenter": {
                  "summary": "Datacenter",
                  "value": {
                    "purchase": {
                      "productSlug": "datacenter",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "DE",
                          "quantity": 2
                        }
                      ]
                    }
                  }
                },
                "mobile": {
                  "summary": "Mobile",
                  "value": {
                    "purchase": {
                      "productSlug": "mobile",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": null,
                          "quantity": 1
                        }
                      ]
                    }
                  }
                },
                "residential": {
                  "summary": "Residential",
                  "value": {
                    "purchase": {
                      "productSlug": "residential",
                      "trafficGb": 10
                    }
                  }
                },
                "renewal": {
                  "summary": "Renew ISP",
                  "value": {
                    "purchase": {
                      "productSlug": "isp",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "US",
                          "quantity": 1,
                          "targetProxyIds": [
                            "proxy_01JQ8A"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                },
                "example": {
                  "productSlug": "isp",
                  "productType": "ISP",
                  "productName": "ISP",
                  "currency": "USD",
                  "amountCents": 1000,
                  "durationDays": 30,
                  "quantity": 2,
                  "items": [
                    {
                      "countryCode": "US",
                      "quantity": 2,
                      "targetProxyIds": [],
                      "trafficGb": null,
                      "unitAmountCents": 500,
                      "totalAmountCents": 1000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Session-authenticated write from a non-dashboard origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "INVALID_REQUEST_ORIGIN": {
                    "summary": "Session-authenticated write from a non-dashboard origin.",
                    "value": {
                      "error": {
                        "code": "INVALID_REQUEST_ORIGIN",
                        "message": "Request origin is not allowed"
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedContentType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/proxies": {
      "get": {
        "operationId": "listProxyInventory",
        "tags": [
          "Use static proxies"
        ],
        "summary": "List your static proxies",
        "description": "Returns active ISP, Datacenter, or Mobile proxies with connection credentials. Expired and released proxies are excluded.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:proxies:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "product",
            "in": "query",
            "required": true,
            "example": "isp",
            "description": "Static proxy product: isp, datacenter, or mobile.",
            "schema": {
              "type": "string",
              "enum": [
                "isp",
                "datacenter",
                "mobile"
              ],
              "description": "Static proxy product: isp, datacenter, or mobile."
            }
          },
          {
            "name": "checkoutSessionId",
            "in": "query",
            "required": false,
            "description": "First page only: checks whether this checkout is still awaiting order creation and populates pendingCheckout.",
            "schema": {
              "description": "First page only: checks whether this checkout is still awaiting order creation and populates pendingCheckout.",
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Results per page (1–200, default 100).",
            "schema": {
              "default": 100,
              "description": "Results per page (1–200, default 100).",
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "pagination.nextCursor from the previous response.",
            "schema": {
              "description": "pagination.nextCursor from the previous response.",
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of active proxies and pagination cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProxyPage"
                },
                "example": {
                  "data": [
                    {
                      "id": "proxy_01JQ8A",
                      "product": "isp",
                      "countryCode": "US",
                      "country": "United States",
                      "host": "proxy.example.com",
                      "port": 10001,
                      "username": "pl-user",
                      "password": "example-secret",
                      "protocol": "http",
                      "proxy": "proxy.example.com:10001:pl-user:example-secret",
                      "purchasedAt": "2026-01-15T12:00:00.000Z",
                      "expiresAt": "2026-02-14T12:00:00.000Z",
                      "daysLeft": 25,
                      "note": "Primary rotation",
                      "tags": [
                        "production"
                      ]
                    }
                  ],
                  "pagination": {
                    "nextCursor": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "- `API_KEY_SCOPE_MISSING`: Use a key with the proxies:read permission.\n- `OAUTH_SCOPE_MISSING`: Request the rest:proxies:read OAuth scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "API_KEY_SCOPE_MISSING": {
                    "summary": "Use a key with the proxies:read permission.",
                    "value": {
                      "error": {
                        "code": "API_KEY_SCOPE_MISSING",
                        "message": "This API key does not have the proxies:read permission"
                      }
                    }
                  },
                  "OAUTH_SCOPE_MISSING": {
                    "summary": "Request the rest:proxies:read OAuth scope.",
                    "value": {
                      "error": {
                        "code": "OAUTH_SCOPE_MISSING",
                        "message": "The OAuth token is missing a required permission"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "x-required-scope": "proxies:read"
      },
      "patch": {
        "operationId": "updateProxyMetadata",
        "tags": [
          "Use static proxies"
        ],
        "summary": "Update Proxy Notes and Tags",
        "description": "Updates notes and tags atomically. Requires at least one change. replaceTags cannot be combined with addTags or removeTags. scope: product is allowed only with removeTags and excludes proxyIds. Inactive or unmatched proxies are skipped.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:proxy:write"
            ]
          }
        ],
        "x-required-scope": "proxy:write",
        "requestBody": {
          "required": true,
          "description": "Product, target, and at least one change.",
          "x-max-bytes": 65536,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProxyMetadataRequest"
              },
              "examples": {
                "replace": {
                  "summary": "Replace a note and tags",
                  "value": {
                    "product": "isp",
                    "proxyIds": [
                      "proxy_01JQ8A"
                    ],
                    "replaceTags": [
                      "production",
                      "eu-team"
                    ],
                    "note": "Primary rotation"
                  }
                },
                "clear": {
                  "summary": "Clear a note and tags",
                  "value": {
                    "product": "isp",
                    "proxyIds": [
                      "proxy_01JQ8A"
                    ],
                    "replaceTags": [],
                    "note": ""
                  }
                },
                "edit": {
                  "summary": "Change a note and adjust tags",
                  "value": {
                    "product": "isp",
                    "proxyIds": [
                      "proxy_01JQ8A"
                    ],
                    "note": "Primary rotation",
                    "addTags": [
                      "production"
                    ],
                    "removeTags": [
                      "staging"
                    ]
                  }
                },
                "removeFromProduct": {
                  "summary": "Remove tags from the entire product",
                  "value": {
                    "product": "isp",
                    "scope": "product",
                    "removeTags": [
                      "staging"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Count of matched proxies updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProxyWrite"
                },
                "example": {
                  "updated": 1
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedContentType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/proxies/tags": {
      "get": {
        "operationId": "getProxyTagUsage",
        "tags": [
          "Use static proxies"
        ],
        "summary": "Count proxies with a tag",
        "description": "Counts active proxies in one product with an exact, case-sensitive tag.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:proxies:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "product",
            "in": "query",
            "required": true,
            "example": "isp",
            "description": "Static proxy product: isp, datacenter, or mobile.",
            "schema": {
              "type": "string",
              "enum": [
                "isp",
                "datacenter",
                "mobile"
              ],
              "description": "Static proxy product: isp, datacenter, or mobile."
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": true,
            "example": "production",
            "description": "Case-sensitive tag (1–64 chars). URL-encode spaces and special characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "description": "Case-sensitive tag (1–64 chars). URL-encode spaces and special characters."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching tag and proxy count.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaggedProxyCount"
                },
                "example": {
                  "tag": "production",
                  "count": 12
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "- `API_KEY_SCOPE_MISSING`: Use a key with the proxies:read permission.\n- `OAUTH_SCOPE_MISSING`: Request the rest:proxies:read OAuth scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "API_KEY_SCOPE_MISSING": {
                    "summary": "Use a key with the proxies:read permission.",
                    "value": {
                      "error": {
                        "code": "API_KEY_SCOPE_MISSING",
                        "message": "This API key does not have the proxies:read permission"
                      }
                    }
                  },
                  "OAUTH_SCOPE_MISSING": {
                    "summary": "Request the rest:proxies:read OAuth scope.",
                    "value": {
                      "error": {
                        "code": "OAUTH_SCOPE_MISSING",
                        "message": "The OAuth token is missing a required permission"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "x-required-scope": "proxies:read"
      }
    },
    "/api/v1/orders": {
      "get": {
        "operationId": "listOrders",
        "tags": [
          "Orders"
        ],
        "summary": "List order and top-up history",
        "description": "Returns proxy orders (`historyKind: 'order'`) and wallet top-ups (`historyKind: 'balance_top_up'`).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:orders:read"
            ]
          }
        ],
        "x-required-scope": "orders:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Entries per page.",
            "schema": {
              "default": 20,
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "nextCursor from the previous response.",
            "schema": {
              "description": "nextCursor from the previous response.",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderPage"
                },
                "example": {
                  "items": [
                    {
                      "historyKind": "order",
                      "occurredAt": "2026-01-15T12:00:00.000Z",
                      "id": "order_01JQ8B",
                      "paymentStatus": "PAID",
                      "fulfillmentStatus": "FULFILLED",
                      "currency": "USD",
                      "totalAmount": 1000,
                      "subtotalAmount": 1000,
                      "discountAmount": 0,
                      "taxAmount": 0,
                      "paymentMethod": {
                        "provider": "balance",
                        "method": "balance"
                      },
                      "items": [
                        {
                          "id": "item_01JQ8C",
                          "kind": null,
                          "durationDays": 30,
                          "quantity": 2,
                          "trafficGb": null,
                          "unitAmount": 500,
                          "totalAmount": 1000,
                          "countryCode": "US",
                          "fulfillmentStatus": "FULFILLED",
                          "failureReason": null,
                          "fulfilledAt": "2026-01-15T12:01:00.000Z",
                          "product": {
                            "name": "ISP",
                            "type": "ISP"
                          }
                        }
                      ]
                    }
                  ],
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "post": {
        "operationId": "purchaseWithBalance",
        "tags": [
          "Buy proxies"
        ],
        "summary": "Create an order and pay from balance",
        "description": "Creates a proxy order using prepaid wallet balance. Returns `201` on payment; delivery runs asynchronously. Returns `409` without charging if balance is insufficient.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:orders:write"
            ]
          }
        ],
        "x-required-scope": "orders:write",
        "x-rate-limit": "30 purchase requests per API key per 10 minutes, at least one second apart.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Optional when `clientOperationId` is sent in the body; both values must match if supplied.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "UUID for this purchase."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Purchase payload and optional clientOperationId (required if Idempotency-Key header is omitted).",
          "x-max-bytes": 32768,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BalanceOrderRequest"
              },
              "examples": {
                "isp": {
                  "summary": "ISP",
                  "value": {
                    "purchase": {
                      "productSlug": "isp",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "US",
                          "quantity": 2
                        }
                      ]
                    }
                  }
                },
                "datacenter": {
                  "summary": "Datacenter",
                  "value": {
                    "purchase": {
                      "productSlug": "datacenter",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "DE",
                          "quantity": 2
                        }
                      ]
                    }
                  }
                },
                "mobile": {
                  "summary": "Mobile",
                  "value": {
                    "purchase": {
                      "productSlug": "mobile",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": null,
                          "quantity": 1
                        }
                      ]
                    }
                  }
                },
                "residential": {
                  "summary": "Residential",
                  "value": {
                    "purchase": {
                      "productSlug": "residential",
                      "trafficGb": 10
                    }
                  }
                },
                "renewal": {
                  "summary": "Renew ISP",
                  "value": {
                    "purchase": {
                      "productSlug": "isp",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "US",
                          "quantity": 1,
                          "targetProxyIds": [
                            "proxy_01JQ8A"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Paid order ID, checkout session ID, and updated prepaid balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateOrder"
                },
                "example": {
                  "orderId": "order_01JQ8B",
                  "checkoutSessionId": "checkout_01JQ8D",
                  "balanceCents": 1500
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/PurchaseConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedContentType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/checkouts": {
      "post": {
        "operationId": "createCheckout",
        "tags": [
          "Buy proxies"
        ],
        "summary": "Create a Stripe, Crypto, or Balance checkout",
        "description": "Starts a proxy purchase, renewal, or wallet top-up (`balance-topup`). `stripe` returns a hosted `paymentUrl`; `crypto` returns a deposit address, coin amount, and `paymentUrl`; `balance` returns the resulting order.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:orders:write"
            ]
          }
        ],
        "x-required-scope": "orders:write",
        "x-rate-limit": "30 purchase requests per API key per 10 minutes, at least one second apart.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Optional UUID; must match `clientOperationId` if both are sent.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "UUID for this purchase."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Purchase or top-up payload and paymentMethod (stripe, crypto, or balance).",
          "x-max-bytes": 32768,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutRequest"
              },
              "examples": {
                "stripe": {
                  "summary": "Stripe hosted checkout (ISP)",
                  "value": {
                    "purchase": {
                      "productSlug": "isp",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "US",
                          "quantity": 2
                        }
                      ]
                    },
                    "paymentMethod": "stripe"
                  }
                },
                "crypto": {
                  "summary": "Crypto invoice (USDT on TRON)",
                  "value": {
                    "purchase": {
                      "productSlug": "residential",
                      "trafficGb": 10
                    },
                    "paymentMethod": "crypto",
                    "cryptoCurrency": "USDT",
                    "cryptoNetwork": "TRON"
                  }
                },
                "balance": {
                  "summary": "Prepaid balance purchase",
                  "value": {
                    "purchase": {
                      "productSlug": "datacenter",
                      "durationDays": 30,
                      "items": [
                        {
                          "countryCode": "DE",
                          "quantity": 2
                        }
                      ]
                    },
                    "paymentMethod": "balance"
                  }
                },
                "topup": {
                  "summary": "Top up balance",
                  "value": {
                    "purchase": {
                      "productSlug": "balance-topup",
                      "amountCents": 2500
                    },
                    "paymentMethod": "stripe"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Checkout session with paymentUrl (stripe/crypto) or completed orderId (balance).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutResponse"
                },
                "example": {
                  "checkoutSessionId": "checkout_01JQ8D",
                  "paymentMethod": "stripe",
                  "status": "pending",
                  "currency": "USD",
                  "amountCents": 1000,
                  "paymentUrl": "https://checkout.stripe.com/c/pay/cs_test_example",
                  "expiresAt": "2026-01-15T13:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/PurchaseConflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedContentType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/checkouts/{id}": {
      "get": {
        "operationId": "getCheckoutStatus",
        "tags": [
          "Orders"
        ],
        "summary": "Get checkout payment and delivery status",
        "description": "Returns payment state (`status`) and delivery state (`fulfillmentStatus`, `provisioningPending`, `orderId`) for a checkout session.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:orders:read"
            ]
          }
        ],
        "x-required-scope": "orders:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "checkoutSessionId returned by POST /api/v1/checkouts or POST /api/v1/orders.",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current payment and delivery status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutStatus"
                },
                "example": {
                  "checkoutSessionId": "checkout_01JQ8D",
                  "status": "completed",
                  "provisioningPending": false,
                  "paymentProvider": "stripe",
                  "orderId": "order_01JQ8B",
                  "fulfillmentStatus": "FULFILLED",
                  "failureMessage": null,
                  "balanceCents": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Checkout session not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "CHECKOUT_SESSION_NOT_FOUND": {
                    "summary": "Checkout session not found for this account.",
                    "value": {
                      "error": {
                        "code": "CHECKOUT_SESSION_NOT_FOUND",
                        "message": "Checkout session not found"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/residential": {
      "get": {
        "operationId": "getResidentialAccess",
        "tags": [
          "Use residential proxies"
        ],
        "summary": "Get Residential balance and credentials",
        "description": "Returns remaining Residential traffic and gateway credentials.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:proxies:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResidentialSnapshot"
                },
                "example": {
                  "trafficBalance": {
                    "balanceMb": 10240,
                    "isStale": false
                  },
                  "proxyCredentials": {
                    "providerSubuserId": 123456,
                    "host": "gw.proxy-layer.com",
                    "login": "pl-user",
                    "password": "example-secret",
                    "stickyRangeStart": 10000,
                    "stickyRangeEnd": 30000,
                    "rotatingPort": null
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "- `API_KEY_SCOPE_MISSING`: Use a key with the proxies:read permission.\n- `OAUTH_SCOPE_MISSING`: Request the rest:proxies:read OAuth scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "API_KEY_SCOPE_MISSING": {
                    "summary": "Use a key with the proxies:read permission.",
                    "value": {
                      "error": {
                        "code": "API_KEY_SCOPE_MISSING",
                        "message": "This API key does not have the proxies:read permission"
                      }
                    }
                  },
                  "OAUTH_SCOPE_MISSING": {
                    "summary": "Request the rest:proxies:read OAuth scope.",
                    "value": {
                      "error": {
                        "code": "OAUTH_SCOPE_MISSING",
                        "message": "The OAuth token is missing a required permission"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/ResidentialUnavailable"
          }
        },
        "x-required-scope": "proxies:read"
      }
    },
    "/api/v1/residential/proxies": {
      "get": {
        "operationId": "getResidentialProxies",
        "tags": [
          "Use residential proxies"
        ],
        "summary": "Generate ready-to-use Residential proxy strings",
        "description": "Generates formatted Residential proxy strings (HTTP, HTTPS, SOCKS5, or raw `host:port:login:password`) with country, city, US state, ASN, and zero-cooldown rotation (`session=rotating` on ports 823/824 or `session=sticky` on ports 10000–30000 with TTL). Also returns `trafficBalance`.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "oauth2": [
              "rest:proxies:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": false,
            "example": "us",
            "description": "Two-letter ISO country code (e.g. us, de, gb), or omit for any country.",
            "schema": {
              "default": "",
              "description": "Two-letter ISO country code (e.g. us, de, gb), or omit for any country.",
              "type": "string",
              "maxLength": 16
            }
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "description": "City name (requires country).",
            "schema": {
              "description": "City name (requires country).",
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "region",
            "in": "query",
            "required": false,
            "description": "US state name (requires country=us).",
            "schema": {
              "description": "US state name (requires country=us).",
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "asn",
            "in": "query",
            "required": false,
            "description": "ASN number, e.g. 7922 or AS7922 (requires country).",
            "schema": {
              "description": "ASN number, e.g. 7922 or AS7922 (requires country).",
              "type": "string",
              "maxLength": 32
            }
          },
          {
            "name": "session",
            "in": "query",
            "required": false,
            "example": "sticky",
            "description": "sticky: keeps one IP for ttl minutes; rotating: new IP per request.",
            "schema": {
              "default": "rotating",
              "description": "sticky: keeps one IP for ttl minutes; rotating: new IP per request.",
              "type": "string",
              "enum": [
                "sticky",
                "rotating"
              ]
            }
          },
          {
            "name": "ttl",
            "in": "query",
            "required": false,
            "description": "Sticky session lifetime in minutes (0–120; 0 uses gateway default).",
            "schema": {
              "default": 0,
              "description": "Sticky session lifetime in minutes (0–120; 0 uses gateway default).",
              "type": "integer",
              "minimum": 0,
              "maximum": 120
            }
          },
          {
            "name": "quantity",
            "in": "query",
            "required": false,
            "description": "Number of proxy lines to generate (1–100).",
            "schema": {
              "default": 1,
              "description": "Number of proxy lines to generate (1–100).",
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "example": "http://login:password@ip:port",
            "description": "Output string format.",
            "schema": {
              "default": "http://login:password@ip:port",
              "description": "Output string format.",
              "type": "string",
              "enum": [
                "ip:port:login:password",
                "ip:port@login:password",
                "login:password:ip:port",
                "login:password@ip:port",
                "http://ip:port:login:password",
                "http://login:password@ip:port",
                "https://ip:port:login:password",
                "https://login:password@ip:port",
                "socks5://ip:port:login:password",
                "socks5://login:password@ip:port"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Traffic balance and generated proxy strings.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResidentialProxiesResponse"
                },
                "example": {
                  "trafficBalance": {
                    "balanceMb": 10240,
                    "isStale": false
                  },
                  "format": "http://login:password@ip:port",
                  "proxies": [
                    "http://pl-user__cr.us:example-secret@gw.proxy-layer.com:10001"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "- `API_KEY_SCOPE_MISSING`: Use a key with the proxies:read permission.\n- `OAUTH_SCOPE_MISSING`: Request the rest:proxies:read OAuth scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "API_KEY_SCOPE_MISSING": {
                    "summary": "Use a key with the proxies:read permission.",
                    "value": {
                      "error": {
                        "code": "API_KEY_SCOPE_MISSING",
                        "message": "This API key does not have the proxies:read permission"
                      }
                    }
                  },
                  "OAUTH_SCOPE_MISSING": {
                    "summary": "Request the rest:proxies:read OAuth scope.",
                    "value": {
                      "error": {
                        "code": "OAUTH_SCOPE_MISSING",
                        "message": "The OAuth token is missing a required permission"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Purchase Residential traffic first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "RESIDENTIAL_NOT_PROVISIONED": {
                    "summary": "Purchase Residential traffic first.",
                    "value": {
                      "error": {
                        "code": "RESIDENTIAL_NOT_PROVISIONED",
                        "message": "Residential proxy access is not provisioned yet. Purchase residential traffic first."
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "$ref": "#/components/responses/ResidentialUnavailable"
          }
        },
        "x-required-scope": "proxies:read"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ProxyLayer API key",
        "description": "ProxyLayer API key. See the API Overview for key modes and scopes."
      },
      "oauth2": {
        "type": "oauth2",
        "description": "Use authorization code with S256 PKCE. Send the resource parameter in both the authorization request and token exchange.",
        "x-resource": "https://app.proxy-layer.com/api/v1",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://app.proxy-layer.com/api/auth/oauth2/authorize",
            "tokenUrl": "https://app.proxy-layer.com/api/auth/oauth2/token",
            "refreshUrl": "https://app.proxy-layer.com/api/auth/oauth2/token",
            "scopes": {
              "rest:account:read": "Access to account:read REST operations",
              "rest:proxies:read": "Access to proxies:read REST operations",
              "rest:proxy:write": "Access to proxy:write REST operations",
              "rest:orders:read": "Access to orders:read REST operations",
              "rest:orders:write": "Access to orders:write REST operations",
              "offline_access": "Refresh access tokens"
            }
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Authentication failed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "API_KEY_INVALID": {
                "summary": "API key is missing, invalid, or revoked.",
                "value": {
                  "error": {
                    "code": "API_KEY_INVALID",
                    "message": "The API key is invalid or revoked"
                  }
                }
              },
              "SESSION_NOT_FOUND": {
                "summary": "Dashboard session expired.",
                "value": {
                  "error": {
                    "code": "SESSION_NOT_FOUND",
                    "message": "Session not found"
                  }
                }
              }
            }
          }
        }
      },
      "TooLarge": {
        "description": "Request body is too large.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "PAYLOAD_TOO_LARGE": {
                "summary": "Request body is too large.",
                "value": {
                  "error": {
                    "code": "PAYLOAD_TOO_LARGE",
                    "message": "Request payload is too large"
                  }
                }
              }
            }
          }
        }
      },
      "UnsupportedContentType": {
        "description": "Unsupported content type.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "UNSUPPORTED_CONTENT_TYPE": {
                "summary": "Set Content-Type: application/json.",
                "value": {
                  "error": {
                    "code": "UNSUPPORTED_CONTENT_TYPE",
                    "message": "Unsupported content type"
                  }
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Request rate limit reached.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "AUTH_RATE_LIMITED": {
                "summary": "Request rate limit reached.",
                "value": {
                  "error": {
                    "code": "AUTH_RATE_LIMITED",
                    "message": "API request limit reached; retry in a minute"
                  }
                }
              }
            }
          }
        }
      },
      "ServerError": {
        "description": "Internal server error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "INTERNAL_SERVER_ERROR": {
                "summary": "Internal server error.",
                "value": {
                  "error": {
                    "code": "INTERNAL_SERVER_ERROR",
                    "message": "Something went wrong"
                  }
                }
              }
            }
          }
        }
      },
      "Unavailable": {
        "description": "Upstream service unavailable.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "AUTH_RATE_LIMIT_UNAVAILABLE": {
                "summary": "Rate limiter temporarily unavailable.",
                "value": {
                  "error": {
                    "code": "AUTH_RATE_LIMIT_UNAVAILABLE",
                    "message": "Rate limiting is temporarily unavailable"
                  }
                }
              }
            }
          }
        }
      },
      "BadRequest": {
        "description": "Invalid request. See the [API Overview](https://docs.proxy-layer.com/api#error-codes) for error codes and examples.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The token lacks a required scope or the request origin is not allowed. See the [API Overview](https://docs.proxy-layer.com/api#error-codes).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "PurchaseConflict": {
        "description": "The purchase conflicts with account or checkout state. See the [API Overview](https://docs.proxy-layer.com/api#error-codes).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "ResidentialUnavailable": {
        "description": "Residential service is temporarily unavailable. See the [API Overview](https://docs.proxy-layer.com/api#error-codes).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      }
    },
    "schemas": {
      "OtpRequest": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          }
        },
        "required": [
          "email"
        ],
        "additionalProperties": false
      },
      "OtpRequestResponse": {
        "type": "object",
        "properties": {
          "sent": {
            "type": "boolean"
          },
          "email": {
            "type": "string"
          },
          "expiresInSeconds": {
            "type": "integer"
          }
        },
        "required": [
          "sent",
          "email",
          "expiresInSeconds"
        ],
        "additionalProperties": false
      },
      "OtpVerifyRequest": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "code": {
            "type": "string",
            "pattern": "^\\d{6}$"
          },
          "keyName": {
            "default": "AI Agent",
            "description": "Key label. Re-verifying with the same name rotates the key.",
            "type": "string"
          },
          "access": {
            "default": "read",
            "description": "Permission preset. Ignored if scopes is set.",
            "type": "string",
            "enum": [
              "read",
              "full"
            ]
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "account:read",
                "proxies:read",
                "proxy:write",
                "orders:read",
                "orders:write"
              ]
            }
          },
          "mode": {
            "default": "live",
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          }
        },
        "required": [
          "email",
          "code"
        ],
        "additionalProperties": false
      },
      "OtpVerifyResponse": {
        "type": "object",
        "properties": {
          "apiKey": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "keyId": {
            "type": "string"
          },
          "keyPrefix": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "user": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "email": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "email"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "apiKey",
          "mode",
          "keyId",
          "keyPrefix",
          "scopes",
          "user"
        ],
        "additionalProperties": false
      },
      "Catalog": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string"
          },
          "products": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "slug": {
                  "type": "string",
                  "enum": [
                    "isp",
                    "residential",
                    "datacenter",
                    "mobile"
                  ]
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "ISP",
                    "RESIDENTIAL",
                    "DATACENTER",
                    "MOBILE"
                  ]
                },
                "name": {
                  "type": "string"
                },
                "billingMode": {
                  "type": "string",
                  "enum": [
                    "FIXED",
                    "TRAFFIC"
                  ],
                  "description": "FIXED: priced by proxy count and durationDays. TRAFFIC: priced by trafficGb."
                },
                "durationsDays": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true
                  },
                  "description": "Available rental terms in days. Empty array for TRAFFIC products."
                },
                "countries": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "code",
                      "name"
                    ],
                    "additionalProperties": false
                  },
                  "description": "Available countries. Quotes validate the country and durationDays combination."
                },
                "prices": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "ruleType": {
                        "type": "string",
                        "enum": [
                          "BASE",
                          "COUNTRY",
                          "TRAFFIC_TIER",
                          "QUANTITY_TIER"
                        ],
                        "description": "Pricing tier type: base rate, country override, traffic volume tier, or quantity tier."
                      },
                      "durationDays": {
                        "nullable": true,
                        "description": "Term in days, or null for TRAFFIC products.",
                        "type": "integer"
                      },
                      "countryCode": {
                        "nullable": true,
                        "description": "Country for this rule, or null for a default rule.",
                        "type": "string"
                      },
                      "minQuantity": {
                        "nullable": true,
                        "type": "integer"
                      },
                      "maxQuantity": {
                        "nullable": true,
                        "type": "integer"
                      },
                      "minTrafficGb": {
                        "nullable": true,
                        "type": "integer"
                      },
                      "maxTrafficGb": {
                        "nullable": true,
                        "type": "integer"
                      },
                      "unitAmountCents": {
                        "type": "integer",
                        "description": "Per-proxy or per-GB price in integer USD cents."
                      },
                      "packageAmountCents": {
                        "nullable": true,
                        "description": "Fixed package total in USD cents when set; overrides unitAmountCents.",
                        "type": "integer"
                      },
                      "currency": {
                        "type": "string",
                        "enum": [
                          "USD"
                        ]
                      }
                    },
                    "required": [
                      "ruleType",
                      "durationDays",
                      "countryCode",
                      "minQuantity",
                      "maxQuantity",
                      "minTrafficGb",
                      "maxTrafficGb",
                      "unitAmountCents",
                      "packageAmountCents",
                      "currency"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "slug",
                "type",
                "name",
                "billingMode",
                "durationsDays",
                "countries",
                "prices"
              ],
              "additionalProperties": false
            }
          },
          "limits": {
            "type": "object",
            "properties": {
              "maxProxyQuantity": {
                "type": "integer"
              },
              "maxResidentialTrafficGb": {
                "type": "integer"
              }
            },
            "required": [
              "maxProxyQuantity",
              "maxResidentialTrafficGb"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "currency",
          "products",
          "limits"
        ],
        "additionalProperties": false
      },
      "QuoteRequest": {
        "type": "object",
        "properties": {
          "purchase": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "productSlug": {
                    "type": "string",
                    "enum": [
                      "isp",
                      "datacenter",
                      "mobile"
                    ],
                    "description": "Static proxy product slug: isp, datacenter, or mobile."
                  },
                  "durationDays": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 2147483647,
                    "description": "Rental term in days, from the product's durationsDays in the catalog."
                  },
                  "items": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "countryCode": {
                          "nullable": true,
                          "description": "Two-letter ISO country code from the catalog, or null for products without country selection.",
                          "type": "string",
                          "pattern": "^[a-z]{2}$"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 0,
                          "exclusiveMinimum": true,
                          "maximum": 500,
                          "description": "Number of proxies. For renewals, must equal targetProxyIds.length."
                        },
                        "targetProxyIds": {
                          "default": [],
                          "description": "Active ISP or Datacenter proxy IDs to renew. Omit or pass [] to buy new proxies.",
                          "maxItems": 500,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          }
                        }
                      },
                      "required": [
                        "countryCode",
                        "quantity"
                      ],
                      "additionalProperties": false
                    },
                    "description": "One entry per country (no duplicate countries). Total quantity across all entries cannot exceed 500."
                  }
                },
                "required": [
                  "productSlug",
                  "durationDays",
                  "items"
                ],
                "additionalProperties": false,
                "title": "Static / Renewal"
              },
              {
                "type": "object",
                "properties": {
                  "productSlug": {
                    "type": "string",
                    "enum": [
                      "residential"
                    ]
                  },
                  "trafficGb": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 5000,
                    "description": "Whole GB of Residential traffic to add (1 to 5000)."
                  }
                },
                "required": [
                  "productSlug",
                  "trafficGb"
                ],
                "additionalProperties": false,
                "title": "Residential"
              }
            ]
          }
        },
        "required": [
          "purchase"
        ],
        "additionalProperties": false
      },
      "Quote": {
        "type": "object",
        "properties": {
          "productSlug": {
            "type": "string",
            "enum": [
              "isp",
              "residential",
              "datacenter",
              "mobile"
            ]
          },
          "productType": {
            "type": "string",
            "enum": [
              "ISP",
              "RESIDENTIAL",
              "DATACENTER",
              "MOBILE"
            ]
          },
          "productName": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "amountCents": {
            "type": "integer"
          },
          "durationDays": {
            "nullable": true,
            "type": "integer"
          },
          "quantity": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "countryCode": {
                  "nullable": true,
                  "type": "string"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 0
                },
                "targetProxyIds": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "trafficGb": {
                  "nullable": true,
                  "type": "integer",
                  "minimum": 0,
                  "exclusiveMinimum": true
                },
                "unitAmountCents": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Rounded unit price per proxy or GB in USD cents."
                },
                "totalAmountCents": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Exact line total in USD cents (use this for reconciliation)."
                }
              },
              "required": [
                "countryCode",
                "quantity",
                "targetProxyIds",
                "trafficGb",
                "unitAmountCents",
                "totalAmountCents"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "productSlug",
          "productType",
          "productName",
          "currency",
          "amountCents",
          "durationDays",
          "quantity",
          "items"
        ],
        "additionalProperties": false
      },
      "ProxyPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique proxy ID. Pass in proxyIds (notes/tags) or targetProxyIds (renewals)."
                },
                "product": {
                  "type": "string",
                  "enum": [
                    "isp",
                    "datacenter",
                    "mobile"
                  ]
                },
                "countryCode": {
                  "type": "string",
                  "description": "Two-letter ISO country code, or ANY when unassigned."
                },
                "country": {
                  "type": "string"
                },
                "host": {
                  "type": "string"
                },
                "port": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 65535
                },
                "username": {
                  "type": "string"
                },
                "password": {
                  "type": "string"
                },
                "protocol": {
                  "type": "string",
                  "description": "Connection protocol, e.g. http or socks5."
                },
                "proxy": {
                  "type": "string",
                  "description": "Ready-to-use string in host:port:username:password format."
                },
                "purchasedAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "expiresAt": {
                  "nullable": true,
                  "description": "ISO 8601 expiry timestamp, or null if non-expiring.",
                  "type": "string",
                  "format": "date-time"
                },
                "daysLeft": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Days until expiry, rounded up (0 if non-expiring)."
                },
                "note": {
                  "type": "string",
                  "description": "Custom note (empty string if unset)."
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "id",
                "product",
                "countryCode",
                "country",
                "host",
                "port",
                "username",
                "password",
                "protocol",
                "proxy",
                "purchasedAt",
                "expiresAt",
                "daysLeft",
                "note",
                "tags"
              ],
              "additionalProperties": false
            }
          },
          "pagination": {
            "type": "object",
            "properties": {
              "nextCursor": {
                "nullable": true,
                "description": "Pass as cursor with the same product and limit to fetch the next page. Null on the last page.",
                "type": "string"
              }
            },
            "required": [
              "nextCursor"
            ],
            "additionalProperties": false
          },
          "pendingCheckout": {
            "description": "Present on page 1 if the supplied checkoutSessionId is still awaiting order creation.",
            "type": "object",
            "properties": {
              "checkoutSessionId": {
                "type": "string"
              },
              "quantity": {
                "type": "integer",
                "minimum": 0
              },
              "checkingPayment": {
                "type": "boolean"
              }
            },
            "required": [
              "checkoutSessionId",
              "quantity"
            ],
            "additionalProperties": false
          },
          "provisioningOrders": {
            "description": "Paid orders still being delivered for this product (first page only).",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "orderId": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 0
                },
                "fulfillmentStatus": {
                  "type": "string",
                  "enum": [
                    "PENDING",
                    "FULFILLED",
                    "FAILED",
                    "NEEDS_CHECK"
                  ]
                },
                "provisioningPending": {
                  "type": "boolean"
                },
                "failureReason": {
                  "nullable": true,
                  "type": "string"
                }
              },
              "required": [
                "orderId",
                "quantity",
                "fulfillmentStatus"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "data",
          "pagination"
        ],
        "additionalProperties": false
      },
      "ProxyMetadataRequest": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "product": {
                "type": "string",
                "enum": [
                  "isp",
                  "datacenter",
                  "mobile"
                ]
              },
              "proxyIds": {
                "minItems": 1,
                "maxItems": 500,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                },
                "description": "Active proxy IDs from GET /api/v1/proxies."
              },
              "note": {
                "description": "Replaces the note. Send an empty string to clear it.",
                "type": "string",
                "maxLength": 20000
              },
              "replaceTags": {
                "description": "Replaces all tags. Send an empty array to clear them.",
                "maxItems": 10,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                }
              },
              "addTags": {
                "description": "Appends tags up to the limit of 10 per proxy.",
                "minItems": 1,
                "maxItems": 10,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                }
              },
              "removeTags": {
                "description": "Removes tags by exact, case-sensitive match.",
                "minItems": 1,
                "maxItems": 10,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                }
              }
            },
            "required": [
              "product",
              "proxyIds"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "product": {
                "type": "string",
                "enum": [
                  "isp",
                  "datacenter",
                  "mobile"
                ]
              },
              "scope": {
                "type": "string",
                "enum": [
                  "product"
                ],
                "description": "Remove tags from all active proxies of this product."
              },
              "removeTags": {
                "minItems": 1,
                "maxItems": 10,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "description": "Tags to remove by exact, case-sensitive match."
              }
            },
            "required": [
              "product",
              "scope",
              "removeTags"
            ],
            "additionalProperties": false
          }
        ]
      },
      "ProxyWrite": {
        "type": "object",
        "properties": {
          "updated": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "updated"
        ],
        "additionalProperties": false
      },
      "TaggedProxyCount": {
        "type": "object",
        "properties": {
          "tag": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "minimum": 0,
            "description": "Number of active proxies in this product carrying the tag."
          }
        },
        "required": [
          "tag",
          "count"
        ],
        "additionalProperties": false
      },
      "OrderPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "historyKind": {
                  "description": "'order' for proxy purchases/renewals, 'balance_top_up' for wallet top-ups.",
                  "type": "string",
                  "enum": [
                    "order",
                    "balance_top_up"
                  ]
                },
                "occurredAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "Entry timestamp in ISO 8601 UTC."
                },
                "id": {
                  "type": "string"
                },
                "paymentStatus": {
                  "type": "string",
                  "enum": [
                    "PENDING",
                    "PAID",
                    "PARTIALLY_REFUNDED",
                    "REFUNDED",
                    "CANCELLED"
                  ]
                },
                "fulfillmentStatus": {
                  "type": "string",
                  "enum": [
                    "PENDING",
                    "FULFILLED",
                    "FAILED",
                    "NEEDS_CHECK"
                  ],
                  "description": "PENDING (delivering), FULFILLED (ready), or FAILED / NEEDS_CHECK (inspect items[].failureReason)."
                },
                "currency": {
                  "type": "string",
                  "enum": [
                    "USD"
                  ]
                },
                "totalAmount": {
                  "type": "integer",
                  "description": "Total amount in integer USD cents."
                },
                "subtotalAmount": {
                  "type": "integer"
                },
                "discountAmount": {
                  "type": "integer"
                },
                "taxAmount": {
                  "type": "integer"
                },
                "paymentMethod": {
                  "nullable": true,
                  "type": "object",
                  "properties": {
                    "provider": {
                      "type": "string"
                    },
                    "method": {
                      "type": "string",
                      "enum": [
                        "balance",
                        "card",
                        "paypal",
                        "crypto",
                        "stripe",
                        "unknown"
                      ]
                    },
                    "cardBrand": {
                      "nullable": true,
                      "type": "string"
                    },
                    "cardLast4": {
                      "nullable": true,
                      "type": "string"
                    }
                  },
                  "required": [
                    "provider",
                    "method"
                  ],
                  "additionalProperties": false
                },
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "kind": {
                        "nullable": true,
                        "type": "string",
                        "enum": [
                          "balance_top_up"
                        ]
                      },
                      "durationDays": {
                        "nullable": true,
                        "type": "integer"
                      },
                      "quantity": {
                        "type": "integer"
                      },
                      "trafficGb": {
                        "nullable": true,
                        "type": "integer"
                      },
                      "unitAmount": {
                        "type": "integer"
                      },
                      "totalAmount": {
                        "type": "integer"
                      },
                      "countryCode": {
                        "nullable": true,
                        "type": "string"
                      },
                      "fulfillmentStatus": {
                        "type": "string",
                        "enum": [
                          "PENDING",
                          "FULFILLED",
                          "FAILED",
                          "NEEDS_CHECK"
                        ]
                      },
                      "failureReason": {
                        "description": "Reason delivery failed or needs manual review, when applicable.",
                        "nullable": true,
                        "type": "string"
                      },
                      "fulfilledAt": {
                        "nullable": true,
                        "type": "string",
                        "format": "date-time"
                      },
                      "product": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "name",
                          "type"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "id",
                      "kind",
                      "durationDays",
                      "quantity",
                      "trafficGb",
                      "unitAmount",
                      "totalAmount",
                      "countryCode",
                      "product"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "occurredAt",
                "id",
                "paymentStatus",
                "fulfillmentStatus",
                "currency",
                "totalAmount",
                "subtotalAmount",
                "discountAmount",
                "taxAmount",
                "paymentMethod",
                "items"
              ],
              "additionalProperties": false
            }
          },
          "nextCursor": {
            "nullable": true,
            "description": "Pass as cursor with the same limit to fetch the next page. Null on the last page.",
            "type": "string"
          }
        },
        "required": [
          "items",
          "nextCursor"
        ],
        "additionalProperties": false
      },
      "BalanceOrderRequest": {
        "type": "object",
        "properties": {
          "purchase": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "productSlug": {
                    "type": "string",
                    "enum": [
                      "isp",
                      "datacenter",
                      "mobile"
                    ],
                    "description": "Static proxy product slug: isp, datacenter, or mobile."
                  },
                  "durationDays": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 2147483647,
                    "description": "Rental term in days, from the product's durationsDays in the catalog."
                  },
                  "items": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "countryCode": {
                          "nullable": true,
                          "description": "Two-letter ISO country code from the catalog, or null for products without country selection.",
                          "type": "string",
                          "pattern": "^[a-z]{2}$"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 0,
                          "exclusiveMinimum": true,
                          "maximum": 500,
                          "description": "Number of proxies. For renewals, must equal targetProxyIds.length."
                        },
                        "targetProxyIds": {
                          "default": [],
                          "description": "Active ISP or Datacenter proxy IDs to renew. Omit or pass [] to buy new proxies.",
                          "maxItems": 500,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          }
                        }
                      },
                      "required": [
                        "countryCode",
                        "quantity"
                      ],
                      "additionalProperties": false
                    },
                    "description": "One entry per country (no duplicate countries). Total quantity across all entries cannot exceed 500."
                  }
                },
                "required": [
                  "productSlug",
                  "durationDays",
                  "items"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "productSlug": {
                    "type": "string",
                    "enum": [
                      "residential"
                    ]
                  },
                  "trafficGb": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 5000,
                    "description": "Whole GB of Residential traffic to add (1 to 5000)."
                  }
                },
                "required": [
                  "productSlug",
                  "trafficGb"
                ],
                "additionalProperties": false
              }
            ]
          },
          "clientOperationId": {
            "description": "Body alternative to the Idempotency-Key header. One of the two is required; if both are sent, they must match.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "purchase"
        ],
        "additionalProperties": false
      },
      "CreateOrder": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "description": "Paid order ID. Look it up in GET /api/v1/orders to track delivery."
          },
          "checkoutSessionId": {
            "type": "string",
            "description": "Checkout session ID. Poll GET /api/v1/checkouts/{id} to track delivery."
          },
          "balanceCents": {
            "type": "integer",
            "minimum": 0,
            "description": "Remaining prepaid balance in USD cents (on idempotent replays, reflects balance at replay time)."
          }
        },
        "required": [
          "orderId",
          "checkoutSessionId",
          "balanceCents"
        ],
        "additionalProperties": false
      },
      "CheckoutRequest": {
        "type": "object",
        "properties": {
          "purchase": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "productSlug": {
                    "type": "string",
                    "enum": [
                      "isp",
                      "datacenter",
                      "mobile"
                    ],
                    "description": "Static proxy product slug: isp, datacenter, or mobile."
                  },
                  "durationDays": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 2147483647,
                    "description": "Rental term in days, from the product's durationsDays in the catalog."
                  },
                  "items": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "countryCode": {
                          "nullable": true,
                          "description": "Two-letter ISO country code from the catalog, or null for products without country selection.",
                          "type": "string",
                          "pattern": "^[a-z]{2}$"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 0,
                          "exclusiveMinimum": true,
                          "maximum": 500,
                          "description": "Number of proxies. For renewals, must equal targetProxyIds.length."
                        },
                        "targetProxyIds": {
                          "default": [],
                          "description": "Active ISP or Datacenter proxy IDs to renew. Omit or pass [] to buy new proxies.",
                          "maxItems": 500,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          }
                        }
                      },
                      "required": [
                        "countryCode",
                        "quantity"
                      ],
                      "additionalProperties": false
                    },
                    "description": "One entry per country (no duplicate countries). Total quantity across all entries cannot exceed 500."
                  }
                },
                "required": [
                  "productSlug",
                  "durationDays",
                  "items"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "productSlug": {
                    "type": "string",
                    "enum": [
                      "residential"
                    ]
                  },
                  "trafficGb": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 5000,
                    "description": "Whole GB of Residential traffic to add (1 to 5000)."
                  }
                },
                "required": [
                  "productSlug",
                  "trafficGb"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "productSlug": {
                    "type": "string",
                    "enum": [
                      "balance-topup"
                    ]
                  },
                  "amountCents": {
                    "type": "integer",
                    "minimum": 500,
                    "maximum": 500000,
                    "description": "Top-up amount in integer USD cents ($5.00 to $5,000.00)."
                  }
                },
                "required": [
                  "productSlug",
                  "amountCents"
                ],
                "additionalProperties": false
              }
            ]
          },
          "paymentMethod": {
            "default": "stripe",
            "description": "stripe: hosted checkout URL; crypto: deposit address + paymentUrl; balance: debits prepaid wallet immediately.",
            "type": "string",
            "enum": [
              "stripe",
              "crypto",
              "balance"
            ]
          },
          "cryptoCurrency": {
            "description": "Coin for crypto payments (default: USDT).",
            "type": "string",
            "minLength": 1,
            "maxLength": 24,
            "pattern": "^[A-Z0-9]+$"
          },
          "cryptoNetwork": {
            "description": "Network for cryptoCurrency (default: TRON for USDT/USDC).",
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "pattern": "^[A-Z0-9_-]+$"
          },
          "clientOperationId": {
            "description": "Body alternative to Idempotency-Key. Reuse on retries; must match header if both are sent.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "purchase"
        ],
        "additionalProperties": false
      },
      "CheckoutResponse": {
        "type": "object",
        "properties": {
          "checkoutSessionId": {
            "type": "string",
            "description": "Session ID to poll with GET /api/v1/checkouts/{id}."
          },
          "paymentMethod": {
            "type": "string",
            "enum": [
              "stripe",
              "crypto",
              "balance"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed"
            ]
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "amountCents": {
            "type": "integer",
            "minimum": 0,
            "exclusiveMinimum": true,
            "description": "Total checkout amount in integer USD cents."
          },
          "paymentUrl": {
            "description": "Hosted payment link for stripe or crypto checkouts; null for balance.",
            "nullable": true,
            "type": "string"
          },
          "expiresAt": {
            "description": "ISO 8601 expiry time for pending checkouts.",
            "nullable": true,
            "type": "string",
            "format": "date-time"
          },
          "orderId": {
            "description": "Order ID, set immediately on balance purchases.",
            "nullable": true,
            "type": "string"
          },
          "balanceCents": {
            "description": "Remaining prepaid balance in USD cents after a balance purchase.",
            "nullable": true,
            "type": "integer",
            "minimum": 0
          },
          "crypto": {
            "description": "Crypto deposit details, present when paymentMethod is 'crypto'.",
            "type": "object",
            "properties": {
              "address": {
                "type": "string"
              },
              "payerAmount": {
                "type": "string"
              },
              "payerCurrency": {
                "type": "string"
              },
              "network": {
                "type": "string"
              },
              "expiresAt": {
                "nullable": true,
                "description": "Unix timestamp (seconds) when the crypto invoice expires.",
                "type": "number"
              }
            },
            "required": [
              "address",
              "payerAmount",
              "payerCurrency",
              "network",
              "expiresAt"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "checkoutSessionId",
          "paymentMethod",
          "status",
          "currency",
          "amountCents"
        ],
        "additionalProperties": false
      },
      "CheckoutStatus": {
        "type": "object",
        "properties": {
          "checkoutSessionId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "failed",
              "expired",
              "cancelled",
              "refunded"
            ],
            "description": "Payment state. 'completed' means payment succeeded, not that proxies are delivered."
          },
          "provisioningPending": {
            "type": "boolean",
            "description": "True while payment succeeded and order creation or delivery is still in progress."
          },
          "orderId": {
            "nullable": true,
            "description": "Created order ID once payment completes; null for wallet top-ups or unpaid checkouts.",
            "type": "string"
          },
          "fulfillmentStatus": {
            "nullable": true,
            "description": "Delivery state: PENDING (in progress), FULFILLED (ready to use), FAILED, or NEEDS_CHECK. Null before an order exists.",
            "type": "string",
            "enum": [
              "PENDING",
              "FULFILLED",
              "FAILED",
              "NEEDS_CHECK"
            ]
          },
          "failureMessage": {
            "nullable": true,
            "description": "Reason payment or delivery failed, when available.",
            "type": "string"
          },
          "balanceCents": {
            "nullable": true,
            "description": "Updated prepaid wallet balance in USD cents after a top-up or balance purchase; otherwise null.",
            "type": "integer"
          },
          "detail": {
            "description": "Extra crypto payment state: WAITING_CONFIRMATIONS or UNDERPAID.",
            "type": "string",
            "enum": [
              "WAITING_CONFIRMATIONS",
              "UNDERPAID"
            ]
          },
          "paymentProvider": {
            "description": "Payment rail used (e.g. stripe, crypto, balance).",
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "checkoutSessionId",
          "status",
          "provisioningPending",
          "orderId",
          "fulfillmentStatus",
          "failureMessage",
          "balanceCents"
        ],
        "additionalProperties": false
      },
      "ResidentialSnapshot": {
        "type": "object",
        "properties": {
          "trafficBalance": {
            "type": "object",
            "properties": {
              "balanceMb": {
                "type": "integer",
                "minimum": 0,
                "description": "Remaining Residential traffic in MB (1024 MB = 1 GB)."
              },
              "isStale": {
                "type": "boolean",
                "description": "True when returning a cached value or while a balance sync is already running."
              }
            },
            "required": [
              "balanceMb",
              "isStale"
            ],
            "additionalProperties": false
          },
          "proxyCredentials": {
            "nullable": true,
            "description": "Gateway credentials. Null until your first Residential traffic purchase is fulfilled.",
            "type": "object",
            "properties": {
              "providerSubuserId": {
                "type": "integer",
                "description": "Residential gateway sub-account ID."
              },
              "host": {
                "type": "string"
              },
              "login": {
                "type": "string",
                "description": "Base gateway username. Targeting parameters are appended to this username when connecting manually."
              },
              "password": {
                "type": "string"
              },
              "stickyRangeStart": {
                "nullable": true,
                "description": "First port in the sticky session range (default 10000).",
                "type": "integer"
              },
              "stickyRangeEnd": {
                "nullable": true,
                "description": "Last port in the sticky session range (up to 30000).",
                "type": "integer"
              },
              "rotatingPort": {
                "nullable": true,
                "description": "Port for per-request IP rotation. Null uses protocol defaults (823 HTTP/HTTPS, 824 SOCKS5).",
                "type": "integer"
              }
            },
            "required": [
              "providerSubuserId",
              "host",
              "login",
              "password",
              "stickyRangeStart",
              "stickyRangeEnd",
              "rotatingPort"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "trafficBalance",
          "proxyCredentials"
        ],
        "additionalProperties": false
      },
      "ResidentialProxiesResponse": {
        "type": "object",
        "properties": {
          "trafficBalance": {
            "type": "object",
            "properties": {
              "balanceMb": {
                "type": "integer",
                "minimum": 0,
                "description": "Remaining Residential traffic in MB (1024 MB = 1 GB)."
              },
              "isStale": {
                "type": "boolean",
                "description": "True when returning a cached value or while a balance sync is already running."
              }
            },
            "required": [
              "balanceMb",
              "isStale"
            ],
            "additionalProperties": false
          },
          "format": {
            "type": "string",
            "enum": [
              "ip:port:login:password",
              "ip:port@login:password",
              "login:password:ip:port",
              "login:password@ip:port",
              "http://ip:port:login:password",
              "http://login:password@ip:port",
              "https://ip:port:login:password",
              "https://login:password@ip:port",
              "socks5://ip:port:login:password",
              "socks5://login:password@ip:port"
            ]
          },
          "proxies": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "trafficBalance",
          "format",
          "proxies"
        ],
        "additionalProperties": false
      },
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable error code (e.g. VALIDATION_ERROR)."
              },
              "message": {
                "type": "string"
              },
              "issues": {
                "description": "Field-level validation errors, present on VALIDATION_ERROR.",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": {}
                }
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "balanceCents": {
            "type": "integer",
            "description": "Spendable wallet balance in USD cents."
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "scopes": {
            "nullable": true,
            "description": "Scopes granted to the current credential, without the resource prefix. Null for browser sessions.",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "account:read",
                "proxies:read",
                "proxy:write",
                "orders:read",
                "orders:write"
              ]
            }
          }
        },
        "required": [
          "id",
          "name",
          "balanceCents",
          "mode",
          "scopes"
        ],
        "additionalProperties": false
      }
    }
  }
}
