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

# Create a schedule adjustment

> Used to create a schedule adjustment.

## Examples

<Tabs>
  <Tab title="Skip order">
    Skip order for the third cycle with a reason.

    ```json theme={null}
    {
      "matcher": {
        "type": "CYCLE",
        "input": {
          "cycle": 3
        }
      },
      "action": {
        "type": "SKIP_ORDER",
        "input": {
          "reason": "Going on vacation"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Change date">
    Reschedule order for the second cycle to a new date.

    ```json theme={null}
    {
      "matcher": {
        "type": "CYCLE",
        "input": {
          "cycle": 2
        }
      },
      "action": {
        "type": "CHANGE_DATE",
        "input": {
          "newDate": "2025-02-15T00:00:00Z"
        }
      }
    }
    ```

    <Warning>
      `CHANGE_DATE` only supports the `CYCLE` matcher. The new date must be within one billing cycle of the original date and cannot be in the past.
    </Warning>
  </Tab>

  <Tab title="Skip by date">
    Skip all orders scheduled for a specific date.

    ```json theme={null}
    {
      "matcher": {
        "type": "DATE",
        "input": {
          "date": "2025-01-01T00:00:00Z"
        }
      },
      "action": {
        "type": "SKIP_ORDER",
        "input": {
          "reason": "Holiday break"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Update shipping">
    Update shipping address for a specific cycle.

    ```json theme={null}
    {
      "matcher": {
        "type": "CYCLE",
        "input": {
          "cycle": 3
        }
      },
      "action": {
        "type": "UPDATE_SHIPPING",
        "input": {
          "address": {
            "firstName": "John",
            "lastName": "Doe",
            "address1": "123 Main St",
            "city": "New York",
            "countryCode": "US",
            "zip": "10001"
          }
        }
      }
    }
    ```

    <Warning>
      Address must include at least `address1` and `countryCode`.
    </Warning>
  </Tab>

  <Tab title="Update payment method">
    Update payment method for a specific cycle.

    ```json theme={null}
    {
      "matcher": {
        "type": "CYCLE",
        "input": {
          "cycle": 4
        }
      },
      "action": {
        "type": "UPDATE_PAYMENT_METHOD",
        "input": {
          "paymentMethodId": "pm_abc123"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Update products">
    Modify product lines for a specific cycle.

    ```json theme={null}
    {
      "matcher": {
        "type": "CYCLE",
        "input": {
          "cycle": 2
        }
      },
      "action": {
        "type": "UPDATE_PRODUCTS",
        "input": {
          "lines": [
            {
              "lineId": "line_abc123",
              "quantity": 2
            },
            {
              "lineId": "line_def456",
              "variantId": "variant_xyz789"
            },
            {
              "lineId": "line_ghi789",
              "customAttributes": [
                { "key": "gift_message", "value": "Happy birthday!" }
              ]
            }
          ]
        }
      }
    }
    ```

    <Info>
      Each line requires `lineId`. Optional fields: `variantId` (swap variant), `quantity` (min 1), `interval` (override billing interval), `nextBillingDate`, `customAttributes` (merged onto the item by key; reserved/internal keys are rejected with a 400).
    </Info>
  </Tab>

  <Tab title="Apply discount (code)">
    Apply a Shopify discount code to a specific cycle.

    ```json theme={null}
    {
      "matcher": {
        "type": "CYCLE",
        "input": {
          "cycle": 2
        }
      },
      "action": {
        "type": "APPLY_DISCOUNT",
        "input": {
          "discountSource": "code",
          "discountCode": "SAVE20"
        }
      }
    }
    ```

    <Warning>
      `APPLY_DISCOUNT` only supports the `CYCLE` matcher. Discount must exist in Shopify and be valid for subscriptions.
    </Warning>
  </Tab>
</Tabs>


## OpenAPI

````yaml openapi-customer.json POST /schedules/adjustments
openapi: 3.1.0
info:
  version: 8.15.0
  title: '@fastify/swagger'
servers:
  - url: https://api.juo.io/customer/v1
security:
  - DelegatedToken: []
  - AccessToken: []
paths:
  /schedules/adjustments:
    post:
      tags:
        - api.customer.v1
      description: Creates a schedule adjustment
      parameters:
        - $ref: '#/components/parameters/TenantHeader'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                matcher:
                  anyOf:
                    - description: Match by cycle number
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - CYCLE
                        input:
                          type: object
                          properties:
                            cycle:
                              minimum: 0
                              description: Target cycle number
                              type: integer
                          required:
                            - cycle
                      required:
                        - type
                        - input
                    - description: Match by date
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - DATE
                        input:
                          type: object
                          properties:
                            date:
                              format: date-time
                              description: Target date for the adjustment
                              type: string
                          required:
                            - date
                      required:
                        - type
                        - input
                    - description: Match by both cycle and date
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - CYCLE_AND_DATE
                        input:
                          type: object
                          properties:
                            cycle:
                              minimum: 0
                              description: Target cycle number
                              type: integer
                            date:
                              format: date-time
                              description: Target date for the adjustment
                              type: string
                          required:
                            - cycle
                            - date
                      required:
                        - type
                        - input
                action:
                  anyOf:
                    - description: Skip an order in the schedule
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - SKIP_ORDER
                        input:
                          type: object
                          properties:
                            reason:
                              description: Reason for skipping the order
                              type: string
                          required:
                            - reason
                      required:
                        - type
                        - input
                    - description: Change the date of an order in the schedule
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - CHANGE_DATE
                        input:
                          type: object
                          properties:
                            newDate:
                              format: date-time
                              description: New date for the order (ISO 8601)
                              type: string
                          required:
                            - newDate
                      required:
                        - type
                        - input
                    - description: >-
                        Update the shipping address for a specific order in the
                        schedule
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - UPDATE_SHIPPING
                        input:
                          type: object
                          properties:
                            address:
                              type: object
                              properties:
                                firstName:
                                  type:
                                    - 'null'
                                    - string
                                lastName:
                                  type:
                                    - 'null'
                                    - string
                                address1:
                                  type:
                                    - 'null'
                                    - string
                                address2:
                                  type:
                                    - 'null'
                                    - string
                                zip:
                                  type:
                                    - 'null'
                                    - string
                                city:
                                  type:
                                    - 'null'
                                    - string
                                countryCode:
                                  type:
                                    - 'null'
                                    - string
                                provinceCode:
                                  type:
                                    - 'null'
                                    - string
                                phone:
                                  type:
                                    - 'null'
                                    - string
                                company:
                                  type:
                                    - 'null'
                                    - string
                          required:
                            - address
                      required:
                        - type
                        - input
                    - description: >-
                        Update the payment method for a specific order in the
                        schedule
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - UPDATE_PAYMENT_METHOD
                        input:
                          type: object
                          properties:
                            paymentMethodId:
                              minLength: 1
                              description: >-
                                The payment method identifier to use for this
                                order
                              type: string
                          required:
                            - paymentMethodId
                      required:
                        - type
                        - input
                    - description: Update products in an order in the schedule
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - UPDATE_PRODUCTS
                        input:
                          type: object
                          properties:
                            lines:
                              minItems: 1
                              type: array
                              items:
                                type: object
                                properties:
                                  lineId:
                                    description: ID of the line to modify
                                    type: string
                                  variantId:
                                    description: New variant ID to swap to
                                    type: string
                                  quantity:
                                    minimum: 1
                                    description: New quantity for the line
                                    type: integer
                                  interval:
                                    description: Override billing interval for this cycle
                                    type: object
                                    properties:
                                      intervalCount:
                                        minimum: 1
                                        description: Number of intervals
                                        type: integer
                                      interval:
                                        description: Interval unit
                                        anyOf:
                                          - type: string
                                            enum:
                                              - DAY
                                          - type: string
                                            enum:
                                              - WEEK
                                          - type: string
                                            enum:
                                              - MONTH
                                          - type: string
                                            enum:
                                              - YEAR
                                    required:
                                      - intervalCount
                                      - interval
                                  nextBillingDate:
                                    format: date-time
                                    description: Override next billing date (ISO 8601)
                                    type: string
                                  customAttributes:
                                    description: >-
                                      Custom attributes to merge onto the order
                                      item
                                    type: array
                                    items:
                                      type: object
                                      properties:
                                        key:
                                          minLength: 1
                                          description: Attribute key
                                          type: string
                                        value:
                                          description: Attribute value
                                          type: string
                                      required:
                                        - key
                                        - value
                                required:
                                  - lineId
                          required:
                            - lines
                      required:
                        - type
                        - input
                    - description: Apply a discount code to an order in the schedule
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - APPLY_DISCOUNT
                        input:
                          type: object
                          properties:
                            discountSource:
                              type: string
                              enum:
                                - code
                            discountCode:
                              minLength: 1
                              description: The discount code to apply
                              type: string
                          required:
                            - discountSource
                            - discountCode
                      required:
                        - type
                        - input
              required:
                - matcher
                - action
        required: true
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduleAdjustment'
components:
  parameters:
    TenantHeader:
      name: X-Tenant-ID
      x-speakeasy-name-override: tenant
      x-speakeasy-globals-hidden: true
      in: header
      schema:
        type: string
      required: true
      description: >-
        Unique identifier of the tenant in the system (usually a store
        identifier)
  schemas:
    ScheduleAdjustment:
      type: object
      properties:
        id:
          format: uuid
          description: The adjustment identifier
          type: string
        resource:
          type: string
          enum:
            - schedule_adjustment
        customer:
          minLength: 1
          description: The customer identifier
          type: string
        matcher:
          type: object
          properties:
            type:
              minLength: 1
              type: string
            input: {}
          required:
            - type
            - input
        action:
          type: object
          properties:
            type:
              minLength: 1
              type: string
            input: {}
          required:
            - type
            - input
        actor:
          type: object
          properties:
            type:
              type: string
              enum:
                - staff
                - customer
                - system
                - bulk-action
                - api
            id:
              description: The actor identifier, if applicable
              type:
                - 'null'
                - string
          required:
            - type
            - id
        createdAt:
          format: date-time
          description: Creation date of the adjustment
          type: string
        updatedAt:
          format: date-time
          description: Last update date of the adjustment
          type: string
      required:
        - id
        - resource
        - customer
        - matcher
        - action
        - actor
        - createdAt
        - updatedAt
      title: ScheduleAdjustment
  securitySchemes:
    DelegatedToken:
      type: apiKey
      name: X-Delegated-Token
      in: header
    AccessToken:
      type: http
      scheme: bearer

````