# Abort Run

Stop an active run before completion

This endpoint aborts an active run using its hash ID. The run will stop collecting data and begin the export process for any results already gathered.

## Headers

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

## Path Parameters

<ParamField path="run_hash" type="string" required>
  The unique identifier (hash) of the run to abort. Example: `300e9c5c127d421c90f431478d9a2cfb`
</ParamField>

## Response Field Explanations

<ResponseField name="id" type="string">
  The aborted run's identifier. Example: `"300e9c5c127d421c90f431478d9a2cfb"`
</ResponseField>

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

<ResponseField name="status" type="string">
  Run status (typically "uploading" immediately after abort). Example: `"uploading"`
</ResponseField>

<ResponseField name="is_done" type="boolean">
  Whether the run has fully completed. Example: `true`
</ResponseField>

<ResponseField name="done_reason" type="string">
  Will be "aborted" for manually stopped runs. Example: `"aborted"`
</ResponseField>

<ResponseField name="total_results" type="integer">
  Number of results collected before abort. Example: `6`
</ResponseField>

<ResponseField name="duration" type="float">
  Run duration in seconds before abort. Example: `10.4498`
</ResponseField>

<ResponseField name="credit_used" type="float">
  Credits consumed before abort. Example: `10.4498`
</ResponseField>

<Note>
  Aborted runs still export any results collected up to the point of abortion.
</Note>

<Warning>
  You will still be charged credits for the work done before aborting.
</Warning>

<Tip>
  Use Get Run Stats to check progress before deciding to abort a run.
</Tip>

## Code Examples

<CodeGroup>
```bash cURL
curl -X POST "https://api.lobstr.io/v1/runs/300e9c5c127d421c90f431478d9a2cfb/abort" \
  -H "Authorization: Token YOUR_API_KEY"
```

```python Python
import requests

run_hash = "300e9c5c127d421c90f431478d9a2cfb"
url = f"https://api.lobstr.io/v1/runs/{run_hash}/abort"
headers = {
    "Authorization": "Token YOUR_API_KEY"
}

response = requests.post(url, headers=headers)
run = response.json()

print(f"Run aborted!")
print(f"Run ID: {run['id']}")
print(f"Status: {run['status']}")
print(f"Done Reason: {run['done_reason']}")
print(f"Results collected: {run['total_results']}")
print(f"Credits used: {run['credit_used']}")
```
</CodeGroup>

## Response

```json 200
{
  "id": "300e9c5c127d421c90f431478d9a2cfb",
  "object": "run",
  "squid": "e445405ef4ab41208ef7d29b92a1a9dd",
  "is_done": true,
  "started_at": "2025-02-10T14:30:55Z",
  "total_results": 6,
  "total_unique_results": 6,
  "next_launch_at": null,
  "ended_at": "2025-02-10T14:31:10Z",
  "duration": 10.4498,
  "credit_used": 10.4498,
  "origin": "user",
  "force_launch": false,
  "status": "uploading",
  "export_done": null,
  "export_count": 0,
  "export_time": null,
  "expires_at": null,
  "email_done": null,
  "email_time": null,
  "created_at": "2025-02-10T14:30:55Z",
  "done_reason": "aborted",
  "done_reason_desc": null
}
```

```json 404
{
  "error": {
    "message": "Run not found or already completed",
    "type": "not_found_error",
    "param": "run_hash"
  }
}
```
