Del via


Get a subscription by ID

Applies to: Partner Center | Partner Center operated by 21Vianet | Partner Center for Microsoft Cloud for US Government

Gets a Subscription resource that matches the customer ID and the subscription ID.

Prerequisites

  • Credentials as described in Partner Center authentication. This scenario supports authentication with both standalone App and App+User credentials.

  • A customer ID (customer-tenant-id). If you don't know the customer's ID, you can look it up in Partner Center by selecting the Customers workspace, then the customer from the customer list, then Account. On the customer's Account page, look for the Microsoft ID in the Customer Account Info section. The Microsoft ID is the same as the customer ID (customer-tenant-id).

  • A subscription ID.

C#

To get a subscription by ID, begin by obtaining an interface to the subscription operations by calling the IAggregatePartner.Customers.ById method with the customer ID to identify the customer, and the Subscriptions.ById method to identify the subscription. Use that interface to retrieve the subscription details by calling Get.

// IAggregatePartner partnerOperations;
// string selectedCustomerId;
// string subscriptionID;

var subscriptionDetails = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(subscriptionID).Get();

Sample: Console test app. Project: Partner Center SDK Samples Class: GetSubscription.cs

REST request

Request syntax

Method Request URI
GET {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{id-for-subscription} HTTP/1.1

URI parameter

This table lists the required query parameters to get the subscription.

Name Type Required Description
customer-tenant-id guid Y A GUID corresponding to the customer.
id-for-subscription guid Y A GUID corresponding to the subscription.

Request headers

For more information, see Partner Center REST headers.

Request body

None.

Request example

GET https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 8f489776-a3f3-47cb-91c3-538e1f70f560
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Host: api.partnercenter.microsoft.com

REST response

If successful, this method returns a Subscription resource in the response body.

Response success and error codes

Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, error type, and additional parameters. For the full list, see Partner Center REST error codes.

Response example for a Microsoft Azure subscription

HTTP/1.1 200 OK
Content-Length: 833
Content-Type: application/json; charset=utf-8
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: 8f489776-a3f3-47cb-91c3-538e1f70f560
MS-CV: 7v11Wa//5EuGEo+A.0
MS-ServerId: 202010406
Date: Fri, 27 Jan 2017 21:51:40 GMT

{
    "id": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
    "entitlementId": "42226ED6-070A-4E0F-B80C-4CDFB3E97AA7",
    "offerId": "MS-AZR-0145P",
    "offerName": "Microsoft Azure",
    "friendlyName": "Microsoft Azure",
    "quantity": 1,
    "unitType": "Usage-based",
    "creationDate": "2016-05-10T07:30:05.427Z",
    "effectiveStartDate": "2016-05-10T00:00:00Z",
    "commitmentEndDate": "9999-12-10T00:00:00Z",
    "status": "active",
    "autoRenewEnabled": false,
    "billingType": "usage",
    "contractType": "subscription",
    "links": {
        "offer": {
            "uri": "/offers/MS-AZR-0145P?country=US",
            "method": "GET",
            "headers": []
        },
        "self": {
            "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
            "method": "GET",
            "headers": []
        }
    },
    "orderId": "B23FDEDD-D6BD-415A-8B71-3624C81C9644",
    "attributes": {
        "etag": "eyJpZCI6ImEzNTZhYzhjLWUzMTAtNDRmNC1iZjg1LWM3ZjI5MDQ0YWY5OSIsInZlcnNpb24iOjJ9",
        "objectType": "Subscription"
    }
}

Response example for an add-on subscription

The response for an add-on subscription includes the parent subscription ID in the body and in the links.

HTTP/1.1 200 OK
Content-Length: 1132
Content-Type: application/json; charset=utf-8
MS-CorrelationId: bbbb1111-cc22-3333-44dd-555555eeeeee
MS-RequestId: 22bfd0fb-d1e6-4a8f-aa1a-124b7c820d80
MS-CV: cmde2DtbuUWi8JLq.0
MS-ServerId: 201022015
Date: Fri, 27 Jan 2017 00:12:53 GMT

{
    "id": "cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a",
    "offerId": "2828BE95-46BA-4F91-B2FD-0BEF192ECF60",
    "offerName": "Exchange Online Archiving for Exchange Online",
    "friendlyName": "Some friendly name",
    "quantity": 2,
    "unitType": "Licenses",
    "parentSubscriptionId": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
    "creationDate": "2017-01-25T23:01:08.693Z",
    "effectiveStartDate": "2017-01-25T00:00:00Z",
    "commitmentEndDate": "2018-02-10T00:00:00Z",
    "commitmentEndDateTime": "2018-02-10T00:00:00Z",
    "status": "active",
    "autoRenewEnabled": true,
    "billingType": "license",
    "contractType": "subscription",
    "links": {
        "offer": {
            "uri": "/offers/2828BE95-46BA-4F91-B2FD-0BEF192ECF60?country=US",
            "method": "GET",
            "headers": []
        },
        "parentSubscription": {
            "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
            "method": "GET",
            "headers": []
        },
        "self": {
            "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a",
            "method": "GET",
            "headers": []
        }
    },
    "orderId": "CF3B0E37-BE0B-4CDD-B584-D1A97D98A922",
    "attributes": {
        "etag": "eyJpZCI6Ijk2OGJhMWNmLWMxNDYtNGFkZi1hMzAwLTMwOGRjZjcxOGVlZSIsInZlcnNpb24iOjF9",
        "objectType": "Subscription"
    }
}

Response example for a new commerce subscription

Note

The new commerce experiences for license-based services include many new capabilities and are available to all Cloud Solution Provider (CSPs). For more information, see new commerce experiences overview.

HTTP/1.1 200 OK
Content-Length: 1132
Content-Type: application/json; charset=utf-8
MS-CorrelationId: cccc2222-dd33-4444-55ee-666666ffffff
MS-RequestId: 54sfd0fb-d1e6-4a8f-aa1a-124b7c820d80
MS-CV: cmde2DtbuUWi8JLq.0
MS-ServerId: 201022015
Date: Fri, 17 Nov 2023 00:14:53 GMT

{
      "id": "dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b",
      "offerId": "CFQ7TTC0LFLZ:0002:CFQ7TTC0MKD5",
      "offerName": "Microsoft 365 E5",
      "friendlyName": "Microsoft 365 E5",
      "productType": {
        "id": "OnlineServicesNCE",
        "displayName": "OnlineServicesNCE"
      },
      "quantity": 1,
      "unitType": "Licenses",
      "hasPurchasableAddons": false,
      "consumptionType": "overage",
      "creationDate": "2023-11-28T22:28:50.7842638Z",
      "effectiveStartDate": "2023-11-28T00:00:00Z",
      "commitmentEndDate": "2023-12-27T00:00:00Z",
      "commitmentEndDateTime": "2023-12-27T23:59:59Z",
      "cancellationAllowedUntilDate": "2023-12-05T22:29:25.9967858Z",
      "billingCycleEndDate": "2023-12-27T00:00:00Z",
      "billingCycleEndDateTime": "2023-12-27T23:59:59Z",
      "status": "active",
      "autoRenewEnabled": true,
      "isTrial": false,
      "billingType": "license",
      "billingCycle": "monthly",
      "termDuration": "P1M",
      "renewalTermDuration": "",
      "refundOptions": [
        {
          "type": "Full",
          "expiresAt": "2023-11-29T22:29:25.9967858Z"
        }
      ],
      "isMicrosoftProduct": true,
      "partnerId": "",
      "attentionNeeded": false,
      "actionTaken": false,
      "contractType": "subscription",
      "links": {
        "product": {
          "uri": "/products/CFQ7TTC0LFLZ?country=US",
          "method": "GET",
          "headers": []
        },
        "sku": {
          "uri": "/products/CFQ7TTC0LFLZ/skus/0002?country=US",
          "method": "GET",
          "headers": []
        },
        "availability": {
          "uri": "/products/CFQ7TTC0LFLZ/skus/0002/availabilities/CFQ7TTC0MKD5?country=US",
          "method": "GET",
          "headers": []
        },
        "self": {
          "uri": "/customers/bfb6b398-c7f5-40f0-aa75-a1f1adf81374/subscriptions/dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b",
          "method": "GET",
          "headers": []
        }
      },
      "publisherName": "Microsoft Corporation",
      "orderId": "f9a896ba4686",
      "attributes": {
        "objectType": "Subscription"
      }
    }