{
  "openapi": "3.1.0",
  "info": {
    "title": "Virga API",
    "description": "Agent-first Weather API with autonomous onboarding, prepaid credits, and normalized weather data. Designed for programmatic consumption by AI agents and developers.",
    "version": "1.0.0",
    "contact": {
      "name": "Virga Support",
      "url": "https://virga.dev"
    },
    "license": {
      "name": "Proprietary"
    },
    "x-onboarding-flow": {
      "description": "Autonomous onboarding sequence for agents",
      "steps": [
        {
          "step": 1,
          "action": "POST /api/v1/accounts",
          "description": "Create account with a name. Receives a stage API key (sk_virga_stage_...)."
        },
        {
          "step": 2,
          "action": "GET /api/v1/terms",
          "description": "Read current terms of service."
        },
        {
          "step": 3,
          "action": "POST /api/v1/terms/accept",
          "description": "Accept terms by sending the version string."
        },
        {
          "step": 4,
          "action": "POST /api/v1/billing/activate",
          "description": "Set up payment method. Returns a checkout URL."
        },
        {
          "step": 5,
          "action": "POST /api/v1/billing/credits",
          "description": "Purchase a credit bundle (500, 2000, or 10000 credits)."
        },
        {
          "step": 6,
          "action": "POST /api/v1/keys",
          "description": "Create a production API key (sk_virga_prod_...). Requires terms + billing + credits."
        },
        {
          "step": 7,
          "action": "GET /api/v1/weather/current",
          "description": "Query weather data using the production key."
        }
      ]
    }
  },
  "servers": [
    {
      "url": "https://api.virga.dev",
      "description": "Production"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API key prefixed with sk_virga_stage_ or sk_virga_prod_. Can also be passed as ?api_key= query parameter."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": ["error", "code", "message"],
        "properties": {
          "error": { "type": "string", "description": "HTTP error category" },
          "code": { "type": "string", "description": "Machine-readable error code" },
          "message": { "type": "string", "description": "Human-readable error message" }
        }
      },
      "RateLimitError": {
        "allOf": [
          { "$ref": "#/components/schemas/Error" },
          {
            "type": "object",
            "properties": {
              "retryAfter": { "type": "integer", "description": "Seconds until rate limit resets" },
              "limit": { "type": "integer" },
              "remaining": { "type": "integer" }
            }
          }
        ]
      },
      "Meta": {
        "type": "object",
        "properties": {
          "source": { "type": "string", "example": "virga" },
          "upstreamTimestamp": { "type": "string", "format": "date-time" },
          "cacheTTL": { "type": "integer", "description": "Cache TTL in seconds" },
          "cached": { "type": "boolean" },
          "confidence": { "type": "number" },
          "creditsCost": { "type": "integer" },
          "creditsRemaining": { "type": "integer" },
          "environment": { "type": "string", "enum": ["stage", "production"] },
          "rateLimitRemaining": { "type": "integer" },
          "rateLimitReset": { "type": "integer", "description": "Unix timestamp" }
        }
      },
      "Temperature": {
        "type": "object",
        "properties": {
          "current": { "type": "number" },
          "feelsLike": { "type": "number" },
          "min": { "type": "number" },
          "max": { "type": "number" },
          "unit": { "type": "string", "enum": ["celsius"] }
        }
      },
      "Wind": {
        "type": "object",
        "properties": {
          "speed": { "type": "number" },
          "direction": { "type": "number" },
          "gust": { "type": ["number", "null"] },
          "unit": { "type": "string", "enum": ["m/s"] }
        }
      },
      "Precipitation": {
        "type": "object",
        "properties": {
          "probability": { "type": ["number", "null"] },
          "amount": { "type": "number" },
          "unit": { "type": "string", "enum": ["mm"] }
        }
      },
      "Conditions": {
        "type": "object",
        "properties": {
          "code": { "type": "integer" },
          "description": { "type": "string" },
          "icon": { "type": "string" }
        }
      },
      "NormalizedWeather": {
        "type": "object",
        "properties": {
          "temperature": { "$ref": "#/components/schemas/Temperature" },
          "humidity": { "type": "number" },
          "pressure": { "type": "number" },
          "wind": { "$ref": "#/components/schemas/Wind" },
          "precipitation": { "$ref": "#/components/schemas/Precipitation" },
          "conditions": { "$ref": "#/components/schemas/Conditions" },
          "visibility": { "type": "number" },
          "uv": { "type": ["number", "null"] },
          "clouds": { "type": "number" }
        }
      },
      "Location": {
        "type": "object",
        "properties": {
          "lat": { "type": "number" },
          "lon": { "type": "number" },
          "name": { "type": ["string", "null"] }
        }
      },
      "WeatherResponse": {
        "type": "object",
        "properties": {
          "data": { "$ref": "#/components/schemas/NormalizedWeather" },
          "location": { "$ref": "#/components/schemas/Location" },
          "timestamp": { "type": "string", "format": "date-time" },
          "meta": { "$ref": "#/components/schemas/Meta" }
        }
      },
      "ForecastResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/NormalizedWeather" }
          },
          "location": { "$ref": "#/components/schemas/Location" },
          "meta": { "$ref": "#/components/schemas/Meta" }
        }
      },
      "CreditBundle": {
        "type": "object",
        "properties": {
          "bundle": {
            "type": "string",
            "enum": ["500", "2000", "10000"],
            "description": "500 credits = $5, 2000 credits = $18, 10000 credits = $75"
          }
        },
        "required": ["bundle"]
      }
    },
    "parameters": {
      "Lat": {
        "name": "lat",
        "in": "query",
        "required": true,
        "schema": { "type": "number", "minimum": -90, "maximum": 90 },
        "description": "Latitude (-90 to 90)"
      },
      "Lon": {
        "name": "lon",
        "in": "query",
        "required": true,
        "schema": { "type": "number", "minimum": -180, "maximum": 180 },
        "description": "Longitude (-180 to 180)"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request parameters",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "PaymentRequired": {
        "description": "Insufficient credits",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "Forbidden": {
        "description": "Account suspended, quarantined, or key revoked",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "RateLimited": {
        "description": "Rate limit exceeded",
        "headers": {
          "Retry-After": { "schema": { "type": "integer" } },
          "X-RateLimit-Limit": { "schema": { "type": "integer" } },
          "X-RateLimit-Remaining": { "schema": { "type": "integer" } },
          "X-RateLimit-Reset": { "schema": { "type": "integer" } }
        },
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RateLimitError" } } }
      },
      "ServerError": {
        "description": "Internal server error",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    }
  },
  "paths": {
    "/api/v1/accounts": {
      "post": {
        "operationId": "createAccount",
        "summary": "Create a new account",
        "description": "Creates a new account and returns a stage API key. No authentication required.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string", "maxLength": 100, "description": "Account name" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accountId": { "type": "string" },
                    "apiKey": { "type": "string", "description": "Stage API key (sk_virga_stage_...)" },
                    "environment": { "type": "string", "enum": ["stage"] },
                    "message": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" }
        }
      }
    },
    "/api/v1/keys": {
      "get": {
        "operationId": "listKeys",
        "summary": "List API keys",
        "description": "List all API keys for the authenticated account.",
        "responses": {
          "200": {
            "description": "List of keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "keyPrefix": { "type": "string" },
                          "name": { "type": "string" },
                          "environment": { "type": "string" },
                          "status": { "type": "string" },
                          "createdAt": { "type": "number" },
                          "lastUsedAt": { "type": ["number", "null"] }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "post": {
        "operationId": "createKey",
        "summary": "Create a new API key",
        "description": "Create a new API key. Production keys require accepted terms, activated billing, and positive credit balance.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string" },
                  "environment": { "type": "string", "enum": ["stage", "production"], "default": "stage" },
                  "permissions": { "type": "array", "items": { "type": "string" } }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Key created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apiKey": { "type": "string", "description": "Full API key (shown once)" },
                    "keyPrefix": { "type": "string" },
                    "environment": { "type": "string" },
                    "message": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/v1/terms": {
      "get": {
        "operationId": "getTerms",
        "summary": "Get current terms of service",
        "responses": {
          "200": {
            "description": "Current terms",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version": { "type": "string" },
                    "text": { "type": "string" },
                    "accepted": { "type": "boolean" },
                    "acceptedAt": { "type": ["number", "null"] }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/v1/terms/accept": {
      "post": {
        "operationId": "acceptTerms",
        "summary": "Accept terms of service",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["version"],
                "properties": {
                  "version": { "type": "string", "description": "Terms version to accept" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Terms accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": { "type": "string" },
                    "version": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/v1/account": {
      "get": {
        "operationId": "getAccount",
        "summary": "Get account details",
        "responses": {
          "200": {
            "description": "Account details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accountId": { "type": "string" },
                    "name": { "type": "string" },
                    "email": { "type": ["string", "null"] },
                    "environment": { "type": "string" },
                    "status": { "type": "string" },
                    "termsAcceptedVersion": { "type": ["string", "null"] },
                    "billingActivated": { "type": "boolean" },
                    "creditBalance": { "type": "number" },
                    "dailySpendCap": { "type": "number" },
                    "monthlySpendCap": { "type": "number" },
                    "createdAt": { "type": "number" },
                    "activeKeyCount": { "type": "integer" }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/v1/account/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Get usage history",
        "parameters": [
          { "name": "start", "in": "query", "schema": { "type": "number" }, "description": "Start timestamp (ms)" },
          { "name": "end", "in": "query", "schema": { "type": "number" }, "description": "End timestamp (ms)" },
          { "name": "limit", "in": "query", "schema": { "type": "integer" }, "description": "Max records to return" }
        ],
        "responses": {
          "200": {
            "description": "Usage records",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "usage": { "type": "array", "items": { "type": "object" } }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/v1/billing/activate": {
      "post": {
        "operationId": "activateBilling",
        "summary": "Activate billing",
        "description": "Initiates a checkout session to collect a payment method.",
        "responses": {
          "200": {
            "description": "Checkout URL or already activated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checkoutUrl": { "type": "string", "format": "uri" },
                    "message": { "type": "string" },
                    "billingActivated": { "type": "boolean" }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/v1/billing/credits": {
      "post": {
        "operationId": "purchaseCredits",
        "summary": "Purchase credit bundle",
        "description": "Initiates a checkout session for a credit bundle purchase. Requires billing activated.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CreditBundle" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checkoutUrl": { "type": "string", "format": "uri" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/v1/billing/status": {
      "get": {
        "operationId": "getBillingStatus",
        "summary": "Get billing status",
        "responses": {
          "200": {
            "description": "Billing status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "creditBalance": { "type": "number" },
                    "billingActivated": { "type": "boolean" },
                    "paymentCustomerId": { "type": ["string", "null"] },
                    "dailySpendCap": { "type": "number" },
                    "monthlySpendCap": { "type": "number" },
                    "autoTopup": {
                      "type": "object",
                      "properties": {
                        "enabled": { "type": "boolean" },
                        "threshold": { "type": "number" },
                        "bundle": { "type": ["string", "null"] }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/v1/billing/credits/topup": {
      "post": {
        "operationId": "topupCredits",
        "summary": "Top up credits using saved payment method",
        "description": "Charges the saved payment method off-session via Stripe PaymentIntent and adds credits immediately. No checkout URL or browser redirect needed. Requires billing activated with a payment method on file.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CreditBundle" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credits added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": { "type": "string" },
                    "credits": { "type": "number" },
                    "bundle": { "type": "string" },
                    "paymentIntentId": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/v1/billing/auto-topup": {
      "get": {
        "operationId": "getAutoTopup",
        "summary": "Get auto-topup configuration",
        "description": "Returns the current auto-topup settings for the account.",
        "responses": {
          "200": {
            "description": "Auto-topup configuration",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "autoTopup": {
                      "type": "object",
                      "properties": {
                        "enabled": { "type": "boolean" },
                        "threshold": { "type": "number", "description": "Credit balance threshold that triggers auto-topup" },
                        "bundle": { "type": ["string", "null"], "description": "Bundle to purchase when threshold is reached" }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "post": {
        "operationId": "setAutoTopup",
        "summary": "Configure automatic credit replenishment",
        "description": "Set up automatic credit top-up. When credit balance drops below the threshold during API usage, the saved payment method is charged automatically and credits are added. Requires billing activated.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["enabled"],
                "properties": {
                  "enabled": { "type": "boolean", "description": "Enable or disable auto-topup" },
                  "threshold": { "type": "number", "minimum": 1, "description": "Credit balance threshold that triggers auto-topup (required when enabled)" },
                  "bundle": { "type": "string", "enum": ["500", "2000", "10000"], "description": "Bundle to purchase when threshold is reached (required when enabled)" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Auto-topup configured",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": { "type": "string" },
                    "autoTopup": {
                      "type": "object",
                      "properties": {
                        "enabled": { "type": "boolean" },
                        "threshold": { "type": "number" },
                        "bundle": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/api/v1/weather/current": {
      "get": {
        "operationId": "getCurrentWeather",
        "summary": "Get current weather",
        "description": "Returns current weather conditions for the given coordinates.",
        "x-creditCost": 1,
        "x-rateLimit-stage": "10 req/min",
        "x-rateLimit-production": "60 req/min",
        "parameters": [
          { "$ref": "#/components/parameters/Lat" },
          { "$ref": "#/components/parameters/Lon" }
        ],
        "responses": {
          "200": {
            "description": "Current weather data",
            "headers": {
              "X-RateLimit-Limit": { "schema": { "type": "integer" } },
              "X-RateLimit-Remaining": { "schema": { "type": "integer" } },
              "X-RateLimit-Reset": { "schema": { "type": "integer" } }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WeatherResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/v1/weather/forecast/hourly": {
      "get": {
        "operationId": "getHourlyForecast",
        "summary": "Get hourly forecast",
        "description": "Returns 3-hour interval forecast data.",
        "x-creditCost": 2,
        "x-rateLimit-stage": "10 req/min",
        "x-rateLimit-production": "60 req/min",
        "parameters": [
          { "$ref": "#/components/parameters/Lat" },
          { "$ref": "#/components/parameters/Lon" },
          { "name": "hours", "in": "query", "schema": { "type": "integer", "default": 24, "maximum": 120 }, "description": "Hours to forecast" }
        ],
        "responses": {
          "200": {
            "description": "Hourly forecast data",
            "headers": {
              "X-RateLimit-Limit": { "schema": { "type": "integer" } },
              "X-RateLimit-Remaining": { "schema": { "type": "integer" } },
              "X-RateLimit-Reset": { "schema": { "type": "integer" } }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ForecastResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/v1/weather/forecast/daily": {
      "get": {
        "operationId": "getDailyForecast",
        "summary": "Get daily forecast",
        "description": "Returns daily forecast data up to 16 days.",
        "x-creditCost": 2,
        "x-rateLimit-stage": "10 req/min",
        "x-rateLimit-production": "60 req/min",
        "parameters": [
          { "$ref": "#/components/parameters/Lat" },
          { "$ref": "#/components/parameters/Lon" },
          { "name": "days", "in": "query", "schema": { "type": "integer", "default": 7, "maximum": 16 }, "description": "Days to forecast" }
        ],
        "responses": {
          "200": {
            "description": "Daily forecast data",
            "headers": {
              "X-RateLimit-Limit": { "schema": { "type": "integer" } },
              "X-RateLimit-Remaining": { "schema": { "type": "integer" } },
              "X-RateLimit-Reset": { "schema": { "type": "integer" } }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ForecastResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/v1/weather/historical": {
      "get": {
        "operationId": "getHistoricalWeather",
        "summary": "Get historical weather",
        "description": "Returns weather data for a past date.",
        "x-creditCost": 3,
        "x-rateLimit-stage": "10 req/min",
        "x-rateLimit-production": "60 req/min",
        "parameters": [
          { "$ref": "#/components/parameters/Lat" },
          { "$ref": "#/components/parameters/Lon" },
          { "name": "date", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Date as ISO string or Unix timestamp" }
        ],
        "responses": {
          "200": {
            "description": "Historical weather data",
            "headers": {
              "X-RateLimit-Limit": { "schema": { "type": "integer" } },
              "X-RateLimit-Remaining": { "schema": { "type": "integer" } },
              "X-RateLimit-Reset": { "schema": { "type": "integer" } }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WeatherResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/v1/weather/batch": {
      "post": {
        "operationId": "batchWeather",
        "summary": "Batch weather requests",
        "description": "Fetch weather for multiple locations in a single request. Max 25 locations. Credit cost is the sum of individual costs.",
        "x-creditCost": "sum of individual requests",
        "x-rateLimit-stage": "10 req/min",
        "x-rateLimit-production": "60 req/min",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["requests"],
                "properties": {
                  "requests": {
                    "type": "array",
                    "maxItems": 25,
                    "items": {
                      "type": "object",
                      "required": ["lat", "lon"],
                      "properties": {
                        "lat": { "type": "number", "minimum": -90, "maximum": 90 },
                        "lon": { "type": "number", "minimum": -180, "maximum": 180 },
                        "endpoint": { "type": "string", "enum": ["current", "forecast/hourly", "forecast/daily", "historical"], "default": "current" }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch results",
            "headers": {
              "X-RateLimit-Limit": { "schema": { "type": "integer" } },
              "X-RateLimit-Remaining": { "schema": { "type": "integer" } },
              "X-RateLimit-Reset": { "schema": { "type": "integer" } }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": { "type": "array", "items": { "type": "object" } },
                    "meta": { "$ref": "#/components/schemas/Meta" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    }
  }
}
