Partial and full unit transfer using APIs
This guide describes how to perform a partial or full unit transfer with the AppDirect GraphQL API. Unit transfer applies to any product whose edition supports it, including Microsoft NCE and Adobe. The same operations move units from a source subscription to a target edition, either on a new subscription or on an existing one.
For the equivalent steps in the marketplace, see Unit transfer. Vendor rules differ:
- Full upgrades for NCE subscriptions to new and existing subscriptions
- Adobe anytime upgrades in the Marketplace
The operations used below are summarized in Subscription Update v2: UI vs API coverage.
The workflow is:
- Create an API client
- Get the source subscription details
- Get the list of eligible editions
- Get the list of eligible subscriptions
- Get the target subscription details (if applicable)
- Perform the unit transfer operation
- Get the status of the request
π Note: The APIs described in this guide are released in the Preview lifecycle state. For more information about Preview status, see Product lifecycle phases.
Step 1: Create an API clientβ
To create an API client, log in to the marketplace, then go to Manage > Marketplace > Settings > API Clients > Create API Client. Use the following configuration:
- Client Type: Non-interactive application
- System-level scopes: Read and write (corresponds to ROLE_PARTNER when configuring the API authentication)
Keep your client ID and client secret in a safe place.
For the full procedure, see Create API clients for non-interactive applications.
Step 2: Get the source subscription detailsβ
Before the transfer, get the details of the source subscription. You need the current quantity. The combined quantities of the resulting source and target subscriptions after a partial or full transfer must equal the original quantity of the source subscription.
To retrieve the subscription details, use the following endpoint:
GET {{marketplaceURL}}/api/billing/v1/subscriptions/{{subscriptionUuid}}
The response includes the subscription details, including the quantity and unit fields.
Step 3: Get the list of eligible editionsβ
The vendor defines the upgrade path for a given subscription. For Microsoft NCE, Microsoft defines that path. The path uses two dimensions:
- Eligible editions
- Eligible subscriptions
To get the list of eligible editions, use the following GraphQL query:
POST {{marketplaceURL}}/api/graphql/preview
query transferUnitEligibleEditions($subscriptionId: String!) {
transferUnitEligibleEditions(subscriptionId: $subscriptionId) {
sourceSubscriptionId
transferUnitEligibleEditions {
product {
id
version
vendor {
id
name
status
}
}
pricingPlan {
id
editionId
productId
costs {
itemPrices {
prices {
amount
currency
}
}
}
}
edition {
id
name {
locale
value
}
version
code
}
}
}
}
Provide the following input:
{
"subscriptionId": "{{sourceSubscriptionUuid}}"
}
From the response, store the desired pricingPlanId. You use it in later steps as the target pricing plan UUID.
Step 4: Get the list of eligible subscriptions (if applicable)β
The user may be eligible to transfer units from an existing source subscription to an existing target subscription. The vendor defines the eligibility criteria.
To determine whether the user has any eligible subscriptions, use the following GraphQL query:
POST {{marketplaceURL}}/api/graphql/preview
query transferUnitEligibleSubscriptions($subscriptionId: String!, $pricingPlanId: String!) {
transferUnitEligibleSubscriptions(subscriptionId: $subscriptionId, pricingPlanId: $pricingPlanId) {
id
status
pricingPlan {
id
}
units {
quantity
unit
}
product {
id
version
vendor {
id
name
status
}
editions {
id
pricing {
pricingPlanIds
}
}
}
}
}
Provide the following input:
{
"subscriptionId": "{{sourceSubscriptionUuid}}",
"pricingPlanId": "{{targetPricingPlanUuid}}"
}
The pricing plan ID is the pricing plan ID from Step 3.
This query returns an empty object if the user does not have any eligible subscriptions. Otherwise, it returns the list of eligible target subscriptions.
Step 5: Get the target subscription details (if applicable)β
If the user has an eligible target subscription, retrieve its details with the following endpoint:
GET {{marketplaceURL}}/api/billing/v1/subscriptions/{{subscriptionUuid}}
The response includes the subscription details, including the quantity and unit fields.
Step 6: Perform the unit transfer operationβ
After you have collected the required information, request the unit transfer.
POST {{marketplaceURL}}/api/graphql/preview
mutation transferUnits($transferUnitsRequest: TransferUnitsRequestInput!) {
transferUnits(transferUnitsRequest: $transferUnitsRequest) {
purchaseId
subscriptionId
idempotencyKey
}
}
The following input is an example. Set unit and quantity to the unit type and quantities for the subscription you are transferring. transferAllUnits is false for a partial transfer.
{
"transferUnitsRequest": {
"idempotencyKey": "{{idempotencyKey}}",
"subscriptionId": "{{sourceSubscriptionUuid}}",
"transferAllUnits": false,
"items": [{
"unit": {
"unit": "USER",
"quantity": 19
}
}],
"targetSubscription": {
"subscriptionId": "{{targetSubscriptionUuid}}",
"pricingPlanId": "{{targetPricingPlanUuid}}",
"items": [{
"unit": {
"unit": "USER",
"quantity": 1
}
}]
}
}
}
Every request must have a unique idempotency key. This key is used later to track the status of the request.
The target subscription UUID is not mandatory. If the user does not have any eligible subscriptions, omit targetSubscription.subscriptionId.
This request returns the purchase ID, the source subscription UUID, and the idempotency key that was provided in the request.
π Note: This mutation is asynchronous. Processing time can be long depending on the vendor. For Microsoft, requests can take up to 30 seconds. Use the query in Step 7 to get the status of the request.
Step 7: Get the status of the unit transfer requestβ
Because the unit transfer request is asynchronous, use the following GraphQL query to retrieve its status:
POST {{marketplaceURL}}/api/graphql/preview
query ($idempotencyKey: String!) {
subscriptionUpdateRequestStatus(idempotencyKey: $idempotencyKey) {
idempotencyKey
status
purchaseId
subscriptionUpdateRequest {
__typename
... on UnitsTransferSubscriptionUpdateRequest {
subscriptionId
pricingPlanId
transferAllUnits
targetSubscription {
subscriptionId
pricingPlanId
}
}
}
validationErrors {
status
errorCode
errorMessage
timestamp
}
}
}
Sample response:
{
"data": {
"subscriptionUpdateRequestStatus": {
"idempotencyKey": "your-idempotency-key",
"status": "COMPLETED",
"purchaseId": "request_uuid",
"subscriptionUpdateRequest": {
"__typename": "UnitsTransferSubscriptionUpdateRequest",
"subscriptionId": "example-subscription-id",
"pricingPlanId": "example-pricing-plan-id",
"transferAllUnits": true,
"targetSubscription": {
"subscriptionId": "example-target-subscription-id",
"pricingPlanId": "example-target-pricing-plan-id"
}
},
"validationErrors": [
{
"status": "ERROR",
"errorCode": "example-error-code",
"errorMessage": "example-error-message",
"timestamp": "example-timestamp"
}
]
}
}
}
The targetSubscription object returns the details of the target subscription. When transferring to a new subscription, the target subscription ID is available only when the request is completed. When updating an existing subscription, the target subscription ID is available immediately.
The purchaseId maps to the request UUID and can be used to track the status of the request on the vendor side. For Microsoft, that is the identifier used with Microsoft.
Related topicsβ
Was this page helpful?
Tell us moreβ¦
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!