---
title: "Calculates the refund amounts and price of the new purchases."
method: POST
path: "/providers/Microsoft.Capacity/calculateExchange"
tags: ["Exchange"]
---

# Calculates the refund amounts and price of the new purchases.

`POST /providers/Microsoft.Capacity/calculateExchange`

Calculates price for exchanging `Reservations` if there are no policy errors.

## Query parameters

- `api-version` string, required

## Request body

- CalculateExchangeRequest — Calculate exchange request
  - `properties` CalculateExchangeRequestProperties — Calculate exchange request properties
    - `reservationsToPurchase` PurchaseRequest[] — List of reservations that are being purchased in this exchange.
      - `sku` SkuName
        - `name` string
      - `location` string — The Azure Region where the reserved resource lives.
      - `properties` PurchaseRequestProperties
        - `reservedResourceType` 'VirtualMachines' | 'SqlDatabases' | 'SuseLinux' | 'CosmosDb' | 'RedHat' | 'SqlDataWarehouse' | 'VMwareCloudSimple' | 'RedHatOsa' | 'Databricks' | 'AppService' | 'ManagedDisk' | 'BlockBlob' | 'RedisCache' | 'AzureDataExplorer' | 'MySql' | 'MariaDb' | 'PostgreSql' | 'DedicatedHost' | 'SapHana' | 'SqlAzureHybridBenefit' | 'AVS' | 'DataFactory' | 'NetAppStorage' | 'AzureFiles' | 'SqlEdge' | 'VirtualMachineSoftware' — The type of the resource that is being reserved.
        - `billingScopeId` string — Subscription that will be charged for purchasing Reservation
        - `term` 'P1Y' | 'P3Y' | 'P5Y' — Represent the term of Reservation.
        - `billingPlan` 'Upfront' | 'Monthly' — Represent the billing plans.
        - `quantity` integer — Quantity of the SKUs that are part of the Reservation. Must be greater than zero.
        - `displayName` string — Friendly name of the Reservation
        - `appliedScopeType` 'Single' | 'Shared' — Type of the Applied Scope.
        - `appliedScopes` string[] — List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared.
        - `renew` boolean — Setting this to true will automatically purchase a new reservation on the expiration date time.
        - `reservedResourceProperties` object — Properties specific to each reserved resource type. Not required if not applicable.
          - `instanceFlexibility` 'On' | 'Off' — Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.
    - `reservationsToExchange` ReservationToReturn[] — List of reservations that are being returned in this exchange.
      - `reservationId` string — Fully qualified identifier of the Reservation being returned
      - `quantity` integer — Quantity to be returned. Must be greater than zero.

## Response `200`

The request is completed.

- CalculateExchangeOperationResultResponse — CalculateExchange operation result
  - `id` string — It should match what is used to GET the operation result.
  - `name` string — It must match the last segment of the id field, and will typically be a GUID / system generated value.
  - `status` 'Succeeded' | 'Failed' | 'Cancelled' | 'Pending' — Status of the operation.
  - `properties` CalculateExchangeResponseProperties — CalculateExchange response properties
    - `sessionId` string — Exchange session identifier
    - `netPayable` Price
      - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
      - `amount` number, double
    - `refundsTotal` Price
      - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
      - `amount` number, double
    - `purchasesTotal` Price
      - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
      - `amount` number, double
    - `reservationsToPurchase` ReservationToPurchaseCalculateExchange[] — Details of the reservations being purchased
      - `properties` PurchaseRequest
        - `sku` SkuName
          - `name` string
        - `location` string — The Azure Region where the reserved resource lives.
        - `properties` PurchaseRequestProperties
          - `reservedResourceType` 'VirtualMachines' | 'SqlDatabases' | 'SuseLinux' | 'CosmosDb' | 'RedHat' | 'SqlDataWarehouse' | 'VMwareCloudSimple' | 'RedHatOsa' | 'Databricks' | 'AppService' | 'ManagedDisk' | 'BlockBlob' | 'RedisCache' | 'AzureDataExplorer' | 'MySql' | 'MariaDb' | 'PostgreSql' | 'DedicatedHost' | 'SapHana' | 'SqlAzureHybridBenefit' | 'AVS' | 'DataFactory' | 'NetAppStorage' | 'AzureFiles' | 'SqlEdge' | 'VirtualMachineSoftware' — The type of the resource that is being reserved.
          - `billingScopeId` string — Subscription that will be charged for purchasing Reservation
          - `term` 'P1Y' | 'P3Y' | 'P5Y' — Represent the term of Reservation.
          - `billingPlan` 'Upfront' | 'Monthly' — Represent the billing plans.
          - `quantity` integer — Quantity of the SKUs that are part of the Reservation. Must be greater than zero.
          - `displayName` string — Friendly name of the Reservation
          - `appliedScopeType` 'Single' | 'Shared' — Type of the Applied Scope.
          - `appliedScopes` string[] — List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared.
          - `renew` boolean — Setting this to true will automatically purchase a new reservation on the expiration date time.
          - `reservedResourceProperties` object — Properties specific to each reserved resource type. Not required if not applicable.
            - `instanceFlexibility` 'On' | 'Off' — Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.
      - `billingCurrencyTotal` Price
        - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
        - `amount` number, double
    - `reservationsToExchange` ReservationToExchange[] — Details of the reservations being returned
      - `reservationId` string — Fully qualified id of the Reservation being returned.
      - `quantity` integer — Quantity to be returned
      - `billingRefundAmount` Price
        - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
        - `amount` number, double
      - `billingInformation` BillingInformation — billing information
        - `billingCurrencyTotalPaidAmount` Price
          - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
          - `amount` number, double
        - `billingCurrencyProratedAmount` Price
          - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
          - `amount` number, double
        - `billingCurrencyRemainingCommitmentAmount` Price
          - `currencyCode` string — The ISO 4217 3-letter currency code for the currency used by this purchase record.
          - `amount` number, double
    - `policyResult` ExchangePolicyErrors — Exchange policy errors
      - `policyErrors` ExchangePolicyError[] — Exchange Policy errors
        - `code` string
        - `message` string
  - `error` OperationResultError — Required if status == failed or status == canceled.
    - `code` string — Required if status == failed or status == cancelled. If status == failed, provide an invariant error code used for error troubleshooting, aggregation, and analysis.
    - `message` string — Required if status == failed. Localized. If status == failed, provide an actionable error message indicating what error occurred, and what the user can do to address the issue.

## Other responses

- `202` — The request is accepted and is being processed.
- `default` — Unexpected error

---

[API](https://skmtc.net/azure/apis/reservations-microsoft-capacity-reservations.md) · [All operations](https://skmtc.net/azure/apis/reservations-microsoft-capacity-reservations/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/azure/reservations-microsoft-capacity-reservations/revisions/1d4481f1bd1e/schema)
