Delete a user account for a customer
This article explains how to delete an existing user account for a customer.
Prerequisites
Credentials as described in Partner Center authentication. This scenario supports authentication with App+User credentials only.
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 user ID. If you do not have the user ID, see Get a list of all user accounts for a customer.
Deleting a user account
When you delete a user account, the user state is set to inactive for 30 days. After thirty 30 days, the user account and its associated data are purged and made unrecoverable.
You can restore a deleted user account for a customer if the inactive account is within the 30-day window. However, when you restore an account that was deleted and marked as inactive, the account is no longer returned as a member of the user collection (for example, when you get a list of all user accounts for a customer).
GDAP roles
You'll need the following GDAP role:
- User Administrator
C#
To delete an existing customer user account:
Use the IAggregatePartner.Customers.ById method with the customer ID to identify the customer.
Call the Users.ById method to identify the user.
Call the Delete method to delete the user and set the user state to inactive.
// IAggregatePartner partnerOperations;
// string selectedCustomerId;
// string customerUserIdToDelete;
partnerOperations.Customers.ById(selectedCustomerId).Users.ById(customerUserIdToDelete).Delete();
Sample: Console test app. Project: Partner Center SDK Samples Class: DeleteCustomerUser.cs
REST request
Request syntax
Method | Request URI |
---|---|
DELETE | {baseURL}/v1/customers/{customer-tenant-id}/users/{user-id} HTTP/1.1 |
URI parameters
Use the following query parameters to identify the customer and user.
Name | Type | Required | Description |
---|---|---|---|
customer-tenant-id | GUID | Y | The value is a GUID-formatted customer-tenant-id that allows the reseller to filter the results for a given customer. |
user-id | GUID | Y | The value is a GUID-formatted user-id that belongs to a single user account. |
Request headers
For more information, see Partner Center REST headers.
Request body
None.
Request example
DELETE https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users/a45f1416-3300-4f65-9e8d-f123b397a4ea HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: f113b126-ec13-4baa-ab4d-67c245244971
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Host: api.partnercenter.microsoft.com
Content-Length: 0
REST response
If successful, this method returns a 204 No Content status code.
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
HTTP/1.1 204 No Content
Content-Length: 0
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: f113b126-ec13-4baa-ab4d-67c245244971
MS-CV: 90KUJA7HKEaG8wHu.0
MS-ServerId: 101112616
Date: Tue, 24 Jan 2017 23:27:18 GMT