Skip to main content

Endpoint

POST /api/reservations/create-with-payment

Description

Creates a reservation associated with a payment. This endpoint extracts the payment ID from the request body. If no payment ID is found, it returns a success status without creating the reservation. See implementation in server/src/modules/reservations/reservations.controller.ts:43-56.

Authentication

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

Request Body

The request body should include payment information along with reservation details. The exact structure depends on the payment provider (e.g., MercadoPago).
payment_id
string
required
Payment ID from the payment provider (extracted automatically from the request)
client_id
string
required
ID of the client making the reservation
professional_id
string
required
ID of the professional
start_time
string
required
Start time in ISO 8601 format
end_time
string
required
End time in ISO 8601 format
status
string
required
Reservation status (typically CONFIRMED for paid reservations)
session_modality
string
required
Session type: Virtual, Presencial, or empty string

Response

status
number
HTTP status code (200 for success)
data
object
The created reservation object with payment information

Example Request

curl -X POST https://your-domain.com/api/reservations/create-with-payment \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_id": "pay123456",
    "client_id": "abc123",
    "professional_id": "prof456",
    "start_time": "2026-03-15T10:00:00Z",
    "end_time": "2026-03-15T11:00:00Z",
    "status": "CONFIRMED",
    "session_modality": "Presencial"
  }'

Example Response

{
  "status": 200,
  "data": {
    "id": "res789",
    "client_id": "abc123",
    "professional_id": "prof456",
    "start_time": "2026-03-15T10:00:00Z",
    "end_time": "2026-03-15T11:00:00Z",
    "status": "CONFIRMED",
    "session_modality": "Presencial",
    "created_at": "2026-03-10T08:30:00Z"
  }
}

Error Responses

Missing Payment ID

If no payment ID is found in the request:
{
  "status": 200
}

Bad Request

{
  "statusCode": 400,
  "message": "Error al procesar el pago o crear la reserva",
  "error": "Bad Request"
}

Unauthorized

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

Workflow

  1. Create a payment preference using the Create Payment Preference endpoint
  2. Process the payment with your payment provider (e.g., MercadoPago)
  3. Call this endpoint with the payment information to create the reservation
  4. The reservation is created with status CONFIRMED

Notes

  • Payment ID is extracted automatically from the request body
  • Reservations created with payment are typically confirmed immediately
  • Ensure the payment is processed before calling this endpoint

Build docs developers (and LLMs) love