{
  "openapi": "3.1.0",
  "info": {
    "title": "VEX Wallet Public API",
    "version": "1.0.0",
    "summary": "Live USDT/VES and BCV rates, rate history, withdrawal fees and Pago Móvil quotes.",
    "description": "Public, read-only, unauthenticated endpoints. Rates and fees are referential; the rate applied to an operation is confirmed in the VEX Wallet app. CORS is limited to VEX origins, so call from a server or agent.",
    "contact": {
      "name": "VEX Wallet",
      "email": "hi@vexwallet.co",
      "url": "https://vexwallet.co/developers"
    }
  },
  "security": [],
  "externalDocs": {
    "description": "Developer portal",
    "url": "https://vexwallet.co/developers"
  },
  "servers": [
    {
      "url": "https://fx.vexwallet.co/api/v1",
      "description": "VEX FX API (production)"
    },
    {
      "url": "https://api.vexwallet.co/api/v1",
      "description": "VEX Pay API — public endpoints (production)"
    }
  ],
  "tags": [
    {
      "name": "FX",
      "description": "Exchange rates"
    },
    {
      "name": "Fees",
      "description": "Withdrawal fees and quotes"
    }
  ],
  "paths": {
    "/fx/latest": {
      "servers": [
        {
          "url": "https://fx.vexwallet.co/api/v1",
          "description": "VEX FX API (production)"
        }
      ],
      "get": {
        "tags": [
          "FX"
        ],
        "operationId": "getLatestRate",
        "summary": "Latest rate for a pair",
        "parameters": [
          {
            "name": "pair",
            "in": "query",
            "required": false,
            "description": "Currency pair as BASE/QUOTE.",
            "schema": {
              "type": "string",
              "default": "USDT/VES",
              "examples": [
                "USDT/VES",
                "USD/VES"
              ]
            }
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "description": "Rate source: `binance` (P2P) or `bcv` (official).",
            "schema": {
              "type": "string",
              "examples": [
                "binance",
                "bcv"
              ]
            }
          },
          {
            "name": "method",
            "in": "query",
            "required": false,
            "description": "`p2p_floor` selects the Binance P2P floor (VEX reference rate).",
            "schema": {
              "type": "string",
              "examples": [
                "p2p_floor"
              ]
            }
          },
          {
            "name": "side",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "examples": [
                "BUY",
                "SELL",
                "FLOOR",
                "OFFICIAL"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Latest rate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rate"
                }
              }
            }
          },
          "400": {
            "description": "`pair` is not BASE/QUOTE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No rate found for the filter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/fx/history": {
      "servers": [
        {
          "url": "https://fx.vexwallet.co/api/v1",
          "description": "VEX FX API (production)"
        }
      ],
      "get": {
        "tags": [
          "FX"
        ],
        "operationId": "getRateHistory",
        "summary": "Rate history, raw or aggregated by hour/day",
        "parameters": [
          {
            "name": "pair",
            "in": "query",
            "required": false,
            "description": "Currency pair as BASE/QUOTE.",
            "schema": {
              "type": "string",
              "default": "USDT/VES",
              "examples": [
                "USDT/VES",
                "USD/VES"
              ]
            }
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "description": "Rate source: `binance` (P2P) or `bcv` (official).",
            "schema": {
              "type": "string",
              "examples": [
                "binance",
                "bcv"
              ]
            }
          },
          {
            "name": "side",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "examples": [
                "BUY",
                "SELL",
                "FLOOR",
                "OFFICIAL"
              ]
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "hour",
                "day",
                "auto"
              ]
            }
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "avg",
                "min",
                "max",
                "first",
                "last"
              ],
              "default": "avg"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rate series",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateHistory"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/public/withdraw/fee-schedule": {
      "servers": [
        {
          "url": "https://api.vexwallet.co/api/v1",
          "description": "VEX Pay API — public endpoints (production)"
        }
      ],
      "get": {
        "tags": [
          "Fees"
        ],
        "operationId": "getWithdrawalFeeSchedule",
        "summary": "Active withdrawal fee policy",
        "parameters": [
          {
            "name": "x-tenant-id",
            "in": "header",
            "required": false,
            "description": "Tenant whose fee policy applies. Defaults to `vex-wallet`.",
            "schema": {
              "type": "string",
              "default": "vex-wallet"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fee schedule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeSchedule"
                }
              }
            }
          }
        }
      }
    },
    "/public/withdraw/estimate-fee": {
      "servers": [
        {
          "url": "https://api.vexwallet.co/api/v1",
          "description": "VEX Pay API — public endpoints (production)"
        }
      ],
      "get": {
        "tags": [
          "Fees"
        ],
        "operationId": "estimateWithdrawalFee",
        "summary": "Estimate the withdrawal fee for an amount",
        "parameters": [
          {
            "name": "amount_cents",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "method",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "PAGO_MOVIL",
                "CRYPTO_WALLET",
                "ACH",
                "PAYPAL"
              ]
            }
          },
          {
            "name": "network",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "examples": [
                "TRC20",
                "ERC20"
              ]
            }
          },
          {
            "name": "asset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "USDT",
              "examples": [
                "USDT",
                "USDC"
              ]
            }
          },
          {
            "name": "x-tenant-id",
            "in": "header",
            "required": false,
            "description": "Tenant whose fee policy applies. Defaults to `vex-wallet`.",
            "schema": {
              "type": "string",
              "default": "vex-wallet"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fee breakdown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeEstimate"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_amount_cents`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/public/withdraw/pago-movil-quote": {
      "servers": [
        {
          "url": "https://api.vexwallet.co/api/v1",
          "description": "VEX Pay API — public endpoints (production)"
        }
      ],
      "get": {
        "tags": [
          "Fees"
        ],
        "operationId": "getPagoMovilQuote",
        "summary": "Pago Móvil withdrawal quote (base rate, offered rate, VES estimate)",
        "parameters": [
          {
            "name": "amountCents",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1000
            }
          },
          {
            "name": "calculator",
            "in": "query",
            "required": false,
            "description": "`1` applies the full policy fee (no waivers).",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "true"
              ]
            }
          },
          {
            "name": "x-tenant-id",
            "in": "header",
            "required": false,
            "description": "Tenant whose fee policy applies. Defaults to `vex-wallet`.",
            "schema": {
              "type": "string",
              "default": "vex-wallet"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagoMovilQuote"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_amount_cents` or `pago_movil_min_amount`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Exchange rate service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Rate": {
        "type": "object",
        "required": [
          "pair",
          "source",
          "price",
          "asOf"
        ],
        "properties": {
          "pair": {
            "type": "string",
            "examples": [
              "USDT/VES"
            ]
          },
          "source": {
            "type": "string",
            "examples": [
              "binance"
            ]
          },
          "method": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "p2p_floor"
            ]
          },
          "price": {
            "type": "number",
            "examples": [
              961.058
            ]
          },
          "asOf": {
            "type": "string",
            "format": "date-time"
          },
          "fetchedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "side": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "FLOOR"
            ]
          },
          "paymentMethod": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RateHistory": {
        "type": "object",
        "properties": {
          "pair": {
            "type": "string"
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "side": {
            "type": [
              "string",
              "null"
            ]
          },
          "interval": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "hour",
              "day",
              null
            ]
          },
          "aggregation": {
            "type": [
              "string",
              "null"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "pair": {
                  "type": "string"
                },
                "source": {
                  "type": "string"
                },
                "method": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "side": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "price": {
                  "type": "number"
                },
                "asOf": {
                  "type": "string",
                  "format": "date-time"
                },
                "count": {
                  "type": "integer",
                  "description": "Samples in the bucket (aggregated only)."
                }
              }
            }
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "FeeSchedule": {
        "type": "object",
        "required": [
          "policy",
          "minWithdrawalCents",
          "summary"
        ],
        "properties": {
          "policy": {
            "type": "string",
            "enum": [
              "legacy_flat",
              "tiered_v1",
              "tiered_v2"
            ]
          },
          "minWithdrawalCents": {
            "type": "integer",
            "examples": [
              1000
            ]
          },
          "summary": {
            "type": "string",
            "examples": [
              "1.5% + $3.50 + fee de red"
            ]
          },
          "serviceFeePercent": {
            "type": "number"
          },
          "serviceFeeFixedCents": {
            "type": "integer"
          },
          "networkFeeCents": {
            "type": "integer"
          },
          "tiers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "minAmountCents": {
                  "type": "integer"
                },
                "maxAmountCents": {
                  "type": "integer"
                },
                "serviceFeePercent": {
                  "type": "number"
                },
                "serviceFeeFixedCents": {
                  "type": "integer"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "FeeEstimate": {
        "type": "object",
        "required": [
          "serviceFeeCents",
          "blockchainFeeCents",
          "totalFeeCents",
          "amountToReceiveCents"
        ],
        "properties": {
          "serviceFeeCents": {
            "type": "integer"
          },
          "blockchainFeeCents": {
            "type": "integer"
          },
          "totalFeeCents": {
            "type": "integer"
          },
          "amountToReceiveCents": {
            "type": "integer"
          },
          "breakdown": {
            "type": "object",
            "properties": {
              "serviceFee": {
                "type": "number"
              },
              "blockchainFee": {
                "type": "number"
              },
              "totalFee": {
                "type": "number"
              }
            }
          },
          "feePercent": {
            "type": "number"
          },
          "feeFixedCents": {
            "type": "integer"
          },
          "feeTier": {
            "type": "string"
          },
          "feePolicyVersion": {
            "type": "string"
          },
          "feeBreakdownLabel": {
            "type": "string"
          }
        }
      },
      "PagoMovilQuote": {
        "type": "object",
        "required": [
          "exchange_rate_base",
          "exchange_rate_offered",
          "exchange_rate_fetched_at",
          "margin_percent"
        ],
        "properties": {
          "exchange_rate_base": {
            "type": "number"
          },
          "exchange_rate_offered": {
            "type": "number"
          },
          "exchange_rate_fetched_at": {
            "type": "string",
            "format": "date-time"
          },
          "margin_percent": {
            "type": "number"
          },
          "ves_estimate": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "statusCode",
          "message"
        ],
        "properties": {
          "statusCode": {
            "type": "integer",
            "examples": [
              400
            ]
          },
          "error": {
            "type": "string",
            "examples": [
              "Bad Request"
            ]
          },
          "message": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ],
            "examples": [
              "pago_movil_min_amount"
            ]
          }
        }
      }
    }
  }
}