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

# Update a saved query



## OpenAPI

````yaml https://openapi.production.reelevant.io/v1/render/statistics patch /query/{id}
openapi: 3.0.0
info:
  title: statistics
  version: 1276740a176d654cb1c3e602b6648d22e3bf52a9
  description: >-
    # Errors

    | Error code | Message | HTTP status code | Payload |

    | :--- | :--- | :--- | :--- |

    |
    9000,9001,9002,9003,9004,9006,9007,9008,9009,9010,9011,9012,9013,9014,9015,9016,9017
    | A tag key with this name already exists | 409 | ```{"name":"string"}``` |
servers:
  - url: https://api.reelevant.com/v2/statistics/
    description: production
security: []
paths:
  /query/{id}:
    patch:
      tags: []
      summary: Update a saved query
      operationId: update-saved-query
      parameters:
        - name: id
          in: path
          schema:
            type: string
            pattern: ^[0-9a-fA-F]{24}$
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Name of the query
                queries:
                  type: array
                  items:
                    $ref: '#/components/schemas/Query'
                  description: Cube query
                schedule:
                  oneOf:
                    - type: object
                      properties: {}
                      additionalProperties: false
                    - $ref: '#/components/schemas/StatisticsQuerySchedule'
                  description: Optional schedule options
              additionalProperties: false
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - success
                    required:
                      - status
                    additionalProperties: false
                  - $ref: '#/components/schemas/InternalResponse_StatisticsQuery'
      security:
        - password_auth: []
components:
  schemas:
    Query:
      type: object
      properties:
        measures:
          type: array
          items:
            type: string
          description: List of measure id
        dimensions:
          type: array
          items:
            type: string
          description: List of dimension id
        filters:
          type: array
          items:
            $ref: '#/components/schemas/BinaryFilter'
          description: |-
            CubeJS filters on dimension values
            Note: It's not possible to filter on virtual measures
        timeDimensions:
          type: array
          items:
            oneOf:
              - allOf:
                  - $ref: '#/components/schemas/TimeDimensionBase'
                  - $ref: '#/components/schemas/TimeDimensionComparisonFields'
              - allOf:
                  - $ref: '#/components/schemas/TimeDimensionBase'
                  - $ref: '#/components/schemas/TimeDimensionRangedFields'
          description: Time filters
        limit:
          type: number
        order:
          oneOf:
            - $ref: '#/components/schemas/TQueryOrderObject'
            - type: array
              items:
                type: array
                items:
                  oneOf:
                    - type: string
                    - oneOf:
                        - type: string
                          enum:
                            - asc
                        - type: string
                          enum:
                            - desc
      required:
        - measures
        - dimensions
        - filters
        - timeDimensions
      additionalProperties: false
    StatisticsQuerySchedule:
      type: object
      properties:
        cron:
          type: string
          description: Cron string
        destination:
          oneOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - email
                emails:
                  type: array
                  items:
                    type: string
              required:
                - type
                - emails
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - slack
                webhookUrl:
                  type: string
              required:
                - type
                - webhookUrl
              additionalProperties: false
          description: Schedule destination
      required:
        - cron
        - destination
      additionalProperties: false
    InternalResponse_StatisticsQuery:
      type: object
      properties:
        program:
          type: string
        version:
          type: string
        datetime:
          type: string
        status:
          type: string
        code:
          type: number
        message:
          type: string
        data:
          $ref: '#/components/schemas/StatisticsQuery'
      required:
        - program
        - version
        - datetime
        - status
        - message
        - data
      additionalProperties: false
    BinaryFilter:
      type: object
      properties:
        dimension:
          type: string
        member:
          type: string
        operator:
          oneOf:
            - type: string
              enum:
                - equals
            - type: string
              enum:
                - notEquals
            - type: string
              enum:
                - contains
            - type: string
              enum:
                - notContains
            - type: string
              enum:
                - startsWith
            - type: string
              enum:
                - notStartsWith
            - type: string
              enum:
                - endsWith
            - type: string
              enum:
                - notEndsWith
            - type: string
              enum:
                - gt
            - type: string
              enum:
                - gte
            - type: string
              enum:
                - lt
            - type: string
              enum:
                - lte
            - type: string
              enum:
                - inDateRange
            - type: string
              enum:
                - notInDateRange
            - type: string
              enum:
                - beforeDate
            - type: string
              enum:
                - beforeOrOnDate
            - type: string
              enum:
                - afterDate
            - type: string
              enum:
                - afterOrOnDate
        values:
          type: array
          items:
            type: string
      required:
        - operator
        - values
      additionalProperties: false
    TimeDimensionBase:
      type: object
      properties:
        dimension:
          type: string
        granularity:
          type: string
      required:
        - dimension
      additionalProperties: false
    TimeDimensionComparisonFields:
      type: object
      properties:
        compareDateRange:
          type: array
          items:
            oneOf:
              - type: string
              - type: array
                items:
                  oneOf:
                    - type: string
                    - type: string
      required:
        - compareDateRange
      additionalProperties: false
    TimeDimensionRangedFields:
      type: object
      properties:
        dateRange:
          oneOf:
            - type: string
            - type: array
              items:
                oneOf:
                  - type: string
                  - type: string
      additionalProperties: false
    TQueryOrderObject:
      type: object
      properties: {}
      additionalProperties:
        oneOf:
          - type: string
            enum:
              - asc
          - type: string
            enum:
              - desc
    StatisticsQuery:
      allOf:
        - $ref: >-
            #/components/schemas/StatisticsQuery_Without_CompanyId_HasScheduleEnabled_ToJSON
        - type: object
          properties:
            companyId:
              type: string
            id:
              type: string
            createdAt:
              type: string
              format: date-time
            updatedAt:
              type: string
              format: date-time
          required:
            - companyId
            - id
            - createdAt
            - updatedAt
          additionalProperties: false
    StatisticsQuery_Without_CompanyId_HasScheduleEnabled_ToJSON:
      type: object
      properties:
        name:
          type: string
          description: Name of the query
        queries:
          type: array
          items:
            $ref: '#/components/schemas/Query'
          description: Cube query
        schedule:
          oneOf:
            - type: object
              properties: {}
              additionalProperties: false
            - $ref: '#/components/schemas/StatisticsQuerySchedule'
          description: Optional schedule options
      required:
        - name
        - queries
        - schedule
      additionalProperties: false
  securitySchemes:
    password_auth:
      type: oauth2
      flows:
        password:
          tokenUrl: https://api.reelevant.com/v1/auth/token
          refreshUrl: https://api.reelevant.com/v1/auth/token
          scopes: {}

````