# Preview an order

`POST /previews/orders`

> This is a subset of the full specification, limited to the `POST /previews/orders` 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 /previews/orders` 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:
  /previews/orders:
    post:
      x-products:
        - Core
      tags:
        - Orders (legacy)
      summary: Preview an order
      operationId: PostPreviewOrder
      x-sdk-operation-name: order
      description: |-
        Previews an order.
        Use this operation to preview a draft order before making an order.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderPreview'
      responses:
        '200':
          description: Order preview retrieved.
          headers:
            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/OrderPreview'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '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
  headers:
    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:
    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'
    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.
    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
    ContactPhoneNumbers:
      description: List of phone numbers associated with the contact.
      type: array
      items:
        type: object
        required:
          - label
          - value
        properties:
          label:
            description: Phone number label or name.
            type: string
            maxLength: 45
            example: main
          value:
            description: Phone number value.
            type: string
            minLength: 1
            maxLength: 50
            example: 1-512-777-0269
          primary:
            description: Specifies if the phone number is the contact's primary phone number.
            type: boolean
            example: true
    ContactEmails:
      description: List of email addresses associated with the contact.
      type: array
      items:
        type: object
        required:
          - label
          - value
        properties:
          label:
            description: Email label or name.
            type: string
            maxLength: 45
            example: main
          value:
            description: Email address value.
            type: string
            format: email
            maxLength: 255
            example: rebilly@example.com
          primary:
            description: Specifies if the email address is the contact's primary email address.
            type: boolean
            example: true
    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
    ManualShipping:
      description: Manually set shipping amount.
      type: object
      required:
        - amount
        - calculator
      properties:
        amount:
          x-type: Money
          type: number
          format: double
          description: Shipping amount.
        calculator:
          description: Shipping calculator.
          type: string
          enum:
            - manual
    RebillyShipping:
      description: Rebilly-based shipping which is calculated by shipping rates.
      type: object
      required:
        - calculator
      properties:
        calculator:
          description: Shipping calculator.
          type: string
          enum:
            - rebilly
        rateId:
          description: |-
            ID of the shipping rate.
            If this value is not set,
            the cheapest applicable shipping rate is used.
          type:
            - string
            - 'null'
          maxLength: 50
          example: shipping-123-456
        amount:
          type: number
          format: double
          readOnly: true
          description: Shipping amount which is calculated from [Shipping rates](https://www.rebilly.com/catalog/all/shipping-rates).
    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'
    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'
    ShippingOption:
      type: object
      required:
        - name
        - price
        - currency
      properties:
        id:
          type: string
          description: ID of the shipping rate.
          readOnly: true
          maxLength: 50
          example: ship_rate_0YVDN408G4DQE9G1RV1QCFHJ3P
        name:
          type: string
          description: Name of the shipping rate.
        description:
          type:
            - string
            - 'null'
          description: Description of the shipping rate.
        price:
          description: |-
            Price of the shipping rate.
            If `price` is `0`, shipping is free.
          type: number
          format: double
        currency:
          $ref: '#/components/schemas/CurrencyCode'
    OrderPreview:
      type: object
      required:
        - websiteId
        - items
      properties:
        websiteId:
          writeOnly: true
          allOf:
            - $ref: '#/components/schemas/WebsiteId'
        items:
          description: Items details.
          type: array
          writeOnly: true
          minItems: 1
          items:
            type: object
            required:
              - quantity
            properties:
              planId:
                type: string
                description: |-
                  ID of the plan.
                  Either this field or the `plan` object must be provided.
                  Use `plan.id` instead.
                maxLength: 50
                example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
                deprecated: true
              plan:
                description: |-
                  Details of the plan.
                  Either this object or the deprecated `planId` field must be provided.
                oneOf:
                  - $ref: '#/components/schemas/OriginalPlan'
                  - $ref: '#/components/schemas/FlexiblePlan'
              quantity:
                description: Number of product units in the specified plan.
                type: integer
                minimum: 0
                maximum: 1000000000
            oneOf:
              - required:
                  - plan
                properties:
                  planId:
                    not: {}
              - required:
                  - planId
                properties:
                  plan:
                    not: {}
              - required:
                  - plan
                  - planId
        billingAddress:
          description: Billing address details.
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        deliveryAddress:
          description: Delivery address details.
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        couponIds:
          type: array
          writeOnly: true
          description: List of coupons that are applied to the order.
          items:
            type: string
        currency:
          readOnly: true
          $ref: '#/components/schemas/CurrencyCode'
        lineItems:
          type: array
          description: List of purchase items.
          readOnly: true
          items:
            type: object
            properties:
              type:
                description: Type of transaction.
                type: string
                enum:
                  - debit
                  - credit
              description:
                description: Description of the purchase item.
                type: string
              unitPrice:
                description: Unit price of the purchase item.
                type: number
                format: double
                example: 49.95
              quantity:
                description: Total quantity of the purchase item.
                type: number
                format: integer
              price:
                description: Total cost of the purchase item.
                type: number
                format: double
              planId:
                type: string
                description: ID of the related plan.
                maxLength: 50
                example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
              productId:
                type: string
                description: ID of the related product.
                maxLength: 50
                example: prod_0YV7DES3WPC5J8JD8QTVNZBZNZ
        shippingRates:
          type: array
          description: Available shipping rates.
          readOnly: true
          items:
            $ref: '#/components/schemas/ShippingOption'
        taxes:
          type: array
          description: Taxes applied to the purchase.
          readOnly: true
          items:
            type: object
            properties:
              amount:
                description: Amount of tax that is due.
                type: number
                format: double
              description:
                type: string
                description: Description of the tax.
        discounts:
          type: array
          description: Discounts applied to the purchase.
          readOnly: true
          items:
            type: object
            properties:
              couponId:
                type: string
                description: ID of a coupon that is associated with the purchase.
                maxLength: 50
                example: cpn_0YVCNKF81GD778N4YNVGDJK558
              amount:
                description: Total amount of discount from the coupon.
                type: number
                format: double
              description:
                description: Description of the discount.
                type: string
        subtotalAmount:
          description: Subtotal amount of the purchase.
          type: number
          format: double
          readOnly: true
        taxAmount:
          description: Tax amount of the purchase.
          type: number
          format: double
          readOnly: true
        shippingAmount:
          description: Shipping amount of the purchase.
          type: number
          format: double
          readOnly: true
        discountsAmount:
          description: Total discount amount of the purchase.
          type: number
          format: double
          readOnly: true
        total:
          description: Total amount of the purchase.
          type: number
          format: double
          readOnly: true
        initialAmounts:
          type: object
          description: |-
            Total amounts of the initial invoice.
            This displays the amount the customer pays initially.
          readOnly: true
          properties:
            amount:
              description: Total amount of the initial invoice.
              type: number
              x-type: Money
              format: double
            subtotalAmount:
              description: Subtotal amount of the initial invoice.
              type: number
              x-type: Money
              format: double
            discountAmount:
              description: Discount amount applied to the initial invoice.
              type: number
              x-type: Money
              format: double
            shippingAmount:
              description: Shipping amount applied to the initial invoice.
              type: number
              x-type: Money
              format: double
            taxAmount:
              description: Tax amount applied to the initial invoice.
              type: number
              x-type: Money
              format: double
        recurringAmounts:
          type:
            - object
            - 'null'
          description: |-
            Total amounts of the recurring invoice.
            This includes recurring items only.
            If the order does not have recurring items, the value of this field is `null`.
          readOnly: true
          properties:
            amount:
              description: Total amount of the recurring invoice.
              type: number
              x-type: Money
              format: double
            subtotalAmount:
              description: Subtotal amount of the recurring invoice.
              type: number
              x-type: Money
              format: double
            discountAmount:
              description: Discount amount applied to the recurring invoice.
              type: number
              x-type: Money
              format: double
            shippingAmount:
              description: Shipping amount applied to the recurring invoice.
              type: number
              x-type: Money
              format: double
            taxAmount:
              description: Tax amount applied to the recurring invoice.
              type: number
              x-type: Money
              format: double
        shipping:
          writeOnly: true
          $ref: '#/components/schemas/Shipping'
  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'
    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'
```
