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

# Update a Rule

> Updates a Rule. Only fields present (non-null) in the request body are applied. Editing the text, or removing the linked Style Guide's content group or language, would unlink the rule from its Style Guide; set forceUnlink=true to confirm, otherwise the request fails with 409 CONFLICT and no changes are applied.



## OpenAPI

````yaml /openapi/phrase-style-guides.json patch /api/v1/rules/{id}
openapi: 3.1.0
info:
  version: 1.1.0
  title: Style Guide API
  description: REST API for managing Style Guides on the Phrase Platform
  contact:
    name: Linguistic Assets
    email: engineering@phrase.com
servers:
  - url: https://eu.phrase.com/styleguide
    description: Production EU
  - url: https://us.phrase.com/styleguide
    description: Production US
security:
  - bearerAuth: []
tags:
  - name: Style Guide
    description: Public API for managing Style Guides
  - name: Rule
    description: Public API for managing Rules
paths:
  /api/v1/rules/{id}:
    patch:
      tags:
        - Rule
      summary: Update a Rule
      description: >-
        Updates a Rule. Only fields present (non-null) in the request body are
        applied. Editing the text, or removing the linked Style Guide's content
        group or language, would unlink the rule from its Style Guide; set
        forceUnlink=true to confirm, otherwise the request fails with 409
        CONFLICT and no changes are applied.
      operationId: updateRule
      parameters:
        - name: id
          in: path
          description: Rule ID
          required: true
          schema:
            type: string
            format: uuid
          example: 01900000-0000-7000-8000-000000000001
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateRuleRequest'
        required: true
      responses:
        '200':
          description: Rule updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RuleResponse'
        '400':
          description: 'Invalid request. Error codes: VALIDATION_ERROR, INVALID_ARGUMENT.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid or missing authentication token
        '403':
          description: 'Forbidden - Insufficient permissions. Error codes: ACCESS_DENIED.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: 'Rule not found. Error codes: RULE_NOT_FOUND.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >-
            The update would unlink the rule from its Style Guide. Error codes:
            RULE_UNLINK_REQUIRES_CONFIRMATION.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    UpdateRuleRequest:
      type: object
      description: >-
        Request to update an existing Rule. Only fields that are present
        (non-null) in the JSON body are applied.
      properties:
        rule:
          type: string
          description: >-
            Updated rule text. Changing it would unlink the rule from its Style
            Guide; set forceUnlink=true to confirm, otherwise the request fails
            with 409 CONFLICT.
          example: Avoid passive voice in all user-facing content.
          maxLength: 450
          minLength: 0
        allContentGroups:
          type: boolean
          description: >-
            When true, this rule applies to all content groups and
            contentGroupIds must be absent or empty. When false, contentGroupIds
            must be provided and non-empty. Null = no change. Changing the
            content group scope away from the linked Style Guide's content group
            would unlink the rule; set forceUnlink=true to confirm, otherwise
            the request fails with 409 CONFLICT.
        contentGroupIds:
          type: array
          description: >-
            Complete replacement of the Content Group IDs this rule applies to.
            Null = no change. Must be non-empty when allContentGroups is false;
            must be absent or empty when allContentGroups is true. Any
            previously set IDs not included here are removed. Removing the
            linked Style Guide's content group would unlink the rule; set
            forceUnlink=true to confirm, otherwise the request fails with 409
            CONFLICT.
          items:
            type: string
            maxLength: 36
            minLength: 0
          maxItems: 100
          minItems: 0
        allLanguages:
          type: boolean
          description: >-
            When true, this rule applies to all languages and languages must be
            absent or empty. When false, languages must be provided and
            non-empty. Null = no change. Changing the language scope away from
            the linked Style Guide's language would unlink the rule; set
            forceUnlink=true to confirm, otherwise the request fails with 409
            CONFLICT.
        languages:
          type: array
          description: >-
            Complete replacement of the language codes this rule applies to.
            Null = no change. Must be non-empty when allLanguages is false; must
            be absent or empty when allLanguages is true. Any previously set
            codes not included here are removed. Removing the linked Style
            Guide's language would unlink the rule; set forceUnlink=true to
            confirm, otherwise the request fails with 409 CONFLICT.
          items:
            type: string
            minLength: 1
          maxItems: 100
          minItems: 0
        active:
          type: boolean
          description: Whether this rule is active. Null = no change.
        aiCheckEnabled:
          type: boolean
          description: >-
            Whether this rule is used during AI-powered quality checks. Null =
            no change.
        forceUnlink:
          type: boolean
          default: false
          description: >-
            Confirms that this update may unlink the rule from its currently
            linked Style Guide. Required (must be true) when a change to rule
            text, content group scope, or language scope would cause an unlink;
            otherwise the request fails with 409 CONFLICT and no changes are
            applied. Default: false.
    RuleResponse:
      type: object
      description: Rule details
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for this Rule
          example: 01900000-0000-7000-8000-000000000001
        rule:
          type: string
          description: The rule text
          example: Avoid passive voice in all user-facing content.
        active:
          type: boolean
          description: Whether this rule is active
        aiCheckEnabled:
          type: boolean
          description: Whether this rule is used during AI-powered quality checks
        allContentGroups:
          type: boolean
          description: Whether this rule applies to all content groups
        allLanguages:
          type: boolean
          description: Whether this rule applies to all languages
        styleGuide:
          $ref: '#/components/schemas/StyleGuideDetails'
          type: 'null'
          description: >-
            Style Guide this rule was extracted from. Null when the rule is
            unlinked — either manually created or subsequently edited.
        contentGroups:
          type:
            - array
            - 'null'
          description: >-
            Content Groups this rule applies to. Empty list means all content
            groups. Null means no content groups are assigned.
          items:
            $ref: '#/components/schemas/ContentGroupDetails'
        languages:
          type:
            - array
            - 'null'
          description: >-
            Language details for languages this rule applies to. Empty list
            means all languages. Null means no languages are assigned.
          items:
            $ref: '#/components/schemas/SupportedLanguageResponse'
        createdAt:
          type: string
          format: date-time
          description: When this rule was created
          example: '2024-01-15T10:30:00Z'
        lastModifiedAt:
          type: string
          format: date-time
          description: When this rule was last modified
          example: '2024-06-01T14:22:00Z'
        createdBy:
          $ref: '#/components/schemas/UserReference'
          type: 'null'
          description: User who created this rule
        lastModifiedBy:
          $ref: '#/components/schemas/UserReference'
          type: 'null'
          description: User who last modified this rule
      required:
        - active
        - aiCheckEnabled
        - allContentGroups
        - allLanguages
        - contentGroups
        - createdAt
        - id
        - languages
        - lastModifiedAt
        - rule
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        detail:
          type: string
    StyleGuideDetails:
      type: object
      description: Style Guide reference
      properties:
        id:
          type: string
          format: uuid
          description: Style Guide ID
          example: 01900000-0000-7000-8000-000000000002
        name:
          type: string
          description: Style Guide name
          example: English Style Guide
      required:
        - id
        - name
    ContentGroupDetails:
      type: object
      description: Content Group reference
      properties:
        id:
          type: string
          description: Content Group ID
          example: cg-marketing-en
    SupportedLanguageResponse:
      type: object
      description: Supported Style Guide language
      properties:
        bcpCode:
          type: string
          description: Language code in BCP-47 format (more specifically RFC 5646 format)
          example: en-GB
        description:
          type: string
          description: Human-readable language name in English
          example: English (United Kingdom)
        region:
          type: string
          description: Region code, or null if not present
          example: gb
        script:
          type: string
          description: Script code when defined, or null
          enum:
            - ARAB
            - ARMN
            - BENG
            - CANS
            - CYRL
            - DEVA
            - GREK
            - GURU
            - HANG
            - HANS
            - HANT
            - HEBR
            - HMNG
            - JPAN
            - KHMR
            - LAOO
            - LATN
            - MONG
            - MTEI
            - MYMR
            - OLCK
            - ORYA
            - PIQD
            - ROHG
            - SIND
            - SYRC
            - TAML
            - TFNG
            - TELU
          example: LATN
        language:
          type: string
          description: ISO 639-1 language code (e.g., 'cs' from 'cs-CZ')
          example: cs
      required:
        - bcpCode
        - description
        - language
    UserReference:
      type: object
      description: User reference
      properties:
        id:
          type: string
          description: User ID
          example: 01900000-0000-7000-8000-000000000003
  securitySchemes:
    bearerAuth:
      type: http
      description: 'JWT from IDM (Authorization: Bearer <token>)'
      scheme: bearer
      bearerFormat: JWT

````