> For the complete documentation index, see [llms.txt](https://docs.prestashop-project.org/1-5-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.prestashop-project.org/1-5-documentation/english-documentation/developer-guide/developer-tutorials/using-the-prestashop-web-service/chapter-7-removal-remove-customer-accounts-from-the-database.md).

# Chapter 7 - Removal - Remove customer accounts from the database

**Objective**: A Web application for listing and deleting customers.\
&#x20;**Difficulty**: \*

## Preparation <a href="#chapter7-removal-removecustomeraccountsfromthedatabase-preparation" id="chapter7-removal-removecustomeraccountsfromthedatabase-preparation"></a>

Duplicate file `list_the_clients.php` from Chapter 3, rename it to `D-CRUD.php` and put it at the root of your Web server.

For this last part of our tutorial, we will learn how to delete a resource.

Here is the complete, detailed code you need in order to remove a customer:

```
try {
	$webService = new PrestaShopWebservice('http://example.com/' , 'ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT' , false); // Create an instance
	$opt['resource'] = 'customers';            // Resource to use
	opt['id'] = 3;                             // ID to use
	$webService->delete($opt);                 // Delete
	echo 'Client '.3.' successfully deleted!'; // If we can see this message, that means we have not left the try block
}
catch (PrestaShopWebserviceException $ex) {
	$trace = $ex->getTrace();                // Retrieve all info on this error
	$errorCode = $trace[0]['args'][0]; // Retrieve error code 
	if ($errorCode == 401) 
		echo 'Bad auth key';   
	else 
		echo 'Other error: <br />'.$ex->getMessage(); 
	// Display error message{color}
}
```

This code enables you to remove a customer whose ID is "3". As you can see, deleting the customer differs only slightly from retrieving a resource. In fact the only thing different in the code lies in the method called: We will no longer call this method `get()` but instead simply `delete()`!

You must now replace the customer ID by a dynamically-defined ID.

Now create all the script that will display a list of customer IDs and delete a customer of your choice.

Again, if you have trouble, look at the code from the `4-delete.php` sample file.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.prestashop-project.org/1-5-documentation/english-documentation/developer-guide/developer-tutorials/using-the-prestashop-web-service/chapter-7-removal-remove-customer-accounts-from-the-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
