openapi: 3.1.0
info:
  title: Bridge Web Enquiry & Preview API
  version: 2.0.0
  summary: Free bespoke website preview & early-access request API for bridgeweb.io
  description: >
    Validates and stores free website preview and early-access requests from
    business owners in any industry or from AI assistants acting on their behalf.
    The human form at `/start` and `/preview` submits to the same `/api/enquiries`
    endpoint. Stored enquiries remain in our own local store so owners keep full
    ownership and export rights.
  contact:
    name: Bridge HQ Ltd
    email: hello@example.invalid
  license:
    name: Proprietary - Bridge HQ Ltd
    url: https://bridgeweb.io/terms
servers:
  - url: /
    description: Current host (local preview server or portable self-hosted server)
tags:
  - name: Enquiries
    description: Free preview & early-access submission
paths:
  /api/enquiries:
    post:
      tags:
        - Enquiries
      operationId: createEnquiry
      summary: Submit a free bespoke website preview request
      security: []
      description: >
        Validates and stores a free bespoke website preview request for any
        industry. Supports JSON (`application/json`) for API/AI clients and
        progressive JS forms, as well as URL-encoded HTML forms
        (`application/x-www-form-urlencoded`) when JavaScript is disabled.
        Requests where the anti-spam honeypot field (`website`) is non-empty
        are silently ignored and not stored.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnquiryJsonRequest'
            examples:
              londonCarDealer:
                summary: Valid preview request from a London car dealership
                value:
                  business_name: Mayfair Motor House
                  industry: Automotive
                  area: Mayfair, London W1
                  domain_idea: mayfairmotorhouse.co.uk
                  name: Alex Test
                  contact: alex@example.invalid
                  consent: true
                  website: ''
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/EnquiryFormRequest'
      responses:
        '201':
          description: Enquiry validated and stored in the local store.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnquiryCreated'
            text/html:
              schema:
                type: string
                description: HTML confirmation page showing the thank-you state.
        '202':
          description: Request acknowledged; honeypot field was populated so nothing was stored.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnquiryIgnored'
            text/html:
              schema:
                type: string
                description: HTML confirmation page without storing spam submission.
        '400':
          description: Validation failed. Returns per-field error messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
            text/html:
              schema:
                type: string
                description: Re-rendered HTML preview form with inline field error messages.
        '415':
          description: Unsupported media type (expected application/json or application/x-www-form-urlencoded).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
components:
  schemas:
    EnquiryJsonRequest:
      type: object
      additionalProperties: false
      required:
        - business_name
        - area
        - name
        - contact
        - consent
      properties:
        business_name:
          type: string
          minLength: 1
          maxLength: 120
          description: Name of the business, brand, or project.
        industry:
          type: string
          maxLength: 80
          description: Optional business sector (e.g. Automotive, Legal, Retail, Hospitality, Personal).
        area:
          type: string
          minLength: 1
          maxLength: 120
          description: City, neighbourhood, or operating region (e.g. London W1, Global).
        domain_idea:
          type: string
          maxLength: 120
          description: Optional desired custom domain or existing domain name.
        name:
          type: string
          minLength: 1
          maxLength: 120
          description: Name of the founder, owner, or manager.
        contact:
          type: string
          minLength: 5
          maxLength: 160
          description: Email address or UK/international phone number.
        consent:
          type: boolean
          const: true
          description: Must be explicitly true; consent checkbox is never pre-ticked.
        website:
          type: string
          maxLength: 200
          description: Optional anti-spam honeypot field; must be left empty.
    EnquiryFormRequest:
      type: object
      additionalProperties: false
      required:
        - business_name
        - area
        - name
        - contact
        - consent
      properties:
        business_name:
          type: string
          minLength: 1
          maxLength: 120
        industry:
          type: string
          maxLength: 80
        area:
          type: string
          minLength: 1
          maxLength: 120
        domain_idea:
          type: string
          maxLength: 120
        name:
          type: string
          minLength: 1
          maxLength: 120
        contact:
          type: string
          minLength: 5
          maxLength: 160
        consent:
          type: string
          enum:
            - 'on'
            - 'true'
            - '1'
        website:
          type: string
          maxLength: 200
    EnquiryCreated:
      type: object
      required:
        - id
        - status
        - received_at
        - business_name
        - area
        - name
        - contact
        - consent
        - message
      properties:
        id:
          type: string
        status:
          type: string
          const: received
        received_at:
          type: string
          format: date-time
        business_name:
          type: string
        industry:
          type: string
        area:
          type: string
        domain_idea:
          type: string
        name:
          type: string
        contact:
          type: string
        consent:
          type: boolean
          const: true
        message:
          type: string
    EnquiryIgnored:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          const: accepted
        message:
          type: string
    ValidationError:
      type: object
      required:
        - error
        - fields
      properties:
        error:
          type: string
        fields:
          type: object
          additionalProperties:
            type: string
    ErrorMessage:
      type: object
      required:
        - error
      properties:
        error:
          type: string
