> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oleria.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List

> Returns a paginated list of saved queries. Supports case-insensitive `contains` filtering, single-field sorting, and cursor pagination. All filter params combine with AND.




## OpenAPI

````yaml /developer-docs/api-reference/trustfusion-openapi-schema-1.0.0.yaml get /v1/query/saved-queries
openapi: 3.0.3
info:
  title: TrustFusion Facets API
  description: >
    API for all facets exposed by TrustFusion, including:


    - **Query**: Validate queries against validation rules, execute governed
    semantic queries

    - **Schema**: Discover semantic models, datasets, fields, relationships, and
    metrics

    - **Threats**: Discover threats and fetch a threat's investigation template
    or advisory by ID


    All endpoints require a valid Cognito JWT token.
  version: 1.0.0
servers:
  - url: https://devx.{environment}.oleria.io
    description: Oleria DevX Server
    variables:
      environment:
        default: prod
        description: Environment name (prod, staging, dev)
        enum:
          - prod
          - staging
          - dev
security:
  - clientCredentials: []
paths:
  /v1/query/saved-queries:
    get:
      tags:
        - Saved Query
      summary: List
      description: >
        Returns a paginated list of saved queries. Supports case-insensitive
        `contains` filtering, single-field sorting, and cursor pagination. All
        filter params combine with AND.
      operationId: ListSavedQueries
      parameters:
        - name: q
          in: query
          required: false
          schema:
            type: string
          description: Case-insensitive `contains` over `name` OR `description`.
          example: mfa
        - name: name
          in: query
          required: false
          schema:
            type: string
          description: Case-insensitive `contains` over `name`.
        - name: description
          in: query
          required: false
          schema:
            type: string
          description: Case-insensitive `contains` over `description`.
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum:
              - name
              - created_at
              - last_modified_at
            default: name
          description: >
            Field to sort by. `query_id` is always appended as a final
            tiebreaker for stable, deterministic ordering.
        - name: order
          in: query
          required: false
          schema:
            type: string
            enum:
              - asc
              - desc
            default: asc
          description: Sort direction — `asc` (ascending) or `desc` (descending).
        - name: page_size
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 15
          description: Page size; defaults to 15, capped at 200.
        - name: after
          in: query
          required: false
          schema:
            type: string
          description: >
            Opaque cursor from `page_info.end_cursor`. Pass the value back
            exactly as received — do not parse or construct cursor values.
        - name: before
          in: query
          required: false
          schema:
            type: string
          description: >
            Opaque cursor from `page_info.start_cursor`. Pass the value back
            exactly as received — do not parse or construct cursor values.
      responses:
        '200':
          description: Paginated list of saved queries.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavedQueryList'
        '400':
          description: Invalid query parameter (e.g. unknown sort field).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Valid token but insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - clientCredentials:
            - ClientCredentialsResourceServer/client_credentials_base_scope
components:
  schemas:
    SavedQueryList:
      type: object
      required:
        - items
        - page_info
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/SavedQuery'
        page_info:
          $ref: '#/components/schemas/PageInfo'
    ErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Machine-readable error code for programmatic handling.
          example: QUERY_PARSE_ERROR
        message:
          type: string
          description: Human-readable error description.
          example: Failed to parse SQL query
        details:
          type: object
          additionalProperties: true
          description: Additional context for debugging (optional, free-form).
          example:
            line: 3
            column: 15
            hint: Unexpected token near 'SELCT'
        reasons:
          type: array
          description: >
            Policy violation details. Present when `code` is `POLICY_VIOLATION`.
            Each entry identifies a governance policy that the query violated.
          items:
            $ref: '#/components/schemas/Reason'
    SavedQuery:
      type: object
      required:
        - query_id
        - name
        - query_string
        - model
        - created_by
        - last_modified_by
        - version
        - created_at
        - last_modified_at
      description: A stored SQL query with authorship metadata.
      properties:
        query_id:
          type: string
          format: uuid
          description: |
            Opaque stable identifier. Clients key on this, never the name.
          example: 550e8400-e29b-41d4-a716-446655440000
        name:
          type: string
          description: |
            Free-form label, unique within the tenant (case-insensitive).
          example: Disabled MFA accounts
        description:
          type: string
          description: Optional free-form context about the query.
          example: Accounts where MFA is disabled — weekly review
        query_string:
          type: string
          description: The stored SQL text.
          example: >-
            SELECT account_id, mfa_status FROM oleria_account WHERE mfa_status =
            :status
        model:
          type: string
          description: Semantic model the query targets.
          example: oleria_identity
        created_by:
          $ref: '#/components/schemas/Principal'
        last_modified_by:
          $ref: '#/components/schemas/Principal'
        version:
          type: integer
          description: >
            Monotonic version — 1 on create, incremented on every update.
            Doubles as the optimistic-concurrency token on update.
          example: 3
        created_at:
          type: string
          format: date-time
          example: '2026-06-01T10:00:00Z'
        last_modified_at:
          type: string
          format: date-time
          example: '2026-06-04T09:30:00Z'
    PageInfo:
      type: object
      required:
        - has_next_page
        - has_previous_page
      description: Pagination metadata for list responses.
      properties:
        has_next_page:
          type: boolean
        has_previous_page:
          type: boolean
        start_cursor:
          type: string
          nullable: true
          description: >
            Opaque server-issued cursor marking the first item on this page.
            Pass back as-is via the `before` parameter to fetch the previous
            page — do not parse or construct this value.
        end_cursor:
          type: string
          nullable: true
          description: >
            Opaque server-issued cursor marking the last item on this page. Pass
            back as-is via the `after` parameter to fetch the next page — do not
            parse or construct this value.
        total_count:
          type: integer
          description: >
            Total number of items matching the current filter, across all pages.
            Omitted when the total count is unavailable (e.g. keyset
            pagination).
          example: 42
    Reason:
      type: object
      required:
        - code
        - message
      description: A single policy violation identified during query validation.
      properties:
        code:
          type: string
          description: >
            Stable, machine-readable identifier for the denial reason.
            SCREAMING_SNAKE_CASE; declared on the violated policy.
          example: MUTATION_NOT_ALLOWED
        message:
          type: string
          description: Human-readable explanation of the denial.
          example: >-
            Only SELECT queries are permitted. Mutation statements are not
            allowed.
    Principal:
      type: object
      required:
        - type
        - id
      description: >
        The principal (user or service client) that created or last modified the
        saved query, identified by a stable, opaque id.
      properties:
        type:
          type: string
          enum:
            - user
            - client
          description: Principal kind.
          example: user
        id:
          type: string
          description: >
            Opaque principal identifier — the `oleriaUserId` for `user`, the
            `client_id` for `client`. Treat as opaque.
          example: ol_a1b2c3d4-e5f6-7890-abcd-ef1234567890
  securitySchemes:
    clientCredentials:
      type: oauth2
      description: >
        OAuth 2.0 Client Credentials flow. The tokenUrl shown is for the
        production environment. For other environments, replace `prod` with the
        target environment name (e.g., `auth.staging.oleria.io` for staging).
      flows:
        clientCredentials:
          tokenUrl: https://auth.prod.oleria.io/oauth/token
          scopes:
            ClientCredentialsResourceServer/client_credentials_base_scope: >-
              Default scope used for all client credentials (RBAC is controlled
              via permissions in the bearer token)

````