Appointments & Bookings API
Manage legal consultation bookings and appointments in upLegal.Create Booking
Endpoint:POST /api/bookings/create
Authentication: Not required (public endpoint for guest bookings)
Creates a new booking and generates a MercadoPago payment link.
Request Body
Lawyer’s user ID
Client’s email address
Client’s full name
Appointment date (YYYY-MM-DD format)
Appointment time (HH:MM format, 24-hour)
Duration in minutes (30, 60, 90, or 120)
Price in CLP (minimum 1000)
Example Request
Response
Operation success status
Created booking ID (UUID)
MercadoPago checkout URL
Success message
Example Response
200 - Success
Error Responses
400 - Missing Fields
400 - Invalid Duration
400 - Invalid Email
404 - Lawyer Not Found
409 - Time Slot Taken
Get Booking
Endpoint:GET /api/bookings/:bookingId
Authentication: Not required (public endpoint)
Retrieve booking details by ID.
Path Parameters
Booking ID (UUID)
Response
Booking details
Booking ID
Lawyer’s user ID
Client’s user ID (null for guest bookings until payment)
Client email
Client name
Appointment date (YYYY-MM-DD)
Appointment time (HH:MM)
Duration in minutes
Price in CLP
Booking status:
pending, confirmed, or cancelledMercadoPago payment ID
MercadoPago preference ID
Confirmation timestamp (ISO 8601)
Cancellation timestamp (ISO 8601)
Creation timestamp (ISO 8601)
Last update timestamp (ISO 8601)
Example Response
200 - Success
404 - Not Found
Booking Workflow
- Client creates booking via
POST /api/bookings/create - System checks availability and prevents double-booking
- MercadoPago preference created with payment details
- Client redirected to payment using the
payment_link - Payment processed by MercadoPago
- Webhook notification confirms payment (see Payments API)
- Booking confirmed and appointment created
- Email notifications sent to both client and lawyer
- User account created for guest bookings (if not exists)
Booking States
| Status | Description |
|---|---|
pending | Created, awaiting payment |
confirmed | Payment successful, appointment scheduled |
cancelled | Booking cancelled |
Double-Booking Prevention
The system automatically checks for overlapping bookings:- Same lawyer
- Same date
- Overlapping time slots
- Only checks
pendingandconfirmedbookings
Email Notifications
Client Confirmation Email
- Sent to
user_emailafter payment confirmation - Includes appointment details
- Contains magic link for account access
- Sent from:
LegalUp <[email protected]>
Lawyer Notification Email
- Sent to lawyer’s registered email
- Includes client details and appointment info
- Link to dashboard
- Sent from:
LegalUp <[email protected]>
Auto-Created Appointments
After successful payment, the system automatically creates anappointments record:
- Links to the booking via
booking_id - Status set to
confirmed - Consultation type:
paid - Contact method:
platform - Visible in lawyer dashboard
RLS Policies
Bookings Table
- SELECT: Public read for booking details by ID
- INSERT: Service role only (via API endpoint)
- UPDATE: Service role only (via webhook)
- DELETE: Not allowed