# Delete a Customer Our customer John Doe has requested to be removed from our webshop. Let's comply with his wish and delete him. If you have to follow such requests, make sure you read our advice on complying with public regulations such as the [European Union's Data Protection Regulation (GDPR)](https://docs.commercetools.com/api/gdpr.md). For the full SDK reference on managing Customers, see [SDK example code](https://docs.commercetools.com/learning-composable-commerce-developer-essentials/dev-tooling/sdk-example-code.md#manage-customers). To delete a resource in commercetools, you identify the resource with its `key` or `id` and then send a DELETE call when using the REST API, together with the correct version. For Customers, see our documentation on [deleting Customers](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcustomers%2F%7Bid%7D%3ADELETE). An example request would be: ```bash DELETE https://api.{region}.commercetools.com/{projectKey}/customers/key={key}?version={version} Authorization: Bearer my_token ``` ## Use the SDKs Create a file called `customerDelete.js` and copy the following code: ```typescript import { apiRoot } from '../impl/apiClient.js'; // Update to map to your API root const customerKey = 'john-doe-example'; // Change the version number if necessary const customerVersion = 1; async function customerDeleteByKey(customerKey, customerVersion) { try { const response = await apiRoot .customers() .withKey({ key: customerKey }) .delete({ queryArgs: { version: customerVersion, }, }) .execute(); console.log('Success', JSON.stringify(response.body, null, 2)); } catch (error) { console.log(JSON.stringify(error, null, 2)); } } customerDeleteByKey(customerKey, customerVersion); ``` In the following code we have combined the code snippets from the service and exercise class. Make sure you place the code into the correct files and add import statements as needed. ```java CustomerService: public CompletableFuture> deleteCustomerByKey(String customerKey, long version) { return apiRoot .customers() .withKey(customerKey) .delete() .withVersion(version) .execute(); } CustomerExercise: logger.info("Customer deleted: " + customerService .deleteCustomerByKey( "john-doe-example", 1L ) .toCompletableFuture().get() .getBody().getEmail() ); ``` Don’t forget to verify in the Merchant Center or programmatically that the Customer has indeed been deleted. ## Related pages - [Section overview page](https://docs.commercetools.com/learning-composable-commerce-developer-essentials.md) - [Previous page: Update a Customer](https://docs.commercetools.com/learning-composable-commerce-developer-essentials/manage-resources-with-the-sdk/update-a-customer.md) - [Next page: Best practices](https://docs.commercetools.com/learning-composable-commerce-developer-essentials/manage-resources-with-the-sdk/best-practices.md)