Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/despacho-backend/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint allows an authenticated lawyer to accept a pending client reservation and confirm (or override) the appointment’s date and time. When called, the server looks up the reservation by its MongoDB ObjectId, sets reservation_accepted to true, and updates preferred_date and preferred_hour with the values supplied in the request body. The full updated reservation document is returned in the response.

Endpoint

POST /api/form/reserve/accept/:reserveId/reserve

Authentication

Required. Include a valid JWT in the Authorization header as a Bearer token. The token is verified against the lawyer user database; requests with a missing, expired, or invalid token are rejected before the handler runs.
Authorization: Bearer <token>

Path Parameters

reserveId
string
required
The MongoDB ObjectId of the reservation to accept. This value is found in the _id field of any reservation document returned by the list or create endpoints.

Request Body

preferred_date
string
required
The confirmed appointment date as set by the lawyer. Recommended format: YYYY-MM-DD (e.g., "2025-08-20"). This value overwrites the client’s originally requested date.
preferred_hour
string
required
The confirmed appointment time as set by the lawyer. Recommended format: HH:MM in 24-hour notation (e.g., "11:00"). This value overwrites the client’s originally requested time.

Example Request

curl -X POST https://your-api-domain.com/api/form/reserve/accept/64f3a2b1c9e77b001f3d8a12/reserve \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -d '{
    "preferred_date": "2025-08-20",
    "preferred_hour": "11:00"
  }'

Responses

200 — Reservation Accepted

The reservation was successfully updated. reservation_accepted is now true and the confirmed date and time are reflected in the returned document.
{
  "msj": "Reserva aceptada/modificada correctamente",
  "status": true,
  "update_reserve": {
    "_id": "64f3a2b1c9e77b001f3d8a12",
    "full_name": "María García López",
    "email": "maria.garcia@example.com",
    "phone": 5512345678,
    "required_service": "Derecho familiar",
    "preferred_date": "2025-08-20",
    "preferred_hour": "11:00",
    "additional_message": "Necesito asesoría sobre un proceso de divorcio.",
    "reservation_accepted": true,
    "createdAt": "2025-07-30T14:22:10.000Z",
    "updatedAt": "2025-07-30T16:05:33.000Z",
    "__v": 0
  }
}

404 — Reservation Not Found

Returned when no reservation document exists in the database for the provided reserveId.
{
  "msj": "Reserva no encontrada",
  "status": false
}

401 — Missing Token

Returned when the Authorization header is absent from the request.
{
  "msj": "Sin autorizacion",
  "status": false
}

403 — Expired Token

Returned when the JWT is present but the session has expired.
{
  "msj": "Sesion finalizada",
  "status": false
}

403 — Invalid Token

Returned when the JWT is present but fails signature verification or is otherwise malformed.
{
  "msj": "<err.message>. Rechazo en la conexion",
  "status": false
}

404 — Lawyer User Not Found

Returned by the Token middleware when the token is valid but the associated lawyer user no longer exists in the database.
{
  "msj": "Usuario no encontrado",
  "status": false
}

500 — Server Error

Returned when an unexpected error occurs on the server (e.g., database write failure). The response body is the raw error object thrown by the server.
This endpoint doubles as a modification endpoint. If a reservation has already been accepted and the lawyer needs to reschedule, calling this endpoint again with the new preferred_date and preferred_hour will update the confirmed date and time without changing the reservation_accepted status, which remains true.

Build docs developers (and LLMs) love