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

# Update Dashboard Widget

> Update a widget's fields within this dashboard, using copy-on-write for shared widgets.

If the widget belongs only to this dashboard it is updated in place; if it is
referenced by more than one dashboard, a new widget is created with the updates
applied and swapped into this dashboard's `widget_order`, leaving the other
dashboards' copy untouched. The widget must already be in this dashboard's
`widget_order`, otherwise the call is rejected. The result is recomputed
synchronously when the `query` changes or when the widget was cloned; otherwise the
existing cached result is returned. For `table` widgets, conditional-formatting
column references are re-resolved against the (possibly updated) query on each save.
The dashboard must exist and not be archived.



## OpenAPI

````yaml https://api.dev-sgp.scale.com/openapi-versions/v5/openapi.json patch /v5/evaluation-dashboards/{dashboard_id}/widgets/{widget_id}
openapi: 3.1.0
info:
  title: EGP API V5
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
paths:
  /v5/evaluation-dashboards/{dashboard_id}/widgets/{widget_id}:
    patch:
      tags:
        - Evaluation Dashboards
      summary: Update Dashboard Widget
      description: >-
        Update a widget's fields within this dashboard, using copy-on-write for
        shared widgets.


        If the widget belongs only to this dashboard it is updated in place; if
        it is

        referenced by more than one dashboard, a new widget is created with the
        updates

        applied and swapped into this dashboard's `widget_order`, leaving the
        other

        dashboards' copy untouched. The widget must already be in this
        dashboard's

        `widget_order`, otherwise the call is rejected. The result is recomputed

        synchronously when the `query` changes or when the widget was cloned;
        otherwise the

        existing cached result is returned. For `table` widgets,
        conditional-formatting

        column references are re-resolved against the (possibly updated) query
        on each save.

        The dashboard must exist and not be archived.
      operationId: PATCH-V5-/v5/evaluation-dashboards/dashboard_id/widgets/widget_id
      parameters:
        - name: dashboard_id
          in: path
          required: true
          schema:
            type: string
            title: Dashboard Id
        - name: widget_id
          in: path
          required: true
          schema:
            type: string
            title: Widget Id
        - name: x-selected-account-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Account ID Header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EvaluationDashboardWidgetUpdateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EvaluationWidgetWithResultResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    EvaluationDashboardWidgetUpdateRequest:
      properties:
        title:
          type: string
          maxLength: 256
          minLength: 1
          title: Title
          description: Widget title
        query:
          anyOf:
            - $ref: '#/components/schemas/SeriesQuery'
            - $ref: '#/components/schemas/MetricQuery'
          title: Query
          description: >-
            Structured query AST for metric computation (SeriesQuery or
            MetricQuery)
        config:
          title: Config
          description: Chart-specific display configuration
          additionalProperties: true
          type: object
      type: object
      title: EvaluationDashboardWidgetUpdateRequest
    EvaluationWidgetWithResultResponse:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the widget
        object:
          type: string
          const: evaluation_widget
          title: Object
          default: evaluation_widget
        title:
          type: string
          title: Title
          description: Widget title
        type:
          $ref: '#/components/schemas/EvaluationWidgetTypeEnum'
          description: Widget type
        query:
          anyOf:
            - $ref: '#/components/schemas/SeriesQuery'
            - $ref: '#/components/schemas/MetricQuery'
          title: Query
          description: Structured query AST for computation (SeriesQuery or MetricQuery)
        config:
          title: Config
          description: Display configuration
          additionalProperties: true
          type: object
        account_id:
          type: string
          title: Account Id
          description: Account that owns this widget
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the widget was created
        result:
          $ref: '#/components/schemas/EvaluationWidgetResultResponse'
          description: Computed result for this widget
      type: object
      required:
        - id
        - title
        - type
        - account_id
        - created_at
      description: Response model for widget creation - includes widget and computed result
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SeriesQuery:
      properties:
        select:
          items:
            $ref: '#/components/schemas/SelectItem'
          type: array
          minItems: 1
          title: Select
        filter:
          $ref: '#/components/schemas/Filter'
          description: Filter conditions (WHERE clause)
        groupBy:
          title: Groupby
          description: Columns to group by
          items:
            type: string
          type: array
        orderBy:
          title: Orderby
          description: Sort order
          items:
            $ref: '#/components/schemas/OrderByColumn'
          type: array
        limit:
          title: Limit
          description: Max rows to return
          type: integer
          minimum: 1
        evaluation_ids:
          title: Evaluation Ids
          description: >-
            Optional subset of evaluation IDs to compute on. Only applicable for
            evaluation group dashboards. If omitted, computes on all evaluations
            in the group.
          items:
            type: string
          type: array
          minItems: 1
        latest_only:
          title: Latest Only
          description: >-
            When True, the widget computes against rows from only the most
            recent active evaluation in the group (by EvaluationORM.created_at).
            Only applicable for evaluation group dashboards. Composes with
            evaluation_ids (latest within the subset). Cannot be combined with
            per-aggregation evaluation_ids; the use case enforces these rules.
          type: boolean
      type: object
      required:
        - select
      title: SeriesQuery
      description: >-
        Query that returns a series of records (used for
        table/bar/histogram/donut/scatter widgets).


        Used for widget types: table, bar, histogram, donut, scatter.

        Returns: {"type": "series", "data": [...]}


        Example SQL equivalent:
            SELECT category, AVG(score) as avg_score, COUNT(*) as count
            FROM evaluation_items
            WHERE score > 0.5 AND category = 'test'
            GROUP BY category
            ORDER BY avg_score DESC
            LIMIT 100
    MetricQuery:
      properties:
        select:
          items:
            $ref: '#/components/schemas/SelectItem'
          type: array
          maxItems: 1
          minItems: 1
          title: Select
        filter:
          $ref: '#/components/schemas/Filter'
          description: Filter conditions (WHERE clause)
        evaluation_ids:
          title: Evaluation Ids
          description: >-
            Optional subset of evaluation IDs to compute on. Only applicable for
            evaluation group dashboards. If omitted, computes on all evaluations
            in the group.
          items:
            type: string
          type: array
          minItems: 1
        latest_only:
          title: Latest Only
          description: >-
            When True, the widget computes against rows from only the most
            recent active evaluation in the group (by EvaluationORM.created_at).
            Only applicable for evaluation group dashboards. Composes with
            evaluation_ids (latest within the subset). Cannot be combined with
            per-aggregation evaluation_ids; the use case enforces these rules.
          type: boolean
      type: object
      required:
        - select
      title: MetricQuery
      description: |-
        Query that returns a single metric value (used for metric widgets).

        Used for widget type: metric.
        Enforces exactly 1 aggregation in select.
        Returns: {"type": "metric", "data": ...}

        Example SQL equivalent:
            SELECT AVG(score) as average_score
            FROM evaluation_items
    EvaluationWidgetTypeEnum:
      type: string
      enum:
        - bar
        - histogram
        - donut
        - scatter
        - metric
        - table
        - markdown
        - heading
        - timeseries
      title: EvaluationWidgetTypeEnum
      description: Widget types for dashboard visualizations
    EvaluationWidgetResultResponse:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the widget result
        widget_id:
          type: string
          title: Widget Id
          description: Widget ID this result belongs to
        computed_result:
          title: Computed Result
          description: >-
            Computed result data. Metric: {type: 'metric', data: 42}, Series:
            {type: 'series', data: [{x: 'A', y: 10}, ...]}
          additionalProperties: true
          type: object
        computation_status:
          type: string
          title: Computation Status
          description: 'Status: pending, completed, or failed'
        error_message:
          title: Error Message
          description: Error message if computation failed
          type: string
        computed_at:
          title: Computed At
          description: When computation completed
          type: string
          format: date-time
      type: object
      required:
        - id
        - widget_id
        - computation_status
      title: EvaluationWidgetResultResponse
      description: Computed result for a widget - used in widget creation response
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          title: Error Type
          type: string
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    SelectItem:
      properties:
        alias:
          title: Alias
          description: Optional alias for the selected item
          type: string
        expression:
          anyOf:
            - $ref: '#/components/schemas/Column'
            - $ref: '#/components/schemas/Aggregation'
          title: Expression
      type: object
      required:
        - expression
      title: SelectItem
      description: Column in SELECT clause
    Filter:
      properties:
        conditions:
          items:
            $ref: '#/components/schemas/FilterCondition'
          type: array
          minItems: 1
          title: Conditions
        logicalOperators:
          title: Logicaloperators
          description: >-
            Logical operators connecting conditions. Length must be
            len(conditions) - 1
          items:
            $ref: '#/components/schemas/LogicalOperatorEnum'
          type: array
      type: object
      required:
        - conditions
      title: Filter
      description: >-
        Filter clause with conditions connected by logical operators.


        Conditions are evaluated left-to-right without precedence (no
        nesting/parentheses).

        Example: condition1 AND condition2 OR condition3 evaluates as
        ((condition1 AND condition2) OR condition3)


        Example:
            {
                "conditions": [
                    {"column": "score", "operator": ">", "value": 0.5},
                    {"column": "category", "operator": "=", "value": "test"}
                ],
                "logicalOperators": ["AND"]
            }
    OrderByColumn:
      properties:
        column:
          type: string
          title: Column
          description: Column name to sort by
        source:
          title: Source
          description: 'Column source: ''data'' or ''task_result_cache'''
          type: string
        direction:
          $ref: '#/components/schemas/SortDirectionEnum'
          description: Sort direction
          default: ASC
      type: object
      required:
        - column
      title: OrderByColumn
      description: Column in ORDER BY clause
    Column:
      properties:
        type:
          type: string
          const: COLUMN
          title: Type
          default: COLUMN
        column:
          type: string
          title: Column
          description: Column name from evaluation_items.data
        source:
          title: Source
          description: 'Column source: ''data'' or ''task_result_cache'''
          type: string
      type: object
      required:
        - column
      title: Column
      description: |-
        Reference to a column from evaluation_items.data

        Example:
            {"type": "COLUMN", "column": "category"}
    Aggregation:
      properties:
        type:
          type: string
          const: AGGREGATION
          title: Type
          default: AGGREGATION
        function:
          $ref: '#/components/schemas/AggregationFunctionEnum'
        column:
          type: string
          title: Column
          description: Column to aggregate, or '*' for COUNT(*)
        source:
          title: Source
          description: 'Column source: ''data'' or ''task_result_cache'''
          type: string
        params:
          title: Params
          description: >-
            Function parameters (e.g., {'percentile': 95} for PERCENTILE,
            {'percentage_filters': Filter} for PERCENTAGE)
          additionalProperties: true
          type: object
        evaluation_ids:
          title: Evaluation Ids
          description: >-
            Optional subset of evaluation IDs for per-aggregation filtering in
            evaluation group dashboards.
          items:
            type: string
          type: array
          minItems: 1
      type: object
      required:
        - function
        - column
      title: Aggregation
      description: |-
        Aggregation function to apply

        Examples:
            {"type": "AGGREGATION", "function": "AVG", "column": "score"}
            {"type": "AGGREGATION", "function": "COUNT", "column": "*"}
            {"type": "AGGREGATION", "function": "PERCENTILE", "column": "score", "params": {"percentile": 95}}
    FilterCondition:
      properties:
        column:
          type: string
          title: Column
          description: Column name to filter on
        source:
          title: Source
          description: 'Column source: ''data'' or ''task_result_cache'''
          type: string
        operator:
          $ref: '#/components/schemas/ComparisonOperatorEnum'
          description: Comparison operator
        value:
          anyOf:
            - type: string
            - type: integer
            - type: number
            - type: boolean
            - items: {}
              type: array
          title: Value
          description: >-
            Value to compare against. Not required for IS NULL / IS NOT NULL
            operators.
      type: object
      required:
        - column
        - operator
      title: FilterCondition
      description: |-
        Single filter condition comparing a column to a value.

        Example:
            {"column": "score", "operator": ">", "value": 0.5}
            {"column": "category", "operator": "=", "value": "test"}
    LogicalOperatorEnum:
      type: string
      enum:
        - AND
        - OR
      title: LogicalOperatorEnum
      description: Logical operators for connecting filter conditions
    SortDirectionEnum:
      type: string
      enum:
        - ASC
        - DESC
      title: SortDirectionEnum
      description: Sort directions
    AggregationFunctionEnum:
      type: string
      enum:
        - COUNT
        - SUM
        - AVG
        - MIN
        - MAX
        - STDDEV
        - VARIANCE
        - PERCENTILE
        - COUNT_DISTINCT
        - PERCENTAGE
      title: AggregationFunctionEnum
      description: Supported aggregation functions
    ComparisonOperatorEnum:
      type: string
      enum:
        - '='
        - '!='
        - '>'
        - <
        - '>='
        - <=
        - IN
        - NOT IN
        - LIKE
        - NOT LIKE
        - IS NULL
        - IS NOT NULL
      title: ComparisonOperatorEnum
      description: Supported comparison operators for filtering
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````