{
  "openapi": "3.1.0",
  "info": {
    "title": "Digital Foundry public agent API",
    "version": "1.0.0",
    "description": "Public, anonymous REST API for AI agents interacting with Digital Foundry: structured contact intake and meeting booking. An equivalent MCP endpoint (Streamable HTTP) is available at https://digitalfoundry.com/mcp — see https://digitalfoundry.com/.well-known/mcp/server-card.json. All endpoints are rate-limited per IP.",
    "contact": {
      "email": "webuildit@digitalfoundry.com",
      "url": "https://digitalfoundry.com"
    }
  },
  "servers": [{ "url": "https://digitalfoundry.com" }],
  "externalDocs": {
    "description": "Agent-facing site guide (llms.txt)",
    "url": "https://digitalfoundry.com/llms.txt"
  },
  "paths": {
    "/api/agent-contact": {
      "post": {
        "operationId": "submitAgentContact",
        "summary": "Submit a structured contact request on behalf of a company or individual",
        "description": "The preferred REST entry point for AI agents to initiate a business conversation with Digital Foundry. Agent identity may also be supplied via the X-Agent-Id and X-Agent-Framework headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AgentContactRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Contact accepted and routed for qualification",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ContactAccepted" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/contact": {
      "post": {
        "operationId": "submitContactForm",
        "summary": "Submit the website contact form",
        "description": "Simple contact intake matching the website form. Requires company name or email at minimum.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["company", "email", "message"],
                "properties": {
                  "name": { "type": "string" },
                  "company": { "type": "string" },
                  "email": { "type": "string", "format": "email" },
                  "message": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Submission accepted",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ContactAccepted" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/book-meeting/availability": {
      "get": {
        "operationId": "getMeetingAvailability",
        "summary": "List available 30-minute meeting slots for a date",
        "description": "Business hours are 9 AM–5 PM US Eastern.",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "Date to check, YYYY-MM-DD",
            "schema": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" }
          }
        ],
        "responses": {
          "200": {
            "description": "Available and total slots for the day",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "available_slots": { "type": "array", "items": { "type": "string" } },
                    "all_slots": { "type": "array", "items": { "type": "string" } }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/book-meeting": {
      "post": {
        "operationId": "bookMeeting",
        "summary": "Book a 30-minute meeting with Digital Foundry",
        "description": "Creates a Google Calendar event with a Google Meet link and emails a calendar invite to the attendee. If the requested time is unavailable, the response lists open slots for that date instead.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["attendee_name", "attendee_email", "preferred_date", "preferred_time"],
                "properties": {
                  "attendee_name": { "type": "string" },
                  "attendee_email": { "type": "string", "format": "email" },
                  "preferred_date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
                  "preferred_time": {
                    "type": "string",
                    "pattern": "^\\d{2}:\\d{2}$",
                    "description": "Start time, HH:MM 24-hour, US Eastern"
                  },
                  "note": { "type": "string", "description": "Optional agenda or context for the meeting" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Booking result (confirmed meeting, or available slots if the time was taken)"
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Service health check",
        "responses": {
          "200": {
            "description": "Service is up",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "status": { "type": "string", "const": "ok" } }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentContactRequest": {
        "type": "object",
        "required": ["acting_on_behalf_of", "intent", "message"],
        "properties": {
          "acting_on_behalf_of": {
            "type": "object",
            "required": ["company_name"],
            "properties": {
              "company_name": { "type": "string", "description": "Legal name of the company you represent" },
              "contact_name": { "type": "string" },
              "contact_email": { "type": "string", "format": "email" },
              "contact_title": { "type": "string" }
            }
          },
          "intent": {
            "type": "string",
            "enum": [
              "meeting_request",
              "rfp_response",
              "general_inquiry",
              "info_gathering",
              "partnership_inquiry",
              "vendor_evaluation"
            ]
          },
          "message": { "type": "string", "description": "Your inquiry, problem statement, or message" },
          "agent_id": { "type": "string" },
          "agent_framework": { "type": "string", "description": "e.g. \"Claude\", \"LangChain\"" },
          "program_context": { "type": "string" },
          "budget_range": { "type": "string", "description": "e.g. \"$500K–$2M\"" },
          "timeline": { "type": "string", "description": "e.g. \"Q3 2026\"" },
          "preferred_response_channel": {
            "type": "string",
            "enum": ["email", "phone", "agent_endpoint", "any"]
          }
        }
      },
      "ContactAccepted": {
        "type": "object",
        "properties": {
          "contact_id": { "type": "string" },
          "received_at": { "type": "string", "format": "date-time" },
          "status": { "type": "string" },
          "next_steps": { "type": "string" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "message": { "type": "string" }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid or incomplete payload",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/Error" } }
        }
      },
      "RateLimited": {
        "description": "Per-IP rate limit exceeded; retry_after is in seconds",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/Error" } }
        }
      }
    }
  }
}
