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

# Update a rule



## OpenAPI

````yaml /api-reference/openapi.json put /rules/{id}
openapi: 3.1.0
info:
  title: Joinery REST API
  version: 1.0.0
  description: >-
    Endpoints added to WordPress by Joinery Core, under /wp-json/joinery/v1.
    Price preview is public; rule management needs a user with the
    manage_woocommerce capability.
  license:
    name: GPL-2.0-or-later
    identifier: GPL-2.0-or-later
servers:
  - url: https://{site}/wp-json/joinery/v1
    variables:
      site:
        default: example.com
        description: Your WordPress site's host.
security: []
tags:
  - name: Prices
    description: For storefronts, including headless.
  - name: Rules
    description: Manage pricing and reward rules.
paths:
  /rules/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    put:
      tags:
        - Rules
      summary: Update a rule
      operationId: updateRule
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RuleInput'
      responses:
        '200':
          description: The updated rule.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Rule'
        '400':
          description: Invalid rule.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Not signed in.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Needs the manage_woocommerce capability.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - applicationPassword: []
        - cookieNonce: []
components:
  schemas:
    RuleInput:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          maxLength: 190
          example: Bulk hardware
        active:
          type: boolean
          default: true
        priority:
          type: integer
          default: 10
          description: Lower runs first.
        exclusive:
          type: boolean
          default: false
          description: Don't combine with other rules.
        conditions:
          type: array
          maxItems: 20
          items:
            $ref: '#/components/schemas/RulePart'
        actions:
          type: array
          maxItems: 20
          items:
            $ref: '#/components/schemas/RulePart'
          example:
            - type: dp_tiered_price
              settings:
                tiers:
                  - min: 10
                    percent: 10
                  - min: 50
                    percent: 20
    Rule:
      allOf:
        - type: object
          required:
            - id
          properties:
            id:
              type: integer
              example: 1
        - $ref: '#/components/schemas/RuleInput'
    Error:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        data:
          type: object
          properties:
            status:
              type: integer
    RulePart:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          example: product_category
          description: Condition or action ID. See Rule types.
        settings:
          type: object
          additionalProperties: true
          example:
            categories:
              - 17
  securitySchemes:
    applicationPassword:
      type: http
      scheme: basic
      description: >-
        A WordPress application password (Users → Profile → Application
        passwords).
    cookieNonce:
      type: apiKey
      in: header
      name: X-WP-Nonce
      description: >-
        The logged-in cookie plus a wp_rest nonce, for requests from wp-admin or
        the same site.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.