Verify domain availability

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

How to determine if a domain is available for use.

Prerequisites

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

  • A domain (for example contoso.onmicrosoft.com).

C#

To verify if a domain is available, first call IAggregatePartner.Domains to obtain an interface to domain operations. Then call the ByDomain method with the domain to check. This method retrieves an interface to the operations available for a specific domain. Finally, call the Exists method to see if the domain already exists.

// IAggregatePartner partnerOperations;
// const string domain = "contoso.onmicrosoft.com";

bool result = partnerOperations.Domains.ByDomain(domain).Exists();

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

REST request

Request syntax

Method Request URI
HEAD {baseURL}/v1/domains/{domain} HTTP/1.1

URI parameter

Use the following query parameter to verify domain availability.

Name Type Required Description
domain string Y A string that identifies the domain to check.

Request headers

For more information, see Partner Center REST headers.

Request body

None

Request example

HEAD https://api.partnercenter.microsoft.com/v1/domains/contoso.onmicrosoft.com HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: cf5b00d6-9240-431c-a973-cc06c904e5bf
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Host: api.partnercenter.microsoft.com
Connection: Keep-Alive

REST response

If the domain exists, it isn't available for use and a response status code 200 OK is returned. If the domain isn't found, it's available for use and a response status code 404 Not Found is returned.

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 when the domain is already in use

HTTP/1.1 200 OK
Content-Length: 0
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: cf5b00d6-9240-431c-a973-cc06c904e5bf
MS-CV: 7UXAHds8J0mNUCSp.0
MS-ServerId: 201022015
Date: Tue, 31 Jan 2017 22:22:35 GMT

Response example for when the domain is available

HTTP/1.1 404 Not Found
Content-Length: 0
MS-CorrelationId: bbbb1111-cc22-3333-44dd-555555eeeeee
MS-RequestId: 1169a4cd-3be7-4e29-9cb3-0f78ffa2e91e
MS-CV: RRmc+bEw9U2e97CC.0
MS-ServerId: 202010406
Date: Tue, 31 Jan 2017 22:36:01 GMT