API Endpoints
All endpoints require authentication and are prefixed with/v3/order:
POST /v3/order/psc/appointment/availability- Get available time slotsPOST /v3/order/{order_id}/psc/appointment/book- Book an appointmentPATCH /v3/order/{order_id}/psc/appointment/reschedule- Reschedule an appointmentPATCH /v3/order/{order_id}/psc/appointment/cancel- Cancel an appointmentGET /v3/order/{order_id}/psc/appointment- Get appointment detailsGET /v3/order/psc/appointment/cancellation-reasons- Get cancellation reasons
Error Handling
Environment Differences
⚠️ Important: Currently, error behavior differs between sandbox and production environments:| Environment | Quest Integration | Slot Conflict Behavior |
|---|---|---|
| Sandbox | Mock client | Returns 400 (mock doesn’t simulate conflicts) |
| Production | Real Quest API | Returns 404 (actual Quest response) |
Frequently Asked Questions
Q: Do I need to parse error messages to distinguish between different 400 errors?
Yes. Since multiple error types return 400 status codes, you must examine the error message content to determine the appropriate handling:- Time in the past:
"This appointment slot is no longer available. Please select a new time."→ Select new slot - Invalid booking key:
"Invalid booking key format"→ Fix request - Missing parameters:
"radius must be provided when using zip_code"→ Fix request - Order state issues:
"Order is not in a state that allows booking..."→ Contact support
Error Categories
Slot Unavailability Errors
The user should select a different time slot| Status | Error Message | When It Occurs | User Action |
|---|---|---|---|
| 400 | "This appointment slot is no longer available. Please select a new time." | Requested time is in the past | Select a future time slot |
| 400 or 404 | Quest-specific error messages | Slot already taken or no longer exists | Select a different time slot |
| 404 | "No slots found for zip code" | No locations/slots in the area | Try a different location or date range |
| 404 | "No slots found. Not all PSCs support scheduling..." | All locations lack scheduling capability | Use different locations |
Input Validation Errors
Fix the request parameters| Status | Error Message | When It Occurs | User Action |
|---|---|---|---|
| 400 | "Invalid booking key format" | Malformed or corrupted booking key | Refresh availability and get a new booking key |
| 400 | "Location with site code {code} not found" | Invalid PSC location code | Use a valid site code from the availability API |
| 400 | "Location with site code {code} is no longer active" | PSC location disabled | Select a different location |
| 400 | "start_date must be greater or equal than the current date" | Past date in the availability request | Use current or future date |
| 400 | "site_codes or zip_code must be provided" | Missing search parameters | Provide either site codes or zip code |
| 400 | "radius must be provided when using zip_code" | Missing radius with zip code search | Include radius parameter |
| 400 | "site_codes must be less than or equal to 3" | Too many site codes | Limit to 3 site codes maximum |
| 404 | "This order doesn't exist." | Invalid order ID | Verify order ID is correct |
| 404 | "This order is not a walk-in phlebotomy order." | Wrong order type | Use the correct order type |
Order State Errors
Order workflow or business logic issues| Status | Error Message | When It Occurs | User Action |
|---|---|---|---|
| 400 | "Order is not a walkin phlebotomy order" | Wrong order type for PSC booking | Contact support |
| 400 | "Order does not have a sample ID..." | Order missing requisition | Wait for requisition or contact support |
| 400 | "Order is not in a state that allows booking..." | Order workflow prevents booking | Contact support |
| 400 | "Order is not in a state that allows cancelling..." | Order workflow prevents cancellation | Contact support |
| 400 | "Order is not in a state that allows rescheduling..." | Order workflow prevents rescheduling | Contact support |
| 400 | "This order does not have a requisition..." | Missing requisition for appointment | Wait or contact support |
| 400 | "This lab is not supported." | Order not for Quest lab | Use a supported lab |
Appointment Management Errors
Appointment-specific business rules| Status | Error Message | When It Occurs | User Action |
|---|---|---|---|
| 400 | "This order doesn't have an appointment yet." | Trying to modify a non-existent appointment | Book an appointment first |
| 400 | "This appointment cannot be rescheduled." | Appointment marked non-reschedulable | Cancel and book a new appointment |
| 400 | "This appointment has been cancelled or completed." | Operating on finalized appointment | No further action is possible |
| 400 | "This appointment has already been cancelled." | Cancelling already cancelled appointment | No action needed |
| 404 | "Appointment not found." | Appointment doesn’t exist | Verify appointment exists |
Authorization Errors
Access control issues| Status | Error Message | When It Occurs | User Action |
|---|---|---|---|
| 401 | Authentication error | Invalid or expired token | Re-authenticate |
| 403 | "Action forbidden" | User lacks permission for the order | Contact support |
Service Availability Errors
System configuration or availability| Status | Error Message | When It Occurs | User Action |
|---|---|---|---|
| 503 | "Feature not enabled" | PSC scheduling disabled | Contact support or try later |
Testing Error Scenarios
Sandbox Testing
- Most validation errors can be tested in sandbox
- Slot conflicts cannot be reliably tested (mock client always succeeds)
- Use invalid parameters to test input validation
Production Testing
- Test with caution using real appointments
- Slot conflicts will return actual 404 errors from Quest
- Time-based errors can be tested with past dates
Quest API Limitations
- Timeout: 15 seconds read timeout, 5 seconds connection timeout
- Slot availability: Real-time, can change between availability check and booking
- Mock client: Doesn’t simulate all real-world scenarios
- Rate limiting: Standard Quest API rate limits apply
Beta Features
These features are in closed beta.Interested in these features? Get in touch with your Customer Success Manager.
Availability Cache
Junction maintains a fast Availability Cache containing the next 21 days of availability for all locations. Each location is refreshed every 5 minutes on average. When you set theallow_stale parameter on the PSC Appointment Availability endpoint, your request is fulfilled directly from the Availability Cache, provided that:
- All requested locations have a cache hit; and
- The cached information is reasonably fresh (less than 15 minutes old).
When to use
Useallow_stale when you need fast response times and can tolerate slightly stale availability data—for example, when displaying initial availability options to a user before they select a specific slot.
Idempotency Key
Consider specifying an Idempotency Key (X-Idempotency-Key header) when submitting a booking request to the
Book PSC Appointment endpoint. Requests with the same
idempotency key within a 14-day retention window will return the original request’s response.
Note that the response is frozen at the time it is first emitted. For example, if a pending appointment later transitions to confirmed via Async Confirmation, requests with that idempotency key will still return the appointment in its original pending status.
When to use
When a booking request fails on your side (API consumer side), it could be a transient connection issue or a Junction request queueing issue. Your request might have still reached the Junction API server and might have been processed. Using an Idempotency Key allows your system to safely retry booking requests, without the risk of double booking appointments.Async Confirmation
When calling the Book PSC Appointment endpoint, Junction by default returns a 500 Internal Server Error if the PSC Appointment Provider fails to acknowledge the booking request. With Async Confirmation enabled, Junction waits synchronously for the provider to acknowledge the booking request, up tosync_confirmation_timeout_millisecond (default: 2.5s, range: 1–10s).
- If an acknowledgement is received before the timeout, Junction creates a reserved or confirmed appointment immediately and returns it in the response.
- If no acknowledgement is received before the timeout, Junction creates a placeholder pending appointment and returns it in the response.
Background retries
If a pending appointment is created, Junction continues to retry the booking request with the PSC Appointment Provider in the background, up toasync_confirmation_timeout_millisecond (default: 15min, range: 1min–48hr).
- If an acknowledgement is received before the timeout, the appointment transitions to reserved or confirmed status.
- If the provider still fails to acknowledge after the timeout, the pending appointment transitions to cancelled status.
Webhooks
You will receive thelabtest.appointment.updated event for the initial appointment creation, as well as for all state transitions described above.