Purpose
This endpoint checks whether a specific vehicle is available for rental within a selected date and time range, and calculates the current pricing.
π Availability Check Endpoint
Availability checking is the first and most critical step in the booking process. It returns real-time results using the Util::has_overlap() and PricingEngine classes.
π Endpoint Detailsβ
- URL:
/wp-json/mhm-rentiva/v1/availability - Method:
POST - Permission: Public (if not an admin/vendor interface)
π₯ Request Parameters (JSON Body)β
| Parameter | Type | Required | Description |
|---|---|---|---|
vehicle_id | int | Yes | The ID of the vehicle to check. |
pickup_date | string | Yes | Pickup date (YYYY-MM-DD). |
pickup_time | string | Yes | Pickup time (HH:MM). |
return_date | string | Yes | Return date (YYYY-MM-DD). |
return_time | string | Yes | Return time (HH:MM). |
location_id | int | No | Delivery location (may affect pricing). |
π€ Successful Response Exampleβ
{
"success": true,
"data": {
"available": true,
"pricing": {
"base_price": 1200.00,
"service_fee": 150.00,
"total_price": 1350.00,
"currency": "TRY"
},
"duration": {
"days": 3,
"hours": 0
}
}
}
π‘οΈ Security and Validationβ
- Date Order: The return date cannot precede the pickup date.
- Time Check: The pickup time must comply with minimum booking duration rules.
RateLimiter: Multiple queries from the same IP within a second are automatically throttled.- Sanitization: All input data is sanitized via
Sanitizer::absint()andsanitize_text_field().
β Error Statesβ
| Code | Message | Reason |
|---|---|---|
| 400 | INVALID_DATE_RANGE | Pickup/return dates are illogical. |
| 404 | VEHICLE_NOT_FOUND | No vehicle found with the specified ID. |
| 409 | VEHICLE_NOT_AVAILABLE | Vehicle is already booked for the specified dates. |
| 429 | TOO_MANY_REQUESTS | Rate limit exceeded. |
Section Summaryβ
- The
availabilityendpoint provides both availability and pricing information. Util::has_overlap()detects conflicts within seconds.- Used for reactive updates in front-end calendars and booking forms.
Changelogβ
| Date | Version | Note |
|---|---|---|
| 23.04.2026 | 4.27.2 | English translation added. |
| 19.03.2026 | 4.21.2 | JSON request/response schema and error codes detailed. |