Preludio API

Backend documentation for event management, ticketing, and payments.

Health Checks

GET /api/health
Direct health check (bypasses DB connection). Returns {"ok": true, "mode": "direct"}.
GET /api/express-health
Express health check. Verifies that the Express app is running.

Authentication (/api/auth)

POST /register
Register a new user.
Parameter Type Description
nombreREQUIRED string First name
apellidoREQUIRED string Last name
dniREQUIRED string Unique ID number
emailREQUIRED string Unique email address
passwordREQUIRED string Password
fechaNacimientoREQUIRED date Date of birth (YYYY-MM-DD)
telefonoREQUIRED string Phone number
rolOPTIONAL string "USUARIO" (default) or "ADMIN" (only allowed if 0 admins exist)
POST /login
Login. Returns JWT in HttpOnly cookie.
Parameter Type Description
emailREQUIRED string Registered email
passwordREQUIRED string Password
POST /login2
Login (Bearer Token). Returns JWT in response body (for API clients).
Parameter Type Description
emailREQUIRED string Registered email
passwordREQUIRED string Password
POST /logout
Logout. Clears authentication cookies.
GET /me
Auth
Get current authenticated user details.

Events (/api/events)

GET /
List events with filtering and pagination.
Query Param Type Description
pageOPTIONAL number Page number (default: 1)
limitOPTIONAL number Items per page (default: 10)
sortOPTIONAL string Field to sort by (default: "fecha")
orderOPTIONAL string "asc" or "desc" (default: "asc")
qOPTIONAL string Search term (title, description, location)
categoriaOPTIONAL string Filter by category
ciudadOPTIONAL string Filter by city
fromOPTIONAL date Start date filter
toOPTIONAL date End date filter
hideSoldOutOPTIONAL boolean Hide sold out events
GET /categories
Get list of event categories.
GET /:id
Get event details by ID.
POST /
AuthAdmin
Create a new event.
Parameter Type Description
tituloREQUIRED string Event title
descripcionREQUIRED string Event description
fechaREQUIRED date Event date
horaREQUIRED string Event time
ubicacionREQUIRED object { lugar, direccion, ciudad, provincia, lat, lng }
categoriaREQUIRED string Event category
capacidadTotalREQUIRED number Total tickets available
precioREQUIRED number Ticket price
imagenOPTIONAL string URL of event image
PUT /:id
AuthAdmin
Update an existing event.

Users (/api/users)

GET /me
Auth
Get my profile.
PATCH /me
Auth
Update my basic info.
Parameter Type Description
emailOPTIONAL string New email
telefonoOPTIONAL string New phone number
PUT /me/profile
Auth
Update my full profile.
PUT /me/change-password
Auth
Change password.
Parameter Type Description
currentPasswordREQUIRED string Current password
newPasswordREQUIRED string New password
GET /
AuthAdmin
List all users (paginated).
GET /search
Search users by name.
GET /:id
Auth
Get user details by ID.
POST /
AuthAdmin
Create a user (Admin).
PUT /:id
AuthAdmin
Update a user (Admin).

Tickets (/api/tickets)

GET /
Auth
List my tickets.
POST /
Auth
Create a ticket (Manual creation).
Parameter Type Description
eventoREQUIRED string Event ID
tipoEntradaREQUIRED string Ticket type (e.g., "GENERAL")
precioPagadoOPTIONAL number Price paid (defaults to event price)
compradorOPTIONAL string User ID (Admin only)
GET /:id
Auth
Get ticket details by ID.
DELETE /:id
Auth
Cancel/Delete ticket.
PUT /:id
AuthAdmin
Update ticket.
GET /user/:userId
AuthAdmin
Get tickets by user ID.

Payments (/api/pagos)

POST /checkout
Auth
Process a payment and generate a ticket.
Parameter Type Description
eventoREQUIRED string Event ID (if creating new ticket)
tipoEntradaREQUIRED string Ticket type (if creating new ticket)
precioPagadoREQUIRED number Amount paid
metodoREQUIRED string Payment method (e.g., "CREDIT_CARD")
montoREQUIRED number Total amount
referenciaExternaOPTIONAL string External payment reference
ticketIdOPTIONAL string Existing ticket ID (if paying for existing ticket)
GET /
Auth
List my payments.
GET /list
AuthAdmin
List all payments.
GET /:id
Auth
Get payment by ID.

Reviews (/api/reviews)

GET /
List all reviews.
GET /list
List reviews (paginated).
POST /
Auth
Create a review.
Parameter Type Description
ratingREQUIRED number Rating (1-5)
commentREQUIRED string Review text
GET /me/review
Auth
Get my review.
PUT /me
Auth
Update my review.
DELETE /me
Auth
Delete my review.
GET /:id
Get review by ID.
PUT /:id
AuthAdmin
Update review (Admin).
DELETE /:id
AuthAdmin
Delete review (Admin).