{"openapi":"3.0.0","info":{"title":"PAM Tools Service API","version":"1.0.0","description":"Scheduling fulfillment service that proxies AI tool calls to DMS/CRM integrations (XTime, Tekion, CDK, etc.)","contact":{"name":"API Support","email":"support@pamhq.com"}},"servers":[{"url":"https://tools.pamws.com/api","description":"Production"},{"url":"http://localhost:3000/api","description":"Local Development"}],"components":{"securitySchemes":{"internalSecret":{"type":"apiKey","in":"header","name":"x-internal-secret","description":"Internal secret for service-to-service authentication (INTERNAL_SECRET env var)"}},"schemas":{"Error":{"type":"object","properties":{"success":{"type":"boolean","example":false},"error":{"type":"string","description":"Error message"},"error_code":{"type":"string","description":"Error code for programmatic handling","enum":["VALIDATION_ERROR","PROVIDER_ERROR","SLOT_UNAVAILABLE","APPOINTMENT_NOT_FOUND","INTERNAL_ERROR"]},"retryable":{"type":"boolean","description":"Whether the request can be retried"},"validation_errors":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"message":{"type":"string"}}}}},"required":["success","error"]},"ToolContext":{"type":"object","description":"Enriched context from OOS (campaign, contact, client data already looked up)","properties":{"campaign_id":{"type":"string","format":"uuid","description":"Campaign identifier"},"contact_id":{"type":"string","format":"uuid","description":"Contact identifier"},"client_org_id":{"type":"string","description":"Client organization identifier","example":"E2E_XTIME_f6919e98"},"touchpoint_id":{"type":"string","format":"uuid","description":"Touchpoint identifier"},"journey_id":{"type":"string","format":"uuid","description":"Journey identifier"},"contact":{"type":"object","description":"Contact data (already looked up from database)","properties":{"firstName":{"type":"string","example":"John"},"lastName":{"type":"string","example":"Doe"},"phoneNumber":{"type":"string","example":"7039463356"},"email":{"type":"string","example":"john@example.com"},"vin":{"type":"string","example":"1HGCY1F26SA076194"},"vehicleYear":{"type":"string","example":"2025"},"vehicleMake":{"type":"string","example":"HONDA"},"vehicleModel":{"type":"string","example":"ACCORD"}},"required":["firstName","lastName","phoneNumber"]},"campaign":{"type":"object","description":"Campaign data (already looked up from database)","properties":{"serviceIds":{"type":"array","items":{"type":"string"},"example":["2323363"]},"recallIds":{"type":"array","items":{"type":"string"},"example":[]}}}},"required":["campaign_id","contact_id","client_org_id","touchpoint_id","journey_id","contact"]}}},"security":[{"internalSecret":[]}],"paths":{"/tools/scheduling/search-availability":{"post":{"summary":"Search scheduling availability","description":"Search for available appointment slots via DMS/CRM integration. This is a simple proxy that fetches the DMS URL from Config API and forwards the enriched request.","operationId":"searchSchedulingAvailability","tags":["Scheduling"],"security":[{"internalSecret":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"requestedDate":{"type":"string","format":"date","description":"Requested date from AI (YYYY-MM-DD)","example":"2024-12-30"},"requestedTime":{"type":"string","nullable":true,"description":"Optional requested time from AI","example":null},"_context":{"$ref":"#/components/schemas/ToolContext"}},"required":["requestedDate","_context"]},"examples":{"basic_search":{"summary":"Basic Availability Search","value":{"requestedDate":"2024-12-30","requestedTime":null,"_context":{"campaign_id":"campaign-uuid-123","contact_id":"contact-uuid-456","client_org_id":"E2E_XTIME_f6919e98","touchpoint_id":"touchpoint-uuid-789","journey_id":"journey-uuid-abc","contact":{"firstName":"John","lastName":"Doe","phoneNumber":"7039463356","vin":"1HGCY1F26SA076194","vehicleYear":"2025","vehicleMake":"HONDA","vehicleModel":"ACCORD"},"campaign":{"serviceIds":["2323363"],"recallIds":[]}}}}}}}},"responses":{"200":{"description":"Availability data from DMS (raw response)","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","description":"Raw DMS response (format varies by provider: XTime, Tekion, CDK)","additionalProperties":true,"example":{"Tuesday, December 30th, 2025":["08:00","08:15","08:30","09:00"],"todaysDate":"Monday, December 23rd, 2025","message":"These are the availabilities for the requested date","recommendedServices":[{"serviceName":"Synthetic Oil & Filter Change","serviceId":"2323363"}]}}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing_date":{"summary":"Missing requestedDate","value":{"success":false,"error":"Invalid request","error_code":"VALIDATION_ERROR","retryable":false,"validation_errors":[{"field":"requestedDate","message":"Invalid input: expected string, received undefined"}]}}}}}},"401":{"description":"Unauthorized - missing or invalid internal secret","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"DMS integration error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"provider_error":{"summary":"DMS API Error","value":{"success":false,"error":"Error fetching dealer service menu","error_code":"PROVIDER_ERROR","retryable":true}}}}}}}}},"/tools/scheduling/book-appointment":{"post":{"summary":"Book scheduling appointment","description":"Book an appointment via DMS/CRM integration. This is a simple proxy that fetches the DMS URL from Config API and forwards the enriched booking request.","operationId":"bookSchedulingAppointment","tags":["Scheduling"],"security":[{"internalSecret":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date","description":"Appointment date from AI (YYYY-MM-DD)","example":"2025-12-30"},"time":{"type":"string","description":"Appointment time from AI","example":"09:00"},"mileage":{"type":"number","description":"Vehicle mileage from AI (optional)","example":5000},"email_address":{"type":"string","format":"email","description":"Email address from AI (optional)","example":"customer@example.com"},"_context":{"$ref":"#/components/schemas/ToolContext"}},"required":["date","time","_context"]},"examples":{"book_appointment":{"summary":"Book Appointment","value":{"date":"2025-12-30","time":"09:00","mileage":5000,"email_address":"haroun@example.com","_context":{"campaign_id":"campaign-uuid-123","contact_id":"contact-uuid-456","client_org_id":"E2E_XTIME_f6919e98","touchpoint_id":"touchpoint-uuid-789","journey_id":"journey-uuid-abc","contact":{"firstName":"Haroun","lastName":"Ansari","phoneNumber":"7039463356","email":"appointment@pamhq.com","vin":"1HGCY1F26SA076194","vehicleYear":"2025","vehicleMake":"HONDA","vehicleModel":"ACCORD"},"campaign":{"serviceIds":["2323363"],"recallIds":[]}}}}}}}},"responses":{"200":{"description":"Appointment booked successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","description":"Raw DMS response (format varies by provider)","properties":{"appointmentId":{"type":"string","example":"X05RHN6BS8#7039463356"},"message":{"type":"string","example":"Thank you for scheduling your service appointment..."},"smsSent":{"type":"boolean","example":true}}},"message":{"type":"string","example":"Appointment booked successfully!"}},"required":["success","data","message"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Slot unavailable (booking conflict)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"slot_conflict":{"summary":"Slot No Longer Available","value":{"success":false,"error":"This time slot is no longer available. Please search for availability again.","error_code":"SLOT_UNAVAILABLE","retryable":true}}}}}},"500":{"description":"DMS integration error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tools/scheduling/cancel-appointment":{"post":{"summary":"Cancel scheduling appointment","description":"Cancel an appointment via DMS/CRM integration. If the DMS does not support cancellation API, returns a manual cancellation message.","operationId":"cancelSchedulingAppointment","tags":["Scheduling"],"security":[{"internalSecret":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"appointment_id":{"type":"string","description":"Appointment ID from booking response","example":"X05RHN6BS8#7039463356"},"confirmation_number":{"type":"string","description":"Confirmation number from booking response","example":"CONF123456"},"reason":{"type":"string","description":"Cancellation reason (optional)","example":"Customer needs to reschedule"},"_context":{"type":"object","properties":{"campaign_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid"},"client_org_id":{"type":"string","example":"E2E_XTIME_f6919e98"}},"required":["campaign_id","contact_id","client_org_id"]}},"required":["appointment_id","confirmation_number","_context"]}}}},"responses":{"200":{"description":"Appointment cancelled or manual cancellation required","content":{"application/json":{"schema":{"oneOf":[{"type":"object","description":"Cancelled via DMS","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Appointment cancelled successfully"},"cancelled_at":{"type":"string","format":"date-time"},"appointment_id":{"type":"string"},"confirmation_number":{"type":"string"}}},{"type":"object","description":"Manual cancellation required","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Please contact the dealership directly to cancel this appointment"},"appointment_id":{"type":"string"},"confirmation_number":{"type":"string"},"requires_manual_cancellation":{"type":"boolean","example":true}}}]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Appointment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"not_found":{"summary":"Appointment Not Found","value":{"success":false,"error":"Appointment not found with the provided confirmation number","error_code":"APPOINTMENT_NOT_FOUND","retryable":false}}}}}},"500":{"description":"DMS integration error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"tags":[{"name":"Scheduling","description":"Scheduling tool endpoints that proxy to DMS/CRM integrations"}]}