# Order change applied

`POST orders-experimental-order-change-applied`

> This is a subset of the full specification, limited to the `POST orders-experimental-order-change-applied` operation.
>
> You can find the full specification here: /_bundle/docs/dev-docs/api/index.yaml

```yaml
openapi: 3.1.1
info:
  version: latest
  title: Core APIs
  contact:
    name: Rebilly API Support
    url: https://www.rebilly.com/contact/
    email: integrations@rebilly.com
  license:
    name: Rebilly
    url: https://www.rebilly.com/api-license/
  termsOfService: https://www.rebilly.com/terms-of-use/
  x-logo:
    url: https://rebilly-core.redoc.ly/rb_apiLogo.svg
    backgroundColor: '#0044d4'
  description: This is a subset of the full specification, limited to the `POST orders-experimental-order-change-applied` operation. Components more than 3 `$ref` hops away are not included.
  x-metadata:
    description: The most common APIs used to automate common workflows.
    redocly_category: API Reference
servers:
  - url: https://api-sandbox.rebilly.com/organizations/{organizationId}
    description: Sandbox server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
  - url: https://api.rebilly.com/organizations/{organizationId}
    description: Live server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
security:
  - SecretApiKey: []
  - JWT: []
tags:
  - name: Orders
    description: Use these operations to manage orders that include items with mixed recurring subscription plans.
x-tagGroups:
  - name: Orders & Invoices
    tags:
      - Orders
paths: {}
webhooks:
  orders-experimental-order-change-applied:
    post:
      summary: Order change applied
      operationId: orders-experimental-order-change-applied
      x-products:
        - Core
      tags:
        - Orders
      requestBody:
        $ref: '#/components/requestBodies/OrderAndOrderChange'
      responses:
        2xx:
          description: Returns any 2xx status to indicate that data is received.
components:
  securitySchemes:
    JWT:
      description: |-
        JWT is a short lifetime token that can be assigned a specific expiration time.

        Usage format: `Bearer <JWT>`.
      type: http
      scheme: bearer
      bearerFormat: JWT
    SecretApiKey:
      description: |-
        Never share your secret keys.
        Keep them guarded and secure.

        Use your secret API key only to make requests from the server side.
        To authenticate, provide your secret key in the request header.
      name: REB-APIKEY
      type: apiKey
      in: header
  schemas:
    CreatedTime:
      type: string
      description: |-
        Date and time when the resource is created.
        This value is set automatically when the resource is created.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Creation Time
    UpdatedTime:
      type: string
      description: |-
        Date and time when the resource is updated.
        This value is set automatically when the resource is updated.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Last Update Time
    SelfLink:
      type: array
      description: Related links.
      readOnly: true
      items:
        type: object
        properties:
          href:
            description: Link URL.
            type: string
          rel:
            description: Type of link.
            type: string
            enum:
              - self
    OriginalPlan:
      type: object
      description: |-
        Use an existing plan without changes for the current order.

        To create a new plan, see [Create a plan](https://www.rebilly.com/catalog/all/plans/postplan).
      required:
        - id
      additionalProperties: false
      properties:
        id:
          description: ID of the plan.
          $ref: '#/components/schemas/ResourceId'
    FlexiblePlan:
      oneOf:
        - allOf:
            - type: object
              required:
                - id
              properties:
                id:
                  type: string
                  description: ID of the plan.
                  maxLength: 50
                  example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
            - $ref: '#/components/schemas/OneTimeSalePlan'
        - allOf:
            - type: object
              required:
                - id
              properties:
                id:
                  type: string
                  description: ID of the plan.
                  maxLength: 50
                  example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
            - $ref: '#/components/schemas/SubscriptionPlan'
        - allOf:
            - type: object
              required:
                - id
              properties:
                id:
                  type: string
                  description: ID of the plan.
                  maxLength: 50
                  example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
            - $ref: '#/components/schemas/TrialOnlyPlan'
    UsageLimits:
      type: object
      description: |-
        Specifies the soft and hard usage limit thresholds for an item with a metered billing plan.
        This value is ignored when the plan is not metered.
      properties:
        softLimit:
          type: object
          description: |-
            Defines thresholds for notification purposes.
            For example, to notify the customer that their usage is near the hard limit of their metered billing plan.
            This notification informs the customer so that they can upgrade their plan before the hard limit is reached.
            When metered usage equals or exceeds the configured soft limit, the `soft-usage-limit-reached` event is triggered.

            The quantity limit applies to the larger of the reported and billed quantity.
            If a minimum billable quantity results in a billed quantity that is higher than the reported quantity, the billed quantity applies to the limit.
            If a maximum billable quantity results in a billed quantity that is lower than the reported quantity, the reported quantity applies to the limit.
            The amount limit applies to the billed amount.

            To notify the customer, a webhook and notification can be configured for this event.
            This field is useful for accounting and customer success purposes.
            The usage of metered billing plans can still be reported if the soft limit is reached.
          minProperties: 1
          maxProperties: 1
          properties:
            quantity:
              type: integer
              description: Usage limit quantity.
              minimum: 0
            amount:
              type: number
              format: double
              description: Usage limit amount in the currency of the order.
              minimum: 0
        hardLimit:
          type: object
          description: |-
            Defines a limit where the customer can no longer use the service.
            Hard limits are used in addition to soft limits.
            When a soft limit is reached,
            a customer may receive a notification
            but the service can still be provided up to the hard limit value so that the customer can upgrade their plan.

            When the reported usage reaches the configured limit,
            a specific event is triggered.
            To notify the customer in the merchant system,
            or block a service,
            a webhook and notification can be configured for this event.
            When the total usage reaches the hard limit quantity,
            or amount values,
            metered billing plan usages can no longer be reported.

            Plans with a minimum quantity, fixed fee, or flat stairstep bracket set a minimum billable quantity and amount.
            A `quantity` value below the minimum billable quantity is invalid.
            An `amount` value below the minimum billable amount is invalid.
            A `0` value remains valid even on plans with minimum billing.
          minProperties: 1
          maxProperties: 1
          properties:
            quantity:
              type: integer
              description: Usage limit quantity.
              minimum: 0
            amount:
              type: number
              format: double
              description: Usage limit amount in the currency of the order.
              minimum: 0
        trialLimit:
          oneOf:
            - type: number
              format: double
              minimum: 0
            - type: 'null'
          description: |-
            Defines a usage cap during the trial period of a subscription.
            This limit is enforced only while the subscription is in its trial phase.
            When the reported usage reaches the configured trial limit, an event called 'trial-usage-limit-reached' is triggered.
            To notify the customer or restrict access to the service, a webhook and notification can be configured for this event.
            When the trial limit is reached, additional usage cannot be reported unless the trial ends.
          example: 20.725
    RecurringOrder:
      type: object
      required:
        - type
        - customerId
        - websiteId
        - items
      properties:
        id:
          type: string
          description: ID of the order.
          readOnly: true
          maxLength: 50
          example: ord_01HVKA5975PJBSQ1SX72G3MSZC
        type:
          type: string
          description: Type of the order.
          const: recurring
        organizationId:
          type: string
          description: |-
            Unique organization identifier.
            An organization is an entity that represents a company.
            For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
          maxLength: 50
          readOnly: true
          example: org_0YVDM8RC7GDADADSBSMW124JA8
        customerId:
          $ref: '#/components/schemas/CustomerId'
        websiteId:
          $ref: '#/components/schemas/WebsiteId'
        activationInvoiceId:
          type: string
          description: ID of the activation invoice.
          readOnly: true
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        recentInvoiceId:
          description: |-
            ID of the most recently issued invoice.
            The invoice might not be `paid` yet.
          readOnly: true
          type:
            - string
            - 'null'
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        status:
          description: Status of the order.
          type: string
          readOnly: true
          enum:
            - pending
            - active
            - canceled
            - churned
            - paused
            - voided
            - completed
            - trial-ended
            - abandoned
        inTrial:
          description: Specifies if the subscription is currently in a trial period.
          type: boolean
          readOnly: true
        trial:
          type: object
          description: |-
            Details of the trial.
            To use plan defaults, omit the `trial` key or set this value to `null`.
          properties:
            enabled:
              description: |-
                Specifies if there is a trial for this order.
                Plans without trial prices are free trials.
                If the order is active, all order items are in a trial, and `isTrialOnly` is `false`, setting this value to `false` ends the trial immediately.
                If the request that sets this value to `false` also changes `currentPeriodEnd`, the order renews at that time.
                If the request does not change `currentPeriodEnd`, the order renews immediately.
                In the response, this field remains `true`, and `endTime` contains the date and time when the trial ended.
                If only some items of an active order are in a trial, changing this value from `true` to `false` returns a 409 error.
              type: boolean
            endTime:
              description: |-
                Time and date when the trial ends.
                If the order churns during the trial, this value is the time when the order churned.
                If a trial is enabled on this subscription, a value must be provided.

                If the specified trial end time is in the past, the current time is used.
              type:
                - string
                - 'null'
              format: date-time
        isTrialOnly:
          description: |-
            Specifies if a subscription ends after a trial period.
            If this value is `true`, recurring settings are ignored.
          type: boolean
          default: false
        trialConversionTime:
          description: |-
            Date and time when the subscription had a trial conversion.
            Trial conversion occurs when the first successful payment is made after a trial period.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        items:
          type: array
          minItems: 1
          description: Item in the order.
          items:
            type: object
            discriminator:
              propertyName: type
              mapping:
                one-time-sale: '#/components/schemas/OneTimeSaleItem'
                subscription: '#/components/schemas/SubscriptionItem'
            oneOf:
              - $ref: '#/components/schemas/SubscriptionItem'
              - $ref: '#/components/schemas/OneTimeSaleItem'
        invoiceIssueTimeShift:
          description: |-
            Invoice issue time shift interval in ISO-8601 format.

            This field adjusts the issue date and time of renewal invoices for the order.

            This interval value supports the `-` symbol.
          type: string
          default: +P00Y00M00DT00H00M00S
          example: +P00Y00M00DT00H00M00S
        invoiceDueTimeShift:
          description: |-
            Invoice due time shift interval in ISO-8601 format.

            Use this field to adjust when payment is due for the order.
            If autopay is configured, payment is collected automatically on this date.

            This interval value supports the `+` symbol.
          type: string
          default: +P00Y00M00DT00H00M00S
          example: +P00Y00M00DT00H00M00S
        paymentInstrumentId:
          type:
            - string
            - 'null'
          description: |-
            ID of the payment instrument to use for autopay.
            If this value is not provided, or if the payment instrument is inactive,
            the customer's default payment instrument is used.
          maxLength: 50
          example: inst_0YVB8KPKNXCBR9EDX7JHSED75N
        poNumber:
          description: Purchase order number that is displayed on the issued invoices.
          type:
            - string
            - 'null'
          example: PO123456
        sandboxRetention:
          $ref: '#/components/schemas/SandboxRetention'
        notes:
          description: Notes for the customer that are displayed on the order invoice.
          type: string
        billingAddress:
          description: |-
            Billing address of the order.
            Changes to the billing address apply to the upcoming invoice and to invoices created after the change.
            Issued invoices are not updated unless the order is `pending`.
            To change the billing address on an issued invoice that has no payment attempts or applied credits, use the [upsert an invoice API operation](https://www.rebilly.com/catalog/all/invoices/putinvoice#invoices/putinvoice/t=request&path=billingaddress).
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        deliveryAddress:
          description: |-
            Delivery address of the order.
            Changes to the delivery address apply to the upcoming invoice and to invoices created after the change.
            Issued invoices are not updated unless the order is `pending`.
            To change the delivery address on an unpaid, past-due, or partially paid invoice, use the [upsert an invoice API operation](https://www.rebilly.com/catalog/all/invoices/putinvoice#invoices/putinvoice/t=request&path=deliveryaddress).
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        delinquencyPeriod:
          type:
            - string
            - 'null'
          description: |-
            Length of time, in ISO-8601 durations format,
            which is added to the due time of the order when setting the delinquency time for all related invoices.
            When the delinquency time of an invoice is reached, the order is automatically canceled.

            If the provided value is `null`, the order does not change state.
          example: +P00Y00M07DT00H00M00S
          default: null
        couponIds:
          type:
            - array
            - 'null'
          description: |-
            List of coupons to redeem on the customer and restrict to this order.

            For more information, see [Coupons](https://www.rebilly.com/docs/settings/coupons-and-discounts/).

            This parameter uses the following logic:

            - If this parameter is not supplied, applied coupons are not changed.
            - If an empty array is supplied, all applied coupon redemptions are canceled.
            - If a list of coupons is supplied, unapplied coupons in the list are applied.
              Coupons that have already been applied do not change state.
              Applied coupons that are not supplied in list are canceled.

            If the list of applied coupons on a pending order is changed by this parameter during an order update, the invoice for the order is reissued.
          writeOnly: true
          items:
            type: string
            description: ID of the coupon.
        riskMetadata:
          description: |-
            Risk metadata.
            If this value is `null`, this field uses risk metadata that is captured when creating the payment token.
          oneOf:
            - $ref: '#/components/schemas/RiskMetadata'
            - type: 'null'
        startTime:
          description: |-
            Date and time when the subscription starts.
            If this value is `null`, the current time is used.
            This value cannot be more than one service period in the past.
          type:
            - string
            - 'null'
          x-sortable: true
          x-basic: true
          example: null
          default: null
          format: date-time
        activationTime:
          description: Date and time when the order is activated.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        currency:
          description: Currency of the order.
          readOnly: true
          $ref: '#/components/schemas/CurrencyCode'
        shipping:
          description: |-
            Shipping settings of the order.
            Changes to shipping apply to the upcoming invoice and to invoices created after the change.
            Issued invoices are not updated unless the order is `pending`.
            To change shipping on an unpaid, past-due, or partially paid invoice, use the [upsert an invoice API operation](https://www.rebilly.com/catalog/all/invoices/putinvoice#invoices/putinvoice/t=request&path=shipping).
          $ref: '#/components/schemas/Shipping'
        autopay:
          description: |-
            Specifies if payment attempts are made automatically.
            If autopay is enabled, the payment is retrieved from the customer on the renewal date using the payment instrument that is set at `paymentInstrumentId`,
            or the default payment instrument on the order.
          type: boolean
          default: true
        abandonTime:
          type:
            - string
            - 'null'
          description: |-
            Date and time when the pending order is automatically abandoned.
            If this value is not passed during order creation,
            a [pending order TTL](https://www.rebilly.com/catalog/all/organizations/patchorganization/#!t=request&path=settings/billing/pendingOrderTtl) setting is used to calculate the value.
          format: date-time
        abandonReminderTime:
          description: Date and time when the abandon order reminder event triggers.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        abandonReminderNumber:
          description: Number of abandon order reminder events that are triggered.
          type:
            - integer
            - 'null'
          readOnly: true
        voidTime:
          description: Date and time when the order is voided.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        churnTime:
          description: Date and time when the order is deactivated.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        cancellationTime:
          description: Date and time when an order is canceled.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        canceledBy:
          description: Specifies who initiated the cancellation.
          type:
            - string
            - 'null'
          readOnly: true
          enum:
            - merchant
            - customer
            - rebilly
            - null
        cancelCategory:
          description: |-
            Category of the cancellation.

            The `sandbox-retention` value is set only in the sandbox environment when a recurring order is canceled 90 days after creation.
          type:
            - string
            - 'null'
          readOnly: true
          enum:
            - billing-failure
            - did-not-use
            - did-not-want
            - missing-features
            - bugs-or-problems
            - do-not-remember
            - risk-warning
            - contract-expired
            - too-expensive
            - never-started
            - switched-plan
            - organization-deactivated
            - delinquency
            - sandbox-retention
            - other
            - null
        cancelDescription:
          description: Description of the cancellation reason in free form.
          type:
            - string
            - 'null'
          readOnly: true
          maxLength: 255
        billingPortalToken:
          description: |-
            Customer JWT to access a billing portal.
            This field is presented only if a billing portal exists.
            This is an experimental field and can be changed or removed in the future.
          type:
            - string
            - 'null'
          readOnly: true
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        lineItems:
          description: Order line items that queue until the next renewal, or interim, invoice is issued for the order.
          readOnly: true
          type: array
          items:
            type: object
            description: Invoice line item.
            properties:
              type:
                description: Type of invoice line item.
                type: string
                enum:
                  - debit
                  - credit
              description:
                description: Description of the line item.
                type: string
                maxLength: 1000
              unitPriceAmount:
                description: Unit price of the line item.
                type: number
                format: double
                example: 49.95
              unitPriceCurrency:
                $ref: '#/components/schemas/CurrencyCode'
              quantity:
                description: Quantity of the line item.
                type: integer
                example: 1
              periodStartTime:
                description: Date and time when the service period begins for this item.
                type: string
                format: date-time
              periodEndTime:
                description: Date and time when the service period ends for this item.
                type: string
                format: date-time
              createdTime:
                $ref: '#/components/schemas/CreatedTime'
              updatedTime:
                $ref: '#/components/schemas/UpdatedTime'
        lineItemSubtotal:
          type: object
          readOnly: true
          description: |-
            Subtotal of line items in this order (signed value).
            If credits exceed debits, this value is a negative number.
          properties:
            currency:
              $ref: '#/components/schemas/CurrencyCode'
            amount:
              type: number
              x-type: Money
              x-sortable: true
              description: Amount of the subtotal.
              format: double
              example: 49.95
        mrr:
          description: Monthly recurring revenue of the order.
          type: number
          x-type: Money
          x-sortable: true
          format: double
          readOnly: true
          example: 49.95
        revision:
          description: |-
            Number of times the order data has been modified.

            The revision is useful when analyzing webhook data to determine if the
            change takes precedence over the current representation.
          type: integer
          readOnly: true
        currentPeriodStart:
          description: Date and time of the current service period start.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        currentPeriodEnd:
          description: |-
            Date and time of the current service period end.
            If subscriptions have different recurring settings or the order is not active, providing this field causes the request to be rejected with a conflict.
            This field is ignored if the order is in trial, unless the same request sets `trial.enabled` to `false`.
          type:
            - string
            - 'null'
          format: date-time
        renewalTime:
          description: Date and time when the next subscription in this recurring order renews.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        isNewOrder:
          description: Specifies if the order is a new order.
          type: boolean
          readOnly: true
          example: true
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          $ref: '#/components/schemas/SelfLink'
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            customer:
              $ref: '#/components/schemas/Customer'
            activationInvoice:
              $ref: '#/components/schemas/Invoice'
            recentInvoice:
              $ref: '#/components/schemas/Invoice'
            upcomingInvoice:
              $ref: '#/components/schemas/OrderUpcomingInvoice'
            paymentInstrument:
              $ref: '#/components/schemas/PaymentInstrument'
            website:
              $ref: '#/components/schemas/Website'
    OneTimeOrder:
      type: object
      required:
        - type
        - customerId
        - websiteId
        - items
      properties:
        id:
          type: string
          description: ID of the order.
          readOnly: true
          maxLength: 50
          example: ord_01HVKA5975PJBSQ1SX72G3MSZC
        type:
          type: string
          description: Type of the order.
          const: one-time
        organizationId:
          type: string
          description: |-
            Unique organization identifier.
            An organization is an entity that represents a company.
            For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
          maxLength: 50
          readOnly: true
          example: org_0YVDM8RC7GDADADSBSMW124JA8
        customerId:
          $ref: '#/components/schemas/CustomerId'
        websiteId:
          $ref: '#/components/schemas/WebsiteId'
        activationInvoiceId:
          type: string
          description: ID of the activation invoice.
          readOnly: true
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        recentInvoiceId:
          description: |-
            ID of the most recently issued invoice.
            The invoice might not be `paid` yet.
          readOnly: true
          type:
            - string
            - 'null'
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        status:
          description: Status of the order.
          type: string
          readOnly: true
          enum:
            - pending
            - voided
            - completed
            - abandoned
        items:
          type: array
          minItems: 1
          description: Item in the order.
          items:
            $ref: '#/components/schemas/OneTimeSaleItem'
        poNumber:
          description: Purchase order number that is displayed on the issued invoices.
          type:
            - string
            - 'null'
          example: PO123456
        notes:
          description: Notes for the customer that are displayed on the order invoice.
          type: string
        billingAddress:
          description: Billing address of the order.
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        deliveryAddress:
          description: Delivery address of the order.
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        delinquencyPeriod:
          type:
            - string
            - 'null'
          description: |-
            Length of time, in ISO-8601 durations format,
            which is added to the due time of the order when setting the delinquency time for all related invoices.
            When the delinquency time of an invoice is reached, the order is automatically canceled.

            If the provided value is `null`, the order does not change state.
          example: +P00Y00M07DT00H00M00S
          default: null
        couponIds:
          type:
            - array
            - 'null'
          description: |-
            List of coupons to redeem on the customer and restrict to this order.

            For more information, see [Coupons](https://www.rebilly.com/docs/settings/coupons-and-discounts/).

            This parameter uses the following logic:

            - If this parameter is not supplied, applied coupons are not changed.
            - If an empty array is supplied, all applied coupon redemptions are canceled.
            - If a list of coupons is supplied, unapplied coupons in the list are applied.
              Coupons that have already been applied do not change state.
              Applied coupons that are not supplied in list are canceled.

            If the list of applied coupons on a pending order is changed by this parameter during an order update, the invoice for the order is reissued.
          writeOnly: true
          items:
            type: string
            description: ID of the coupon.
        riskMetadata:
          description: |-
            Risk metadata.
            If this value is `null`, this field uses risk metadata that is captured when creating the payment token.
          oneOf:
            - $ref: '#/components/schemas/RiskMetadata'
            - type: 'null'
        activationTime:
          description: Date and time when the order is activated.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        currency:
          description: Currency of the order.
          readOnly: true
          $ref: '#/components/schemas/CurrencyCode'
        shipping:
          $ref: '#/components/schemas/Shipping'
        abandonTime:
          type:
            - string
            - 'null'
          description: |-
            Date and time when the pending order is automatically abandoned.
            If this value is not passed during order creation,
            a [pending order TTL](https://www.rebilly.com/catalog/all/organizations/patchorganization/#!t=request&path=settings/billing/pendingOrderTtl) setting is used to calculate the value.
          format: date-time
        abandonReminderTime:
          description: Date and time when the abandon order reminder event triggers.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        abandonReminderNumber:
          description: Number of abandon order reminder events that are triggered.
          type:
            - integer
            - 'null'
          readOnly: true
        voidTime:
          description: Date and time when the order is voided.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        revision:
          description: |-
            Number of times the order data has been modified.

            The revision is useful when analyzing webhook data to determine if the
            change takes precedence over the current representation.
          type: integer
          readOnly: true
        isNewOrder:
          description: Specifies if the order is a new order.
          type: boolean
          readOnly: true
          example: true
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          $ref: '#/components/schemas/SelfLink'
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            customer:
              $ref: '#/components/schemas/Customer'
            activationInvoice:
              $ref: '#/components/schemas/Invoice'
            recentInvoice:
              $ref: '#/components/schemas/Invoice'
            upcomingInvoice:
              $ref: '#/components/schemas/OrderUpcomingInvoice'
            paymentInstrument:
              $ref: '#/components/schemas/PaymentInstrument'
            website:
              $ref: '#/components/schemas/Website'
    Order:
      type: object
      discriminator:
        propertyName: type
        mapping:
          recurring: '#/components/schemas/RecurringOrder'
          one-time: '#/components/schemas/OneTimeOrder'
      oneOf:
        - $ref: '#/components/schemas/RecurringOrder'
        - $ref: '#/components/schemas/OneTimeOrder'
    OrderChange:
      type: object
      description: |-
        Change to the items of a recurring order.
        A change with `applyAt` set to `now` replaces the items immediately.
        A change with `applyAt` set to `nextRenewal` records the new items and applies them at the next renewal.
        The current items remain until the next renewal, when the new items are applied and billed on the renewal invoice.

        This resource records changes made through this resource and changes created by a quote with `applyAt` set to `nextRenewal`.
        Changes made through the `POST /orders/{id}/change-items` operation or through a quote with `applyAt` set to `now` are not recorded.
        A change with `applyAt` set to `now` triggers the `order-change-created` and `order-change-applied` events and the item events of the order.
      required:
        - orderId
        - items
      properties:
        id:
          description: ID of the order change.
          type: string
          maxLength: 50
          readOnly: true
          example: ord_chg_0YV7DES3WPC5J8JD8QTVNZBZQ8
        orderId:
          description: ID of the order.
          type: string
          maxLength: 50
          example: ord_01HRF27SATGE4Z6PBJE6PD8328
        status:
          description: Status of the order change.
          type: string
          readOnly: true
          enum:
            - pending
            - applied
            - canceled
            - superseded
          x-enumDescriptions:
            pending: Scheduled to apply at the next renewal.
            applied: Items of the order are replaced.
            canceled: Canceled before the change is applied.
            superseded: Replaced by a later change for the same order.
        applyAt:
          description: |-
            Time when the new items are applied.

            - `now`: The items change immediately.
              `renewalPolicy`, `prorated`, and `effectiveTime` apply.
            - `nextRenewal`: The current items stay until the next renewal.
              The new items are billed on the next renewal invoice.
              `renewalPolicy`, `prorated`, and `effectiveTime` are not allowed.
              A later change for the same order supersedes the pending change.
              The pending change is locked when the next renewal invoice is issued.
              To remove a pending change, use the `DELETE /order-changes/{id}` operation.
              The new items must differ from the current items.
              One-time sale items that are already on the order remain.
              A one-time sale item cannot be added with `nextRenewal`.
          type: string
          enum:
            - now
            - nextRenewal
          default: now
        effectiveTime:
          description: |-
            Date and time when the change is applied.
            If `applyAt` is set to `now`, this value is the date from which the renewal time for `resetToRecurring` and the proration are calculated.
            If this field is omitted, this value defaults to the current time.
            If `applyAt` is set to `nextRenewal`, this value is read-only and equals the renewal time of the order.
          type: string
          format: date-time
        lockedTime:
          description: |-
            Date and time when the items of a pending change are billed.
            After this time, the change is locked and cannot be modified until the renewal.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        appliedTime:
          description: Date and time when the items of the order are replaced.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        quoteId:
          description: |-
            ID of the quote that is used to create the change.
            This value is `null` if the change is not created from a quote.
          type:
            - string
            - 'null'
          maxLength: 50
          readOnly: true
        items:
          description: |-
            New items for the order.
            To remove an item, include the items array and exclude the items you want to remove.
          type: array
          minItems: 1
          items:
            type: object
            required:
              - plan
            properties:
              plan:
                description: Plan details.
                oneOf:
                  - $ref: '#/components/schemas/OriginalPlan'
                  - $ref: '#/components/schemas/FlexiblePlan'
              quantity:
                description: Number of units of the product on the specified plan.
                type: integer
              usageLimits:
                oneOf:
                  - $ref: '#/components/schemas/UsageLimits'
                  - type: 'null'
              excludeFromMrr:
                description: Specifies if this item is excluded from monthly recurring revenue calculations.
                type:
                  - boolean
                  - 'null'
        renewalPolicy:
          description: |-
            How the service periods and trial state of the order are managed when its items change now.
            Required when `applyAt` is `now`.
            Not allowed when `applyAt` is `nextRenewal`.
          type: string
          enum:
            - resetToRecurring
            - retainRecurring
            - retainTrialThenRecurring
            - retainTrialOnly
          x-enumDescriptions:
            resetToRecurring: Resets the service periods, ends any trial, and converts trial-only items to recurring.
            retainRecurring: Retains the current service periods, ends any trial, and converts trial-only items to recurring.
            retainTrialThenRecurring: |-
              Retains the trial until it ends, then converts the item to recurring.
              Returns a validation error if the order has no trial.
            retainTrialOnly: |-
              Retains the trial and keeps the item as trial-only.
              Returns a validation error if the order is not trial-only.
        prorated:
          description: |-
            Specifies whether to give a pro rata credit for the amount of time remaining between the `effectiveTime` and the end of the current period.
            Required when `applyAt` is `now`.
            Not allowed when `applyAt` is `nextRenewal`.

            If `renewalTime` is retained by setting `renewalPolicy` to `retainRecurring`, `retainTrialThenRecurring`, or `retainTrialOnly`,
            a pro rata debit is also applied for the time between `effectiveTime` and `renewalTime`, as a percentage of the normal period size.
          type: boolean
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          $ref: '#/components/schemas/SelfLink'
  requestBodies:
    OrderAndOrderChange:
      content:
        application/json:
          schema:
            properties:
              orderId:
                type: string
                description: ID of the order.
                example: ord_01HRF27SATGE4Z6PBJE6PD8328
              orderChangeId:
                type: string
                description: ID of the order change.
                example: ord_chg_0YV7DES3WPC5J8JD8QTVNZBZQ8
              eventType:
                type: string
                description: Type of event that triggered the webhook.
                enum:
                  - order-change-created
                  - order-change-canceled
                  - order-change-applied
              _embedded:
                type: object
                description: Embedded objects related to the order change event.
                properties:
                  order:
                    $ref: '#/components/schemas/Order'
                  orderChange:
                    $ref: '#/components/schemas/OrderChange'
              _links:
                type: array
                description: Links to related resources.
                items:
                  type: object
                  properties:
                    href:
                      description: URL of the link.
                      type: string
                    rel:
                      description: Relationship type of the link.
                      type: string
                      enum:
                        - order
                        - orderChange
      description: Payload of a webhook event related to an order change.
```
