{
  "openapi": "3.1.0",
  "info": {
    "title": "SILO API v2",
    "version": "v2",
    "description": "The v2 gateway over SILO's schema `api`: 14 resources, five shared parameters, one envelope and one error object. Generated from supabase/functions/silo-api/registry.ts by scripts/gen_openapi_v2.py; do not edit by hand. The original v1 API stays available until it is retired."
  },
  "servers": [
    {
      "url": "https://zcjbtpxuhdekpwcxmepn.supabase.co/functions/v1/silo-api/v2",
      "description": "The silo-api Edge Function."
    }
  ],
  "security": [
    {},
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Discovery"
    },
    {
      "name": "Markets and macro"
    },
    {
      "name": "Companies and funds"
    },
    {
      "name": "Research"
    }
  ],
  "paths": {
    "/portfolio/fees": {
      "post": {
        "operationId": "v2_portfolio_fees",
        "summary": "Disclosed and estimated fees",
        "tags": [
          "Research"
        ],
        "description": "Disclosed fees and estimates from accounting records, shown separately.",
        "x-mint": {
          "href": "/api-docs/v2/operations/portfolio/fees"
        },
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "required": false,
            "description": "Any date in the requested month.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Rows per page, subject to your tier.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Cursor from the next page URL.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "details",
            "in": "query",
            "required": false,
            "description": "Include request diagnostics.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The v2 envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "data": [
                    {
                      "cnpj": "33000167000101",
                      "fund_name": null,
                      "month": null,
                      "nav": null,
                      "adm_fee_flow": null
                    }
                  ],
                  "meta": {
                    "tier": "pro"
                  }
                }
              }
            }
          },
          "default": {
            "description": "The v2 error object. A SILO refusal (over_limit) keeps its message, hint and details verbatim.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "description": "A JSON object of lists. Every other parameter goes in the query string.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cnpjs": {
                    "type": "array",
                    "items": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "description": "Fund CNPJs (14 digits each)."
                  }
                },
                "required": [
                  "cnpjs"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "SILO user access token for authenticated data requests."
      }
    },
    "schemas": {
      "Envelope": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {},
            "description": "Always a list. Rows as the endpoint returned them; null stays null."
          },
          "meta": {
            "type": "object",
            "required": [
              "tier"
            ],
            "properties": {
              "source": {
                "type": "string",
                "description": "The canonical request to cite: /v2/<resource>? with every applied parameter, defaults included, so it replays the same rows. POST says so; its lists are in meta.body."
              },
              "data_through": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date",
                "description": "The newest elapsed period SILO holds for the dataset this endpoint reads (the coverage resource's data_through for coverage_dataset). Null when no coverage row applies or the coverage read failed; never a guess."
              },
              "coverage_dataset": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The coverage dataset data_through comes from; null when none applies."
              },
              "data_through_error": {
                "type": "string",
                "description": "Present only when the coverage read failed: why data_through is null. The rows are unaffected."
              },
              "tier": {
                "type": "string",
                "enum": [
                  "anonymous",
                  "signed_in",
                  "pro"
                ]
              },
              "tier_cap_reached": {
                "type": "boolean",
                "description": "True when the result is partial because of the tier cap."
              }
            },
            "additionalProperties": true
          },
          "next_page_url": {
            "type": "string",
            "description": "Present only when more rows remain. It carries one opaque cursor."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "reason",
              "message",
              "target",
              "innererror"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "bad_request",
                  "unknown_parameter",
                  "unknown_id",
                  "unauthorized",
                  "payment_required",
                  "forbidden_for_tier",
                  "over_limit",
                  "rate_limited",
                  "timeout",
                  "unavailable",
                  "internal"
                ]
              },
              "reason": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "row_cap",
                  "tier_cap",
                  null
                ],
                "description": "over_limit only: row_cap (over one 1,000-row page: narrow or page) or tier_cap (over the tier ceiling: narrow or sign in). Null otherwise."
              },
              "message": {
                "type": "string"
              },
              "target": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "innererror": {
                "type": "object",
                "properties": {
                  "sqlstate": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "hint": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "details": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
