# Retrieve orders

`GET /orders`

> This is a subset of the full specification, limited to the `GET /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 `GET /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
    description: Use these operations to manage orders that include items with mixed recurring subscription plans.
x-tagGroups:
  - name: Orders & Invoices
    tags:
      - Orders
paths:
  /orders:
    get:
      x-products:
        - Core
      tags:
        - Orders
      summary: Retrieve orders
      operationId: GetOrderCollection
      x-sdk-operation-name: getAll
      security:
        - SecretApiKey: []
        - JWT: []
        - ApplicationJWT: []
      description: Retrieves a collection of orders.
      parameters:
        - $ref: '#/components/parameters/collectionFilter'
        - $ref: '#/components/parameters/collectionSort'
        - $ref: '#/components/parameters/orderCollectionLimit'
        - $ref: '#/components/parameters/collectionOffset'
        - $ref: '#/components/parameters/collectionQuery'
        - $ref: '#/components/parameters/orderExpand'
      responses:
        '200':
          description: List of orders retrieved.
          headers:
            Pagination-Total:
              $ref: '#/components/headers/Pagination-Total'
            Pagination-Limit:
              $ref: '#/components/headers/Pagination-Limit'
            Pagination-Offset:
              $ref: '#/components/headers/Pagination-Offset'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Order'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
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
    ApplicationJWT:
      description: |-
        Applications in the Rebilly App Store can create a JSON Web Token (JWT) by fetching an user's instance.
        For more information, see Retrieve an application instance.

        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:
    collectionOffset:
      name: offset
      in: query
      description: Specifies the starting point within the collection of items to be returned.
      schema:
        type: integer
        minimum: 0
        maximum: 1000
    collectionSort:
      name: sort
      in: query
      description: |-
        Sorts and orders the collection of items. To sort in descending
        order, prefix with `-`. Multiple fields can be sorted by separating each with `,`.
      style: form
      explode: false
      schema:
        type: array
        items:
          type: string
    collectionFilter:
      name: filter
      in: query
      description: |-
        Criteria for filtering collection items.
        This field requires a special format.
        Use `,` to specify multiple allowed values.
        Use `;` to specify multiple fields.

        For more information, see [Search filters](https://www.rebilly.com/docs/dev-docs/search-filters).
      schema:
        type: string
    collectionQuery:
      name: q
      in: query
      description: Use this field to perform a partial search of text fields.
      schema:
        type: string
    orderCollectionLimit:
      name: limit
      in: query
      description: |-
        Maximum number of orders to return.
        To return an empty collection with the total number of matching orders in `Pagination-Total`, use `0`.
        If `expand` includes `activationInvoice`, `recentInvoice`, or `upcomingInvoice`,
        a maximum of `100` orders is returned.
      schema:
        type: integer
        minimum: 0
        maximum: 1000
    orderExpand:
      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=customer,activationInvoice`.

        Available arguments are:

          - `customer`
          - `activationInvoice`
          - `recentInvoice`
          - `upcomingInvoice`
          - `paymentInstrument`
          - `website`

        For more information, see [Embedded resources](https://www.rebilly.com/docs/dev-docs/expand-embedded-resources).
      schema:
        type: string
  headers:
    Pagination-Total:
      description: |-
        Total number of items that match the request.
        The value is independent of `limit`, including when `limit` is `0`.
      schema:
        type: integer
      example: 332
    Pagination-Limit:
      description: Maximum number of items per page.
      schema:
        type: integer
      example: 100
    Pagination-Offset:
      description: |-
        Specifies the starting point within the
        collection of resource results. For example, a request with
        `limit=20` retrieves and displays the first 20 results on a page. A
        following request with `limit=20` and `offset=20`, retrieves the next
        page of 20 results.
      schema:
        type: integer
      example: 2
  schemas:
    CreatedTime:
      type: string
      description: |-
        Date and time when the resource is created.
        This value is set automatically when the resource is created.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Creation Time
    UpdatedTime:
      type: string
      description: |-
        Date and time when the resource is updated.
        This value is set automatically when the resource is updated.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Last Update Time
    SelfLink:
      type: array
      description: Related links.
      readOnly: true
      items:
        type: object
        properties:
          href:
            description: Link URL.
            type: string
          rel:
            description: Type of link.
            type: string
            enum:
              - self
    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'
    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
    Customer:
      type: object
      description: Customer information.
      properties:
        id:
          type: string
          description: ID of the customer.
          readOnly: true
          example: cus_0YV7DDSDD1C8DA64KHH2W33CPF
          maxLength: 50
        email:
          description: Customer's email address.
          type:
            - string
            - 'null'
          format: email
          readOnly: true
          x-sortable: true
          x-basic: true
        firstName:
          description: Customer's first name.
          type:
            - string
            - 'null'
          x-basic: true
          readOnly: true
        lastName:
          description: Customer's last name.
          type:
            - string
            - 'null'
          x-sortable: true
          x-basic: true
          readOnly: true
        websiteId:
          x-sortable: true
          allOf:
            - $ref: '#/components/schemas/WebsiteId'
        paymentToken:
          type: string
          writeOnly: true
          description: |-
            Write-only payment token.
            If supplied, the token is converted into a payment instrument, and its ID is assigned to `defaultPaymentInstrumentId` value.
            The value of this property overrides the `defaultPaymentInstrumentId` if both are supplied.
            This token may only be used once before it expires.
        defaultPaymentInstrument:
          type:
            - object
            - 'null'
          description: |-
            Default payment instrument of the customer.

            The default payment instrument is used to automatically pay subscription renewals,
            and for transaction requests where a specific payment instrument is not provided.
          readOnly: true
          required:
            - method
            - paymentInstrumentId
          properties:
            method:
              $ref: '#/components/schemas/PaymentMethod'
            paymentInstrumentId:
              type: string
              description: ID of the payment instrument.
              maxLength: 50
              example: inst_0YVB8KPKNXCBR9EDX7JHSED75N
        defaultPaymentInstrumentId:
          type:
            - string
            - 'null'
          description: |-
            ID of the customer's default payment instrument.

            The default payment instrument is used to automatically pay subscription renewals,
            and for transaction requests where a specific payment instrument is not provided.
          maxLength: 50
          example: inst_0YVB8KPKNXCBR9EDX7JHSED75N
          writeOnly: true
        preferredPayoutInstrumentId:
          type:
            - string
            - 'null'
          description: ID of the customer's preferred payment instrument for payouts.
          maxLength: 50
          example: inst_0YVB8KPKNXCBR9EDX7JHSED75N
          default: null
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        primaryAddress:
          description: Customer's primary address.
          oneOf:
            - $ref: '#/components/schemas/ContactObject'
            - type: 'null'
        company:
          $ref: '#/components/schemas/Company'
        averageValue:
          $ref: '#/components/schemas/CustomerAverageValue'
        paymentCount:
          x-label: Payments
          x-sortable: true
          x-basic: true
          description: |-
            Total number of approved payments made by the customer.
            Payments are the result of `sale` or `capture` transactions.
          readOnly: true
          type: integer
        lastPaymentTime:
          x-label: Last Payment
          x-sortable: true
          x-basic: true
          description: |-
            Date and time when the customer made their last approved payment.
            Payments are the result of `sale` or `capture` transactions.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        lifetimeRevenue:
          $ref: '#/components/schemas/CustomerLifetimeRevenue'
        invoiceCount:
          x-sortable: true
          description: |-
            Total number of invoices issued to the customer.
            This value is auto-incrementing.
            If this value is `0`, the record relates to a lead.
            A lead is a customer who has not made a payment yet.
            If this value is greater than or equal to `1` the record relates to a customer.
          readOnly: true
          type: integer
        tags:
          description: List of customer tags.
          readOnly: true
          type: array
          items:
            $ref: '#/components/schemas/Tag'
        revision:
          description: |-
            Number of times the customer's data has been modified.

            Use this value when analyzing webhook data to determine if a change must take precedence over the current representation.
          type: integer
          readOnly: true
        hasFulfilledKyc:
          description: Specifies if the customer has accepted and reviewed identity and address documents, or an accepted credit file document.
          type: boolean
          readOnly: true
        organizationId:
          readOnly: true
          allOf:
            - $ref: '#/components/schemas/OrganizationId'
        locale:
          type:
            - string
            - 'null'
          description: Language locale identifier in [RFC 5646](https://tools.ietf.org/html/rfc5646) format.
          example: fr-FR
          default: null
        taxNumbers:
          type:
            - array
            - 'null'
          description: Tax numbers of the customer.
          items:
            $ref: '#/components/schemas/TaxNumber'
        leadSource:
          allOf:
            - $ref: '#/components/schemas/LeadSourceData'
          writeOnly: true
        personId:
          type:
            - string
            - 'null'
          description: ID of the associated person.
          maxLength: 50
          example: prs_0YV7DDSDD1C8DA64KHH2W33CPF
        notificationEmails:
          type: array
          description: |-
            Email addresses for notification delivery in event-based email notifications.
            When you configure event-based email notifications, you can send to these addresses, the customer's primary email address, or another email address you specify.
            For more information, see [Manage notification emails](https://www.rebilly.com/docs/data-tables/manage-customer-information#manage-notification-emails).
          items:
            type: string
            format: email
        _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
                  - defaultPaymentInstrument
                  - leadSource
                  - website
        _embedded:
          type: object
          description: Embedded objects that are requested using the `expand` query string parameter.
          readOnly: true
          properties:
            defaultPaymentInstrument:
              type: object
            website:
              type: object
            leadSource:
              type: object
    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
    Invoice:
      required:
        - customerId
        - currency
        - websiteId
      properties:
        id:
          type: string
          description: ID of the invoice.
          readOnly: true
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        websiteId:
          $ref: '#/components/schemas/WebsiteId'
        invoiceNumber:
          description: Auto-incrementing number based on the sequence of invoices for any particular customer.
          readOnly: true
          type: integer
          x-basic: true
        orderId:
          description: ID of the order (experimental).
          readOnly: true
          example: ord_01HVKA5975PJBSQ1SX72G3MSZC
          type:
            - string
            - 'null'
        subscriptionId:
          type: string
          description: |-
            ID of the related subscription order, if available.
            This field is `null` if there are no related subscription orders.
          readOnly: true
          maxLength: 50
          example: sub_01HRF27SATGE4Z6PBJE6PD8328
        quoteId:
          type:
            - string
            - 'null'
          description: |-
            ID of the related quote, if available.
            This field is `null` if there are no related quotes.
          readOnly: true
          maxLength: 50
          example: qt_01HXBZMEGPETPHJZH6V4RHBMA8
        currency:
          x-sortable: true
          x-basic: true
          $ref: '#/components/schemas/CurrencyCode'
        amount:
          description: Amount of the invoice.
          type: number
          x-type: Money
          x-sortable: true
          x-basic: true
          format: double
          readOnly: true
        amountDue:
          description: Amount that is due on the invoice.
          type: number
          x-type: Money
          x-sortable: true
          format: double
          readOnly: true
        subtotalAmount:
          description: Subtotal amount of the invoice.
          type: number
          x-type: Money
          format: double
          readOnly: true
        discountAmount:
          description: Discount amount that is applied to the invoice.
          type: number
          x-type: Money
          format: double
          readOnly: true
        shipping:
          description: |-
            Shipping settings of the invoice.
            The `calculator` property is `manual` when the shipping amount is provided
            and `rebilly` when the amount is calculated from shipping rates.
            If `calculator` is `manual` and an issued invoice is recalculated or its items change,
            the shipping amount is not changed, even if no invoice item requires shipping.
            If `calculator` is `manual` and no invoice item requires shipping, the shipping amount is 0 in these cases:

            - A draft invoice is issued with the [Issue an invoice](https://www.rebilly.com/catalog/all/invoices/postinvoiceissuance) operation, a renewal invoice is issued, or a scheduled draft invoice is recalculated.
            - An order is created or previewed, a quote is created, or a `pending` order is updated.
              This applies to the order invoice. The order keeps its shipping amount.

            To change the shipping amount of an issued invoice, use the [Upsert an invoice](https://www.rebilly.com/catalog/all/invoices/putinvoice) operation.
          $ref: '#/components/schemas/Shipping'
        tax:
          $ref: '#/components/schemas/Taxes'
        organizationTaxIdNumber:
          description: Organization tax ID number that is displayed on the invoice.
          type:
            - object
            - 'null'
          required:
            - type
            - value
          properties:
            type:
              type: string
              description: Type of the tax ID number.
              enum:
                - eu-vat
                - other
              example: eu-vat
            value:
              type: string
              description: Value of the tax ID number.
              example: GB980780684
        customerTaxIdNumber:
          description: Customer tax ID number that is displayed on the invoice.
          type:
            - object
            - 'null'
          required:
            - type
            - value
          properties:
            type:
              type: string
              description: Type of the tax ID number.
              enum:
                - eu-vat
                - other
              example: eu-vat
            value:
              type: string
              description: Value of the tax ID number.
              example: GB980780684
        billingAddress:
          description: |-
            Billing address of the invoice.
            After the first payment is made for an invoice, this value cannot be changed.
          $ref: '#/components/schemas/ContactObject'
        deliveryAddress:
          description: Delivery address of the invoice.
          $ref: '#/components/schemas/ContactObject'
        poNumber:
          description: Purchase order number that is displayed on the invoice.
          type:
            - string
            - 'null'
          example: PO123456
          maxLength: 50
        notes:
          description: Notes for the customer that are displayed on the invoice.
          type: string
          maxLength: 65535
        items:
          type: array
          description: Invoice items array.
          readOnly: true
          items:
            $ref: '#/components/schemas/InvoiceItem'
        discounts:
          type: array
          description: Discounts applied.
          readOnly: true
          items:
            type: object
            readOnly: true
            properties:
              couponId:
                type: string
                description: ID of the coupon.
                maxLength: 50
                example: cpn_0YVCNKF81GD778N4YNVGDJK558
              redemptionId:
                description: ID of the redemption.
                $ref: '#/components/schemas/ResourceId'
              amount:
                description: Total amount discounted by this coupon.
                type: number
                format: double
              description:
                type: string
                description: Description of the discount.
              context:
                $ref: '#/components/schemas/DiscountContext'
        autopayScheduledTime:
          description: Date and time when an automatic payment (autopay) is scheduled.
          type:
            - string
            - 'null'
          x-sortable: true
          format: date-time
        autopayRetryNumber:
          description: Number of times that an automatic payment (autopay) has been attempted on an invoice.
          readOnly: true
          type: integer
          x-sortable: true
          minimum: 0
          default: 0
        status:
          type: string
          description: Status of the invoice.
          x-basic: true
          readOnly: true
          enum:
            - draft
            - quotation
            - unpaid
            - paid
            - partially-paid
            - past-due
            - abandoned
            - voided
            - partially-refunded
            - refunded
            - disputed
        delinquentCollectionPeriod:
          type: integer
          description: Length of time, in days, between when the invoice is due and when the invoice is paid.
          x-sortable: true
          readOnly: true
        collectionPeriod:
          type: integer
          x-sortable: true
          description: Length of time, in days, between when the invoice is issued and when the invoice is paid.
          readOnly: true
        abandonedTime:
          description: Date and time when the invoice is abandoned.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        voidedTime:
          description: Date and time when the invoice is voided.
          x-sortable: true
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        paidTime:
          x-label: Payment Date
          x-sortable: true
          x-basic: true
          description: Date and time when the invoice is paid.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        dueTime:
          description: Date and time when the invoice is due for payment.
          type: string
          x-sortable: true
          format: date-time
        issuedTime:
          description: Date and time when the invoice is issued.
          x-label: Date Issued
          x-sortable: true
          x-basic: true
          $ref: '#/components/schemas/ServerTimestamp'
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        paymentFormUrl:
          type:
            - string
            - 'null'
          readOnly: true
          format: uri
          description: |-
            URL where the customer is redirected to pay the invoice
            using one of the methods which are available to the customer.
            This is an alternative to creating a new transaction with empty
            `methods`.
        creditMemoAllocations:
          type: array
          description: Credit memo allocations to an invoice.
          readOnly: true
          items:
            $ref: '#/components/schemas/CreditMemoInvoiceAllocation'
        isNewOrder:
          description: Specifies if the order is a new order.
          type: boolean
          readOnly: true
          example: true
        customerId:
          x-basic: true
          allOf:
            - $ref: '#/components/schemas/CustomerId'
        transactions:
          type: array
          description: |-
            Up to 10 of the most recent transactions for the invoice.
            To retrieve transactions for an invoice, use [Retrieve transactions](https://www.rebilly.com/catalog/all/transactions/gettransactioncollection) with the `invoiceIds` filter.
            Search results can lag briefly behind a write.
          maxItems: 10
          readOnly: true
          items:
            $ref: '#/components/schemas/Transaction'
        retryInstruction:
          description: |-
            Invoice payment retry instruction.
            This object specifies how to proceed if a payment related to the invoice fails.
          type:
            - object
            - 'null'
          properties:
            attempts:
              type: array
              description: Describes the retry instruction.
              minItems: 1
              items:
                type: object
                properties:
                  scheduleInstruction:
                    $ref: '#/components/schemas/InvoiceRetryScheduleInstruction'
                  amountAdjustmentInstruction:
                    $ref: '#/components/schemas/InvoiceRetryAmountAdjustmentInstruction'
                  tryBackupInstruments:
                    description: Specifies whether to use backup payment instruments on an invoice payment retry.
                    type: boolean
                    default: false
                required:
                  - scheduleInstruction
            afterAttemptPolicies:
              description: Describes the action to take when a payment attempt concludes, and payment is not collected.
              type: array
              items:
                type: string
                enum:
                  - change-subscription-renewal-time
            afterRetryEndPolicies:
              description: Describes the action to take when all scheduled payment retries, in a retry instruction, have concluded and payment is not collected.
              type: array
              items:
                type: string
                enum:
                  - abandon-invoice
                  - cancel-subscription
          required:
            - attempts
            - afterAttemptPolicies
            - afterRetryEndPolicies
        revision:
          description: |-
            Number of times the invoice data has been modified.

            Use the revision number when analyzing webhook data to
            determine if a change should take precedence over the current
            representation.
          type: integer
          readOnly: true
        type:
          description: Type of invoice.
          type: string
          enum:
            - initial
            - renewal
            - interim
            - cancellation
            - one-time
            - refund
            - charge
            - one-time-sale
          readOnly: true
        dueReminderTime:
          description: Date and time when a past due reminder event is triggered.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        dueReminderNumber:
          description: Number of past due reminder events that have been triggered.
          type:
            - integer
            - 'null'
          readOnly: true
        organizationId:
          readOnly: true
          allOf:
            - $ref: '#/components/schemas/OrganizationId'
        delinquencyTime:
          description: |-
            Date and time when the related order is considered delinquent, and is canceled.
            If this value is `null`, no delinquency time is configured.
            When the invoice `dueTime` is changed to a later date and time, `delinquencyTime` increases by the same amount.
            If `dueTime` is changed to an earlier date and time or `delinquencyTime` is `null`, `delinquencyTime` remains unchanged.
            Changing `dueTime` to an earlier date and time increases the gap between `dueTime` and `delinquencyTime`.
            This wider gap is preserved if `dueTime` subsequently changes to a later date and time.
            If the request also specifies `delinquencyTime`, the specified value takes precedence.
            If `delinquencyTime` is earlier than the invoice `dueTime`, it is set to the same value as `dueTime`.

            If an invoice is not related to an order, this field can only be `null`.
          type:
            - string
            - 'null'
          format: date-time
          default: null
        _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
                  - organization
                  - attachments
                  - leadSource
                  - transactionAllocations
                  - recalculateInvoice
                  - subscription
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            customer:
              type: object
            website:
              type: object
            organization:
              type: object
            leadSource:
              type: object
            shippingRate:
              type: object
    PaymentInstrument:
      discriminator:
        propertyName: method
        mapping:
          payment-card: '#/components/schemas/PaymentCard'
          ach: '#/components/schemas/BankAccount'
          paypal: '#/components/schemas/PayPalAccount'
          Khelocard: '#/components/schemas/AlternativeInstrument'
          cash: '#/components/schemas/AlternativeInstrument'
          check: '#/components/schemas/AlternativeInstrument'
          AdvCash: '#/components/schemas/AlternativeInstrument'
          Alfa-click: '#/components/schemas/AlternativeInstrument'
          Alipay: '#/components/schemas/AlternativeInstrument'
          AstroPay Card: '#/components/schemas/AlternativeInstrument'
          AstroPay-GO: '#/components/schemas/AlternativeInstrument'
          BankReferenced: '#/components/schemas/AlternativeInstrument'
          bank-transfer: '#/components/schemas/AlternativeInstrument'
          bank-transfer-2: '#/components/schemas/AlternativeInstrument'
          bank-transfer-3: '#/components/schemas/AlternativeInstrument'
          bank-transfer-4: '#/components/schemas/AlternativeInstrument'
          bank-transfer-5: '#/components/schemas/AlternativeInstrument'
          bank-transfer-6: '#/components/schemas/AlternativeInstrument'
          bank-transfer-7: '#/components/schemas/AlternativeInstrument'
          bank-transfer-8: '#/components/schemas/AlternativeInstrument'
          bank-transfer-9: '#/components/schemas/AlternativeInstrument'
          Baloto: '#/components/schemas/AlternativeInstrument'
          Beeline: '#/components/schemas/AlternativeInstrument'
          Belfius-direct-net: '#/components/schemas/AlternativeInstrument'
          bitcoin: '#/components/schemas/AlternativeInstrument'
          Bizum: '#/components/schemas/AlternativeInstrument'
          Boleto: '#/components/schemas/AlternativeInstrument'
          cash-deposit: '#/components/schemas/AlternativeInstrument'
          CASHlib: '#/components/schemas/AlternativeInstrument'
          CashToCode: '#/components/schemas/AlternativeInstrument'
          China UnionPay: '#/components/schemas/AlternativeInstrument'
          Cleo: '#/components/schemas/AlternativeInstrument'
          CODVoucher: '#/components/schemas/AlternativeInstrument'
          Commas-Checkout: '#/components/schemas/AlternativeInstrument'
          Conekta-oxxo: '#/components/schemas/AlternativeInstrument'
          Cupon-de-pagos: '#/components/schemas/AlternativeInstrument'
          cryptocurrency: '#/components/schemas/AlternativeInstrument'
          domestic-cards: '#/components/schemas/AlternativeInstrument'
          ecoPayz: '#/components/schemas/AlternativeInstrument'
          ecoVoucher: '#/components/schemas/AlternativeInstrument'
          Efecty: '#/components/schemas/AlternativeInstrument'
          EPS: '#/components/schemas/AlternativeInstrument'
          ePay.bg: '#/components/schemas/AlternativeInstrument'
          eZeeWallet: '#/components/schemas/AlternativeInstrument'
          FasterPay: '#/components/schemas/AlternativeInstrument'
          Flexepin: '#/components/schemas/AlternativeInstrument'
          Fyntra-Checkout: '#/components/schemas/AlternativeInstrument'
          Giropay: '#/components/schemas/AlternativeInstrument'
          Gpaysafe: '#/components/schemas/AlternativeInstrument'
          Google Pay: '#/components/schemas/AlternativeInstrument'
          iDebit: '#/components/schemas/AlternativeInstrument'
          iDEAL: '#/components/schemas/AlternativeInstrument'
          ING-homepay: '#/components/schemas/AlternativeInstrument'
          INOVAPAY-pin: '#/components/schemas/AlternativeInstrument'
          INOVAPAY-wallet: '#/components/schemas/AlternativeInstrument'
          InstaDebit: '#/components/schemas/AlternativeInstrument'
          instant-bank-transfer: '#/components/schemas/AlternativeInstrument'
          InstantPayments: '#/components/schemas/AlternativeInstrument'
          Interac: '#/components/schemas/AlternativeInstrument'
          Interac-online: '#/components/schemas/AlternativeInstrument'
          Interac-eTransfer: '#/components/schemas/AlternativeInstrument'
          invoice: '#/components/schemas/AlternativeInstrument'
          iWallet: '#/components/schemas/AlternativeInstrument'
          Jeton: '#/components/schemas/AlternativeInstrument'
          jpay: '#/components/schemas/AlternativeInstrument'
          Klarna: '#/components/schemas/AlternativeInstrument'
          KNOT: '#/components/schemas/AlternativeInstrument'
          loonie: '#/components/schemas/AlternativeInstrument'
          Matrix: '#/components/schemas/AlternativeInstrument'
          MaxiCash: '#/components/schemas/AlternativeInstrument'
          Megafon: '#/components/schemas/AlternativeInstrument'
          MiFinity-eWallet: '#/components/schemas/AlternativeInstrument'
          miscellaneous: '#/components/schemas/AlternativeInstrument'
          Bancontact: '#/components/schemas/AlternativeInstrument'
          Bancontact-mobile: '#/components/schemas/AlternativeInstrument'
          MTS: '#/components/schemas/AlternativeInstrument'
          MuchBetter: '#/components/schemas/AlternativeInstrument'
          Multibanco: '#/components/schemas/AlternativeInstrument'
          Neosurf: '#/components/schemas/AlternativeInstrument'
          Netbanking: '#/components/schemas/AlternativeInstrument'
          Neteller: '#/components/schemas/AlternativeInstrument'
          Nordea-Solo: '#/components/schemas/AlternativeInstrument'
          OchaPay: '#/components/schemas/AlternativeInstrument'
          online-bank-transfer: '#/components/schemas/AlternativeInstrument'
          Onlineueberweisen: '#/components/schemas/AlternativeInstrument'
          oriental-wallet: '#/components/schemas/AlternativeInstrument'
          OXXO: '#/components/schemas/AlternativeInstrument'
          P24: '#/components/schemas/AlternativeInstrument'
          Pagadito: '#/components/schemas/AlternativeInstrument'
          PagoEffectivo: '#/components/schemas/AlternativeInstrument'
          Pagsmile-deposit-express: '#/components/schemas/AlternativeInstrument'
          Pagsmile-lottery: '#/components/schemas/AlternativeInstrument'
          PayCash: '#/components/schemas/AlternativeInstrument'
          Payeer: '#/components/schemas/AlternativeInstrument'
          PaymentAsia-crypto: '#/components/schemas/AlternativeInstrument'
          Paymero: '#/components/schemas/AlternativeInstrument'
          Perfect-money: '#/components/schemas/AlternativeInstrument'
          Piastrix: '#/components/schemas/AlternativeInstrument'
          plaid-account: '#/components/schemas/AlternativeInstrument'
          PayTabs: '#/components/schemas/AlternativeInstrument'
          Paysafecard: '#/components/schemas/AlternativeInstrument'
          Paysafecash: '#/components/schemas/AlternativeInstrument'
          Pay4Fun: '#/components/schemas/AlternativeInstrument'
          Paynote: '#/components/schemas/AlternativeInstrument'
          PinPay: '#/components/schemas/AlternativeInstrument'
          phone: '#/components/schemas/AlternativeInstrument'
          PhonePe: '#/components/schemas/AlternativeInstrument'
          POLi: '#/components/schemas/AlternativeInstrument'
          PostFinance-card: '#/components/schemas/AlternativeInstrument'
          PostFinance-e-finance: '#/components/schemas/AlternativeInstrument'
          QIWI: '#/components/schemas/AlternativeInstrument'
          QPay: '#/components/schemas/AlternativeInstrument'
          QQPay: '#/components/schemas/AlternativeInstrument'
          rapyd-checkout: '#/components/schemas/AlternativeInstrument'
          Resurs: '#/components/schemas/AlternativeInstrument'
          SafetyPay: '#/components/schemas/AlternativeInstrument'
          SEPA: '#/components/schemas/AlternativeInstrument'
          Skrill: '#/components/schemas/AlternativeInstrument'
          Skrill Rapid Transfer: '#/components/schemas/AlternativeInstrument'
          SMSVoucher: '#/components/schemas/AlternativeInstrument'
          Sofort: '#/components/schemas/AlternativeInstrument'
          SparkPay: '#/components/schemas/AlternativeInstrument'
          swift-dbt: '#/components/schemas/AlternativeInstrument'
          Tele2: '#/components/schemas/AlternativeInstrument'
          Terminaly-RF: '#/components/schemas/AlternativeInstrument'
          Thunes-Checkout: '#/components/schemas/AlternativeInstrument'
          ToditoCash-card: '#/components/schemas/AlternativeInstrument'
          Trustly: '#/components/schemas/AlternativeInstrument'
          UPayCard: '#/components/schemas/AlternativeInstrument'
          UPI: '#/components/schemas/AlternativeInstrument'
          USD-coin: '#/components/schemas/AlternativeInstrument'
          VCreditos: '#/components/schemas/AlternativeInstrument'
          VenusPoint: '#/components/schemas/AlternativeInstrument'
          voucher: '#/components/schemas/AlternativeInstrument'
          voucher-2: '#/components/schemas/AlternativeInstrument'
          voucher-3: '#/components/schemas/AlternativeInstrument'
          voucher-4: '#/components/schemas/AlternativeInstrument'
          Webmoney: '#/components/schemas/AlternativeInstrument'
          Webpay: '#/components/schemas/AlternativeInstrument'
          Webpay-2: '#/components/schemas/AlternativeInstrument'
          Webpay Card: '#/components/schemas/AlternativeInstrument'
          WeChat Pay: '#/components/schemas/AlternativeInstrument'
          XPay-P2P: '#/components/schemas/AlternativeInstrument'
          XPay-QR: '#/components/schemas/AlternativeInstrument'
          Yandex-money: '#/components/schemas/AlternativeInstrument'
          Zotapay: '#/components/schemas/AlternativeInstrument'
          Zimpler: '#/components/schemas/AlternativeInstrument'
      oneOf:
        - $ref: '#/components/schemas/PaymentCard'
        - $ref: '#/components/schemas/BankAccount'
        - $ref: '#/components/schemas/PayPalAccount'
        - $ref: '#/components/schemas/AlternativeInstrument'
    OneTimeSaleItem:
      type: object
      required:
        - type
        - plan
      properties:
        id:
          type: string
          description: ID of the one-time sale.
          readOnly: true
          maxLength: 50
          example: ots_01HRF27SATGE4Z6PBJE6PD8328
        type:
          description: Specifies the type of order item.
          type: string
          x-basic: true
          const: one-time-sale
        productId:
          type: string
          description: ID of the related product.
          maxLength: 50
          example: prod_0YV7DES3WPC5J8JD8QTVNZBZNZ
          readOnly: true
        plan:
          description: Details of the plan.
          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
        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
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
    SubscriptionItem:
      type: object
      required:
        - type
        - plan
      properties:
        id:
          type: string
          description: ID of the subscription.
          readOnly: true
          maxLength: 50
          example: sub_01HRF27SATGE4Z6PBJE6PD8328
        type:
          description: Specifies the type of order item.
          type: string
          x-basic: true
          const: subscription
        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
        recurringInterval:
          type:
            - object
            - 'null'
          description: |-
            Recurring interval to override plan settings.
            To use plan settings, set this value to `null`.

            To use multiple plans in one subscription,
            all plans must have the same recurring period length.
          example: null
          properties:
            periodAnchorInstruction:
              $ref: '#/components/schemas/ServicePeriodAnchorInstruction'
        renewalTime:
          description: |-
            Date and time when the subscription renews.
            If the item has no trial, the first service period ends at the date and time specified in the request that creates an order or updates a `pending` order.
            If the item has a trial, the specified date and time are ignored, and the subscription renews when the trial ends.
          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
        productId:
          type: string
          description: ID of the related product.
          maxLength: 50
          example: prod_0YV7DES3WPC5J8JD8QTVNZBZNZ
          readOnly: true
        plan:
          description: Details of the plan.
          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
        quantityFilled:
          description: Number of filled product units.
          type:
            - number
            - 'null'
          format: double
          example: 5.125
        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 item.
        excludeFromMrr:
          type: boolean
          description: Specifies if this item should be excluded from monthly recurring revenue calculations.
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
    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
    OrderUpcomingInvoice:
      type: object
      readOnly: true
      properties:
        id:
          description: |-
            ID of the upcoming invoice.
            This value is persisted in the future renewal invoice.
          type: string
          readOnly: true
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        currency:
          x-sortable: true
          x-basic: true
          $ref: '#/components/schemas/CurrencyCode'
        revision:
          description: |-
            Number of times the upcoming invoice data has changed.

            Use the revision number when analyzing webhook data to
            determine if a change should take precedence over the current
            representation.
          type: integer
        items:
          type: array
          description: Upcoming invoice items array.
          items:
            $ref: '#/components/schemas/OrderUpcomingInvoiceItem'
        amount:
          description: Amount of the invoice.
          type: number
          x-type: Money
          x-sortable: true
          x-basic: true
          format: double
          readOnly: true
        amountDue:
          description: Amount that is due on the invoice.
          type: number
          x-type: Money
          x-sortable: true
          format: double
          readOnly: true
        subtotalAmount:
          description: Subtotal amount of the invoice.
          type: number
          x-type: Money
          format: double
          readOnly: true
        discountAmount:
          description: Discount amount that is applied to the invoice.
          type: number
          x-type: Money
          format: double
          readOnly: true
        shipping:
          $ref: '#/components/schemas/Shipping'
        tax:
          $ref: '#/components/schemas/Taxes'
        discounts:
          type: array
          description: Discounts applied.
          readOnly: true
          items:
            type: object
            readOnly: true
            properties:
              couponId:
                type: string
                description: ID of the coupon.
                maxLength: 50
                example: cpn_0YVCNKF81GD778N4YNVGDJK558
              redemptionId:
                description: ID of the redemption.
                $ref: '#/components/schemas/ResourceId'
              amount:
                description: Total amount discounted by this coupon.
                type: number
                format: double
              description:
                type: string
                description: Description of the discount.
              context:
                $ref: '#/components/schemas/DiscountContext'
        issuedTime:
          description: Date and time when the invoice is issued.
          x-label: Date Issued
          x-sortable: true
          x-basic: true
          $ref: '#/components/schemas/ServerTimestamp'
        isNewOrder:
          description: Specifies if the order is a new order.
          type: boolean
          readOnly: true
          example: true
        dueTime:
          description: Date and time when the invoice is due for payment.
          type: string
          x-sortable: true
          format: date-time
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          $ref: '#/components/schemas/SelfLink'
    Website:
      type: object
      required:
        - name
        - url
        - servicePhone
        - serviceEmail
      properties:
        id:
          readOnly: true
          allOf:
            - $ref: '#/components/schemas/WebsiteId'
        name:
          description: Name of the website.
          type: string
        url:
          description: Domain address of the website.
          type: string
        servicePhone:
          description: Customer service phone number of the website.
          type: string
        serviceEmail:
          description: Customer service email address of the website.
          type: string
          format: email
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        customFields:
          $ref: '#/components/schemas/ResourceCustomFields'
        settings:
          type: object
          description: Website settings.
          properties:
            paymentForm:
              type: object
              description: Payment form settings.
              properties:
                css:
                  description: Hosted payment form [CSS options](https://www.rebilly.com/docs/content/concepts-and-features/tutorial/customize-style-rebilly-instruments/#2-use-css-property-to-override-any-styles).
                  type:
                    - string
                    - 'null'
                theme:
                  description: |-
                    Hosted payment form [theme options](https://www.rebilly.com/docs/content/concepts-and-features/tutorial/customize-style-rebilly-instruments/#adjust-the-default-style).

                    The `pageColorBackground` property sets the background color of the page around the form.
                    It is read by the hosted payment form page and is not passed to Rebilly Instruments.
                  type:
                    - object
                    - 'null'
                  additionalProperties:
                    type: string
                  example:
                    colorPrimary: '#504CCA'
                    pageColorBackground: '#F6F8F9'
                features:
                  description: Hosted payment form features.
                  type:
                    - object
                    - 'null'
                  properties:
                    showCoupons:
                      type:
                        - array
                        - 'null'
                      items:
                        type: string
                    fullPageRedirect:
                      type:
                        - boolean
                        - 'null'
                      description: Specifies whether the hosted payment form uses a full page redirect, or the default iframe modal, for approval URL redirects.
                      default: false
                    skipRedirectOnPaymentComplete:
                      type:
                        - boolean
                        - 'null'
                      description: Specifies whether the hosted payment form skips the redirect to the website URL when the payment is completed.
                      default: false
                    hideZeroAmountSummaryItems:
                      type:
                        - boolean
                        - 'null'
                      description: Specifies if the hosted payment form displays 0 amount line items in the summary.
                      default: false
            amplitude:
              type: object
              description: |-
                Amplitude settings.
                Amplitude is an analytics tool for tracking user behavior.
              properties:
                tracking:
                  description: Specifies if the hosted pages, such as KYC pages, include Amplitude analytics.
                  type: boolean
                  default: false
                apiKey:
                  description: API key of an Amplitude project.
                  type:
                    - string
                    - 'null'
                  minLength: 20
                  maxLength: 50
                  example: 35d1795750c585984f7e6b01c0ca6e19
            payoutRequest:
              type: object
              description: Payout request settings for the website.
              properties:
                automaticReadinessEnabled:
                  type: boolean
                  default: false
                  description: |-
                    Specifies whether pending payout requests are automatically marked as `ready`.
                    When this value is `false`, payout requests are created in the `ready` status and automatic transition is not used.
                    When this value is `true`, payout requests remain in the `pending` status until the pending period elapses and the configured transition time is reached.
                pendingPeriodHours:
                  type: integer
                  description: |-
                    Minimum number of hours a payout request stays in the `pending` status before it can be automatically set to `ready`.
                    Required when `automaticReadinessEnabled` is `true`.
                  minimum: 1
                  maximum: 8760
                  example: 48
                automaticReadinessTime:
                  description: |-
                    Time of day when the automatic readiness job processes eligible pending payout requests.
                    Required when `automaticReadinessEnabled` is `true`.
                    Use extended ISO-8601 time format (`HH:MM:SS`) with an optional timezone offset.
                    When the timezone offset is omitted, the server timezone is used.
                  allOf:
                    - $ref: '#/components/schemas/TimeIso8601Extended'
                  example: 10:00:00Z
                automaticReadinessLastExecutedAt:
                  type:
                    - string
                    - 'null'
                  format: date-time
                  readOnly: true
                  description: Date and time when the automatic readiness job last completed successfully for this website.
        logoId:
          type:
            - string
            - 'null'
          description: ID of the linked file object.
          maxLength: 50
          example: 4f6cf35x-2c4y-483z-a0a9-158621f77a21
        logoUrl:
          readOnly: true
          description: URL of the website logo.
          type:
            - string
            - 'null'
        organizationId:
          deprecated: true
          readOnly: true
          allOf:
            - $ref: '#/components/schemas/OrganizationId'
        _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
                  - logoUrl
    RecurringOrder:
      type: object
      required:
        - type
        - customerId
        - websiteId
        - items
      properties:
        id:
          type: string
          description: ID of the order.
          readOnly: true
          maxLength: 50
          example: ord_01HVKA5975PJBSQ1SX72G3MSZC
        type:
          type: string
          description: Type of the order.
          const: recurring
        organizationId:
          type: string
          description: |-
            Unique organization identifier.
            An organization is an entity that represents a company.
            For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
          maxLength: 50
          readOnly: true
          example: org_0YVDM8RC7GDADADSBSMW124JA8
        customerId:
          $ref: '#/components/schemas/CustomerId'
        websiteId:
          $ref: '#/components/schemas/WebsiteId'
        activationInvoiceId:
          type: string
          description: ID of the activation invoice.
          readOnly: true
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        recentInvoiceId:
          description: |-
            ID of the most recently issued invoice.
            The invoice might not be `paid` yet.
          readOnly: true
          type:
            - string
            - 'null'
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        status:
          description: Status of the order.
          type: string
          readOnly: true
          enum:
            - pending
            - active
            - canceled
            - churned
            - paused
            - voided
            - completed
            - trial-ended
            - abandoned
        inTrial:
          description: Specifies if the subscription is currently in a trial period.
          type: boolean
          readOnly: true
        trial:
          type: object
          description: |-
            Details of the trial.
            To use plan defaults, omit the `trial` key or set this value to `null`.
          properties:
            enabled:
              description: |-
                Specifies if there is a trial for this order.
                Plans without trial prices are free trials.
                If the order is active, all order items are in a trial, and `isTrialOnly` is `false`, setting this value to `false` ends the trial immediately.
                If the request that sets this value to `false` also changes `currentPeriodEnd`, the order renews at that time.
                If the request does not change `currentPeriodEnd`, the order renews immediately.
                In the response, this field remains `true`, and `endTime` contains the date and time when the trial ended.
                If only some items of an active order are in a trial, changing this value from `true` to `false` returns a 409 error.
              type: boolean
            endTime:
              description: |-
                Time and date when the trial ends.
                If the order churns during the trial, this value is the time when the order churned.
                If a trial is enabled on this subscription, a value must be provided.

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

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

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

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

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

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

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

            This parameter uses the following logic:

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

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

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

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

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

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

            This parameter uses the following logic:

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

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

            The revision is useful when analyzing webhook data to determine if the
            change takes precedence over the current representation.
          type: integer
          readOnly: true
        isNewOrder:
          description: Specifies if the order is a new order.
          type: boolean
          readOnly: true
          example: true
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          $ref: '#/components/schemas/SelfLink'
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            customer:
              $ref: '#/components/schemas/Customer'
            activationInvoice:
              $ref: '#/components/schemas/Invoice'
            recentInvoice:
              $ref: '#/components/schemas/Invoice'
            upcomingInvoice:
              $ref: '#/components/schemas/OrderUpcomingInvoice'
            paymentInstrument:
              $ref: '#/components/schemas/PaymentInstrument'
            website:
              $ref: '#/components/schemas/Website'
    Order:
      type: object
      discriminator:
        propertyName: type
        mapping:
          recurring: '#/components/schemas/RecurringOrder'
          one-time: '#/components/schemas/OneTimeOrder'
      oneOf:
        - $ref: '#/components/schemas/RecurringOrder'
        - $ref: '#/components/schemas/OneTimeOrder'
  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'
```
