# Delete Scans

> Delete scans from Copyleaks API.

<RequestExample>

```bash title="cURL" icon="terminal"
curl --request PATCH \
  --url https://api.copyleaks.com/v3.1/scans/delete \
  --header 'Authorization: Bearer YOUR_LOGIN_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "scans": [
      { "id": "Your-scan-id-1" },
      { "id": "Your-scan-id-2" }
    ],
    "purge": false
  }'
```

```python title="Python" icon="python"
from copyleaks.copyleaks import Copyleaks
from copyleaks.models.delete import Delete, DeleteScan

auth_token = Copyleaks.login("your@email.address", "YOUR_API_KEY")

delete = Delete()
delete.set_scans([DeleteScan("Your-scan-id-1"), DeleteScan("Your-scan-id-2")])
delete.set_purge(False)

Copyleaks.delete(auth_token, delete)
```

</RequestExample>

<ResponseExample>

```json 202 Accepted
{}
```

</ResponseExample>

Delete scans from Copyleaks API. Only completed scans can be deleted. All of the scan results, metadata and information will be removed.

The delete is performed in the background, the deletion process can take few minutes.

<Warning>
**Authentication Required.** You need to login with a user and API key in order to access this method. Add this HTTP header to your request:

**Authorization: Bearer &lt;Your-Login-Token&gt;**
</Warning>

## Request

### Headers

```http
Content-Type: application/json
Authorization: Bearer YOUR_LOGIN_TOKEN
```

### Request Body

The request body is a JSON object containing the scans to delete.

<ParamField body="scans" type="array<object>" required>
  The list of scans to delete.

      `<= 10000` items

      Example: `[ {"id": "Your-scan-id-1"}, {"id": "Your-scan-id-2"} ]`
</ParamField>
<ParamField body="purge" type="boolean" default="false">
  Deleting and purging a scan through the API will remove all traces of the scan from Copyleaks servers, including Shared Data Hubs and Private Cloud Hubs. Once purged, the scan will be permanently deleted and will not be available for future scans.
</ParamField>
<ParamField body="completionWebhook" type="string">
  Allows you to register to a webhook that will be fired once the removal has been completed. Make sure that your endpoint is listening to a POST method (no body parameters were supplied).

      Example: `https://yoursite.com/webhook/deleted`
</ParamField>
<ParamField body="headers" type="array[array]" default="null">
  Adds user specific headers to the request. This is needed in case the webhook endpoint requires any custom headers.

      Example: `[ [ "header-key", "header-value" ], ... ]`
</ParamField>

## Responses

<Tabs>
  <Tab title="202">
    <Check>**202 Accepted** - The request was placed for removal. Note that this process is asynchronous. This means that the actual removal will take place once one of our servers will be free. In order to get notified after the command execution, register to webhook notification (completionWebhook).</Check>
  </Tab>
  <Tab title="400">
    <Warning>**400 Bad Request** - Bad Request.</Warning>
  </Tab>
  <Tab title="401">
    <Warning>**401 Unauthorized** - Authorization has been denied for this request.</Warning>
  </Tab>
</Tabs>
