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

# Update a model

> Updates an existing model. Requires admin access to the organization.



## OpenAPI

````yaml https://charts.basedash.com/api/public/openapi patch /api/public/organizations/{orgId}/models/{id}
openapi: 3.1.0
info:
  title: Basedash Public API
  version: 0.0.0
  description: >-
    API for programmatic access to Basedash features. Use API keys for
    authentication.
  contact:
    name: Basedash Support
    url: https://basedash.com
    email: support@basedash.com
servers:
  - url: https://charts.basedash.com
    description: Production
security: []
tags:
  - name: Organizations
    description: Manage organizations
  - name: Groups
    description: Manage organization groups and memberships
  - name: Data Sources
    description: Manage database connections and data sources
  - name: MCP servers
    description: Manage MCP server data sources
  - name: Insights
    description: Manage generated insights
  - name: Automations
    description: Manage automations and automation runs
  - name: Skills
    description: Manage organization skills
  - name: Models
    description: Manage reusable SQL models
  - name: Dashboards
    description: Manage dashboards and their tabs
  - name: Charts
    description: Manage charts and their SQL queries
  - name: Chats
    description: >-
      Chat with the Basedash AI agent about your data. Start a chat by sending a
      message, then continue the conversation with follow-up messages. The
      assistant responds asynchronously: pass the `wait` query parameter to
      receive the finished response in the same request, or poll the assistant
      message (or stream its events) after an HTTP 202. Chats created through
      the API are not shown in the Basedash app.
paths:
  /api/public/organizations/{orgId}/models/{id}:
    patch:
      tags:
        - Models
      summary: Update a model
      description: Updates an existing model. Requires admin access to the organization.
      parameters:
        - schema:
            type: string
            description: Organization ID
          required: true
          description: Organization ID
          name: orgId
          in: path
        - schema:
            type: string
            description: Model ID
          required: true
          description: Model ID
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateModelInput'
      responses:
        '200':
          description: Model updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ModelResponse'
                required:
                  - data
        '400':
          description: Bad request - Invalid JSON body or validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - Model not found or no admin access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflict - Model reference name already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded - Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      deprecated: false
      security:
        - bearerAuth: []
components:
  schemas:
    UpdateModelInput:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Human-readable model name
        referenceName:
          type: string
          minLength: 1
          maxLength: 100
          description: Stable SQL reference name for the model
        description:
          type: string
          maxLength: 10000
          description: Model description
        sqlQuery:
          type: string
          minLength: 1
          maxLength: 100000
          description: SQL query that defines the reusable dataset
        measures:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 100
                pattern: ^[a-z][a-z0-9_]*$
              sql:
                type: string
                minLength: 1
                maxLength: 10000
              description:
                type: string
                maxLength: 10000
            required:
              - name
              - sql
          maxItems: 50
          description: Ordered reusable aggregate expressions
        segments:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 100
                pattern: ^[a-z][a-z0-9_]*$
              sql:
                type: string
                minLength: 1
                maxLength: 10000
              description:
                type: string
                maxLength: 10000
            required:
              - name
              - sql
          maxItems: 50
          description: Ordered reusable predicate expressions
        defaultTimeColumn:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 256
          description: Default date result column, or null for no default
        verified:
          type: boolean
          description: Whether the model is verified
    ModelResponse:
      type: object
      properties:
        id:
          type: string
          description: Model ID
        createdAt:
          type: string
          format: date-time
          description: Model creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Model last update timestamp
        name:
          type: string
          description: Human-readable model name
        referenceName:
          type: string
          description: Stable SQL reference name for the model
        description:
          type: string
          description: Model description
        sqlQuery:
          type: string
          description: SQL query for the latest model version
        organizationId:
          type: string
          description: Organization ID
        databaseConnectionId:
          type: string
          description: Data source ID
        verifiedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: Verification timestamp for the current model SQL
        verifiedByMemberId:
          type:
            - string
            - 'null'
          description: Member who verified the current model SQL
        columns:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              description:
                type: string
                maxLength: 10000
              type:
                type: string
                enum:
                  - array
                  - bigint
                  - boolean
                  - date
                  - mixed
                  - 'null'
                  - number
                  - object
                  - string
                  - unknown
                description: Best-effort type inferred from sampled result values.
              nullable:
                type: boolean
                description: Whether null or undefined appeared in sampled result values.
              example:
                anyOf:
                  - type: string
                  - type: number
                  - type: boolean
                  - type: 'null'
                description: First non-null sampled value, normalized for JSON.
              sampleValues:
                type: array
                items:
                  anyOf:
                    - type: string
                    - type: number
                    - type: boolean
                    - type: 'null'
                description: >-
                  Distinct non-null sampled values (capped), normalized for
                  JSON.
            required:
              - name
              - type
              - nullable
              - example
          description: Inferred result columns and their documentation
        measures:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 100
                pattern: ^[a-z][a-z0-9_]*$
              sql:
                type: string
                minLength: 1
                maxLength: 10000
              description:
                type: string
                maxLength: 10000
            required:
              - name
              - sql
          maxItems: 50
          description: Ordered reusable aggregate expressions
        segments:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 100
                pattern: ^[a-z][a-z0-9_]*$
              sql:
                type: string
                minLength: 1
                maxLength: 10000
              description:
                type: string
                maxLength: 10000
            required:
              - name
              - sql
          maxItems: 50
          description: Ordered reusable predicate expressions
        defaultTimeColumn:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 256
          description: Default date result column
        warnings:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                enum:
                  - base_sql_contains_group_by
                  - default_time_column_cleared
                  - measure_may_not_aggregate
                  - semantic_expression_may_be_stale
              message:
                type: string
              field:
                type: string
                enum:
                  - sqlQuery
                  - measures
                  - segments
                  - defaultTimeColumn
              name:
                type: string
            required:
              - code
              - message
              - field
          description: Non-blocking semantic metadata warnings
      required:
        - id
        - createdAt
        - updatedAt
        - name
        - referenceName
        - description
        - sqlQuery
        - organizationId
        - databaseConnectionId
        - verifiedAt
        - verifiedByMemberId
        - columns
        - measures
        - segments
        - defaultTimeColumn
        - warnings
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ApiError'
      required:
        - error
    RateLimitErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/RateLimitError'
      required:
        - error
    ApiError:
      type: object
      properties:
        title:
          type: string
          description: Error type identifier
        detail:
          type: string
          description: Human-readable error description
      required:
        - title
        - detail
    RateLimitError:
      allOf:
        - $ref: '#/components/schemas/ApiError'
        - type: object
          properties:
            title:
              type: string
              enum:
                - RateLimitExceeded
            retryAfterMs:
              type: number
              description: Milliseconds until the rate limit window resets
          required:
            - retryAfterMs
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication using Bearer token format: `Bearer
        <basedash_api_key>`

````