{
  "openapi": "3.1.0",
  "info": {
    "title": "Total Advisory Services Ltd. Enquiry API",
    "version": "1.0.0",
    "description": "Submit a consented financing enquiry or meeting request. Never send ID documents, bank numbers or credit reports."
  },
  "servers": [
    {
      "url": "https://www.totaladvisory.ca"
    }
  ],
  "paths": {
    "/api/agent/enquiries": {
      "post": {
        "summary": "Submit an authorized financing enquiry",
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 12,
              "maxLength": 80
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "https://www.totaladvisory.ca/enquiry.schema.json"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved; response includes received and reference",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "received",
                    "reference"
                  ],
                  "properties": {
                    "received": {
                      "const": true
                    },
                    "reference": {
                      "type": "string",
                      "pattern": "^TAS-[0-9]{8}-[A-F0-9]{8}$"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Repeated idempotency key; original reference",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "received",
                    "reference"
                  ],
                  "properties": {
                    "received": {
                      "const": true
                    },
                    "reference": {
                      "type": "string",
                      "pattern": "^TAS-[0-9]{8}-[A-F0-9]{8}$"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Agent key missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Idempotency key already used for a different inquiry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content type must be application/json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "summary": "Check enquiry storage availability",
        "responses": {
          "200": {
            "description": "Enquiry storage ready"
          },
          "503": {
            "description": "Enquiry storage unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "agentKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Request an agent key privately from Total Advisory Services Ltd.; never publish it in client-side code."
      }
    }
  }
}