> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leadlex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk Delete Deals

> Delete up to 500 deals in a single call

## Request

Deletion is permanent. Associated activities, notes, and tasks remain on the timeline but lose their deal back-reference. Documents remain available via the document library.

### Headers

```
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
```

<ParamField header="Idempotency-Key" type="string">
  Strongly recommended. Same key returns the same result within 24 hours.
</ParamField>

### Body Parameters

<ParamField body="deal_ids" type="array" required>
  Array of deal UUIDs to delete. Maximum 500.
</ParamField>

<ParamField body="dry_run" type="boolean" default="false">
  When `true`, the API validates input and returns counts but makes no changes.
</ParamField>

## Response

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="deleted_count" type="integer">Deals successfully deleted</ResponseField>
    <ResponseField name="not_found_count" type="integer">Input IDs that did not exist</ResponseField>
    <ResponseField name="errors" type="array">Array of `{ deal_id, code, message }` for rows that failed</ResponseField>
  </Expandable>
</ResponseField>

Responses include `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`, and `X-Request-ID`. Each successful deletion emits a `deal.deleted` webhook event.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
    https://data.leadlex.com/functions/v1/api-gateway/v1/deals/bulk-delete \
    -H "Authorization: Bearer wbk_your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{"deal_ids": ["deal_01HY1", "deal_02HY2"]}'
  ```

  ```python Python theme={null}
  import requests, uuid

  API_KEY = "wbk_your_api_key_here"
  BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"

  r = requests.post(
      f"{BASE_URL}/v1/deals/bulk-delete",
      headers={
          "Authorization": f"Bearer {API_KEY}",
          "Content-Type": "application/json",
          "Idempotency-Key": str(uuid.uuid4()),
      },
      json={"deal_ids": ["deal_01HY1", "deal_02HY2"]},
  )
  print(r.json()["data"])
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    'https://data.leadlex.com/functions/v1/api-gateway/v1/deals/bulk-delete',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer wbk_your_api_key_here',
        'Content-Type': 'application/json',
        'Idempotency-Key': crypto.randomUUID(),
      },
      body: JSON.stringify({ deal_ids: ['deal_01HY1', 'deal_02HY2'] }),
    }
  );
  const { data } = await res.json();
  console.log(data);
  ```
</CodeGroup>

### Example Response

```json theme={null}
{
  "data": {
    "deleted_count": 2,
    "not_found_count": 0,
    "errors": []
  }
}
```

## Errors

| Status | Code                       | Description                             |
| ------ | -------------------------- | --------------------------------------- |
| 400    | `validation_error`         | More than 500 IDs or missing `deal_ids` |
| 401    | `invalid_key`              | Invalid or expired API key              |
| 403    | `insufficient_permissions` | Missing `write:deals` permission        |
| 429    | `rate_limited`             | Rate limit exceeded                     |
