{
  "openapi": "3.1.0",
  "info": {
    "title": "Neta Bresler: delegated quote inquiries",
    "version": "1.0.0",
    "description": "Agents may submit on a client's behalf with the client's permission. Send what is known; the team will clarify missing details. Submission is an inquiry, not a booking or confirmation of price or availability. Send a natural-language brief. No public inquiry lookup exists. Store the receipt privately. Maximum request body: 24000 UTF-8 bytes. Notifications may be delivered after the durable save."
  },
  "servers": [
    {
      "url": "https://avnhrbmhizhfrsxpbqpu.supabase.co/functions/v1/agent-inquiry"
    }
  ],
  "paths": {
    "/session": {
      "get": {
        "operationId": "createInquirySession",
        "summary": "Get a short-lived write-only submission token",
        "security": [],
        "responses": {
          "200": {
            "description": "Anonymous capability; expires in 900 seconds. Keep it out of URLs and logs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "access_token",
                    "token_type",
                    "expires_in",
                    "scope"
                  ],
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "type": "string",
                      "const": "Bearer"
                    },
                    "expires_in": {
                      "type": "integer",
                      "const": 900
                    },
                    "scope": {
                      "type": "string",
                      "const": "inquiry:create"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Session capacity exceeded. Respect Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inquiries": {
      "post": {
        "operationId": "submitClientInquiry",
        "summary": "Save a client-authorized quote request",
        "description": "Reuse the same Idempotency-Key and unchanged body after timeouts or 503. Renew the session after expiry. A 409 means the key was reused with different content. Respect Retry-After on 429. Limits: 5 new inquiries per session, 5 per reply contact per hour and 60 total per hour. Successful replays do not consume a new slot. A receipt confirms storage, not availability, notification delivery, a price or a booking.",
        "security": [
          {
            "submissionToken": []
          }
        ],
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "description": "Random UUID v4 for this request. Reuse unchanged after uncertain responses, even with a renewed session.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "client_name",
                  "reply_to",
                  "brief"
                ],
                "properties": {
                  "client_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Name of the client or organization requesting a quote."
                  },
                  "reply_to": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "One client-approved email address or phone number where the team should reply."
                  },
                  "brief": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 6000,
                    "description": "Natural-language description of the request. Include known quote details; unknown details may be omitted."
                  },
                  "locale": {
                    "type": "string",
                    "enum": [
                      "he",
                      "en"
                    ],
                    "default": "en"
                  }
                }
              },
              "example": {
                "client_name": "Dana (example)",
                "reply_to": "buyer@example.com",
                "brief": "I'm contacting you for Dana at a product company. She needs an English workshop on influence and decision-making for about 70 employees in Tel Aviv during November. Preferred duration: about one hour. The exact date and budget are not yet decided. Please suggest suitable formats and a quote.",
                "locale": "en"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Same request already saved; returns the original receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "receipt_id",
                    "replayed"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "received"
                    },
                    "receipt_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Saved: lead, receipt and notification outbox committed atomically.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "receipt_id",
                    "replayed"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "received"
                    },
                    "receipt_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or idempotency key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or expired capability. Get a new session and retry the same request key/body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Same idempotency key with different request content.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Body exceeds 24000 UTF-8 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Use Content-Type: application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Capacity exceeded. Respect Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "503": {
            "description": "Storage could not be confirmed. Retry with the same request key/body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "submissionToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Opaque capability returned by GET /session. It grants inquiry creation only, never lead access."
      }
    }
  }
}
