{
  "openapi": "3.0.3",
  "info": {
    "title": "LionVoice API",
    "version": "v1",
    "description": "REST API for LionVoice agents, calls, knowledge, numbers, webhooks and billing. Brain is Lion-AI."
  },
  "servers": [
    {
      "url": "https://api.lionvoice.app/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "lv_live_"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-LV-Api-Key"
      }
    }
  },
  "paths": {
    "/ping": {
      "get": {
        "security": [],
        "summary": "Health",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/tenant": {
      "get": {
        "summary": "Current tenant (no webhook_secret; webhook_signing.prefix only)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agents": {
      "get": {
        "summary": "List agents",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Create agent",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/calls": {
      "get": {
        "summary": "List calls",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Originate outbound. Body: to_number (E.164), agent_id, schedule_at?",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "summary": "List tenant webhooks (no secrets)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Create webhook. Body: url (https), events[]. Signing secret shown once.",
        "responses": {
          "200": {
            "description": "OK; signing_secret once"
          }
        }
      }
    },
    "/webhooks/{id}": {
      "delete": {
        "summary": "Delete webhook",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/webhooks/{id}/test": {
      "post": {
        "summary": "Send test call.ended (SSRF-safe HTTPS client). No customer PII.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery result"
          }
        }
      }
    },
    "/webhooks/{id}/rotate-secret": {
      "post": {
        "summary": "Rotate HMAC secret (shown once)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "New signing_secret once"
          }
        }
      }
    },
    "/webhooks/{id}/deliveries": {
      "get": {
        "summary": "Delivery log: event_id, delivery_id, HTTP, ms. No payload body.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/webhooks/snippet": {
      "get": {
        "summary": "HMAC verify snippet. Query lang=php|javascript|python|curl",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Snippet text"
          }
        }
      }
    },
    "/webhook-secret/regenerate": {
      "post": {
        "summary": "Rotate legacy tenant-level webhook HMAC secret (shown once). Prefer POST /webhooks/{id}/rotate-secret.",
        "responses": {
          "201": {
            "description": "webhook_secret returned once; GET /tenant never includes it"
          }
        }
      }
    }
  }
}
