View deleted users for a customer

Applies To

  • Partner Center

Gets a list of deleted CustomerUser resources for a customer by customer ID. You can optionally set a page size. You must supply a filter.


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

What happens when you delete a user account?

The user state is set to "inactive" when you delete a user account. It remains that way for thirty days, after which the user account and its associated data are purged and made unrecoverable. If you want to restore a deleted user account within the thirty day window, see Restore a deleted user for a customer. Note that once deleted and marked "inactive" the user account is no longer returned as a member of the user collection (for example, using Get a list of all user accounts for a customer). To get a list of deleted users that have not yet been purged, you must query for user accounts that have been set to inactive.


To retrieve a list of deleted users, construct a query that filters for customer users whose status is set to inactive. First, create the filter by instantiating a SimpleFieldFilter object with the parameters as shown in the following code snippet. Then create the query using the BuildIndexedQuery method. Note that if you do not want paged results, you can use the BuildSimpleQuery method instead. Next, use the IAggregatePartner.Customers.ById method with the customer ID to identify the customer. Finally, call the Query method to send the request.

// IAggregatePartner partnerOperations;
// int customerUserPageSize;

// Create a filter for users whose status is inactive (i.e. deleted).
var filter = new SimpleFieldFilter("UserState", FieldFilterOperation.Equals, "Inactive");

// Build a paged query.
var simpleQueryWithFilter = QueryFactory.Instance.BuildIndexedQuery(customerUserPageSize, 0, filter);

// Send the request.
var customerUsers = partnerOperations.Customers.ById(selectedCustomerId).Users.Query(simpleQueryWithFilter);

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


Request syntax

Method Request URI
GET {baseURL}/v1/customers/{customer-id}/users?size={size}&filter={filter} HTTP/1.1

URI parameter

Use the following path and query parameters when creating the request.

Name Type Required Description
customer-id guid Yes The value is a GUID formatted customer-id that identifies the customer.
size int No The number of results to be displayed at one time. This parameter is optional.
filter filter Yes The query that filters the user search. To retrieve deleted users, you must include and encode the following string: {"Field":"UserState","Value":"Inactive","Operator":"equals"}.

Request headers

Request body


Request example

Authorization: Bearer <token>
Accept: application/json
MS-RequestId: c11feb95-55d2-45b6-9d1b-74b55d2221fb
MS-CorrelationId: 2b4ab588-f48c-4874-b479-a61895e107b2
X-Locale: en-US


If successful, this method returns a collection of CustomerUser resources in the response body.

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 200 OK
Content-Length: 802
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 690b34ca-07c8-4f8a-ab13-f22a50594a43
MS-RequestId: 1187f9ad-02b4-4d96-b668-7cf3d289467b
MS-CV: 3TLmR9gz6EaCVCjR.0
MS-ServerId: 101112616
Date: Fri, 20 Jan 2017 19:13:14 GMT

    "totalCount": 1,
    "items": [{
            "usageLocation": "US",
            "id": "a45f1416-3300-4f65-9e8d-f123b397a4ea",
            "userPrincipalName": "",
            "firstName": "Ferdinand",
            "lastName": "Filibuster",
            "displayName": "Ferdinand",
            "userDomainType": "none",
            "state": "inactive",
            "softDeletionTime": "2017-01-20T00:33:34Z",
            "links": {
                "self": {
                    "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users/a45f1416-3300-4f65-9e8d-f123b397a4ea",
                    "method": "GET",
                    "headers": []
            "attributes": {
                "objectType": "CustomerUser"
    "links": {
        "self": {
            "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users?size=500&amp;filter=%7B%22Field%22%3A%22UserStatus%22%2C%22Value%22%3A%22Inactive%22%2C%22Operator%22%3A%22equals%22%7D",
            "method": "GET",
            "headers": []
    "attributes": {
        "objectType": "Collection"