{
  "openapi": "3.0.0",
  "info": {
    "title": "CloudPaya API",
    "description": "API documentation for CloudPaya Crypto Payment Gateway. This API allows you to manage transactions, balances, settings, and more.",
    "version": "1.3.1"
  },
  "servers": [
    {
      "url": "https://cloudpaya.com",
      "description": "Production Server"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "query",
        "name": "api-key"
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/api.php": {
      "post": {
        "summary": "Execute API Function",
        "description": "Main entry point for all API calls. The specific action is determined by the 'function' parameter in the request body.",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "api-key": {
                    "type": "string",
                    "description": "Your API Key (can also be passed as a query parameter)"
                  },
                  "function": {
                    "type": "string",
                    "description": "The function to execute",
                    "enum": [
                      "get-balances",
                      "get-settings",
                      "save-settings",
                      "get-transactions",
                      "get-transaction",
                      "download-transactions",
                      "check-transaction",
                      "check-transactions",
                      "update-transaction",
                      "create-transaction",
                      "delete-transaction",
                      "get-checkouts",
                      "save-checkout",
                      "delete-checkout",
                      "get-fiat-value",
                      "cron",
                      "invoice",
                      "update",
                      "vat",
                      "vat-validation",
                      "get-cryptocurrency-codes",
                      "payment-link",
                      "get-custom-tokens",
                      "settings-get-address",
                      "eth-curl",
                      "eth-transfer",
                      "eth-swap",
                      "eth-get-contract",
                      "eth-wait-confirmation",
                      "eth-get-transactions-after-timestamp",
                      "eth-generate-address",
                      "eth-get-balance",
                      "btc-curl",
                      "btc-transfer",
                      "btc-generate-address",
                      "btc-generate-address-xpub",
                      "btc-get-utxo",
                      "refund",
                      "get-exchange-rates",
                      "get-usd-rates",
                      "validate-license-key",
                      "encryption"
                    ]
                  },
                  "amount": {
                    "type": "number",
                    "description": "Amount for transaction or transfer"
                  },
                  "cryptocurrency_code": {
                    "type": "string",
                    "description": "Cryptocurrency code (e.g., BTC, ETH)"
                  },
                  "currency_code": {
                    "type": "string",
                    "description": "Fiat currency code (e.g., USD)"
                  },
                  "transaction_id": {
                    "type": "string",
                    "description": "Transaction ID"
                  },
                  "external_reference": {
                    "type": "string",
                    "description": "External reference ID"
                  },
                  "title": {
                    "type": "string",
                    "description": "Transaction title"
                  },
                  "description": {
                    "type": "string",
                    "description": "Transaction description"
                  },
                  "redirect": {
                    "type": "string",
                    "description": "Redirect URL after payment"
                  },
                  "checkout_id": {
                    "type": "string",
                    "description": "Checkout ID"
                  },
                  "checkout": {
                    "type": "string",
                    "description": "Checkout data (JSON string)"
                  },
                  "settings": {
                    "type": "string",
                    "description": "Settings data (JSON string)"
                  },
                  "values": {
                    "type": "string",
                    "description": "Values to update (JSON string)"
                  },
                  "domain": {
                    "type": "string",
                    "description": "Domain for update"
                  },
                  "vat_number": {
                    "type": "string",
                    "description": "VAT number for validation"
                  },
                  "method": {
                    "type": "string",
                    "description": "Method for curl calls"
                  },
                  "cryptocurrency_code_from": {
                    "type": "string",
                    "description": "Source cryptocurrency for swap"
                  },
                  "hash": {
                    "type": "string",
                    "description": "Transaction hash"
                  },
                  "timestamp": {
                    "type": "integer",
                    "description": "Timestamp"
                  },
                  "xpub": {
                    "type": "string",
                    "description": "XPUB key"
                  },
                  "license_key": {
                    "type": "string",
                    "description": "License key"
                  },
                  "value": {
                    "type": "string",
                    "description": "Value to encrypt"
                  }
                },
                "required": ["function"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "response": {
                      "type": "object",
                      "description": "The result of the function call"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request (Missing parameters)"
          },
          "403": {
            "description": "Forbidden (Invalid API Key)"
          }
        }
      }
    }
  }
}
