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

# Bulk Delete Hotel Stays by Filters

> Delete every hotel stay matching the current list filters, instead of an explicit id list

[← Hotel Stays API](/api-reference/hotel-stays/overview)

Deletes every hotel stay matching the given filters — the same filters [`GET /v1/hotel-stays`](/api-reference/hotel-stays/list) accepts — and their associated `total_impacts` rows, in a single request. Powers "select all matching" in the UI: the client never has to page through the whole result set to collect ids first.

The request must echo the `filter_hash` from the list response that showed those filters, to confirm the delete targets exactly what the caller saw. No filters at all is a valid request: it deletes every hotel stay in scope.

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Query Parameters

Same filters as [`GET /v1/hotel-stays`](/api-reference/hotel-stays/list): `status[]`, `start_date`, `end_date`, `name`, `file_id[]`, `created_at_from`, `created_at_to`. Pass the exact same query string you listed with.

### Body

<ParamField body="filter_hash" type="string" required>
  The `filter_hash` from the matching list response. A mismatch (filters changed since the list was
  loaded) returns `409 Conflict` and deletes nothing.

  **Example:** `d4f9a2b81c3e0f77`
</ParamField>

## Response

<ResponseField name="success_count" type="integer">
  Number of hotel stays successfully deleted
</ResponseField>

<ResponseField name="success_ids" type="array[string]">
  UUIDs of hotel stays that were successfully deleted
</ResponseField>

<ResponseField name="failed_count" type="integer">
  Number of hotel stays that could not be deleted
</ResponseField>

<ResponseField name="failed_ids" type="array[string]">
  UUIDs that could not be deleted (outside the authorized organization scope)
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable summary, e.g. `"Successfully deleted 12 hotel stay(s)"`
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/hotel-stays/bulk-delete-by-filters?status[]=active" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{"filter_hash": "d4f9a2b81c3e0f77"}'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
  }

  # 1. List with the filters you want to delete, and keep the filter_hash
  listed = requests.get(
      "https://api.dcycle.io/v1/hotel-stays",
      headers=headers,
      params={"status[]": ["active"]},
  ).json()

  # 2. Echo the same filters + filter_hash to delete everything that matched
  response = requests.post(
      "https://api.dcycle.io/v1/hotel-stays/bulk-delete-by-filters",
      headers=headers,
      params={"status[]": ["active"]},
      json={"filter_hash": listed["filter_hash"]},
  )
  result = response.json()
  print(f"Deleted {result['success_count']}, failed {result['failed_count']}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID
  };

  const params = { 'status[]': ['active'] };

  const { data: listed } = await axios.get('https://api.dcycle.io/v1/hotel-stays', { headers, params });

  const { data: result } = await axios.post(
    'https://api.dcycle.io/v1/hotel-stays/bulk-delete-by-filters',
    { filter_hash: listed.filter_hash },
    { headers, params }
  );
  console.log(`Deleted ${result.success_count}, failed ${result.failed_count}`);
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 12,
  "success_ids": ["550e8400-e29b-41d4-a716-446655440000"],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Successfully deleted 12 hotel stay(s)"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 409 Conflict

**Cause:** `filter_hash` doesn't match the current filters — they changed since the list was loaded

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."}
```

### 422 Unprocessable Entity

**Cause:** Missing `filter_hash` in the body

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["body", "filter_hash"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Hotel Stays" icon="list" href="/api-reference/hotel-stays/list">
    Browse all hotel stays and get a filter\_hash
  </Card>

  <Card title="Bulk Delete by IDs" icon="trash" href="/api-reference/hotel-stays/bulk-delete">
    Delete an explicit list of hotel stay ids
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.