---
title: "Update a model"
method: PATCH
path: "/api/public/organizations/{orgId}/models/{id}"
tags: ["Models"]
---

# Update a model

`PATCH /api/public/organizations/{orgId}/models/{id}`

## Request

- Base URL: `https://charts.basedash.com`
- URL: `https://charts.basedash.com/api/public/organizations/{orgId}/models/{id}`
- Auth: HTTP bearer

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

## Path parameters

- `orgId` string, required: Organization ID
- `id` string, required: Model ID

## Request body

- UpdateModelInput
  - `name` string: Human-readable model name
  - `referenceName` string: Stable SQL reference name for the model
  - `description` string: Model description
  - `sqlQuery` string: SQL query that defines the reusable dataset
  - `measures` object[]: Ordered reusable aggregate expressions
    - `name` string, required
    - `sql` string, required
    - `description` string
    - `synonyms` string[]
  - `segments` object[]: Ordered reusable predicate expressions
    - `name` string, required
    - `sql` string, required
    - `description` string
    - `synonyms` string[]
  - `defaultTimeColumn` string, nullable: Default date result column, or null for no default
  - `synonyms` string[]: Alternative names for the model
  - `grain` string: What one row in the model represents
  - `keyColumns` string[]: Columns that uniquely identify a row
  - `relationships` object[]: Relationships from this model to other models
    - `targetModelId` string, required
    - `sourceColumn` string, required
    - `targetColumn` string, required
    - `cardinality` 'many_to_one' | 'one_to_one' | 'one_to_many', required
  - `usageGuidance` string: Guidance about when and how to use the model
  - `columnSynonyms` object[]: Alternative names for model result columns
    - `name` string, required
    - `synonyms` string[], required
  - `verified` boolean: Whether the model is verified

## Response `200`

Model updated successfully

- object
  - `data` ModelResponse, required
    - `id` string, required: Model ID
    - `createdAt` string, date-time, required: Model creation timestamp
    - `updatedAt` string, date-time, required: Model last update timestamp
    - `name` string, required: Human-readable model name
    - `referenceName` string, required: Stable SQL reference name for the model
    - `description` string, required: Model description
    - `sqlQuery` string, required: SQL query for the latest model version
    - `organizationId` string, required: Organization ID
    - `databaseConnectionId` string, required: Data source ID
    - `verifiedAt` string, date-time, nullable, required: Verification timestamp for the current model SQL
    - `verifiedByMemberId` string, nullable, required: Member who verified the current model SQL
    - `columns` object[], required: Inferred result columns and their documentation
      - `name` string, required
      - `description` string
      - `synonyms` string[]
      - `type` 'array' | 'bigint' | 'boolean' | 'date' | 'mixed' | 'null' | 'number' | 'object' | 'string' | 'unknown', required: Best-effort type inferred from sampled result values.
      - `nullable` boolean, required: Whether null or undefined appeared in sampled result values.
      - `example` union, required: First non-null sampled value, normalized for JSON.
        - string
        - number
        - boolean
      - `sampleValues` union[]: Distinct non-null sampled values (capped), normalized for JSON.
        - union
          - string
          - number
          - boolean
    - `measures` object[], required: Ordered reusable aggregate expressions
      - `name` string, required
      - `sql` string, required
      - `description` string
      - `synonyms` string[]
    - `segments` object[], required: Ordered reusable predicate expressions
      - `name` string, required
      - `sql` string, required
      - `description` string
      - `synonyms` string[]
    - `defaultTimeColumn` string, nullable, required: Default date result column
    - `synonyms` string[], required: Alternative model names
    - `grain` string, required: What one model row represents
    - `keyColumns` string[], required: Columns that uniquely identify a model row
    - `relationships` object[], required: Relationships to other models
      - `targetModelId` string, required
      - `sourceColumn` string, required
      - `targetColumn` string, required
      - `cardinality` 'many_to_one' | 'one_to_one' | 'one_to_many', required
    - `usageGuidance` string, required: Guidance about when and how to use the model
    - `warnings` object[], required: Non-blocking semantic metadata warnings
      - `code` 'base_sql_contains_group_by' | 'default_time_column_cleared' | 'measure_may_not_aggregate' | 'semantic_expression_may_be_stale', required
      - `message` string, required
      - `field` 'sqlQuery' | 'measures' | 'segments' | 'defaultTimeColumn', required
      - `name` string

## Other responses

- `400`: Bad request - Invalid JSON body or validation error
- `401`: Unauthorized - Missing or invalid API key
- `404`: Not found - Model not found or no admin access
- `409`: Conflict - Another model in the organization already uses this reference name, or the model changed while it was being edited
- `429`: Rate limit exceeded - Too many requests
- `500`: Internal server error

---

[API](https://skmtc.dev/basedash/apis/basedash-public-api.md) - [All operations](https://skmtc.dev/basedash/apis/basedash-public-api/llms.txt) - [OpenAPI document](https://skmtc.dev/basedash/apis/basedash-public-api/revisions/efb9d40bc6f7?raw)
