# Change subscription order items

`POST /subscriptions/{id}/change-items`

> This is a subset of the full specification, limited to the `POST /subscriptions/{id}/change-items` 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 /subscriptions/{id}/change-items` 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 (legacy)
    description: |-
      Use these operations to manage customer orders.

      This is the legacy order model.
      If you are new to Rebilly, use [these order operations](#tag/orders).
      Organizations that use the current order model cannot create legacy orders.
      For these organizations, the operations that create a legacy order return a validation error.

      For information on the legacy order model, and how to upgrade to the current order model, see [Legacy orders model](https://www.rebilly.com/docs/glossary#legacy-orders-model).

      An order is a customer's request to purchase items.
      It can contain subscription and one-time sale items.
      When an order contains one or more subscription items, it is a subscription order.

      An order generates an invoice.
      A subscription order generates an invoice for each service period.
      For more information, see [Orders](https://www.rebilly.com/docs/dev-docs/concepts/#orders).
x-tagGroups:
  - name: Orders & Invoices
    tags:
      - Orders (legacy)
paths:
  /subscriptions/{id}/change-items:
    parameters:
      - $ref: '#/components/parameters/resourceId'
    post:
      x-products:
        - Core
      tags:
        - Orders (legacy)
      summary: Change subscription order items
      operationId: PostSubscriptionItemsChange
      x-sdk-operation-name: changeItems
      parameters:
        - $ref: '#/components/parameters/subscriptionExpand'
      description: |-
        Changes the items or quantities of an order that contains subscription items and specifies if and when to give pro rata credits.
        To change the items at the next renewal, use the `POST /order-changes` operation with `applyAt` set to `nextRenewal`.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscriptionChange'
        description: Change items request.
        required: true
      responses:
        '201':
          description: Order changed.
          headers:
            Location:
              $ref: '#/components/headers/Location'
            Rate-Limit-Limit:
              $ref: '#/components/headers/Rate-Limit-Limit'
            Rate-Limit-Remaining:
              $ref: '#/components/headers/Rate-Limit-Remaining'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionOrOneTimeSale'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Change to the order items rejected.
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
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
  parameters:
    resourceId:
      name: id
      in: path
      description: ID of the resource.
      required: true
      schema:
        type: string
        maxLength: 50
        pattern: ^[@~\-\.\w]+$
    subscriptionExpand:
      name: expand
      in: query
      description: |-
        Expand a response to receive a full related object in the `_embedded` path.

        To expand multiple objects, use a comma-separated list.
        Example: `expand=recentInvoice,initialInvoice`.

        Available arguments are:

          - `customer`
          - `leadSource`
          - `website`
          - `shippingRate`
          - `initialInvoice`
          - `recentInvoice`
          - `upcomingInvoice`
          - `paymentInstrument`

        For more information, see [Embedded resources](https://www.rebilly.com/docs/dev-docs/expand-embedded-resources).
      schema:
        type: string
  headers:
    Location:
      description: Location of the related resource.
      schema:
        type: string
        format: uri
      example: https://api.rebilly.com/example
    Rate-Limit-Limit:
      description: |-
        Maximum number of requests available at one time for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 500
    Rate-Limit-Remaining:
      description: |-
        Number of requests still available for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 499
    Rate-Limit-Retry-After:
      description: Number of seconds to wait before retrying the request.
      schema:
        type: integer
      example: 1
  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
    ResourceId:
      type: string
      description: Unique resource ID.
      maxLength: 50
      example: 4f6cf35x-2c4y-483z-a0a9-158621f77a21
    BaseProblem:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    Unauthorized:
      allOf:
        - title: Unauthorized
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 401
              maximum: 401
        - $ref: '#/components/schemas/BaseProblem'
    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
      example: org_0YVDM8RC7GDADADSBSMW124JA8
    Forbidden:
      allOf:
        - title: Forbidden
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 403
              maximum: 403
            error:
              type: string
              description: |-
                Message that describes why the request is forbidden.
                Most responses use a descriptive message, such as `Not allowed to change security settings`.
                If the organization requires multi-factor authentication (MFA) and MFA verification has not been completed for the session, this value is `mfa_required`.
                If MFA verification has not been completed for the session and the operation requires a confirmed session, this value is `mfa_required_for_caller`.
                This includes turning on `requireMfa` and resetting MFA for a user.
                If the organization restricts access to a list of IP addresses and the request comes from an IP address that is not in the list, this value is `ip_not_allowed`.
            organizationId:
              description: |-
                ID of the organization that requires MFA or does not allow the IP address of the request.
                This property is present only if `error` is `mfa_required` or `ip_not_allowed`.
                The organization is the organization of the request or another organization that the request acts on.
              $ref: '#/components/schemas/OrganizationId'
        - $ref: '#/components/schemas/BaseProblem'
    NotFound:
      allOf:
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 404
              maximum: 404
        - $ref: '#/components/schemas/BaseProblem'
    InvalidFields:
      type: array
      description: Invalid field details.
      items:
        type: object
        properties:
          field:
            type: string
            description: |-
              Name of the field.
              Dot notation is used for nested object field names.
          message:
            description: Message field.
            type: string
      example:
        - field: field1
          message: field1 is invalid
        - field: subObject.field2
          message: field2 is invalid
        - field: subObject.field2
          message: another error in the field2
    ValidationError:
      allOf:
        - title: Validation error
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 422
              maximum: 422
        - $ref: '#/components/schemas/BaseProblem'
        - type: object
          properties:
            invalidFields:
              $ref: '#/components/schemas/InvalidFields'
    TooManyRequests:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
          example: about:blank
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
          example: Rate Limit Exceeded
        status:
          type: integer
          description: HTTP status code.
          minimum: 429
          maximum: 429
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
          example: A request cannot be executed because the user has sent too many requests within a certain period of time
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    Conflict:
      allOf:
        - title: Conflict
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 409
              maximum: 409
        - $ref: '#/components/schemas/BaseProblem'
    CustomerId:
      type: string
      description: ID of the customer resource.
      maxLength: 50
      example: cus_0YV7DDSDD1C8DA64KHH2W33CPF
      x-basic: true
    CurrencyCode:
      type: string
      description: Currency code in ISO 4217 format.
      minLength: 3
      maxLength: 3
      example: USD
      x-label: Currency
    WebsiteId:
      type: string
      description: |-
        ID of the website.
        A website is where an organization obtains a customer.
        For more information, see [Obtain an organization ID and website ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
      maxLength: 50
      example: web_0YV7DE4Z26DQSA1AC92FBJ7SEG
    ResourceCustomFields:
      description: |-
        Use custom fields to extend a resource scheme to include custom data that is not provided as a common field.
        For more information, see [Custom fields](https://www.rebilly.com/catalog/all/custom-fields).
      type: object
      default: {}
      example:
        foo: bar
    ContactObject:
      type: object
      description: Contact's information.
      properties:
        firstName:
          description: Contact's first name.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 45
          example: Benjamin
        lastName:
          description: Contact's last name.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 45
          example: Franklin
        organization:
          description: Contact's organization.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 255
          example: Rebilly
        address:
          description: First line of the contact's street address.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 60
          example: 36 Craven St
        address2:
          description: Second line of the contact's street address.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 60
        city:
          description: Contact's city of residence.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 45
          example: Austin
        region:
          description: Contact's region of residence.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 45
          example: Texas
        country:
          description: |-
            Contact's country of residence in ISO 3166 alpha-2 country code.
            For examples, see [ISO.org](https://www.iso.org/obp/ui/#search/code/).
          type:
            - string
            - 'null'
          pattern: ^[A-Z]{2}$
          maxLength: 2
          example: GB
        postalCode:
          description: Contact's postal code.
          type:
            - string
            - 'null'
          pattern: ^[\w\s\-]+$
          maxLength: 10
          example: WC2N 5NF
        phoneNumbers:
          $ref: '#/components/schemas/ContactPhoneNumbers'
        emails:
          $ref: '#/components/schemas/ContactEmails'
        dob:
          description: Contact's date of birth in ISO-8601 `YYYY-MM-DD` format.
          type:
            - string
            - 'null'
          format: date
          example: '1980-04-01'
        jobTitle:
          description: Contact's job title.
          type:
            - string
            - 'null'
          pattern: ^[\u0000-\uFFFF]+$
          maxLength: 255
          example: CEO
        hash:
          description: |-
            Hash value for the contact.
            Use this value to compare contacts for identical attribute values.
          type: string
          maxLength: 40
          example: 056ae6d97c788b9e98b049ebafd7b229bf852221
          readOnly: true
    Shipping:
      description: Shipping settings.
      type: object
      discriminator:
        propertyName: calculator
        mapping:
          manual: '#/components/schemas/ManualShipping'
          rebilly: '#/components/schemas/RebillyShipping'
      oneOf:
        - $ref: '#/components/schemas/ManualShipping'
        - $ref: '#/components/schemas/RebillyShipping'
    RiskMetadata:
      type: object
      title: Risk metadata
      description: Risk metadata used for 3D Secure and risk scoring.
      properties:
        ipAddress:
          description: Customer's IP address.
          type:
            - string
            - 'null'
          format: ipv4 or ipv6
          example: 93.92.91.90
        fingerprint:
          description: |-
            Customer's device fingerprint.
            A device fingerprint is a unique token that is used to identify the customer.
            The device fingerprint is generated based on device attributes, such as: hardware,
            software, IP address, language, browser, and more.
          type:
            - string
            - 'null'
          maxLength: 50
          example: pIUt3xbgX3l9g3YDiLbx
        httpHeaders:
          oneOf:
            - $ref: '#/components/schemas/HttpHeaders'
            - type: 'null'
        browserData:
          type:
            - object
            - 'null'
          description: Browser data used for 3D Secure and risk scoring.
          required:
            - colorDepth
            - isJavaEnabled
            - language
            - screenWidth
            - screenHeight
            - timeZoneOffset
          properties:
            colorDepth:
              description: |-
                Browser color depth in bits per pixel.
                This value is obtained using the `screen.colorDepth` property.
              type: integer
              minimum: 1
              maximum: 48
              example: 24
            isJavaEnabled:
              description: |-
                Specifies if Java is enabled in a browser.
                This value is obtained from the `navigator.javaEnabled` property.
              type: boolean
            language:
              description: |-
                Browser language settings.
                This value is obtained from the `navigator.language` property.
              type: string
              example: en-US
              maxLength: 8
            screenWidth:
              description: |-
                Width of the browser screen.
                This value is obtained from the `screen.width` property.
              type: integer
              minimum: 0
              maximum: 65535
              example: 1920
            screenHeight:
              description: |-
                Height of the browser screen.
                This value is obtained from the `screen.height` property.
              type: integer
              minimum: 0
              maximum: 65535
              example: 1080
            timeZoneOffset:
              description: |-
                Browser time zone offset in minutes from UTC.
                A positive offset indicates that the local time is behind UTC.
                A negative offset indicates that the local time is ahead of UTC.
                You can find this value using the `(new Date()).getTimezoneOffset()` property.
              type: integer
              minimum: -1410
              maximum: 1410
              example: 300
            isAdBlockEnabled:
              description: Specifies if the usage of ad block has been detected in the browser.
              type:
                - boolean
                - 'null'
        extraData:
          type:
            - object
            - 'null'
          description: Third-party data used for risk scoring.
          properties:
            kountFraudSessionId:
              description: Alpha-numeric `fraudSessionId` as provided by the Kount SDK.
              type:
                - string
                - 'null'
              minLength: 10
              maxLength: 32
              example: abcdefg12345abababab123456789012
            payPalMerchantSessionId:
              description: PayPal `MerchantSessionID` as generated by the PayPal Fraudnet SDK.
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 64
              example: dd65ratxc5qv15iph3vyoq7l6davuowa
            threatMetrixSessionId:
              description: Temporary identifier that is unique to the visitor session and passed to ThreatMetrix.
              pattern: '[a-zA-Z0-9_-]+'
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 128
              example: dd65ratxc5qv15iph3vyoq7l6davuowadd65ratxc5qv15iph3vyoq7l6davuowa
        isProxy:
          description: Specifies if the customer's IP address is related to a proxy.
          type: boolean
          readOnly: true
        isVpn:
          description: Specifies if the customer's IP address is related to a VPN.
          type: boolean
          readOnly: true
        isTor:
          description: Specifies if the customer's IP address is related to TOR.
          type: boolean
          readOnly: true
        isHosting:
          description: Specifies if the customer's IP address is related to hosting.
          type: boolean
          readOnly: true
        hostingName:
          description: Name of the data center or hosting provider, if available.
          type:
            - string
            - 'null'
          readOnly: true
        isp:
          description: Internet Service Provider (ISP) name, if available.
          type:
            - string
            - 'null'
          readOnly: true
        country:
          description: Country ISO Alpha-2 code of the specified IP address.
          maxLength: 2
          type:
            - string
            - 'null'
          readOnly: true
          example: US
        region:
          description: Region of the specified IP address.
          type:
            - string
            - 'null'
          readOnly: true
          example: NY
        city:
          description: City of the specified IP address.
          type:
            - string
            - 'null'
          readOnly: true
          example: New York
        latitude:
          description: Latitude of the specified IP address.
          type:
            - number
            - 'null'
          format: double
          readOnly: true
        longitude:
          description: Longitude of the specified IP address.
          type:
            - number
            - 'null'
          format: double
          readOnly: true
        postalCode:
          description: Postal code of the specified IP address.
          type:
            - string
            - 'null'
          maxLength: 10
          readOnly: true
        timeZone:
          description: Time zone of the specified IP address.
          type:
            - string
            - 'null'
          readOnly: true
          example: America/New_York
        accuracyRadius:
          description: Accuracy radius of the specified IP address, in kilometers.
          type:
            - integer
            - 'null'
          readOnly: true
        distance:
          description: Distance between the customer's IP address and the billing address geolocation, in kilometers.
          type:
            - integer
            - 'null'
          readOnly: true
        hasMismatchedBillingAddressCountry:
          description: Specifies if the customer's billing address country and geo-IP address are not the same.
          type: boolean
          readOnly: true
        hasMismatchedBankCountry:
          description: Specifies if the customer's bank country and geo-IP address are not the same.
          type: boolean
          readOnly: true
        hasMismatchedTimeZone:
          description: Specifies if the customer's browser time zone and the IP address associated time zone are not the same.
          type: boolean
          readOnly: true
        hasMismatchedHolderName:
          description: Specifies if the customer's billing address name and primary address name are not the same.
          type: boolean
          readOnly: true
        hasFakeName:
          description: Specifies if the holder name seems fake.
          type: boolean
          readOnly: true
        isHighRiskCountry:
          description: Specifies if the geo-IP country, or the customer's billing country, is considered a high risk country.
          type: boolean
          readOnly: true
        paymentInstrumentVelocity:
          description: Number of transactions for this payment instrument, based on fingerprint, in the last 24 hours.
          type: integer
          readOnly: true
        declinedPaymentInstrumentVelocity:
          description: Number of declined transactions for this payment instrument fingerprint in the last 24 hours.
          type: integer
          readOnly: true
        deviceVelocity:
          description: Number of transactions for this device, based on fingerprint, in the last 24 hours.
          type: integer
          readOnly: true
        ipVelocity:
          description: Number of transactions for this IP address in the last 24 hours.
          type: integer
          readOnly: true
        emailVelocity:
          description: Number of transactions for this email address in the last 24 hours.
          type: integer
          readOnly: true
        billingAddressVelocity:
          description: Number of transactions for this billing address in the last 24 hours.
          type: integer
          readOnly: true
        paymentInstrumentApprovedTransactionCount:
          description: Number of approved transactions for this payment instrument.
          type: integer
          readOnly: true
        score:
          description: |-
            Computed risk score based on IP risk data,
            such as: `isVpn`, `isTor`, and `isProxy`.
          type: integer
          readOnly: true
    InvoiceTimeShift:
      type:
        - object
        - 'null'
      description: |-
        Use invoice time shift to control the billing time.

        Invoice time shift adjusts the invoice issue and due date when billing must occur before the service period changes.

        Use invoice time shift in conjunction with `billingTiming` to:

        - Bill immediately when the service period starts.
        - Bill immediately after the service period ends.
        - Bill at an interval of time before the service period starts.
        - Bill at an interval of time after the service period starts.
        - Bill at an interval of time before the service period ends.
        - Bill at an interval of time after the service period ends.
      properties:
        issueTimeShift:
          type: object
          description: |-
            Calculation instruction of the billing time.

            This is used in conjunction with the service period anchor to calculate
            the time at which the invoice is issued. For more information, see
            [Service period anchor, billing timing, and invoice time shift](https://www.rebilly.com/docs/dev-docs/subscriptions#service-period-anchor-billing-timing-and-invoice-time-shift).
          required:
            - chronology
            - duration
            - unit
          properties:
            chronology:
              type: string
              description: Sequential order of the billing time relative to the start of the service period.
              enum:
                - before
            duration:
              type: integer
              description: Amount of time by which to move the invoice issue time or date.
              minimum: 1
            unit:
              description: Unit of time.
              oneOf:
                - $ref: '#/components/schemas/TimeUnit'
                - $ref: '#/components/schemas/TimePluralUnit'
        dueTimeShift:
          type: object
          required:
            - duration
            - unit
          description: |-
            Calculation instruction of the invoice due time.

            This is used in conjunction with the service period anchor to calculate when
            an invoice is due for payment. For more information, see
            [Service period anchor, billing timing, and invoice time shift](https://www.rebilly.com/docs/dev-docs/subscriptions#service-period-anchor-billing-timing-and-invoice-time-shift).

            The sequential order of due time shift is always after the due date.
          default:
            duration: 1
            unit: hour
          properties:
            duration:
              type: integer
              description: Amount of time by which to move the invoice due time or date.
              minimum: 1
            unit:
              description: Unit of time.
              oneOf:
                - $ref: '#/components/schemas/TimeUnit'
                - $ref: '#/components/schemas/TimePluralUnit'
    SubscriptionPlan:
      title: SubscriptionPlan
      description: |-
        Details of the subscription order plan.
        Use this plan for subscriptions or sales that reoccur over a period of time.
      type: object
      required:
        - name
        - currency
        - productId
        - pricing
        - recurringInterval
      properties:
        type:
          type: string
          description: |-
            Variant of the plan.
            This field is optional in create and update requests.
            The variant is `subscription` when `recurringInterval` is present.
            If included, this field must match the applicable variant.
            A mismatch results in an HTTP `422` response.
            Responses always include this field.
          enum:
            - subscription
        name:
          description: |-
            Name of the plan.
            This name is displayed on invoices and receipts.
          type: string
          maxLength: 255
        description:
          type: string
          description: |-
            Plain-text description of the plan.
            This field accepts plain-text only.
          maxLength: 65535
        richDescription:
          type: string
          description: |-
            Rich-text description of the plan.
            This field accepts rich text formatting, such as: bold, underline, italic, and hyperlinks.
          maxLength: 65535
        productId:
          type: string
          description: ID of the related product.
          maxLength: 50
          example: prod_0YV7DES3WPC5J8JD8QTVNZBZNZ
        productOptions:
          type:
            - object
            - 'null'
          description: Name-value pairs that specify the product options.
          additionalProperties:
            type: string
          example:
            region: US
            size: xxl
        currency:
          $ref: '#/components/schemas/CurrencyCode'
        currencySign:
          description: Currency sign.
          readOnly: true
          type: string
        pricing:
          $ref: '#/components/schemas/PlanPriceFormula'
        setup:
          $ref: '#/components/schemas/PlanSetup'
        setupFee:
          $ref: '#/components/schemas/PlanSetupFee'
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        isActive:
          type: boolean
          description: Specifies if the plan is active.
          default: true
        revision:
          type: integer
          readOnly: true
          description: |-
            Number of times the plan is modified.
            Compare this value with materialized subscription item revision values.
        isTrialOnly:
          type: boolean
          const: false
          description: Specifies if a plan is a trial that does not have recurring instructions.
          readOnly: true
        recurringInterval:
          description: Service interval settings.
          type: object
          required:
            - unit
            - length
          properties:
            periodAnchorInstruction:
              $ref: '#/components/schemas/ServicePeriodAnchorInstruction'
            unit:
              description: Unit of time.
              type: string
              enum:
                - day
                - week
                - month
                - year
            length:
              description: Length of time.
              type: integer
              minimum: 1
            limit:
              description: |-
                Number of invoices the subscription order generates.
                If this value is `1`, only the initial order creation is generated.

                Example: For a 1 year contract that is billed monthly,
                where the `periodUnit` is `month` and the `periodDuration` is `1`,
                set this field to `12`.
              type:
                - integer
                - 'null'
              minimum: 1
              maximum: 65535
            billingTiming:
              type: string
              default: prepaid
              description: |-
                Billing timing in relation to the service period.
                For `prepaid` plans the customer pays when the service period starts,
                whereas, for `postpaid` plans, the customer pays when the service period ends.
              enum:
                - prepaid
                - postpaid
        trial:
          description: |-
            Trial configuration setting.
            If you do not want to offer a trial, set this value to `null`.
          $ref: '#/components/schemas/PlanTrial'
        meteredBilling:
          type:
            - object
            - 'null'
          required:
            - strategy
          description: |-
            Use metered billing when an exact quantity is unknown.
            Report usage during a service period and charge customers afterwards.
            Metered billing plans must be postpaid.
          properties:
            strategy:
              type: string
              enum:
                - sum
                - last
              x-enumDescriptions:
                sum: Total amount of reported invoice item quantity usage.
                last: Last reported invoice item quantity usage.
            min:
              description: Minimum quantity that is charged at the end of a service period regardless of reported usage.
              type:
                - number
                - 'null'
              format: float
              minimum: 0.01
            max:
              description: Maximum quantity that is charged at the end of a service period regardless of reported usage.
              type:
                - number
                - 'null'
              format: float
              minimum: 0.01
            sticky:
              description: |-
                When enabled, if no usage is reported during a service period,
                the plan bills the last known reported quantity from a previous period instead of zero.
                This is suitable for hosted or persistent resources with usage that does not change every period.
                Only supported with `strategy`: `last`.
              type: boolean
              default: false
              example: false
        invoiceTimeShift:
          readOnly: true
          deprecated: true
          $ref: '#/components/schemas/InvoiceTimeShift'
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          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
                  - attachments
    OneTimeSalePlan:
      title: OneTimeSalePlan
      type: object
      description: |-
        Details of the one-time sale plan.
        Use this plan for non-recurring, one-time, sales.
      required:
        - name
        - currency
        - productId
        - pricing
      properties:
        type:
          type: string
          description: |-
            Variant of the plan.
            This field is optional in create and update requests.
            The variant is `one-time-sale` when both `recurringInterval` and `trial` are omitted.
            If included, this field must match the applicable variant.
            A mismatch results in an HTTP `422` response.
            Responses always include this field.
          enum:
            - one-time-sale
        name:
          description: |-
            Name of the plan.
            This name is displayed on invoices and receipts.
          type: string
          maxLength: 255
        description:
          type: string
          description: |-
            Plain-text description of the plan.
            This field accepts plain-text only.
          maxLength: 65535
        richDescription:
          type: string
          description: |-
            Rich-text description of the plan.
            This field accepts rich text formatting, such as: bold, underline, italic, and hyperlinks.
          maxLength: 65535
        productId:
          type: string
          description: ID of the related product.
          maxLength: 50
          example: prod_0YV7DES3WPC5J8JD8QTVNZBZNZ
        productOptions:
          type:
            - object
            - 'null'
          description: Name-value pairs that specify the product options.
          additionalProperties:
            type: string
          example:
            region: US
            size: xxl
        currency:
          $ref: '#/components/schemas/CurrencyCode'
        currencySign:
          description: Currency sign.
          readOnly: true
          type: string
        pricing:
          $ref: '#/components/schemas/PlanPriceFormula'
        setup:
          $ref: '#/components/schemas/PlanSetup'
        setupFee:
          $ref: '#/components/schemas/PlanSetupFee'
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        isActive:
          type: boolean
          description: Specifies if the plan is active.
          default: true
        revision:
          type: integer
          readOnly: true
          description: |-
            Number of times the plan is modified.
            Compare this value with materialized subscription item revision values.
        isTrialOnly:
          type: boolean
          const: false
          description: Specifies if a plan is a trial that does not have recurring instructions.
          readOnly: true
        recurringInterval:
          type: 'null'
          description: Service interval settings.
          readOnly: true
        trial:
          type: 'null'
          description: Trial configuration setting.
          readOnly: true
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          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
                  - attachments
    TrialOnlyPlan:
      title: TrialOnlyPlan
      description: |-
        Details of the trial-only plan.
        Use this plan for limited-time product trials.
        Trials may have a reduced fee, or may be free.
      type: object
      required:
        - name
        - currency
        - productId
        - trial
      properties:
        type:
          type: string
          description: |-
            Variant of the plan.
            This field is optional in create and update requests.
            The variant is `trial-only` when `trial` is present without `recurringInterval`.
            If included, this field must match the applicable variant.
            A mismatch results in an HTTP `422` response.
            Responses always include this field.
          enum:
            - trial-only
        name:
          description: |-
            Name of the plan.
            This name is displayed on invoices and receipts.
          type: string
          maxLength: 255
        description:
          type: string
          description: |-
            Plain-text description of the plan.
            This field accepts plain-text only.
          maxLength: 65535
        richDescription:
          type: string
          description: |-
            Rich-text description of the plan.
            This field accepts rich text formatting, such as: bold, underline, italic, and hyperlinks.
          maxLength: 65535
        productId:
          type: string
          description: ID of the related product.
          maxLength: 50
          example: prod_0YV7DES3WPC5J8JD8QTVNZBZNZ
        productOptions:
          type:
            - object
            - 'null'
          description: Name-value pairs that specify the product options.
          additionalProperties:
            type: string
          example:
            region: US
            size: xxl
        currency:
          $ref: '#/components/schemas/CurrencyCode'
        currencySign:
          description: Currency sign.
          readOnly: true
          type: string
        setup:
          $ref: '#/components/schemas/PlanSetup'
        setupFee:
          $ref: '#/components/schemas/PlanSetupFee'
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        isActive:
          type: boolean
          description: Specifies if the plan is active.
          default: true
        revision:
          type: integer
          readOnly: true
          description: |-
            Number of times the plan is modified.
            Compare this value with materialized subscription item revision values.
        isTrialOnly:
          type: boolean
          const: true
          description: Specifies if a plan is a trial that does not have recurring instructions.
          readOnly: true
        recurringInterval:
          type: 'null'
          description: Service interval settings.
          readOnly: true
        trial:
          description: Trial configuration settings.
          allOf:
            - type: object
            - $ref: '#/components/schemas/PlanTrial'
        invoiceTimeShift:
          readOnly: true
          deprecated: true
          description: |-
            Use invoice time shift to adjust the invoice issue and due date when billing must occur before the service period changes.
            For example, rent must be paid in advance,
            so the invoice must be in advance of the billing date.
            For more information, see [Service period anchor, billing timing, and invoice time shift](https://www.rebilly.com/docs/dev-docs/subscriptions#service-period-anchor-billing-timing-and-invoice-time-shift).
          $ref: '#/components/schemas/InvoiceTimeShift'
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          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
                  - attachments
    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
    SandboxRetention:
      type:
        - object
        - 'null'
      description: |-
        Sandbox recurring order retention.
        In the sandbox environment, a recurring order is canceled 90 days after it is created or on the start date of the policy,
        whichever is later.
        The order is not canceled if it is retained or if the organization is excluded from the policy.
        This property is returned in the sandbox environment only, for recurring orders.
        In the live environment, if the request includes this property with a value, a validation error is returned.
        A `null` value in a request does not update the property.
      required:
        - excluded
      properties:
        autoCancelTime:
          description: |-
            Date and time of the automatic cancellation of the order: 90 days after the order is created or the start date of the policy,
            whichever is later.
            This value is `null` when the organization is excluded from the policy,
            and for an order that can no longer bill, such as a churned or abandoned order.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
          example: '2027-01-10T06:00:00+00:00'
        excluded:
          description: |-
            Specifies if the order is retained and not canceled on its `autoCancelTime`.
            An organization retains up to 50 recurring orders.
            If the request omits `sandboxRetention`, this value is not updated.
          type: boolean
          example: false
    SubscriptionOrOneTimeSaleItem:
      type: object
      required:
        - plan
      properties:
        id:
          type: string
          description: ID of the order item.
          readOnly: true
          maxLength: 50
        planId:
          description: |-
            ID of the plan.

            > **Note:** This field is deprecated. Use the `plan.id` field instead.
          deprecated: true
          x-basic: true
          type: string
          maxLength: 50
          example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
        quantity:
          description: Number of product units in the specified plan.
          type: integer
          minimum: 0
          maximum: 1000000000
        quantityFilled:
          description: Number of filled product units.
          type:
            - number
            - 'null'
          format: double
          example: 5.125
        plan:
          oneOf:
            - $ref: '#/components/schemas/OriginalPlan'
            - $ref: '#/components/schemas/FlexiblePlan'
        usageLimits:
          oneOf:
            - $ref: '#/components/schemas/UsageLimits'
            - type: 'null'
          default: null
        usageStatus:
          oneOf:
            - $ref: '#/components/schemas/UsageStatus'
            - type: 'null'
          default: null
        revision:
          type: integer
          readOnly: true
          description: Revision number that increments with each overriding change to this specific plan item.
        isModified:
          type: boolean
          readOnly: true
          description: Specifies if the plan information is modified for this subscription.
        isGrandfathered:
          type: boolean
          readOnly: true
          description: Specifies if the current plan revision number is greater than the plan item revision number.
        excludeFromMrr:
          type: boolean
          description: Specifies if this item should be excluded from monthly recurring revenue calculations.
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            product:
              type: object
    Subscription:
      type: object
      required:
        - orderType
        - customerId
        - websiteId
        - items
      properties:
        id:
          type: string
          description: ID of the order.
          readOnly: true
          maxLength: 50
          example: sub_01HRF27SATGE4Z6PBJE6PD8328
        orderType:
          description: |-
            Specifies the type of order.
            An order may be a subscription or a one-time purchase.

            > **Note:** The order type cannot be changed after creation.
          type: string
          x-basic: true
          enum:
            - subscription-order
        customerId:
          $ref: '#/components/schemas/CustomerId'
        renewalReminderTime:
          description: Date and time when the renewal reminder event triggers.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        renewalReminderNumber:
          description: Number of triggered renewal reminder events.
          type:
            - integer
            - 'null'
          readOnly: true
        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
        organizationId:
          readOnly: true
          allOf:
            - $ref: '#/components/schemas/OrganizationId'
        status:
          description: |-
            Status of the subscription service.
            A subscription starts in the `pending` status, and becomes `active` when the service period begins.
          type: string
          readOnly: true
          enum:
            - pending
            - active
            - abandoned
            - canceled
            - churned
            - paused
            - voided
            - completed
            - trial-ended
        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 `renewalTime`, the order renews at that time.
                If the request does not change `renewalTime`, 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
        invoiceTimeShift:
          description: |-
            Shifts issue time and due time of invoices for this subscription.

            This setting overrides plan settings.
            To use plan settings, set this value to `null`.

            To use multiple plans in one subscription,
            all plans must have the same billing period,
            this property enables the customer to subscribe to different plans.
          $ref: '#/components/schemas/InvoiceTimeShift'
        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 subscription.
          type: boolean
          default: true
        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
        churnTime:
          description: Date and time when the subscription is deactivated.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        renewalTime:
          description: |-
            Date and time when the subscription renews.
            If the order has no trial, the first service period ends at the date and time specified in the request that creates the order.
            If the order has a trial, the specified date and time are ignored, and the subscription renews when the trial ends.
            If the order is in a trial, the date and time specified in a request that updates the order are ignored, unless that request also sets `trial.enabled` to `false`.
          type:
            - string
            - 'null'
          x-sortable: true
          x-basic: true
          format: date-time
        currentPeriodStart:
          description: Date and time of the current service period start.
          type: string
          format: date-time
          readOnly: true
        currentPeriodEnd:
          description: Date and time of the current service period end.
          type: string
          format: date-time
          readOnly: true
        rebillNumber:
          description: Current billing period number.
          type:
            - integer
            - 'null'
          readOnly: true
          x-sortable: true
        lineItems:
          description: Subscription line items which queue until the next renewal, or interim, invoice is issued for the subscription.
          readOnly: true
          type: array
          deprecated: true
          items:
            type: object
            description: |-
              Invoice line item.
              Use the `isInterim` property of upcoming invoice items instead.
            deprecated: true
            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
          deprecated: true
          description: |-
            Subtotal of line items in this subscription (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
        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
        billingStatus:
          description: |-
            Billing status of the most recent invoice.
            This value is used to determine whether to change the service status of the service,
            such as suspending the service.
          type: string
          readOnly: true
          enum:
            - draft
            - unpaid
            - past-due
            - abandoned
            - paid
            - voided
            - refunded
            - disputed
            - partially-refunded
            - partially-paid
        websiteId:
          type: string
          description: |-
            ID of the website.
            A website is where an organization obtains a customer.
            For more information, see [Obtain an organization ID and website ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).

            > **Note:** The ID of the website cannot be changed after creation.
          maxLength: 50
          example: web_0YV7DE4Z26DQSA1AC92FBJ7SEG
          x-sortable: true
          x-basic: true
        currency:
          description: Currency of the order.
          readOnly: true
          $ref: '#/components/schemas/CurrencyCode'
        initialInvoiceId:
          description: ID of the initial invoice.
          readOnly: true
          type:
            - string
            - 'null'
          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
        items:
          description: Details of items in the order.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/SubscriptionOrOneTimeSaleItem'
        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'
        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'
        activationTime:
          description: Date and time when the order is activated.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        voidTime:
          description: Date and time when the order is voided.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: 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#organizations/patchorganization/t=request&path=settings/billing/pendingorderttl) setting is used to calculate the value.
          format: date-time
        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 `delinquencyPeriod` value is `null`, the order does not change state and remains active.
              You must explicitly configure the delinquency period to enable automatic cancellation of unpaid orders.
            - If you add a delinquency period to an active order, it is applied to all new invoices created for the order. It is not applied to the unpaid and past-due invoices. To apply a delinquency period to unpaid and past-due invoices, set the `delinquencyTime` parameter using the [upsert an invoice API operation](https://www.rebilly.com/catalog/all/invoices/putinvoice#invoices/putinvoice/t=request&path=delinquencytime).

            If this value is not passed during order creation,
            an [order delinquency period](https://www.rebilly.com/catalog/all/organizations/patchorganization#organizations/patchorganization/t=request&path=settings/billing/orderdelinquencyperiod) setting is used to calculate the value.
          example: P7D
          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.
        poNumber:
          description: Purchase order number displayed on the issued invoices.
          type:
            - string
            - 'null'
          example: PO123456
        sandboxRetention:
          $ref: '#/components/schemas/SandboxRetention'
        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'
        notes:
          description: Notes for the customer displayed on the order invoice.
          type: string
        canceledTime:
          description: Date and time when a subscription 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
            - delinquency
            - 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
            - sandbox-retention
            - other
            - null
        cancelDescription:
          description: Description of the cancellation reason in free form.
          type:
            - string
            - 'null'
          readOnly: true
          maxLength: 255
        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
        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'
        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'
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          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
                  - website
                  - customer
                  - initialInvoice
                  - recentInvoice
                  - approvalUrl
                  - attachments
                  - leadSource
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            recentInvoice:
              type: object
            initialInvoice:
              type: object
            customer:
              type: object
            website:
              type: object
            leadSource:
              type: object
            shippingRate:
              type: object
            paymentInstrument:
              type: object
            upcomingInvoice:
              type: object
    OneTimeSale:
      type: object
      required:
        - orderType
        - customerId
        - websiteId
        - items
      properties:
        id:
          type: string
          description: ID of the one-time sale.
          readOnly: true
          maxLength: 50
          example: ots_01HRF27SATGE4Z6PBJE6PD8328
        orderType:
          description: |-
            Specifies the type of order.
            An order may be a subscription or a one-time purchase.
          type: string
          x-basic: true
          enum:
            - one-time-order
        customerId:
          $ref: '#/components/schemas/CustomerId'
        organizationId:
          deprecated: true
          readOnly: true
          allOf:
            - $ref: '#/components/schemas/OrganizationId'
        status:
          description: Status of the one-time order.
          type: string
          readOnly: true
          enum:
            - pending
            - abandoned
            - completed
            - canceled
        billingStatus:
          description: |-
            Billing status of the most recent invoice.
            This value is used to determine whether to change the service status of the service,
            such as suspending the service.
          type: string
          readOnly: true
          enum:
            - draft
            - unpaid
            - past-due
            - abandoned
            - paid
            - voided
            - refunded
            - disputed
            - partially-refunded
            - partially-paid
        websiteId:
          x-sortable: true
          x-basic: true
          allOf:
            - $ref: '#/components/schemas/WebsiteId'
        currency:
          description: Currency of the order.
          readOnly: true
          $ref: '#/components/schemas/CurrencyCode'
        initialInvoiceId:
          description: ID of the initial invoice (`null` for one-time orders).
          readOnly: true
          type:
            - string
            - 'null'
          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
        items:
          description: Details of items in the order.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/SubscriptionOrOneTimeSaleItem'
        deliveryAddress:
          description: Delivery address of the order.
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        billingAddress:
          description: Billing address of the order.
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        activationTime:
          description: Date and time when the order is activated.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        voidTime:
          description: Date and time when the order is voided.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: 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#organizations/patchorganization/t=request&path=settings/billing/pendingorderttl) setting is used to calculate the value.
          format: date-time
        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.
        poNumber:
          description: Purchase order number displayed on the issued invoices.
          type:
            - string
            - 'null'
          example: PO123456
        shipping:
          $ref: '#/components/schemas/Shipping'
        notes:
          description: Notes for the customer displayed on the order invoice.
          type: string
        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
        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'
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          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
                  - website
                  - customer
                  - initialInvoice
                  - recentInvoice
                  - approvalUrl
                  - attachments
                  - leadSource
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            recentInvoice:
              type: object
            customer:
              type: object
            website:
              type: object
            leadSource:
              type: object
            shippingRate:
              type: object
            paymentInstrument:
              type: object
    SubscriptionOrOneTimeSale:
      type: object
      description: Subscription details.
      discriminator:
        propertyName: orderType
        mapping:
          subscription-order: '#/components/schemas/Subscription'
          one-time-order: '#/components/schemas/OneTimeSale'
      oneOf:
        - $ref: '#/components/schemas/Subscription'
        - $ref: '#/components/schemas/OneTimeSale'
    SubscriptionChange:
      type: object
      required:
        - items
        - renewalPolicy
        - prorated
      properties:
        items:
          description: Details of items in the order.
          type: array
          minItems: 1
          items:
            type: object
            description: |-
              New set of items for the subscription.
              To remove an item, include the items array and exclude the items you want to remove.
            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:
                $ref: '#/components/schemas/UsageLimits'
        renewalPolicy:
          description: |-
            How the service periods and trial state of the subscription order are managed when its items change.

            The `reset` and `retain` values are deprecated.
            The deprecated `keepTrial` and `ignoreRecurring` are ignored unless `reset` or `retain` is used.
          type: string
          enum:
            - resetToRecurring
            - retainRecurring
            - retainTrialThenRecurring
            - retainTrialOnly
            - reset
            - retain
          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.
            reset: |-
              Deprecated.
              Use `resetToRecurring` instead.
              Resets the `renewalTime` to a newly calculated value.
            retain: |-
              Deprecated.
              Use `retainRecurring`, `retainTrialThenRecurring`, or `retainTrialOnly` instead.
              Retains the current `renewalTime`.
        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.

            In addition, if the `renewalTime` is retained, by setting the `renewalPolicy` to `retainRecurring`, `retainTrialThenRecurring` or `retainTrialOnly`,
            a pro rata debit occurs for the amount between the `effectiveTime` and the `renewalTime` as a percentage of the normal period size.
          type: boolean
        effectiveTime:
          description: |-
            Date from which the renewal time for `reset` operations and proration calculations are made.
            If this field is omitted, this value defaults to the current time.
          type: string
          format: date-time
        preview:
          description: |-
            Specifies if changes to the subscription can be previewed.
            Subscriptions cannot be changed in preview.
          type: boolean
          default: false
        keepTrial:
          deprecated: true
          description: |-
            Deprecated.
            Use the `retainTrialThenRecurring` or `retainTrialOnly` value of `renewalPolicy` instead.

            Specifies if the active trial of the order is retained.
            This field is only applicable if `renewalPolicy` is set to the deprecated value `retain`.
          type: boolean
          default: false
        ignoreRecurring:
          deprecated: true
          description: |-
            Deprecated.
            Use the `retainTrialOnly` value of `renewalPolicy` instead.

            Specifies if the order must ignore the recurring settings of its items.
            This field is only applicable if the order is trial-only and the `keepTrial` value is `true`.
            For more information, see [Trial-only order](https://www.rebilly.com/docs/dev-docs/subscriptions#trial-only-subscription).
          type: boolean
          default: false
  responses:
    Unauthorized:
      description: |-
        Unauthorized access.
        Invalid credentials used.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
    Forbidden:
      description: |-
        Access forbidden.
        If the organization requires multi-factor authentication (MFA) and the session has not passed MFA, `error` is `mfa_required`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Forbidden'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NotFound'
    ValidationError:
      description: Invalid data sent.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    TooManyRequests:
      description: Request rate limit exceeded.
      headers:
        Rate-Limit-Limit:
          $ref: '#/components/headers/Rate-Limit-Limit'
        Rate-Limit-Remaining:
          description: |-
            Number of requests still available for this rate limit.
            For more information, see [Rate limits](#section/Rate-limits).
          schema:
            type: integer
          example: 0
        Rate-Limit-Retry-After:
          $ref: '#/components/headers/Rate-Limit-Retry-After'
        Retry-After:
          description: Number of seconds to wait before retrying the request.
          schema:
            type: integer
          example: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TooManyRequests'
    Conflict:
      description: Conflict.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Conflict'
```
