---
title: Delete Batch
slug: serpwow/batches-api/batches/delete
docTags: 
createdAt: 2024-08-05T14:13:33.938Z
---

# Delete Batch

Batches can be deleted by making an `HTTP DELETE` request to the `/batches/BATCH_ID` endpoint (where `BATCH_ID` is the `id` of the Batch you wish to delete).

:::hint{type="info"}
A Batch can only be deleted under certain condidtions.&#x20;

- A batch **cannot be deleted** if it is currently running.&#x20;
- A batch **cannot be deleted** if any results within it have a `webhook_status` of "failed", unless the `force=true` parameter is added to the request. If `force=true` is added to the request, then the batch will be deleted even if there are webhook failures.



To check whether a Batch is currently running use the [Get Batch](https://docs.trajectdata.com/serpwow/batches-api/batches/get) endpoint.

To check whether a webhook has failed, use the [Get Result Set](docId\:Vech8qYNmvyjtn8NS0dqF) endpoint.
:::

***

### Example

<font color="#f5222d">`DELETE`</font>  `/batches/BATCH_ID`

In the example below we delete a Batches with `id=123456` :

:::CodeblockTabs
```curl
$ curl -X DELETE "https://api.serpwow.com/live/batches/123456?api_key=demo"
```

```nodejs
const axios = require('axios');
const params = {
  api_key: 'demo'
}

axios.delete('https://api.serpwow.com/live/batches/123456', { params })
  .then(response => {

    console.log('Batch deleted.');

  }).catch(error => {
    console.log(error);
  });
```

```python
import requests

api_result = requests.delete('https://api.serpwow.com/live/batches/123456?api_key=demo')

print ("Batch deleted.")
```

```php
<?php
      
$queryString = http_build_query([
  'api_key' => 'demo',
]);

$ch = curl_init(sprintf('%s?%s', 'https://api.serpwow.com/live/batches/123456', $queryString));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
# the following options are required if you're using an outdated OpenSSL version
# more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 180);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

$json = curl_exec($ch);
curl_close($ch);

echo "Batch deleted.", PHP_EOL;

?>
```
:::

SerpWow responds with a JSON object confirming that the Batch has been deleted, or detailing the error if it has not been possible to delete the Batch:

```json
{
  "request_info": {
    "success": true,
    "message": "batch deleted"
  }
}
```

### Example when webhook failed

<font color="#f5222d">`DELETE`</font>  `/batches/BATCH_ID?force=true`

In the example below we delete a Batches with `id=123456` :

:::CodeblockTabs
```curl
$ curl -X DELETE "https://api.serpwow.com/live/batches/123456?api_key=demo&force=true"
```

```nodejs
const axios = require('axios');
const params = {
  api_key: 'demo'
  force: 'true'
}

axios.delete('https://api.serpwow.com/live/batches/123456', { params })
  .then(response => {

    console.log('Batch deleted.');

  }).catch(error => {
    console.log(error);
  });
```

```python
import requests

api_result = requests.delete('https://api.serpwow.com/live/batches/123456?api_key=demo&force=true')

print ("Batch deleted.")
```

```php
<?php
      
$queryString = http_build_query([
  'api_key' => 'demo',
  'force'=> 'true'
]);

$ch = curl_init(sprintf('%s?%s', 'https://api.serpwow.com/live/batches/123456', $queryString));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
# the following options are required if you're using an outdated OpenSSL version
# more details: https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 180);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

$json = curl_exec($ch);
curl_close($ch);

echo "Batch deleted.", PHP_EOL;

?>
```
:::

As above, SerpWow responds with a JSON object confirming that the Batch has been deleted, or detailing the error if it has not been possible to delete the Batch:

```json
{
  "request_info": {
    "success": true,
    "message": "batch deleted"
  }
}
```

***





**Next Steps**
     [Get Batches](https://docs.trajectdata.com/serpwow/batches-api/batches/get)
     [List Batches](https://docs.trajectdata.com/serpwow/batches-api/batches/list)
