A reservation in Despacho Backend is an appointment request submitted by a prospective client who needs legal services. The system is built around a clear two-actor model: a client submits a reservation form without needing any account or login, and a lawyer (authenticated via JWT) reviews, accepts, schedules, and optionally removes those reservations through a set of protected API endpoints. Every reservation begins life as unaccepted and only transitions to confirmed once a lawyer explicitly approves it.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.
Reservation lifecycle
Client submits a reservation
The client sends a Required fields:
POST request to /api/form/reserve/create with their personal details and the legal service they require. No authentication is needed — this endpoint is fully public so that any prospective client can reach it without creating an account.full_name, email, phone, required_service, preferred_date, preferred_hour. The additional_message field is optional.Reservation stored as pending
The
FormReserve document is saved to MongoDB with reservation_accepted set to false. The server responds with a confirmation message and the full saved document.Lawyer views pending reservations
After logging in and obtaining a JWT, the lawyer calls The response includes a
POST /api/form/reserve/list/reservation-false to retrieve all reservations where reservation_accepted is false. Results are paginated and sorted newest-first (sort({ _id: -1 })).pagination object alongside the data array (see Pagination below).Lawyer accepts and schedules the reservation
The lawyer sends
POST /api/form/reserve/accept/:reserveId/reserve with the confirmed preferred_date and preferred_hour in the request body. The controller sets reservation_accepted: true and updates the date and time fields in a single $set operation.Lawyer deletes a reservation (optional)
If a reservation needs to be removed — whether cancelled by the client or resolved — the lawyer calls
POST /api/form/reserve/remove/reservation/:reservationId. The controller verifies the document exists before performing a hard delete with FormReserve.deleteOne().Public vs protected endpoints
The reservation creation endpoint (
POST /api/form/reserve/create) requires no authentication. This is intentional — clients should be able to submit appointment requests without needing to register an account. All management operations (listing, accepting, deleting) are restricted to authenticated lawyers.| Endpoint | Method | Auth required |
|---|---|---|
/api/form/reserve/create | POST | Public — no token needed |
/api/form/reserve/accept/:reserveId/reserve | POST | Protected — Token |
/api/form/reserve/list/reservation-true | POST | Protected — Token + Paginate |
/api/form/reserve/list/reservation-false | POST | Protected — Token + Paginate |
/api/form/reserve/list/reservation-all | POST | Protected — Token + Paginate |
/api/form/reserve/remove/reservation/:reservationId | POST | Protected — Token |
Pagination
The three listing endpoints (reservation-true, reservation-false, reservation-all) use the Paginate middleware before the route handler. It reads pagination parameters from the URL path params and injects computed values into req.body for the controller to use.
| Parameter | Source | Default | Description |
|---|---|---|---|
perpage | req.params.perpage | 10 | Number of records to return per page |
pag | req.params.pag | 0 | Current page number (1-indexed in the URL; converted to 0-indexed offset internally) |
skippag | Computed → req.body.skippag | — | Number of documents to skip: (pag - 1) * perpage |
limit | Computed → req.body.limit | — | Passed directly to Mongoose’s .limit() |
pagination object:
| Field | Description |
|---|---|
pag | The current page number from the request params |
perpage | The number of results per page (from req.body.limit) |
pags | Total number of pages: Math.ceil(totalCount / perpage) |
Legal service categories
Therequired_service field on a reservation is an enum — the submitted value must exactly match one of the following six strings defined in FormReserveSchema:
Derecho civil
Civil law — contracts, property, personal injury, and general civil disputes.
Derecho familiar
Family law — divorce, child custody, adoption, and domestic matters.
Derecho mercantil
Commercial law — business formation, contracts, and trade regulations.
Derecho penal
Criminal law — defense and representation in criminal proceedings.
Derecho laboral
Labor law — employment contracts, wrongful termination, and workplace rights.
Derecho inmobiliario
Real estate law — property transactions, leases, and land disputes.