{
  "openapi": "3.0.3",
  "info": {
    "title": "SağlamProxy Bayi API",
    "version": "1.1.0",
    "description": "SağlamProxy bayi API referansı. Kullanım: https://saglamproxy.com/api/v1/. İşlem path sorgu parametresiyle seçilir."
  },
  "servers": [
    {
      "url": "https://panel.saglamproxy.com/bayi-api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/index.php": {
      "get": {
        "operationId": "read",
        "summary": "Katalog, bakiye, durum veya teslimat",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^(ping|products|balance|orders/[A-Za-z0-9][A-Za-z0-9_.-]{0,95}(/delivery)?)$"
            },
            "examples": {
              "catalog": {
                "value": "products"
              },
              "balance": {
                "value": "balance"
              },
              "status": {
                "value": "orders/SITE-1001-1"
              },
              "delivery": {
                "value": "orders/SITE-1001-1/delivery"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Başarılı sorgu. Siparişlerde data.status ayrıca kontrol edilir.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Product"
                          }
                        },
                        {
                          "type": "object"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "426": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "write",
        "summary": "Fiyat önizleme veya bir paket satın alma",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "quotes",
                "orders"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/QuoteRequest"
                  },
                  {
                    "$ref": "#/components/schemas/OrderRequest"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Başarılı sorgu. Siparişlerde data.status ayrıca kontrol edilir.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "426": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "İstek tamamlanamadı. error.code alanını kontrol edin.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "QuoteRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "product_id",
          "cycle"
        ],
        "properties": {
          "product_id": {
            "type": "integer"
          },
          "cycle": {
            "type": "string",
            "example": "monthly",
            "description": "Use the selected product cycles list; daily, weekly, monthly and onetime are examples, not universally available."
          },
          "protocol": {
            "type": "string",
            "enum": [
              "http",
              "socks5"
            ],
            "default": "http",
            "description": "Must be listed in supported_protocols. Growtopia packages require explicit socks5; the legacy default http is unsupported there."
          }
        }
      },
      "OrderRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "product_id",
          "cycle",
          "external_order_id",
          "max_total",
          "currency",
          "terms"
        ],
        "properties": {
          "product_id": {
            "type": "integer"
          },
          "cycle": {
            "type": "string",
            "example": "monthly",
            "description": "Use the selected product cycles list; daily, weekly, monthly and onetime are examples, not universally available."
          },
          "protocol": {
            "type": "string",
            "enum": [
              "http",
              "socks5"
            ],
            "default": "http",
            "description": "Must be listed in supported_protocols. Growtopia packages require explicit socks5; the legacy default http is unsupported there."
          },
          "external_order_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,95}$"
          },
          "max_total": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,7})\\.[0-9]{2}$",
            "example": "120.00"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "example": "TRY"
          },
          "terms": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "Money": {
        "type": "object",
        "required": [
          "amount",
          "currency"
        ],
        "properties": {
          "amount": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          }
        }
      },
      "Product": {
        "type": "object",
        "required": [
          "id",
          "quantity",
          "cycles",
          "supported_protocols",
          "provisionable",
          "availability_reason",
          "pricing_source"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "family": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "cycles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "supported_protocols": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "http",
                "socks5"
              ]
            }
          },
          "provisionable": {
            "type": "boolean"
          },
          "availability_reason": {
            "type": "string",
            "nullable": true
          },
          "reseller_discount_percent": {
            "type": "number"
          },
          "pricing_source": {
            "type": "string",
            "enum": [
              "account_dealership"
            ]
          },
          "delivery_type": {
            "type": "string",
            "enum": [
              "static",
              "mobile",
              "rotating",
              "ipv6"
            ]
          },
          "delivery_schema_version": {
            "type": "integer"
          }
        }
      },
      "Proxy": {
        "type": "object",
        "required": [
          "host",
          "port",
          "protocol",
          "username",
          "password"
        ],
        "properties": {
          "host": {
            "type": "string",
            "description": "Hostname, IPv4 or IPv6; no port or surrounding brackets."
          },
          "port": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65535
          },
          "protocol": {
            "type": "string",
            "enum": [
              "http",
              "socks5"
            ]
          },
          "username": {
            "type": "string"
          },
          "password": {
            "type": "string",
            "format": "password"
          }
        }
      }
    }
  }
}