{"openapi":"3.1.1","info":{"title":"Avanti Doors consent-bound agent enquiry API","version":"1.0.0","description":"Agent-safe enquiry preparation and submission. Browser form endpoints are deliberately excluded. Submission requires a short-lived, single-use approval token bound to the unchanged prepared payload."},"servers":[{"url":"https://avantidoors.co.uk"}],"paths":{"/api/agent/enquiries/prepare":{"post":{"operationId":"prepareEnquiry","summary":"Prepare an enquiry without submitting it","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnquiryInput"}}}},"responses":{"201":{"description":"Short-lived draft prepared; nothing submitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PreparedEnquiry"}}}},"400":{"description":"Invalid or incomplete service-relevant fields"},"503":{"description":"Draft store unavailable"}}}},"/api/agent/enquiries/review/{request_id}":{"get":{"operationId":"reviewEnquiry","summary":"Read the exact prepared payload and destination","parameters":[{"name":"request_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Exact review data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewEnquiry"}}}},"404":{"description":"Unknown request"},"410":{"description":"Expired or no longer reviewable"}}}},"/api/agent/enquiries/submit":{"post":{"operationId":"submitApprovedEnquiry","summary":"Submit an unchanged enquiry after explicit human approval","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovedSubmission"}}}},"responses":{"200":{"description":"Outcome with per-channel confirmations","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubmissionResult"}}}},"409":{"description":"Approval was altered, expired, reused or is not valid"},"503":{"description":"Submission could not be durably recorded"}}}}},"components":{"schemas":{"EnquiryInput":{"type":"object","additionalProperties":false,"required":["contact","site","service","equipment","summary","timing","preferred_contact","contact_consent"],"properties":{"contact":{"type":"object","additionalProperties":false,"required":["name","email","phone"],"properties":{"name":{"type":"string","minLength":1,"maxLength":100},"company":{"type":"string","maxLength":160},"email":{"type":"string","format":"email","maxLength":254},"phone":{"type":"string","minLength":5,"maxLength":40}}},"site":{"type":"object","additionalProperties":false,"required":["postcode"],"properties":{"address":{"type":"string","maxLength":300},"postcode":{"type":"string","minLength":2,"maxLength":20}}},"service":{"type":"string","enum":["installation","planned-maintenance","maintenance-contracts","reactive-repairs","unsure"]},"equipment":{"type":"array","minItems":1,"maxItems":8,"uniqueItems":true,"items":{"type":"string","minLength":1,"maxLength":80}},"summary":{"type":"string","minLength":10,"maxLength":5000},"timing":{"type":"string","enum":["planned","soon","urgent","unsafe-or-blocked"]},"preferred_contact":{"type":"string","enum":["email","phone"]},"contact_consent":{"type":"boolean","const":true}}},"PreparedEnquiry":{"type":"object","required":["prepared","submitted","request_id","payload_hash","expires_at","exact_payload","destination","review_url"],"properties":{"prepared":{"type":"boolean","const":true},"submitted":{"type":"boolean","const":false},"request_id":{"type":"string","format":"uuid"},"payload_hash":{"type":"string","pattern":"^sha256:[a-f0-9]{64}$"},"expires_at":{"type":"string","format":"date-time"},"exact_payload":{"$ref":"#/components/schemas/EnquiryInput"},"destination":{"$ref":"#/components/schemas/Destination"},"review_url":{"type":"string","format":"uri"}}},"ReviewEnquiry":{"allOf":[{"$ref":"#/components/schemas/PreparedEnquiry"},{"type":"object","properties":{"status":{"type":"string","enum":["prepared","approved"]},"approval_required":{"type":"boolean","const":true}}}]},"Destination":{"type":"object","required":["business","team","primary_email","durable_record"],"properties":{"business":{"type":"string","const":"Avanti Doors Ltd"},"team":{"type":"string"},"primary_email":{"type":"string","format":"email"},"durable_record":{"type":"string","const":"Avanti Doors lead database"},"configured_notifications":{"type":"array","items":{"type":"string","enum":["email","crm"]}}}},"ApprovedSubmission":{"type":"object","additionalProperties":false,"required":["request_id","payload_hash","approval_token"],"properties":{"request_id":{"type":"string","format":"uuid"},"payload_hash":{"type":"string","pattern":"^sha256:[a-f0-9]{64}$"},"approval_token":{"type":"string","minLength":32,"maxLength":200}}},"SubmissionResult":{"type":"object","required":["submitted","request_id","confirmed","message"],"properties":{"submitted":{"type":"boolean"},"request_id":{"type":"string","format":"uuid"},"confirmed":{"type":"object","required":["lead_record","email_notification","crm_ticket"],"properties":{"lead_record":{"type":"boolean"},"email_notification":{"type":["boolean","null"]},"crm_ticket":{"type":["boolean","null"]}}},"message":{"type":"string"}}}}}}