{
  "openapi": "3.1.0",
  "info": {
    "title": "One PBX API",
    "description": "One PBX has one public API endpoint: the demo-request form submitted from https://pbx.one.bd/book-demo. There is no broader public/developer API at this time.\n\nVersioning: paths are versioned in the URL (/api/v1/...). The unversioned /api/demo-leads path is a deprecated alias kept working for backward compatibility; its responses carry a Deprecation header (RFC-draft draft-ietf-httpapi-deprecation-header, the date the deprecation was announced) and a Link header with rel=\"successor-version\" pointing at the versioned path. No removal date has been set yet; check those headers before integrating against it.\n\nRate limits: POST /api/v1/demo-leads (and its deprecated alias, sharing the same budget) is limited per client IP; see the RateLimit-* response headers below, and the 429 response. A 429 also carries Retry-After.\n\nOnly POST is listed below for each path. Any other method (GET, PUT, PATCH, DELETE) returns a structured JSON 405 with the same ApiError shape used everywhere else in this document; it isn't a separate capability, so it isn't listed as one.",
    "version": "1.0.0",
    "contact": {
      "url": "https://pbx.one.bd/contact"
    }
  },
  "servers": [{ "url": "https://pbx.one.bd" }],
  "security": [],
  "paths": {
    "/api/v1/demo-leads": {
      "post": {
        "operationId": "submitDemoLead",
        "summary": "Submit a free-demo request",
        "description": "Backs the form at /book-demo. Validates the submission and stores it for the sales team to follow up on. Rate limited per client IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/DemoLeadRequest" }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Lead accepted and stored.",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              },
              "RateLimit": { "$ref": "#/components/headers/RateLimitCombined" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DemoLeadAccepted" }
              }
            }
          },
          "400": {
            "description": "The request body was not valid JSON, or one or more fields failed validation.",
            "headers": {
              "RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "RateLimit-Reset": {
                "$ref": "#/components/headers/RateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/ApiError" },
                    { "$ref": "#/components/schemas/ValidationError" }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Retry after the number of seconds in Retry-After.",
            "headers": {
              "Retry-After": { "$ref": "#/components/headers/RetryAfter" },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "503": {
            "description": "The lead was valid but could not be stored. Safe to retry.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        }
      }
    },
    "/api/demo-leads": {
      "post": {
        "operationId": "submitDemoLeadDeprecated",
        "summary": "Submit a free-demo request (deprecated alias)",
        "deprecated": true,
        "description": "Deprecated, unversioned alias for POST /api/v1/demo-leads, with the same request/response shape and the same rate-limit budget. Use the versioned path for new integrations. Every response here additionally carries Deprecation and Link (rel=\"successor-version\") headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/DemoLeadRequest" }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Lead accepted and stored.",
            "headers": {
              "Deprecation": { "$ref": "#/components/headers/Deprecation" },
              "Link": { "$ref": "#/components/headers/SuccessorLink" },
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DemoLeadAccepted" }
              }
            }
          },
          "400": {
            "description": "The request body was not valid JSON, or one or more fields failed validation.",
            "headers": {
              "Deprecation": { "$ref": "#/components/headers/Deprecation" },
              "Link": { "$ref": "#/components/headers/SuccessorLink" }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/ApiError" },
                    { "$ref": "#/components/schemas/ValidationError" }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (shared with /api/v1/demo-leads). Retry after the number of seconds in Retry-After.",
            "headers": {
              "Retry-After": { "$ref": "#/components/headers/RetryAfter" },
              "Deprecation": { "$ref": "#/components/headers/Deprecation" },
              "Link": { "$ref": "#/components/headers/SuccessorLink" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          },
          "503": {
            "description": "The lead was valid but could not be stored. Safe to retry.",
            "headers": {
              "Deprecation": { "$ref": "#/components/headers/Deprecation" },
              "Link": { "$ref": "#/components/headers/SuccessorLink" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        }
      }
    },
    "/api/{unknown}": {
      "get": {
        "operationId": "unknownApiPath",
        "summary": "Any other /api/* path",
        "description": "Every path under /api/ that isn't listed above returns a JSON 404, not the site's HTML not-found page.",
        "parameters": [
          {
            "name": "unknown",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "404": {
            "description": "No such API endpoint.",
            "headers": {
              "RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiError" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "headers": {
      "RateLimitLimit": {
        "description": "The total request budget for the current window (draft-ietf-httpapi-ratelimit-headers).",
        "schema": { "type": "integer" }
      },
      "RateLimitRemaining": {
        "description": "Requests remaining in the current window. Reported (not consumed) on responses that aren't the rate-limited action itself.",
        "schema": { "type": "integer" }
      },
      "RateLimitReset": {
        "description": "Seconds until the current window resets.",
        "schema": { "type": "integer" }
      },
      "RateLimitCombined": {
        "description": "The same limit/remaining/reset values as one header: \"limit=N, remaining=N, reset=N\".",
        "schema": { "type": "string" }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying (RFC 9110 §10.2.3).",
        "schema": { "type": "integer" }
      },
      "Deprecation": {
        "description": "HTTP-date of when this path's deprecation was announced (draft-ietf-httpapi-deprecation-header). Present only on the unversioned /api/demo-leads alias.",
        "schema": { "type": "string" }
      },
      "SuccessorLink": {
        "description": "RFC 8288 Link header with rel=\"successor-version\", pointing at /api/v1/demo-leads. Present only on the unversioned /api/demo-leads alias.",
        "schema": { "type": "string" }
      }
    },
    "schemas": {
      "DemoLeadRequest": {
        "type": "object",
        "required": ["name", "phone", "email", "company"],
        "properties": {
          "name": { "type": "string", "minLength": 2, "maxLength": 80 },
          "phone": {
            "type": "string",
            "description": "A Bangladeshi mobile number, in any common local or +880 format."
          },
          "email": { "type": "string", "format": "email", "maxLength": 254 },
          "company": { "type": "string", "minLength": 2, "maxLength": 120 },
          "comment": { "type": "string", "maxLength": 1000 },
          "sourceUrl": {
            "type": "string",
            "description": "The page the form was submitted from."
          },
          "website": {
            "type": "string",
            "description": "Honeypot field. It must be left empty. A non-empty value marks the submission as spam."
          }
        }
      },
      "DemoLeadAccepted": {
        "type": "object",
        "properties": { "ok": { "type": "boolean", "const": true } }
      },
      "ApiError": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "const": false },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_body",
                  "validation_failed",
                  "storage_unavailable",
                  "method_not_allowed",
                  "not_found",
                  "rate_limited"
                ]
              },
              "message": { "type": "string" },
              "hint": { "type": "string" }
            },
            "required": ["code", "message", "hint"]
          }
        },
        "required": ["ok", "error"]
      },
      "ValidationError": {
        "allOf": [
          { "$ref": "#/components/schemas/ApiError" },
          {
            "type": "object",
            "properties": {
              "errors": {
                "type": "object",
                "description": "Per-field error code, keyed by field name.",
                "additionalProperties": {
                  "type": "string",
                  "enum": ["required", "invalid", "tooLong", "spam"]
                }
              }
            }
          }
        ]
      }
    }
  }
}
