# Empty Squid

Remove the tasks of a squid, keeping its settings and the results of its earlier runs

This endpoint removes the tasks of a squid, all of them or one kind, and returns how many it removed. The squid keeps its settings, and the results of its earlier runs stay downloadable, by run and by squid.

## What Gets Removed

Only tasks, depending on the `type` parameter:
- no `type`: every task
- **url**: the URL tasks
- **params**: the parameter tasks (city, keyword...)

The squid itself remains with all its settings (name, parameters, integrations, schedule). This is useful when you want to:
- Remove the done tasks before adding new ones, so the next run only processes the new ones (a run processes every task of the squid)
- Reset a squid without losing its configuration or its results
- Remove tasks that are no longer needed

## Headers

<ParamField header="Authorization" type="string" required>
  Your API authentication token. Value: `Token YOUR_API_KEY`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be application/json. Value: `application/json`
</ParamField>

## Path Parameters

<ParamField path="squid_hash" type="string" required>
  The unique identifier (hash) of the squid to empty. Example: `388d6d5e98134294ac612ec9f99dc5b1`
</ParamField>

## Request Body

<ParamField body="type" type="string">
  Kind of tasks to remove: `url` for URL tasks or `params` for parameter tasks. Leave it out to remove every task. Also accepted in the query string (`?type=url`). Example: `"url"`
</ParamField>

## Response Field Explanations

<ResponseField name="id" type="string">
  Squid identifier. Example: `"388d6d5e98134294ac612ec9f99dc5b1"`
</ResponseField>

<ResponseField name="object" type="string">
  Always "squid". Example: `"squid"`
</ResponseField>

<ResponseField name="emptied" type="boolean">
  Boolean indicating success. Example: `true`
</ResponseField>

<ResponseField name="deleted_count" type="integer">
  Number of tasks removed. Example: `150`
</ResponseField>

<Warning>
  Removed tasks cannot be restored. The results of earlier runs are kept.
</Warning>

<Tip>
  Use this before re-importing tasks to avoid duplicates. Empty the squid, then add fresh tasks.
</Tip>

<Note>
  The squid's settings (parameters, integrations, schedule) and the results of its earlier runs are kept. Only tasks are removed.
</Note>

<Tip>
  Check the 'deleted_count' in the response to verify how many tasks were removed.
</Tip>

<Warning>
  Emptying is refused while a run of the squid is in progress (`RunInProgress`): wait for it to end, or abort it first.
</Warning>

## Code Examples

<CodeGroup>
```bash cURL
curl -X POST "https://api.lobstr.io/v1/squids/388d6d5e98134294ac612ec9f99dc5b1/empty" \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "url"
  }'
```

```python Python
import requests

squid_id = "388d6d5e98134294ac612ec9f99dc5b1"
url = f"https://api.lobstr.io/v1/squids/{squid_id}/empty"
headers = {
    "Authorization": "Token YOUR_API_KEY",
    "Content-Type": "application/json"
}
payload = {
    "type": "url"  # or "params"; leave it out to remove every task
}

response = requests.post(url, headers=headers, json=payload)
result = response.json()

print(f"Squid emptied: {result['emptied']}")
print(f"Tasks deleted: {result['deleted_count']}")
print(f"Squid ID: {result['id']}")
```
</CodeGroup>

## Response

```json 200
{
  "id": "388d6d5e98134294ac612ec9f99dc5b1",
  "object": "squid",
  "emptied": true,
  "deleted_count": 1
}
```
