Renew a Microsoft Store ID key

Use this method to renew a Microsoft Store key. When you generate a Microsoft Store ID key, the key is valid for 30 days. Before the key expires, you can use it to renegotiate a new key by using this method.

The Microsoft.StoreServices library provides the functionality of this method through the UserStoreId.RefreshStoreId API.

Note

Previously Microsoft Store keys had a longer lifetime and in some cases were able to be renewed after the key had already expired. Now, developers should only expect keys to be renewable during their lifetime and should note the expire date on the keys in order to renew them before they expire.

Important

Although Microsoft Store keys are able to be renewed before they expire, the keys may be revoked prior to their expire dates in response to security concerns. Therefore, your services should handle the case where a renewal attempt fails with the AuthenticationTokenInvalid. In this case, you should generate a new Microsoft Store key for the user on the client or the method used to generate the original Microsoft Store key.

Prerequisites

To use this method, you will need:

For more information, see Manage product entitlements from a service.

Request

Request syntax

Key type Method Request URI
Collections POST https://collections.mp.microsoft.com/v6.0/b2b/keys/renew
Purchase POST https://purchase.mp.microsoft.com/v6.0/b2b/keys/renew

Request header

Header Type Description
Host string Must be set to the value collections.mp.microsoft.com or purchase.mp.microsoft.com.
Content-Length number The length of the request body.
Content-Type string Specifies the request and response type. Currently, the only supported value is application/json.

Request body

Parameter Type Description Required
serviceTicket string The Entra ID access token. Yes
key string The expired Microsoft Store ID key. Yes

Request example

POST https://collections.mp.microsoft.com/v6.0/b2b/keys/renew HTTP/1.1
Content-Length: 2774
Content-Type: application/json
Host: collections.mp.microsoft.com

{
    "serviceTicket": "eyJ0eXAiOiJKV1QiLCJhb….",
    "Key": "eyJ0eXAiOiJKV1QiLCJhbG…."
}

Response

Response body

Parameter Type Description
key string The refreshed Microsoft Store key that can be used in future calls to the Microsoft Store collections API or purchase API.

Response example

HTTP/1.1 200 OK
Content-Length: 1646
Content-Type: application/json
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: 1b5fa630-d672-4971-b2c0-3713f4ea6c85
MS-CV: xu2HW6SrSkyfHyFh.0.0
MS-ServerId: 030011428
Date: Tue, 13 Sep 2015 07:31:12 GMT

{
    "key":"eyJ0eXAi….."
}

Error codes

Code Error Inner error code Description
401 Unauthorized AuthenticationTokenInvalid The Entra ID access token or the Microsoft Store Key being renewed are invalid. In some cases the details of the ServiceError will contain more information, such as when the token is expired or the appid claim is missing.
401 Unauthorized InconsistentClientId The clientId claim in the Microsoft Store ID key and the appid claim in the Entra ID access token do not match.