Skip to main content

Endpoint

DELETE /api/reservations/:id

Description

Permanently deletes a reservation from the system by its unique identifier. See implementation in server/src/modules/reservations/reservations.controller.ts:157-168.

Authentication

This endpoint requires Bearer token authentication. Include your access token in the Authorization header.

Path Parameters

id
string
required
The unique identifier of the reservation to deleteExample: res789

Response

status
number
HTTP status code (200 for success)
data
object
Information about the deleted reservation or deletion result

Example Request

curl -X DELETE https://your-domain.com/api/reservations/res789 \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Example Response

{
  "status": 200,
  "data": {
    "id": "res789",
    "deleted": true
  }
}

Error Responses

Not Found

If the reservation doesn’t exist:
{
  "statusCode": 404,
  "message": "Reserva no encontrada",
  "error": "Not Found"
}

Unauthorized

{
  "statusCode": 401,
  "message": "Token inválido o expirado",
  "error": "Unauthorized"
}

Use Cases

  • Cancel an appointment
  • Remove a reservation from the system
  • Clean up test or outdated reservations
  • Allow users to cancel their bookings

Important Considerations

This operation is permanent and cannot be undone. Make sure to confirm with the user before deleting a reservation.

Before Deleting

  • Verify the reservation exists using Get One
  • Check if the reservation has an associated payment that may need refunding
  • Consider the professional’s cancellation policy
  • Notify relevant parties (client and professional) about the cancellation

Alternative Approach

Instead of deleting, consider updating the reservation status to CANCELLED if you need to maintain records:
// Update status instead of deleting (if update endpoint exists)
const cancelReservation = async (reservationId: string) => {
  // Update the reservation status to CANCELLED
  // This maintains the record for historical purposes
};

Best Practices

  • Implement confirmation dialogs in your UI before deletion
  • Log deletion events for audit purposes
  • Handle refunds if payment was processed
  • Send cancellation notifications to affected parties
  • Consider a “soft delete” pattern for business requirements

Build docs developers (and LLMs) love