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

# Create semantic model

> Create a new semantic model manually. For AI-generated models, use the "Generate semantic model" endpoint instead.

**Required roles**: `nx1_semantic_modeller` or `nx1_semantic_admin`



## OpenAPI

````yaml post /api/semantic-models
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/semantic-models:
    post:
      tags:
        - Semantic models
      summary: Create semantic model
      description: >-
        Create a new semantic model manually. For AI-generated models, use the
        "Generate semantic model" endpoint instead.


        **Required roles**: `nx1_semantic_modeller` or `nx1_semantic_admin`
      operationId: create_semantic_model_api_semantic_models_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SemanticModelCreate'
      responses:
        '200':
          description: Model created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SemanticModelResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    SemanticModelCreate:
      properties:
        name:
          type: string
          title: Name
          description: Business-friendly model name.
        description:
          type: string
          title: Description
          description: Model description.
          default: ''
        domain_urn:
          type: string
          title: Domain Urn
          description: DataHub domain URN.
        domain_name:
          type: string
          title: Domain Name
          description: Human-readable domain name.
        source_tables:
          items:
            type: string
          type: array
          title: Source Tables
          description: List of source table URNs.
        generated_sql:
          type: string
          title: Generated Sql
          description: SQL query for the view.
        target_catalog:
          type: string
          title: Target Catalog
          description: Trino catalog.
        target_schema:
          type: string
          title: Target Schema
          description: Trino schema.
        columns:
          items:
            $ref: '#/components/schemas/SemanticModelColumnCreate'
          type: array
          title: Columns
          description: Column definitions.
          default: []
        ai_confidence_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Ai Confidence Score
          description: AI confidence score.
        ai_reasoning:
          anyOf:
            - type: string
            - type: 'null'
          title: Ai Reasoning
          description: AI reasoning for this model.
      type: object
      required:
        - name
        - domain_urn
        - domain_name
        - source_tables
        - generated_sql
        - target_catalog
        - target_schema
      title: SemanticModelCreate
      description: Request to create a semantic model.
    SemanticModelResponse:
      properties:
        name:
          type: string
          title: Name
          description: Business-friendly model name.
        description:
          type: string
          title: Description
          description: Model description.
          default: ''
        domain_urn:
          type: string
          title: Domain Urn
          description: DataHub domain URN.
        domain_name:
          type: string
          title: Domain Name
          description: Human-readable domain name.
        id:
          type: string
          format: uuid
          title: Id
        source_tables:
          type: string
          title: Source Tables
        generated_sql:
          type: string
          title: Generated Sql
        approved_sql:
          anyOf:
            - type: string
            - type: 'null'
          title: Approved Sql
        target_catalog:
          type: string
          title: Target Catalog
        target_schema:
          type: string
          title: Target Schema
        view_name:
          anyOf:
            - type: string
            - type: 'null'
          title: View Name
        status:
          $ref: '#/components/schemas/SemanticModelStatus'
        ai_confidence_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Ai Confidence Score
        ai_reasoning:
          anyOf:
            - type: string
            - type: 'null'
          title: Ai Reasoning
        generation_task_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Generation Task Id
        reviewed_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Reviewed By
        reviewed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Reviewed At
        review_notes:
          anyOf:
            - type: string
            - type: 'null'
          title: Review Notes
        schedule_cron:
          anyOf:
            - type: string
            - type: 'null'
          title: Schedule Cron
        job_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Job Id
        created_by:
          type: string
          title: Created By
        owner_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner Id
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        deployed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Deployed At
        external_id:
          anyOf:
            - type: string
            - type: 'null'
          title: External Id
        version:
          type: integer
          title: Version
        parent_model_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Parent Model Id
      type: object
      required:
        - name
        - domain_urn
        - domain_name
        - id
        - source_tables
        - generated_sql
        - approved_sql
        - target_catalog
        - target_schema
        - view_name
        - status
        - ai_confidence_score
        - ai_reasoning
        - generation_task_id
        - reviewed_by
        - reviewed_at
        - review_notes
        - schedule_cron
        - job_id
        - created_by
        - owner_id
        - created_at
        - updated_at
        - deployed_at
        - external_id
        - version
        - parent_model_id
      title: SemanticModelResponse
      description: Response model for a semantic model.
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: A brief description of the error that occurred.
        code:
          type: integer
          title: Code
          description: The HTTP status code associated with the error.
          default: 500
      type: object
      required:
        - error
      title: ErrorResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SemanticModelColumnCreate:
      properties:
        column_name:
          type: string
          title: Column Name
          description: Technical column name.
        business_name:
          type: string
          title: Business Name
          description: Business-friendly display name.
        description:
          type: string
          title: Description
          description: Column description.
          default: ''
        source_table:
          type: string
          title: Source Table
          description: Source table URN or name.
        source_column:
          type: string
          title: Source Column
          description: Source column name.
        data_type:
          type: string
          title: Data Type
          description: Trino data type.
        is_nullable:
          type: boolean
          title: Is Nullable
          description: Whether column can be null.
          default: true
        transformation_sql:
          anyOf:
            - type: string
            - type: 'null'
          title: Transformation Sql
          description: SQL transformation.
        is_dimension:
          type: boolean
          title: Is Dimension
          description: Whether it's a dimension column.
          default: false
        is_measure:
          type: boolean
          title: Is Measure
          description: Whether it's a measure column.
          default: false
        is_key:
          type: boolean
          title: Is Key
          description: Whether it's a key column.
          default: false
      type: object
      required:
        - column_name
        - business_name
        - source_table
        - source_column
        - data_type
      title: SemanticModelColumnCreate
      description: Model for creating a column.
    SemanticModelStatus:
      type: string
      enum:
        - draft
        - pending_review
        - approved
        - rejected
        - deployed
        - failed
        - archived
      title: SemanticModelStatus
      description: Status of a semantic model.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````