Create a customer for an indirect reseller using Partner Center APIs

Applies to: Partner Center

An indirect provider can create a customer for an indirect reseller.

Prerequisites

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

  • The tenant identifier of the indirect reseller.

  • The indirect reseller must have a partnership with the indirect provider.

C#

To add a new customer for an indirect reseller:

  1. Instantiate a new Customer object and then instantiate and populate the BillingProfile and CompanyProfile. Be sure to assign the indirect reseller ID to the AssociatedPartnerID property.

  2. Use the IAggregatePartner.Customers property to get an interface to customer collection operations.

  3. Call the Create or CreateAsync method to create the customer.

C# example

// IAggregatePartner partnerOperations;
// var indirectResellerId;
var customerToCreate = new Customer()
{
    CompanyProfile = new CustomerCompanyProfile()
    {
        Domain = string.Format(CultureInfo.InvariantCulture,
            "WingtipToys{0}.{1}",
            new Random().Next(),
            this.Context.Configuration.Scenario.CustomerDomainSuffix)
    },
    BillingProfile = new CustomerBillingProfile()
    {
        Culture = "EN-US",
        Email = "Gena@wingtiptoys.com",
        Language = "En",
        CompanyName = "Wingtip Toys",
        DefaultAddress = new Address()
        {
            FirstName = "Gena",
            LastName = "Soto",
            AddressLine1 = "One Microsoft Way",
            City = "Redmond",
            State = "WA",
            Country = "US",
            PostalCode = "98052",
            PhoneNumber = "4255550101"
        }
    },
    AssociatedPartnerId = indirectResellerId
};

var newCustomer = partnerOperations.Customers.Create(customerToCreate);

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

REST request

Request syntax

Method Request URI
POST {baseURL}/v1/customers HTTP/1.1

Request headers

For more information, see Partner Center REST headers.

Request body

This table describes the required properties in the request body.

Name Type Required Description
BillingProfile object Yes The customer's billing profile information.
CompanyProfile object Yes The customer's company profile information.
AssociatedPartnerId string Yes The indirect reseller ID. The indirect reseller as indicated by the ID supplied here must have a partnership with the indirect provider or the request will fail. Also note that if the AssociatedPartnerId value isn't supplied, the customer is created as a direct customer of the indirect provider rather than the indirect reseller.
Domain String Yes The customer's domain name, such as contoso.onmicrosoft.com.
organizationRegistrationNumber string Yes The customer's organization registration number (also referred to as INN number in certain countries/regions). Only required for customer's company/organization located in the following countries/regions: Armenia(AM), Azerbaijan(AZ), Belarus(BY), Hungary(HU), Kazakhstan(KZ), Kyrgyzstan(KG), Moldova(MD), Russia(RU), Tajikistan(TJ), Uzbekistan(UZ), Ukraine(UA), India, Brazil, South Africa, Poland, United Arab Emirates, Saudi Arabia, Türkiye, Thailand, Vietnam, Myanmar, Iraq, South Sudan, and Venezuela. For customer's company/organization located in other countries/regions this is an optional field.

Billing profile

This table describes the minimum required fields from the CustomerBillingProfile resource needed to create a new customer.

Name Type Required Description
email string Yes The customer's email address.
culture string Yes Their preferred culture for communication and currency, such as en-US. See Partner Center supported languages and locales for the supported cultures.
language string Yes The default language. Two character language codes (for example en or fr) are supported.
company_name string Yes The registered company/organization name.
default_address Address Yes The registered address of the customer's company/organization. See the Address resource for information on any length limitations.

Company profile

This table describes the minimum required fields from the CustomerCompanyProfile resource needed to create a new customer.

Name Type Required Description
domain string Yes The customer's domain name, such as contoso.onmicrosoft.com.
organizationRegistrationNumber string Depends on condition The customer's organization registration number (also referred to as the INN number in certain countries/regions).

Completing this field is required only if a customer's company/organization is located in the following countries/regions:

- Armenia (AM)
- Azerbaijan (AZ)
- Belarus (BY)
- Hungary (HU)
- Kazakhstan (KZ)
- Kyrgyzstan (KG)
- Moldova (MD)
- Russia (RU)
- Tajikistan (TJ)
- Uzbekistan (UZ)
- Ukraine (UA)
- India
- Brazil
- South Africa
- Poland
- United Arab Emirates
- Saudi Arabia
- Türkiye
- Thailand
- Vietnam
- Myanmar
- Iraq
- South Sudan
- Venezuela
- China

For customer's company/organization located in other countries/regions, this is an optional field.

GDAP by Default

Name Type Description
enableGDAPByDefault bool Boolean to indicate if we want to enable GDAP by default or not. If true we will create GDAP by default. If false, we will not create GDAP. Note, this is only honored in clouds that support GDAP. If no supported, DAP will be created by default.

Request example

POST https://api.partnercenter.microsoft.com/v1/customers HTTP/1.1
Authorization: Bearer <token>
MS-RequestId: d628adbe-b7ee-412e-ac55-58f22b4ba2f4
MS-CorrelationId: 0dd197a8-992c-44ca-aeae-21cd83494dce
X-Locale: en-US
MS-PartnerCenter-Client: Partner Center .NET SDK
Content-Type: application/json
Host: api.partnercenter.microsoft.com
Content-Length: 823
Expect: 100-continue
Connection: Keep-Alive

{
    "enableGDAPByDefault": false,
    "Id": null,
    "CommerceId": null,
    "CompanyProfile": {
        "TenantId": null,
        "Domain": "WingtipToys678152504.onmicrosoft.com",
        "CompanyName": null,
        "Attributes": {
            "ObjectType": "CustomerCompanyProfile"
        }
    },
    "BillingProfile": {
        "Id": null,
        "FirstName": null,
        "LastName": null,
        "Email": "Gena@wingtiptoys.com",
        "Culture": "EN-US",
        "Language": "En",
        "CompanyName": "Wingtip Toys",
        "DefaultAddress": {
            "Country": "US",
            "Region": null,
            "City": "Redmond",
            "State": "WA",
            "AddressLine1": "One Microsoft Way",
            "AddressLine2": null,
            "PostalCode": "98052",
            "FirstName": "Gena",
            "LastName": "Soto",
            "PhoneNumber": "4255550101"
        },
        "Attributes": {
            "ObjectType": "CustomerBillingProfile"
        }
    },
    "RelationshipToPartner": "none",
    "AllowDelegatedAccess": null,
    "UserCredentials": null,
    "CustomDomains": null,
    "AssociatedPartnerId": "484e548c-f5f3-4528-93a9-c16c6373cb59",
    "Attributes": {
        "ObjectType": "Customer"
    }
}

Important

As of June 2023, the latest Partner Center .NET SDK release 3.4.0 is now archived. You can download the SDK release from GitHub, along with a readme file that contains useful information.

Partners are encouraged to continue to use the Partner Center REST APIs.

REST response

If successful, the response contains a Customer resource for the new customer.

Response success and error codes

Responses come 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

HTTP/1.1 201 Created
Content-Length: 1085
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 0dd197a8-992c-44ca-aeae-21cd83494dce
MS-RequestId: d628adbe-b7ee-412e-ac55-58f22b4ba2f4
MS-CV: Yy/YaA0gYEmfQyR/.0
MS-ServerId: 030020525
Date: Tue, 06 Jun 2017 23:11:40 GMT

{
    "enableGDAPByDefault": false,
    "id": "626099fe-17af-4756-9fd0-6a73b7127859",
    "commerceId": "626099fe-17af-4756-9fd0-6a73b7127859",
    "companyProfile": {
        "tenantId": "626099fe-17af-4756-9fd0-6a73b7127859",
        "domain": "WingtipToys678152504.onmicrosoft.com",
        "companyName": "Wingtip Toys",
        "links": {
            "self": {
                "uri": "/customers/626099fe-17af-4756-9fd0-6a73b7127859/profiles/company",
                "method": "GET",
                "headers": []
            }
        },
        "attributes": {
            "objectType": "CustomerCompanyProfile"
        }
    },
    "billingProfile": {
        "id": "7079246e-7b62-56ef-7cbd-a819514b54b5",
        "email": "Gena@wingtiptoys.com",
        "culture": "en-US",
        "language": "En",
        "companyName": "Wingtip Toys",
        "defaultAddress": {
            "country": "US",
            "city": "Redmond",
            "state": "WA",
            "addressLine1": "One Microsoft Way",
            "postalCode": "98052",
            "firstName": "Gena",
            "lastName": "Soto",
            "phoneNumber": "4255550101"
        },
        "attributes": {
            "etag": "-8799889149591823008",
            "objectType": "CustomerBillingProfile"
        }
    },
    "relationshipToPartner": "reseller",
    "allowDelegatedAccess": true,
    "userCredentials": {
        "userName": "admin",
        "password": "0Krha*Io"
    },
    "associatedPartnerId": "484e548c-f5f3-4528-93a9-c16c6373cb59",
    "attributes": {
        "objectType": "Customer"
    }
}