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

# Update a promotion

> Updates a promotion. The `rules` and `actions` arrays are treated as
a *desired set* — rows with `id` update in place, rows without `id` are
built fresh, and any existing row not present in the array is destroyed.
Pass `rules: []` or `actions: []` to clear them.


**Required scope:** `write_promotions` (for API-key authentication).



## OpenAPI

````yaml /api-reference/admin.yaml patch /api/v3/admin/promotions/{id}
openapi: 3.0.3
info:
  title: Admin API
  contact:
    name: Spree Commerce
    url: https://spreecommerce.org
    email: hello@spreecommerce.org
  description: >
    Spree Admin API v3 - Administrative API for managing products, orders, and
    store settings.


    ## Authentication


    The Admin API requires a secret API key passed in the `x-spree-api-key`
    header.

    Secret API keys can be generated in the Spree admin dashboard.


    ## Response Format


    All responses are JSON. List endpoints return paginated responses with
    `data` and `meta` keys.

    Single resource endpoints return a flat JSON object.


    ## Resource IDs


    Every resource is identified by an opaque string ID (e.g. `prod_86Rf07xd4z`,

    `variant_k5nR8xLq`, `or_UkLWZg9DAJ`). Use these IDs everywhere — URL paths,

    request bodies, and Ransack filters all accept them directly.


    ## Error Handling


    Errors return a consistent format:

    ```json

    {
      "error": {
        "code": "validation_error",
        "message": "Validation failed",
        "details": { "name": ["can't be blank"] }
      }
    }

    ```
  version: v3
servers:
  - url: http://{defaultHost}
    variables:
      defaultHost:
        default: localhost:3000
security: []
tags:
  - name: Authentication
    description: Admin user login, logout, token refresh, and current user profile
  - name: Allowed Origins
    description: CORS allowlist for storefront and admin client origins
  - name: API Keys
    description: Secret and publishable API keys
  - name: Categories
    description: >-
      Hierarchical product categories — tree management, repositioning, and
      product assignments
  - name: Channels
    description: >-
      Sales channels, product publication across channels, and per-channel order
      routing rules
  - name: Custom Fields
    description: >-
      Custom field definitions for products, variants, customers, and other
      resources
  - name: Customer Groups
    description: >-
      Customer groups for segmenting customers (e.g. wholesale, VIP) used by
      pricing and promotions
  - name: Customers
    description: Customer profiles, addresses, credit cards, and store credits
  - name: Email Templates
    description: >-
      Customer email templates, the email layout and shared partials: drafts,
      previews, publishing and history
  - name: Exports
    description: Async CSV exports of admin resources
  - name: Files
    description: Uploading the files that product media, imports, logos and documents use
  - name: Fulfillments
    description: Order fulfillments — shipments, fulfill, cancel, resume, split
  - name: Gift Cards
    description: Gift cards and gift card batches
  - name: Imports
    description: >-
      Async CSV imports of admin resources, with per-row status and failed-row
      retry
  - name: Maintenance Tasks
    description: >-
      Operator-run data work — backfills, reindexes and upgrade steps — and the
      record of every run
  - name: Markets
    description: >-
      Markets — geographic groupings of countries used for pricing, tax, and
      fulfillment rules
  - name: Option Types
    description: >-
      Option types and option values used to build product variants (e.g. Size,
      Color)
  - name: Orders
    description: Orders, order items, applied gift cards, and applied store credits
  - name: Payment Methods
    description: Configured payment providers and their available types
  - name: Payments
    description: Order payments — list, capture, void
  - name: Pricing
    description: >-
      Prices and price lists for currency-, market-, and customer-group-specific
      pricing
  - name: Products
    description: >-
      Products, taxons/categories, product custom field values, and bulk product
      operations
  - name: Policies
    description: The store's legal documents — terms of service, privacy, returns, shipping
  - name: Reasons
    description: >-
      Merchant-owned vocabularies for why a return, claim, refund, cancellation
      or tax exemption happened
  - name: Promotions
    description: Promotions, promotion rules, promotion actions, and coupon codes
  - name: Refunds
    description: Order refunds
  - name: Settings
    description: Store-level settings — store profile, tags, and configuration
  - name: Staff
    description: Admin users, roles, and invitations to the store
  - name: Stock Locations
    description: Warehouses and physical fulfillment locations
  - name: Store Credits
    description: Prepaid customer balances across all customers, and each balance's ledger
  - name: Variants
    description: >-
      Product variants — the individual SKUs (size/color combinations) sold
      under a product
  - name: Webhooks
    description: Webhook endpoints and webhook delivery history
paths:
  /api/v3/admin/promotions/{id}:
    patch:
      tags:
        - Promotions
      summary: Update a promotion
      description: |-
        Updates a promotion. The `rules` and `actions` arrays are treated as
        a *desired set* — rows with `id` update in place, rows without `id` are
        built fresh, and any existing row not present in the array is destroyed.
        Pass `rules: []` or `actions: []` to clear them.


        **Required scope:** `write_promotions` (for API-key authentication).
      parameters:
        - name: x-spree-api-key
          in: header
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PromotionUpdateParams'
        required: true
      responses:
        '200':
          description: rules and actions cleared with empty arrays
          content:
            application/json:
              example:
                id: promo_UkLWZg9DAJ
                name: Summer Sale
                description: null
                code: summer
                starts_at: '2026-01-15T11:00:00.000Z'
                expires_at: null
                usage_limit: null
                match_policy: all
                path: null
                kind: coupon_code
                multi_codes: false
                number_of_codes: null
                code_prefix: null
                promotion_category_id: null
                metadata: {}
                created_at: '2026-01-15T12:00:00.000Z'
                updated_at: '2026-01-15T12:00:00.000Z'
                action_ids: []
                rule_ids: []
      security:
        - api_key: []
          bearer_auth: []
      x-codeSamples:
        - lang: javascript
          label: Spree Admin SDK
          source: |-
            import { createAdminClient } from '@spree/admin-sdk'

            const client = createAdminClient({
              baseUrl: 'https://your-store.com',
              secretKey: 'sk_xxx',
            })

            // Basic field update
            await client.promotions.update(promotionId, {
              description: 'Updated description',
            })

            // One-shot: rewrite rules + actions in a single request
            await client.promotions.update(promotionId, {
              name: 'Holiday Sale',
              rules: [
                // Update an existing rule by id — `preferences` overwrite the prior set
                {
                  id: 'prorule_existing',
                  type: 'currency',
                  preferences: { currency: 'EUR' },
                },
                // Add a new rule
                {
                  type: 'item_total',
                  preferences: { amount_min: '50.00', operator_min: 'gte' },
                },
              ],
              actions: [
                // Swap calculator type on an existing action
                {
                  id: 'proaction_existing',
                  type: 'create_item_adjustments',
                  calculator: {
                    type: 'percent_on_line_item',
                    preferences: { percent: '15' },
                  },
                },
              ],
            })

            // Remove all rules/actions
            await client.promotions.update(promotionId, {
              rules: [],
              actions: [],
            })
        - lang: bash
          label: Spree CLI
          source: >-
            spree api patch /promotions/{id} -d '{"description":"Updated
            description"}'
components:
  schemas:
    PromotionUpdateParams:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
          nullable: true
        code:
          type: string
          description: >-
            Required for single-code coupon promotions. Ignored when
            `multi_codes` is true.
          nullable: true
        path:
          type: string
          nullable: true
        starts_at:
          type: string
          format: date-time
          nullable: true
        expires_at:
          type: string
          format: date-time
          nullable: true
        usage_limit:
          type: integer
          nullable: true
        match_policy:
          type: string
          enum:
            - all
            - any
        kind:
          type: string
          enum:
            - coupon_code
            - automatic
          description: >-
            `coupon_code` needs a code (or `multi_codes`); `automatic` applies
            without one.
        multi_codes:
          type: boolean
          description: Generates `number_of_codes` codes starting with `code_prefix`.
        number_of_codes:
          type: integer
          nullable: true
        code_prefix:
          type: string
          nullable: true
        promotion_category_id:
          type: string
          nullable: true
        rules:
          type: array
          items:
            $ref: '#/components/schemas/PromotionRuleDraftParams'
          description: >-
            The rules the promotion should have: entries with `id` update,
            entries without are created, and rules left out are removed.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/PromotionActionDraftParams'
          description: >-
            The actions the promotion should have, matched the same way as
            `rules`.
    PromotionRuleDraftParams:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          description: The rule kind, from `GET /promotion_rules/types`.
          example: currency
        preferences:
          type: object
          additionalProperties: true
          description: >-
            Values for the rule kind's settings schema, from `GET
            /promotion_rules/types`.
        product_ids:
          type: array
          items:
            type: string
          description: For the `product` rule.
        category_ids:
          type: array
          items:
            type: string
          description: For the `category` rule.
        customer_ids:
          type: array
          items:
            type: string
          description: 'For the `user` rule: the customers who qualify.'
      required:
        - type
    PromotionActionDraftParams:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          description: The action kind, from `GET /promotion_actions/types`.
          example: free_shipping
        preferences:
          type: object
          additionalProperties: true
          description: >-
            Values for the action kind's settings schema, from `GET
            /promotion_actions/types`.
        calculator:
          allOf:
            - $ref: '#/components/schemas/PromotionActionCalculatorParams'
          description: For adjustment actions.
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/PromotionActionLineItemParams'
          description: >-
            For `create_line_items`: the variants to add and their quantities.
            Variants left out are removed.
      required:
        - type
    PromotionActionCalculatorParams:
      type: object
      properties:
        type:
          type: string
          description: >-
            The calculator kind, from `GET /promotion_actions/calculators`.
            Changing it swaps the calculator.
          example: flat_percent_item_total
        preferences:
          type: object
          additionalProperties: true
          description: >-
            Values for the calculator's settings, such as `amount` or
            `flat_percent`.
    PromotionActionLineItemParams:
      type: object
      properties:
        variant_id:
          type: string
        quantity:
          type: integer
      required:
        - variant_id
        - quantity
  securitySchemes:
    api_key:
      type: apiKey
      name: x-spree-api-key
      in: header
      description: Secret API key for admin access
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token for admin user authentication

````

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