> ## Documentation Index
> Fetch the complete documentation index at: https://lightdash-mintlify-9d6f9427.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update SQL chart

> Update sql chart



## OpenAPI

````yaml https://raw.githubusercontent.com/lightdash/lightdash/refs/heads/main/packages/backend/src/generated/swagger.json patch /api/v1/projects/{projectUuid}/sqlRunner/saved/{uuid}
openapi: 3.0.0
info:
  title: Lightdash API
  version: 0.3249.0
  description: >
    Open API documentation for all public Lightdash API endpoints. #
    Authentication Before you get started, you might need to create a Personal
    Access Token to authenticate via the API. You can create a token by
    following this guide: https://docs.lightdash.com/references/personal_tokens
  license:
    name: MIT
  contact:
    name: Lightdash Support
    email: support@lightdash.com
    url: https://docs.lightdash.com/help-and-contact/contact/contact_info/
servers:
  - url: /
security: []
tags:
  - name: My Account
    description: These routes allow users to manage their own user account.
  - name: Organizations
    description: >-
      Each user is a member of a single organization. These routes allow users
      to manage their organization. Most actions are only available to admin
      users.
  - name: Projects
    description: >-
      Projects belong to a single organization. These routes allow users to
      manage their projects, browse content, and execute queries. Users inside
      an organization might have access to a project from an organization-level
      role or they might be granted access to a project directly.
  - name: Spaces
    description: >-
      Spaces allow you to organize charts and dashboards within a project. They
      also allow granular access to content by allowing you to create private
      spaces, which are only accessible to the creator and admins.
  - name: Roles & Permissions
    description: >-
      These routes allow users to manage roles and permissions for their
      organization.
    externalDocs:
      url: https://docs.lightdash.com/references/roles
  - name: Query
    description: >-
      These routes allow users to execute and manage queries against their data
      warehouse. This includes metric queries, SQL queries, and retrieving query
      results.
paths:
  /api/v1/projects/{projectUuid}/sqlRunner/saved/{uuid}:
    patch:
      tags:
        - SQL runner
      summary: Update SQL chart
      description: Update sql chart
      operationId: updateSqlChart
      parameters:
        - description: the uuid for the project
          in: path
          name: projectUuid
          required: true
          schema:
            type: string
        - description: the uuid for the saved sql chart
          in: path
          name: uuid
          required: true
          schema:
            type: string
      requestBody:
        description: the sql chart details to update
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSqlChart'
              description: the sql chart details to update
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiUpdateSqlChart'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorPayload'
      security: []
components:
  schemas:
    UpdateSqlChart:
      properties:
        versionedData:
          $ref: '#/components/schemas/UpdateVersionedSqlChart'
        unversionedData:
          $ref: '#/components/schemas/UpdateUnversionedSqlChart'
      type: object
    ApiUpdateSqlChart:
      properties:
        results:
          properties:
            savedSqlVersionUuid:
              type: string
              nullable: true
            savedSqlUuid:
              type: string
          required:
            - savedSqlVersionUuid
            - savedSqlUuid
          type: object
        status:
          type: string
          enum:
            - ok
          nullable: false
      required:
        - results
        - status
      type: object
    ApiErrorPayload:
      properties:
        error:
          properties:
            data:
              $ref: '#/components/schemas/AnyType'
              description: Optional data containing details of the error
            message:
              type: string
              description: A friendly message summarising the error
            name:
              type: string
              description: Unique name for the type of error
            statusCode:
              type: number
              format: integer
              description: HTTP status code
          required:
            - name
            - statusCode
          type: object
        status:
          type: string
          enum:
            - error
          nullable: false
      required:
        - error
        - status
      type: object
      description: |-
        The Error object is returned from the api any time there is an error.
        The message contains
    UpdateVersionedSqlChart:
      properties:
        config:
          $ref: '#/components/schemas/AllVizChartConfig'
        limit:
          type: number
          format: double
        sql:
          type: string
      required:
        - config
        - limit
        - sql
      type: object
    UpdateUnversionedSqlChart:
      properties:
        spaceUuid:
          type: string
        description:
          type: string
          nullable: true
        name:
          type: string
      required:
        - spaceUuid
        - description
        - name
      type: object
    AnyType:
      description: |-
        This AnyType is an alias for any
        The goal is to make it easier to identify any type in the codebase
        without having to eslint-disable all the time
        These are only used on legacy `any` types, don't use it for new types.
        This is added on a separate file to avoid circular dependencies.
    AllVizChartConfig:
      anyOf:
        - $ref: '#/components/schemas/VizBarChartConfig'
        - $ref: '#/components/schemas/VizLineChartConfig'
        - $ref: '#/components/schemas/VizPieChartConfig'
        - $ref: '#/components/schemas/VizTableConfig'
    VizBarChartConfig:
      allOf:
        - $ref: '#/components/schemas/VizBaseConfig'
        - properties:
            display:
              $ref: '#/components/schemas/CartesianChartDisplay'
            fieldConfig:
              $ref: '#/components/schemas/PivotChartLayout'
            type:
              $ref: '#/components/schemas/ChartKind.VERTICAL_BAR'
          required:
            - type
          type: object
    VizLineChartConfig:
      allOf:
        - $ref: '#/components/schemas/VizBaseConfig'
        - properties:
            display:
              $ref: '#/components/schemas/CartesianChartDisplay'
            fieldConfig:
              $ref: '#/components/schemas/PivotChartLayout'
            type:
              $ref: '#/components/schemas/ChartKind.LINE'
          required:
            - type
          type: object
    VizPieChartConfig:
      allOf:
        - $ref: '#/components/schemas/VizBaseConfig'
        - properties:
            display:
              $ref: '#/components/schemas/VizPieChartDisplay'
            fieldConfig:
              $ref: '#/components/schemas/PivotChartLayout'
            type:
              $ref: '#/components/schemas/ChartKind.PIE'
          required:
            - type
          type: object
    VizTableConfig:
      allOf:
        - $ref: '#/components/schemas/VizBaseConfig'
        - properties:
            display:
              $ref: '#/components/schemas/VizTableDisplay'
            columns:
              $ref: '#/components/schemas/VizColumnsConfig'
            type:
              $ref: '#/components/schemas/ChartKind.TABLE'
          required:
            - columns
            - type
          type: object
    VizBaseConfig:
      properties:
        type:
          $ref: '#/components/schemas/ChartKind'
        metadata:
          properties:
            version:
              type: number
              format: double
          required:
            - version
          type: object
      required:
        - type
        - metadata
      type: object
    CartesianChartDisplay:
      properties:
        stack:
          anyOf:
            - type: boolean
            - $ref: '#/components/schemas/StackType'
        legend:
          properties:
            align:
              type: string
              enum:
                - start
                - center
                - end
            position:
              type: string
              enum:
                - top
                - bottom
                - left
                - right
          required:
            - align
            - position
          type: object
        series:
          properties: {}
          additionalProperties:
            properties:
              whichYAxis:
                $ref: '#/components/schemas/AxisSide'
              valueLabelPosition:
                $ref: '#/components/schemas/ValueLabelPositionOptions'
              type:
                anyOf:
                  - $ref: '#/components/schemas/CartesianSeriesType.LINE'
                  - $ref: '#/components/schemas/CartesianSeriesType.BAR'
              color:
                type: string
              yAxisIndex:
                type: number
                format: double
              format:
                $ref: '#/components/schemas/Format'
              label:
                type: string
            type: object
          type: object
        yAxis:
          items:
            properties:
              format:
                $ref: '#/components/schemas/Format'
              position:
                type: string
              label:
                type: string
            type: object
          type: array
        xAxis:
          properties:
            dateFormat:
              type: string
            type:
              $ref: '#/components/schemas/VizIndexType'
            label:
              type: string
          type: object
      type: object
    PivotChartLayout:
      properties:
        stack:
          anyOf:
            - type: boolean
            - $ref: '#/components/schemas/StackType'
        sortBy:
          items:
            $ref: '#/components/schemas/VizSortBy'
          type: array
        groupBy:
          items:
            properties:
              reference:
                type: string
            required:
              - reference
            type: object
          type: array
        'y':
          items:
            properties:
              aggregation:
                $ref: '#/components/schemas/VizAggregationOptions'
              reference:
                type: string
            required:
              - aggregation
              - reference
            type: object
          type: array
        x:
          properties:
            type:
              $ref: '#/components/schemas/VizIndexType'
            reference:
              type: string
          required:
            - type
            - reference
          type: object
      required:
        - 'y'
      type: object
    ChartKind.VERTICAL_BAR:
      enum:
        - vertical_bar
      type: string
    ChartKind.LINE:
      enum:
        - line
      type: string
    VizPieChartDisplay:
      properties:
        isDonut:
          type: boolean
      type: object
    ChartKind.PIE:
      enum:
        - pie
      type: string
    VizTableDisplay:
      properties: {}
      type: object
    VizColumnsConfig:
      properties: {}
      additionalProperties:
        $ref: '#/components/schemas/VizColumnConfig'
      type: object
    ChartKind.TABLE:
      enum:
        - table
      type: string
    ChartKind:
      enum:
        - line
        - horizontal_bar
        - vertical_bar
        - scatter
        - area
        - mixed
        - pie
        - table
        - big_number
        - funnel
        - custom
        - treemap
        - gauge
        - map
        - sankey
      type: string
    StackType:
      enum:
        - none
        - stack
        - stack100
      type: string
    AxisSide:
      enum:
        - 0
        - 1
      type: number
    ValueLabelPositionOptions:
      enum:
        - hidden
        - top
        - bottom
        - left
        - right
        - inside
      type: string
    CartesianSeriesType.LINE:
      enum:
        - line
      type: string
    CartesianSeriesType.BAR:
      enum:
        - bar
      type: string
    Format:
      enum:
        - km
        - mi
        - usd
        - gbp
        - eur
        - jpy
        - dkk
        - id
        - percent
      type: string
    VizIndexType:
      enum:
        - time
        - category
      type: string
    VizSortBy:
      properties:
        pivotValues:
          items:
            $ref: '#/components/schemas/PivotSortAnchor'
          type: array
          description: Pins the row-sort anchor to a specific pivot column.
        nullsFirst:
          type: boolean
        direction:
          $ref: '#/components/schemas/SortByDirection'
        reference:
          type: string
      required:
        - direction
        - reference
      type: object
    VizAggregationOptions:
      enum:
        - sum
        - count
        - avg
        - min
        - max
        - any
      type: string
    VizColumnConfig:
      properties:
        barConfig:
          properties:
            color:
              type: string
            max:
              type: number
              format: double
            min:
              type: number
              format: double
          type: object
        displayStyle:
          type: string
          enum:
            - text
            - bar
        aggregation:
          $ref: '#/components/schemas/VizAggregationOptions'
        order:
          type: number
          format: double
        frozen:
          type: boolean
        label:
          type: string
        reference:
          type: string
        visible:
          type: boolean
      required:
        - frozen
        - label
        - reference
        - visible
      type: object
    PivotSortAnchor:
      properties:
        value:
          anyOf:
            - type: string
            - type: number
              format: double
            - type: boolean
          nullable: true
        reference:
          type: string
      required:
        - value
        - reference
      type: object
      description: |-
        Coordinates of a single pivot column, used to anchor a row sort to that
        specific column when results are pivoted.
    SortByDirection:
      enum:
        - ASC
        - DESC
      type: string

````