# Retrieve an order cancellation

`GET /order-cancellations/{id}`

> This is a subset of the full specification, limited to the `GET /order-cancellations/{id}` 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 /order-cancellations/{id}` operation.
  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:
  /order-cancellations/{id}:
    parameters:
      - $ref: '#/components/parameters/resourceId'
    get:
      x-products:
        - Core
      tags:
        - Orders
      summary: Retrieve an order cancellation
      operationId: GetOrderCancellation
      x-sdk-operation-name: get
      description: Retrieves an order cancellation with a specified ID.
      responses:
        '200':
          description: Order cancellation retrieved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderCancellation'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  securitySchemes:
    JWT:
      description: |-
        JWT is a short lifetime token that can be assigned a specific expiration time.

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

        Use your secret API key only to make requests from the server side.
        To authenticate, provide your secret key in the request header.
      name: REB-APIKEY
      type: apiKey
      in: header
  parameters:
    resourceId:
      name: id
      in: path
      description: ID of the resource.
      required: true
      schema:
        type: string
        maxLength: 50
        pattern: ^[@~\-\.\w]+$
  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'
    NotFound:
      allOf:
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 404
              maximum: 404
        - $ref: '#/components/schemas/BaseProblem'
    CurrencyCode:
      type: string
      description: Currency code in ISO 4217 format.
      minLength: 3
      maxLength: 3
      example: USD
      x-label: Currency
    OrderCancellation:
      type: object
      required:
        - orderId
      properties:
        id:
          type: string
          description: ID of the cancellation.
          readOnly: true
          maxLength: 50
          example: sub_cnl_0YVJ5XVQM9CDP8248ZQX0RDMKV
        orderId:
          type: string
          description: ID of the canceled order.
          maxLength: 50
          example: sub_01HRF27SATGE4Z6PBJE6PD8328
        proratedInvoiceId:
          type:
            - string
            - 'null'
          description: ID of the invoice on which the cancellation proration is calculated.
          readOnly: true
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        appliedInvoiceId:
          type:
            - string
            - 'null'
          description: ID of the invoice on which the cancellation fees or credits are applied.
          readOnly: true
          maxLength: 50
          example: in_0YVF9605RKC62BP14NE2R7V2XT
        canceledBy:
          description: Specifies who initiated the cancellation.
          type: string
          default: customer
          enum:
            - merchant
            - customer
            - rebilly
        reason:
          description: |-
            Reason for the cancellation.

            The `sandbox-retention` value is set only in the sandbox environment when a recurring order is canceled 90 days after creation.
            If a request includes it, a validation error is returned.
          type: string
          default: other
          enum:
            - did-not-use
            - did-not-want
            - missing-features
            - bugs-or-problems
            - do-not-remember
            - risk-warning
            - contract-expired
            - too-expensive
            - other
            - billing-failure
            - delinquency
            - organization-deactivated
            - sandbox-retention
        description:
          description: Description of the cancellation reason in free form.
          type: string
          maxLength: 255
        prorated:
          description: Specifies if the customer gets a pro rata credit for the time remaining between `churnTime` and order next renewal time.
          type: boolean
          default: false
        status:
          description: Status of the order cancellation.
          type: string
          default: confirmed
          enum:
            - draft
            - confirmed
            - completed
            - revoked
          x-enumDescriptions:
            draft: Creates a draft cancellation so that the cancellation and charge can be previewed.
            confirmed: |-
              Confirms an order cancellation.
              Sets the order to cancel when the `churnTime` is reached.
            completed: |-
              Marks an order cancellation as completed.
              This is a read-only status that is set when the `churnTime` is reached.
              The cancellation may not be changed or deleted when the status is `completed`.
            revoked: Revokes an order cancellation.
        canceledTime:
          description: |-
            Date and time when an order is canceled.
            By default, this occurs when `status` is `confirmed`, unless `draft` is specified.
          type:
            - string
            - 'null'
          format: date-time
          readOnly: true
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        churnTime:
          description: |-
            Date and time when the order is deactivated.
            If this field and `churnTimePolicy` are omitted, this value defaults to the current time.
          type: string
          format: date-time
        churnTimePolicy:
          description: |-
            Specifies when the order is to be deactivated.
            The `churnTimePolicy` takes precedence over the `churnTime` in request.
          type:
            - string
            - 'null'
          enum:
            - null
            - now
            - at-next-renewal
        lineItems:
          description: |-
            Items to be added to the new invoice.
            Proration item is generated and added automatically.
          type: array
          items:
            type: object
            description: Invoice line item.
            required:
              - type
              - unitPriceAmount
              - unitPriceCurrency
              - quantity
            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:
          description: Subtotal of the line items added after the order cancellation.
          readOnly: true
          type: object
          properties:
            amount:
              type: number
              description: Subtotal amount of the line items.
              example: 49.95
            currency:
              $ref: '#/components/schemas/CurrencyCode'
        _links:
          $ref: '#/components/schemas/SelfLink'
  responses:
    Unauthorized:
      description: |-
        Unauthorized access.
        Invalid credentials used.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
    Forbidden:
      description: |-
        Access forbidden.
        If the organization requires multi-factor authentication (MFA) and the session has not passed MFA, `error` is `mfa_required`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Forbidden'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NotFound'
```
