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

# Delete Booking

> Delete an existing booking from the system

## Description

This endpoint allows you to permanently delete a booking from the system. This action is irreversible and should be used with caution.

<Warning>
  **Irreversible Action**: Once deleted, the booking cannot be recovered. Consider using the `cancelled` status instead if you need to maintain a historical record.
</Warning>

## Authentication

<ParamField header="X-API-Key" type="string" required>
  Your LatePoint API Key with deletion permissions
</ParamField>

## Path Parameters

<ParamField path="id" type="integer" required>
  Unique ID of the booking to delete
</ParamField>

## Query Parameters

<ParamField query="force" type="boolean" default="false">
  Force deletion even if the booking is approved or completed
</ParamField>

## Response

### Successful Response (200 OK)

<ResponseField name="status" type="string">
  Response status ("success")
</ResponseField>

<ResponseField name="message" type="string">
  Deletion confirmation message
</ResponseField>

<ResponseField name="data" type="object">
  Basic confirmation of the deletion operation
</ResponseField>

## Examples

### Simple Deletion

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings/22" \
    -H "X-API-Key: lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ"
  ```

  ```javascript JavaScript theme={null}
  const bookingId = 123;

  const response = await fetch(`https://your-site.com/wp-json/latepoint-api/v1/bookings/${bookingId}`, {
    method: 'DELETE',
    headers: {
      'X-API-Key': 'lp_live_1234567890abcdef'
    }
  });

  const result = await response.json();
  console.log(result);
  ```

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

  booking_id = 123

  response = requests.delete(
      f'https://your-site.com/wp-json/latepoint-api/v1/bookings/{booking_id}',
      headers={
          'X-API-Key': 'lp_live_1234567890abcdef'
      }
  )

  result = response.json()
  print(result)
  ```

  ```php PHP theme={null}
  <?php
  $booking_id = 123;

  $curl = curl_init();

  curl_setopt_array($curl, [
      CURLOPT_URL => "http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings/{$booking_id}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'DELETE',
      CURLOPT_HTTPHEADER => [
          'X-API-Key: lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ'
      ]
  ]);

  $response = curl_exec($curl);
  $result = json_decode($response, true);

  curl_close($curl);
  print_r($result);
  ?>
  ```
</CodeGroup>

### Forced Deletion

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "http://latepoint-dev.local/wp-json/latepoint-api/v1/bookings/22?force=true" \
    -H "X-API-Key: lp_n1k6BVf3h7JRyjXkWMSoXi0BBZYRaOLL4QohDPQJ"
  ```

  ```javascript JavaScript theme={null}
  // Delete an approved or completed booking
  const response = await fetch(`https://your-site.com/wp-json/latepoint-api/v1/bookings/123?force=true`, {
    method: 'DELETE',
    headers: {
      'X-API-Key': 'lp_live_1234567890abcdef'
    }
  });

  if (response.ok) {
    const result = await response.json();
    console.log('Booking deleted successfully');
  } else {
    const error = await response.json();
    console.error('Error:', error.error.message);
  }
  ```
</CodeGroup>

## Example Response

### Successful Deletion

```json theme={null}
{
  "success": true,
  "message": "Booking deleted successfully"
}
```

## Error Codes

<ResponseExample>
  ```json Error 404 - Booking Not Found theme={null}
  {
    "status": "error",
    "error": {
      "code": "booking_not_found",
      "message": "Booking with ID 123 was not found"
    }
  }
  ```

  ```json Error 400 - Force Required theme={null}
  {
    "code": "force_required",
    "message": "Force deletion is required for confirmed or completed bookings",
    "data": {
      "status": 400
    }
  }
  ```

  ```json Error 403 - Insufficient Permissions theme={null}
  {
    "status": "error",
    "error": {
      "code": "insufficient_permissions",
      "message": "You do not have permissions to delete bookings",
      "details": {
        "required_permission": "delete_bookings",
        "current_permissions": ["read_bookings", "write_bookings"]
      }
    }
  }
  ```

  ```json Error 500 - Delete Error theme={null}
  {
    "code": "delete_error",
    "message": "Error deleting booking",
    "data": {
      "status": 500
    }
  }
  ```
</ResponseExample>

## Deletion Rules

### States that Allow Direct Deletion

* `pending` - Pending
* `cancelled` - Cancelled

### States that Require `force=true`

* `approved` - Approved
* `completed` - Completed

<Note>
  The current implementation checks for `approved` and `completed` statuses to require force deletion.
</Note>

## Important Notes

<Note>
  **Deletion vs Cancellation**: In most cases, it's better to cancel a booking (change status to `cancelled`) than to delete it permanently.
</Note>

<Warning>
  **Irrecoverable Data**: Once deleted, all booking information is permanently lost. Make sure you have backups if necessary.
</Warning>

<Info>
  **Simple Implementation**: This endpoint provides basic deletion functionality. Advanced features like customer notifications and audit logging are not currently implemented.
</Info>
