> ## 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.

# Get a model

> Returns the full OSI semantic model definition for the given model name, including all datasets, fields, relationships, and metrics. This is the primary endpoint AI agents and BI platforms use to discover the data landscape before generating queries.




## OpenAPI

````yaml /developer-docs/api-reference/trustfusion-openapi-schema-1.0.0.yaml get /v1/schema/models/{model_name}
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/schema/models/{model_name}:
    get:
      tags:
        - Schema
      summary: Get a model
      description: >
        Returns the full OSI semantic model definition for the given model name,
        including all datasets, fields, relationships, and metrics. This is the
        primary endpoint AI agents and BI platforms use to discover the data
        landscape before generating queries.
      operationId: GetSemanticModel
      parameters:
        - name: model_name
          in: path
          required: true
          schema:
            type: string
          description: >
            The unique name of the semantic model. Must be lowercase
            alphanumeric with underscores or hyphens.
          example: oleria_identity
      responses:
        '200':
          description: Full OSI semantic model definition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SemanticModel'
        '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'
        '404':
          description: Semantic model not found
          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:
    SemanticModel:
      type: object
      description: Top-level container representing a complete semantic model
      properties:
        name:
          type: string
          description: Unique identifier for the semantic model
        description:
          type: string
          description: Human-readable description
        ai_context:
          $ref: '#/components/schemas/AIContext'
        datasets:
          type: array
          items:
            $ref: '#/components/schemas/Dataset'
          minItems: 1
          description: Collection of logical datasets
        relationships:
          type: array
          items:
            $ref: '#/components/schemas/Relationship'
          description: Defines how datasets are connected
        metrics:
          type: array
          items:
            $ref: '#/components/schemas/Metric'
          description: Quantifiable measures spanning datasets
        custom_extensions:
          type: array
          items:
            $ref: '#/components/schemas/CustomExtension'
      required:
        - name
        - datasets
      additionalProperties: false
    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'
    AIContext:
      description: Additional context for AI tools
      oneOf:
        - type: string
        - type: object
          properties:
            instructions:
              type: string
              description: Instructions for AI on how to use this entity
            synonyms:
              type: array
              items:
                type: string
              description: Alternative names and terms
            examples:
              type: array
              items:
                type: string
              description: Sample questions or use cases
          additionalProperties: true
    Dataset:
      type: object
      description: Logical dataset representing a business entity (fact or dimension table)
      properties:
        name:
          type: string
          description: Unique identifier for the dataset
        source:
          type: string
          description: >-
            Reference to underlying physical table/view (database.schema.table)
            or query
        primary_key:
          type: array
          items:
            type: string
          description: Primary key columns (single or composite)
        unique_keys:
          type: array
          items:
            type: array
            items:
              type: string
          description: Array of unique key definitions (each can be single or composite)
        description:
          type: string
          description: Human-readable description
        ai_context:
          $ref: '#/components/schemas/AIContext'
        fields:
          type: array
          items:
            $ref: '#/components/schemas/Field'
        custom_extensions:
          type: array
          items:
            $ref: '#/components/schemas/CustomExtension'
      required:
        - name
        - source
      additionalProperties: false
    Relationship:
      type: object
      description: Foreign key relationship between datasets
      properties:
        name:
          type: string
          description: Unique identifier for the relationship
        from:
          type: string
          description: Dataset on the many side of the relationship
        to:
          type: string
          description: Dataset on the one side of the relationship
        from_columns:
          type: array
          items:
            type: string
          minItems: 1
          description: Foreign key columns in the 'from' dataset
        to_columns:
          type: array
          items:
            type: string
          minItems: 1
          description: Primary/unique key columns in the 'to' dataset
        ai_context:
          $ref: '#/components/schemas/AIContext'
        custom_extensions:
          type: array
          items:
            $ref: '#/components/schemas/CustomExtension'
      required:
        - name
        - from
        - to
        - from_columns
        - to_columns
      additionalProperties: false
    Metric:
      type: object
      description: Quantitative measure defined on business data
      properties:
        name:
          type: string
          description: Unique identifier for the metric
        expression:
          $ref: '#/components/schemas/Expression'
        description:
          type: string
          description: Human-readable description of what the metric measures
        ai_context:
          $ref: '#/components/schemas/AIContext'
        custom_extensions:
          type: array
          items:
            $ref: '#/components/schemas/CustomExtension'
      required:
        - name
        - expression
      additionalProperties: false
    CustomExtension:
      type: object
      description: Vendor-specific attributes for extensibility
      properties:
        vendor_name:
          $ref: '#/components/schemas/Vendor'
        data:
          type: string
          description: JSON string containing vendor-specific data
      required:
        - vendor_name
        - data
      additionalProperties: false
    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.
    Field:
      type: object
      description: Row-level attribute for grouping, filtering, and metric expressions
      properties:
        name:
          type: string
          description: Unique identifier for the field within the dataset
        expression:
          $ref: '#/components/schemas/Expression'
        dimension:
          $ref: '#/components/schemas/Dimension'
        label:
          type: string
          description: Label for categorization
        description:
          type: string
          description: Human-readable description
        ai_context:
          $ref: '#/components/schemas/AIContext'
        custom_extensions:
          type: array
          items:
            $ref: '#/components/schemas/CustomExtension'
      required:
        - name
        - expression
      additionalProperties: false
    Expression:
      type: object
      description: Expression definition with multi-dialect support
      properties:
        dialects:
          type: array
          items:
            $ref: '#/components/schemas/DialectExpression'
          minItems: 1
      required:
        - dialects
      additionalProperties: false
    Vendor:
      type: string
      enum:
        - COMMON
        - SNOWFLAKE
        - SALESFORCE
        - DBT
        - DATABRICKS
        - OLERIA
      description: >-
        Supported vendors for custom extensions. NOTE: OLERIA is an Oleria-local
        addition pending upstream OSI Proposal 3 (see osi/DECISIONS.md ADR-019);
        it is not part of the vendored upstream enum.
    Dimension:
      type: object
      description: Dimension metadata
      properties:
        is_time:
          type: boolean
          description: Indicates if this is a time-based dimension for temporal filtering
      additionalProperties: false
    DialectExpression:
      type: object
      description: Expression in a specific dialect
      properties:
        dialect:
          $ref: '#/components/schemas/Dialect'
        expression:
          type: string
          description: SQL or dialect-specific expression
      required:
        - dialect
        - expression
      additionalProperties: false
    Dialect:
      type: string
      enum:
        - ANSI_SQL
        - SNOWFLAKE
        - MDX
        - TABLEAU
        - DATABRICKS
      description: Supported SQL and expression language dialects
  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)

````