{
  "openapi": "3.0.3",
  "info": {
    "title": "EcoWorx AI-Agent Contact API",
    "version": "1.0.0",
    "description": "Submit a plain-text, unverified message to EcoWorx on a person's behalf. No files, secrets, payment data, or sensitive personal information."
  },
  "servers": [
    {
      "url": "https://agents.ecoworx.eu"
    }
  ],
  "x-agent-contact-methods": {
    "structured_api": "https://agents.ecoworx.eu/api/agent-contact",
    "browser_form": "https://agents.ecoworx.eu/contact",
    "plain_text_email": "agent@ecoworx.eu"
  },
  "paths": {
    "/contact": {
      "get": {
        "operationId": "openAgentContactForm",
        "summary": "Open the native no-JavaScript agent contact form",
        "description": "Browser-only agents can request a short-lived, single-use form token and submit a plain-text message without Turnstile.",
        "responses": {
          "200": {
            "description": "Native HTML contact form",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Form-token request limit reached"
          },
          "503": {
            "description": "Agent contact is temporarily unavailable"
          }
        }
      }
    },
    "/api/agent-contact": {
      "post": {
        "operationId": "contactEcoWorx",
        "summary": "Send an unverified agent message to EcoWorx",
        "description": "Low-volume endpoint. The represented person must consent to being contacted. Honor 429 and Retry-After responses. Accepted messages are reviewed separately from the human contact form.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Optional 8-128 character retry key. Reusing it with a different payload returns 409.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentContactRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Message accepted into the separate unverified-agent mailbox",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptedResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "409": {
            "description": "Idempotency key reused with a different payload"
          },
          "413": {
            "description": "Request body exceeds 8 KB"
          },
          "415": {
            "description": "Content type is not application/json"
          },
          "429": {
            "description": "Rate limited; retry after the number of seconds in the Retry-After header",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "503": {
            "description": "Agent contact is temporarily unavailable",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentContactRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schema_version",
          "sender",
          "agent",
          "subject",
          "message",
          "consent_to_contact"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "enum": ["1.0"]
          },
          "sender": {
            "$ref": "#/components/schemas/Sender"
          },
          "agent": {
            "$ref": "#/components/schemas/Agent"
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "message": {
            "type": "string",
            "minLength": 10,
            "maxLength": 4000
          },
          "consent_to_contact": {
            "type": "boolean",
            "enum": [true]
          }
        }
      },
      "Sender": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "email"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "company": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "website": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          }
        }
      },
      "Agent": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "provider": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        }
      },
      "AcceptedResponse": {
        "type": "object",
        "required": ["accepted", "request_id", "status"],
        "properties": {
          "accepted": {
            "type": "boolean",
            "enum": [true]
          },
          "request_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["unverified_agent_message"]
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["error", "message"],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "InvalidRequest": {
        "description": "Invalid or unsupported request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    }
  }
}
