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

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.

# Update a cache rule

> Partial update. `matchers` and `action` REPLACE the stored value when provided (not merged field-by-field). Omitting them leaves the stored value untouched. The rule id + organisation are immutable.



## OpenAPI

````yaml PATCH /api/gateway/v1/cache-rules/{id}
openapi: 3.1.0
info:
  title: LangWatch API
  version: 1.0.0
  description: LangWatch openapi spec
servers:
  - url: https://app.langwatch.ai
security:
  - project_api_key: []
paths:
  /api/gateway/v1/cache-rules/{id}:
    patch:
      tags:
        - Cache Rules
      summary: Update a cache rule
      description: >-
        Partial update. `matchers` and `action` REPLACE the stored value when
        provided (not merged field-by-field). Omitting them leaves the stored
        value untouched. The rule id + organisation are immutable.
      operationId: patchApiGatewayV1CacheRulesById
      parameters:
        - schema:
            type: string
          in: path
          name: id
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 128
                description:
                  type:
                    - string
                    - 'null'
                  maxLength: 512
                priority:
                  type: integer
                  minimum: 0
                  maximum: 1000
                enabled:
                  type: boolean
                matchers:
                  type: object
                  properties:
                    vk_id:
                      type: string
                    vk_tags:
                      type: array
                      items:
                        type: string
                    vk_prefix:
                      type: string
                    principal_id:
                      type: string
                    model:
                      type: string
                    request_metadata:
                      type: object
                      additionalProperties:
                        type: string
                  additionalProperties: false
                action:
                  type: object
                  properties:
                    mode:
                      type: string
                      enum:
                        - respect
                        - force
                        - disable
                    ttl:
                      type: integer
                      minimum: 0
                      maximum: 86400
                    salt:
                      type: string
                      maxLength: 64
                  required:
                    - mode
                  additionalProperties: false
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  cache_rule:
                    type: object
                    properties:
                      id:
                        type: string
                      organization_id:
                        type: string
                      name:
                        type: string
                      description:
                        type:
                          - string
                          - 'null'
                      priority:
                        type: integer
                      enabled:
                        type: boolean
                      matchers:
                        type: object
                        additionalProperties: {}
                      action:
                        type: object
                        properties:
                          mode:
                            type: string
                            enum:
                              - respect
                              - force
                              - disable
                          ttl:
                            type: integer
                          salt:
                            type: string
                        required:
                          - mode
                      mode_enum:
                        type: string
                        enum:
                          - respect
                          - force
                          - disable
                      archived_at:
                        type:
                          - string
                          - 'null'
                      created_at:
                        type: string
                      updated_at:
                        type: string
                    required:
                      - id
                      - organization_id
                      - name
                      - description
                      - priority
                      - enabled
                      - matchers
                      - action
                      - mode_enum
                      - archived_at
                      - created_at
                      - updated_at
                required:
                  - cache_rule
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      meta:
                        type: object
                        additionalProperties: {}
                      trace_id:
                        type: string
                      span_id:
                        type: string
                    required:
                      - type
                      - code
                      - message
                required:
                  - error
      security:
        - project_api_key: []
components:
  securitySchemes:
    project_api_key:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: >-
        Project API key for sending traces and accessing project-scoped
        resources. Format: sk-lw-... (no underscore). Obtain one by creating a
        project via the Admin API or the LangWatch UI.

````