Get a subscription by ID
This guide covers how to retrieve a specific subscription by providing the customer and subscription IDs.
PowerShell
To retrieve a subscription by ID, enter the following commands:
$customer = Get-PCCustomer -TenantId '<customer identifier>'
Get-PCSubscription -TenantId $customer.id -SubscriptionId '<subscription identifier>'
C#
To get a subscription by ID, do the following:
- Get an interface to the subscription operations by calling both of the following:
- The IAggregatePartner.Customers.ById method with the customer ID to identify the customer.
- The Subscriptions.ById method to identify the subscription.
- Use the 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();
REST API
Request
Request syntax
Method | Request URI |
---|---|
GET | {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{id-for-subscription} HTTP/1.1 |
URI parameter
To get the subscription, use the following required query parameters:
Name | Type | Description |
---|---|---|
customer-tenant-id | guid | A GUID that corresponds to the customer. |
id-for-subscription | guid | A GUID that corresponds to the subscription. |
Request example
GET https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/A356AC8C-E310-44F4-BF85-C7F29044AF99 HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 8f489776-a3f3-47cb-91c3-538e1f70f560
MS-CorrelationId: e72e1dc3-4abd-4ce0-908b-d23fdaedcb28
X-Locale: en-US
Host: api.partnercenter.microsoft.com
Response
If the request is successful, this method returns a Subscription resource in the response body.
Response example (standard subscription)
HTTP/1.1 200 OK
Content-Length: 833
Content-Type: application/json; charset=utf-8
MS-CorrelationId: e72e1dc3-4abd-4ce0-908b-d23fdaedcb28
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": "A356AC8C-E310-44F4-BF85-C7F29044AF99",
"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/A356AC8C-E310-44F4-BF85-C7F29044AF99",
"method": "GET",
"headers": []
}
},
"orderId": "B23FDEDD-D6BD-415A-8B71-3624C81C9644",
"attributes": {
"etag": "eyJpZCI6ImEzNTZhYzhjLWUzMTAtNDRmNC1iZjg1LWM3ZjI5MDQ0YWY5OSIsInZlcnNpb24iOjJ9",
"objectType": "Subscription"
}
}
Response example (add-on response)
HTTP/1.1 200 OK
Content-Length: 1132
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 6eacec93-852d-4167-9d96-c57809bea7ed
MS-RequestId: 22bfd0fb-d1e6-4a8f-aa1a-124b7c820d80
MS-CV: cmde2DtbuUWi8JLq.0
MS-ServerId: 201022015
Date: Fri, 27 Jan 2017 00:12:53 GMT
{
"id": "968BA1CF-C146-4ADF-A300-308DCF718EEE",
"offerId": "2828BE95-46BA-4F91-B2FD-0BEF192ECF60",
"offerName": "Exchange Online Archiving for Exchange Online",
"friendlyName": "Some friendly name",
"quantity": 2,
"unitType": "Licenses",
"parentSubscriptionId": "1C2B75C1-74A5-472A-A729-7F8CEFC477F9",
"creationDate": "2017-01-25T23:01:08.693Z",
"effectiveStartDate": "2017-01-25T00:00:00Z",
"commitmentEndDate": "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/1C2B75C1-74A5-472A-A729-7F8CEFC477F9",
"method": "GET",
"headers": []
},
"self": {
"uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/subscriptions/968BA1CF-C146-4ADF-A300-308DCF718EEE",
"method": "GET",
"headers": []
}
},
"orderId": "CF3B0E37-BE0B-4CDD-B584-D1A97D98A922",
"attributes": {
"etag": "eyJpZCI6Ijk2OGJhMWNmLWMxNDYtNGFkZi1hMzAwLTMwOGRjZjcxOGVlZSIsInZlcnNpb24iOjF9",
"objectType": "Subscription"
}
}
Next steps
- Learn about APIs for Azure CSP integration.
- View a list of Azure CSP integration scenarios.