> ## Documentation Index
> Fetch the complete documentation index at: https://octo-98895abd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# portfolio_instruments

> CRA, CRI and debenture codes from a statement (catalog v62; securit cd_isin v67). Per code (trimmed, upper-cased, a leading CRA-, CRI- or DEB- stripped; the hyphen is required, so CRA0260025T keeps its CRA): match_kind securit_cetip returns every series of cvm_securit_serie whose codigo_cetip is the code, at the code's newest data_referencia, one row per (numero_serie, classe) at its highest versao, with the series columns as filed and instrument_type as stored (cra_mensal, cri_mensal), and (v67) cd_isin the series' codigo_isin as filed, not validated, NULL when not filed (issuer_code stays NULL: a CRA or CRI ISIN's characters 3-6 name the securitizer, not the debtor); a code can match several series. Else match_kind cda_ticker: the newest month the code appears in CDA block 4 (cvm_fi_cda_acoes, any tp_aplic) and that month's rows with tp_aplic Debêntures: cd_isin (the most common ISIN), issuer_code (ISIN characters 3-6, never a CNPJ), n_fundos (distinct holding funds), preco_marcacao_fundos (sum of market value over sum of quantity, 6 places: the funds' own marks, not a trade price) and cda_period (the newest CDA month may still be filling, so n_fundos can be low). A code held that month as something other than a debenture is no match, and the reason says what it was held as. Else one row with match_kind NULL and the reason in words (Portuguese). Nothing is inferred from a code's letters. More than 200 codes RAISES 22023; the result is at most one 1000-row page, refused above it, never trimmed.

**Row cap.** A window producing more than 1000 rows raises SQLSTATE `22023` naming this function. Nothing is trimmed to fit — PostgREST would silently cut the response at 1000 and a cut-short series is indistinguishable from one that simply ends. This function does not page — narrow the window instead.



## OpenAPI

````yaml /openapi.json post /rpc/portfolio_instruments
openapi: 3.1.0
info:
  title: SILO Data API
  version: '75'
  summary: >-
    Read-only Brazilian public financial data: CVM filings, BACEN series, B3
    quotes and the B3 BDI group.
  description: >
    Schema `api` over PostgREST. Views are `GET /<view>`; functions are

    `POST /rpc/<function>` with a JSON body.


    **This document is generated** from the live Postgres catalog by

    `scripts/gen_openapi.py` — `pg_get_function_arguments` for the RPC
    signatures,

    `information_schema.columns` for the view columns, and the granted-to-`anon`

    privilege set for which objects exist at all. It is not hand-maintained, and

    `tests/test_openapi_spec.py` fails the build when it drifts from the SQL.


    ### Two different ceilings


    Reading one for the other is the most expensive mistake on this API.


    * **The row cap refuses.** Fifty-nine set-returning functions raise SQLSTATE
      `22023` when the window they were handed would produce more than 1000 rows.
      Nothing is trimmed, and the error says why and how to fix it (the message,
      plus PostgREST's `details` and `hint`). Five of them (`panel`,
      `quote_history`, `fund_nav`, `index_history`, `trade_consolidated_history`)
      take a `p_after` cursor so you can walk the series; the other fifty-four ask you to narrow the window. `fund_nav` paging
      additionally REQUIRES `p_entity_type` — its cursor is a bare period, which
      is unique only within one family, and CNPJs that file under both `fi` and
      `fidc` in the same month would otherwise be ambiguous.
    * **The tier ceiling clamps.** Three other functions (`search_funds`,
      `option_chain`, `option_exercises`) silently lower `p_limit` to a per-tier maximum. No error is raised, so the
      only way to know the result was cut is to know the ceiling. Signing in
      raises it.

    Separately from both, PostgREST's server-wide `db-max-rows = 1000` cuts
    every

    response, on every endpoint, for every tier. On the GET views
    `Content-Range`

    is the signal (`0-999/*`); `Prefer: count=exact` turns the `*` into a total.


    ### Retention


    Most of this warehouse is append-only history. The **B3 BDI group** —

    `short_interest`, `short_interest_by_sector`, `investor_flow`,

    `lending_trades`, `lending_participants` — is not: B3 keeps roughly 21
    business

    days and publishes no archive. A missed session cannot be bought back. See

    Market Coverage.
  license:
    name: See repository
    url: https://github.com/PedroDnT/SILO-BZ
servers:
  - url: https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1
    description: Supabase PostgREST, schema `api`
security:
  - apikey: []
tags:
  - name: ANBIMA
  - name: Company events
  - name: Coverage & catalog
  - name: Derivatives
  - name: FIDC
  - name: FNET documents
  - name: Financials
  - name: Funds
  - name: Holdings
  - name: Inflation
  - name: Lookup
  - name: Macro
  - name: Macro expectations
  - name: Other
  - name: Panel
  - name: Portfolio
  - name: Quotes
  - name: Rates
  - name: Research
  - name: Screens
  - name: Securities lending
  - name: Short interest & flows
paths:
  /rpc/portfolio_instruments:
    post:
      tags:
        - Portfolio
      summary: portfolio_instruments
      description: >-
        CRA, CRI and debenture codes from a statement (catalog v62; securit
        cd_isin v67). Per code (trimmed, upper-cased, a leading CRA-, CRI- or
        DEB- stripped; the hyphen is required, so CRA0260025T keeps its CRA):
        match_kind securit_cetip returns every series of cvm_securit_serie whose
        codigo_cetip is the code, at the code's newest data_referencia, one row
        per (numero_serie, classe) at its highest versao, with the series
        columns as filed and instrument_type as stored (cra_mensal, cri_mensal),
        and (v67) cd_isin the series' codigo_isin as filed, not validated, NULL
        when not filed (issuer_code stays NULL: a CRA or CRI ISIN's characters
        3-6 name the securitizer, not the debtor); a code can match several
        series. Else match_kind cda_ticker: the newest month the code appears in
        CDA block 4 (cvm_fi_cda_acoes, any tp_aplic) and that month's rows with
        tp_aplic Debêntures: cd_isin (the most common ISIN), issuer_code (ISIN
        characters 3-6, never a CNPJ), n_fundos (distinct holding funds),
        preco_marcacao_fundos (sum of market value over sum of quantity, 6
        places: the funds' own marks, not a trade price) and cda_period (the
        newest CDA month may still be filling, so n_fundos can be low). A code
        held that month as something other than a debenture is no match, and the
        reason says what it was held as. Else one row with match_kind NULL and
        the reason in words (Portuguese). Nothing is inferred from a code's
        letters. More than 200 codes RAISES 22023; the result is at most one
        1000-row page, refused above it, never trimmed.


        **Row cap.** A window producing more than 1000 rows raises SQLSTATE
        `22023` naming this function. Nothing is trimmed to fit — PostgREST
        would silently cut the response at 1000 and a cut-short series is
        indistinguishable from one that simply ends. This function does not page
        — narrow the window instead.
      operationId: rpc_portfolio_instruments
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                p_codes:
                  type:
                    - array
                    - 'null'
                  items:
                    type:
                      - string
                      - 'null'
              required:
                - p_codes
      responses:
        '200':
          description: >-
            The result set, oldest first. An unknown id is an empty array, not a
            404 and never a guessed value.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    line_no:
                      type:
                        - integer
                        - 'null'
                      format: int32
                    input_code:
                      type:
                        - string
                        - 'null'
                    code:
                      type:
                        - string
                        - 'null'
                    match_kind:
                      type:
                        - string
                        - 'null'
                    instrument_type:
                      type:
                        - string
                        - 'null'
                    cnpj_securit:
                      type:
                        - string
                        - 'null'
                    numero_serie:
                      type:
                        - integer
                        - 'null'
                      format: int32
                    classe:
                      type:
                        - string
                        - 'null'
                    data_vencimento:
                      type:
                        - string
                        - 'null'
                      format: date
                    situacao:
                      type:
                        - string
                        - 'null'
                    taxa_juros:
                      type:
                        - string
                        - 'null'
                    classificacao_risco_atual:
                      type:
                        - string
                        - 'null'
                    valor_total_integralizado:
                      type:
                        - number
                        - 'null'
                    data_referencia:
                      type:
                        - string
                        - 'null'
                      format: date
                    cd_isin:
                      type:
                        - string
                        - 'null'
                    issuer_code:
                      type:
                        - string
                        - 'null'
                    n_fundos:
                      type:
                        - integer
                        - 'null'
                      format: int32
                    preco_marcacao_fundos:
                      type:
                        - number
                        - 'null'
                    cda_period:
                      type:
                        - string
                        - 'null'
                      format: date
                    reason:
                      type:
                        - string
                        - 'null'
        '400':
          description: >-
            Bad request. Contract violations raise SQLSTATE `22023` with a
            message naming the limit or the argument at fault.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            No usable `apikey`, or a request for a schema outside `api`.
            `Accept-Profile: public` and any `cvm_*` / `b3_cotahist` / `cia_*`
            path answer 401 for every caller, by grant — schema `api` is the
            entire public surface.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No such endpoint in schema `api`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      description: >-
        PostgREST error body. `code` carries the SQLSTATE — `22023` is a
        contract refusal.
      properties:
        code:
          type:
            - string
            - 'null'
          examples:
            - '22023'
        message:
          type:
            - string
            - 'null'
        details:
          type:
            - string
            - 'null'
        hint:
          type:
            - string
            - 'null'
  securitySchemes:
    apikey:
      type: apiKey
      in: header
      name: apikey
      description: >-
        The publishable key (`sb_publishable_…`), on every request. It is NOT a
        JWT — sending it as `Authorization: Bearer` is rejected as an invalid
        JWT. It identifies the project, not you, and maps to the Postgres `anon`
        role.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.