{
  "openapi": "3.1.0",
  "info": {
    "title": "LeadVex API",
    "summary": "Connect a dealership's LeadVex workspace to your website, DMS, CRM, Zapier or Make.",
    "description": "## Introduction\n\nThe LeadVex API lets your systems work with a dealership's LeadVex workspace: push leads from your website or DMS, keep the stock in sync, book test drives, read and answer conversations, and get notified the moment something happens. It is the same API the LeadVex apps use.\n\nBase URL: `https://api.leadvexai.com/api`. Send and receive JSON (UTF-8). IDs are UUIDs. Times are ISO 8601 with a timezone offset; responses use UTC. A token belongs to one dealership, so you never pass a dealership ID.\n\n```bash\ncurl https://api.leadvexai.com/api/api-tokens/current \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\"\n```\n\nWith Zapier or Make you need no code: use \"Webhooks by Zapier\" (or Make's HTTP module) with the requests below to send data, and a \"Catch Hook\" (or Make's custom webhook) URL as a LeadVex webhook endpoint to receive it.\n\n## Authentication\n\nEvery request carries an API token in the `Authorization` header: `Authorization: Bearer lvx_...`. The dealership owner, or a member with the Integrations permission, creates tokens in LeadVex under Integrations > API tokens. A token is shown once, expires after at most 366 days and can be revoked there at any time. Keep it on your server: never put it in a website or a mobile app.\n\nAPI access and webhooks are part of the Enterprise plan. Without them every call answers 403 with `\"code\": \"feature_not_in_plan\"`.\n\nA token can do only what its scopes allow, and never more than the person who created it may do today. Pick the fewest scopes your integration needs:\n\n| Scope | Allows |\n|---|---|\n| `leads:view` | Read leads assigned to the token creator and unassigned leads. |\n| `leads:view_all` | Read every lead, also other salespeople's. |\n| `leads:manage` | Create and update leads, their notes and tags. |\n| `customers:view` | Read customers. |\n| `customers:view_contact_details` | See phones and emails unmasked. |\n| `customers:manage` | Create and update customers. |\n| `customers:manage_consent` | Record a customer's marketing opt-in. |\n| `customers:manage_dncr` | Put a customer on the Do Not Call Register or take them off it. |\n| `conversations:view` | Read conversations and their messages. |\n| `messages:send` | Send messages to customers. |\n| `bookings:view` | Read the token creator's bookings and free slots. |\n| `bookings:view_all` | Read every salesperson's bookings. |\n| `bookings:manage` | Book, reschedule and cancel test drives. |\n| `inventory:view` | Read the stock. |\n| `inventory:manage` | Add, update and remove vehicles. |\n| `integrations:manage` | Manage webhook endpoints. |\n\nA token acts for an integration, not as a person. It cannot sign in, change passwords or 2FA, create tokens, invite people or change their permissions, change the plan or payment, or connect a calendar: those answer 403 `interactive user session required`.\n\n## Errors\n\nErrors use HTTP status codes and a JSON body with a `detail` field. `detail` is a sentence, an object with a stable `code` you can branch on and a `message`, or (422) a list of field problems.\n\n```json\n{\"detail\": \"missing required permission\"}\n```\n\n```json\n{\"detail\": {\"code\": \"slot_taken\", \"resource\": \"agent\",\n            \"message\": \"this agent is already booked during that time\"}}\n```\n\n```json\n{\"detail\": [{\"type\": \"missing\", \"loc\": [\"body\", \"customer_id\"],\n             \"msg\": \"Field required\", \"input\": {}}]}\n```\n\n| Status | Meaning |\n|---|---|\n| `400` | The request is malformed, for example an invalid `Idempotency-Key`. |\n| `401` | The token is missing, wrong, expired or revoked. |\n| `403` | The token lacks a scope, the plan does not include the feature, or the action needs a person. |\n| `404` | The record does not exist in this dealership, or the token may not see it. |\n| `409` | The request conflicts with the current state: a duplicate phone, a taken slot, a closed WhatsApp window, an `Idempotency-Key` still in use. |\n| `422` | A field is missing or invalid. `detail` lists each problem with its location. |\n| `429` | Too many requests. Wait the number of seconds in `Retry-After`. |\n| `500` | Our fault. `correlation_id` identifies the error for our support team. |\n| `503` | A provider the request needs (a calendar, a channel) is unavailable. Retry later. |\n\nEvery response has an `X-Correlation-ID` header. Quote it when you contact support about a request.\n\n## Rate limits\n\nEach token may make 300 requests per minute. Over that the API answers 429 with a `Retry-After` header: wait that many seconds and continue. Limits are per token, so one busy integration does not slow down another.\n\n- Pages hold at most 200 items.\n- `POST /vehicles/import` takes up to 500 vehicles at once: use it instead of one call per car.\n- A dealership can have up to 10 webhook endpoints. Prefer webhooks to polling for changes.\n\n## Pagination\n\nLists take `limit` (1 to 200, default 50) and `offset`, and answer `{\"items\": [...], \"total\": n}`. Fetch pages until `offset` reaches `total`.\n\nMessages in a conversation are paged with a cursor instead, newest first: pass the `next_cursor` you got back as `cursor` to get older messages. `next_cursor` is `null` on the oldest page.\n\n```python\nimport os\n\nimport requests\n\nAPI = \"https://api.leadvexai.com/api\"\nHEADERS = {\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"}\n\nleads, offset = [], 0\nwhile True:\n    page = requests.get(f\"{API}/leads/\", headers=HEADERS,\n                        params={\"status\": \"new\", \"limit\": 200, \"offset\": offset}, timeout=30)\n    page.raise_for_status()\n    body = page.json()\n    leads += body[\"items\"]\n    offset += len(body[\"items\"])\n    if not body[\"items\"] or offset >= body[\"total\"]:\n        break\n```\n\n## Idempotency\n\nA network error can leave you unsure whether a POST went through. Send an `Idempotency-Key` header (any unique string up to 255 characters, a UUID works well) with every POST. If you retry with the same key, LeadVex returns the first answer again with `Idempotent-Replayed: true` instead of creating a second lead, customer, booking or message.\n\n- Keys belong to your token and are kept for 24 hours after the first successful request.\n- Only successful (2xx) answers are kept. After an error you can fix the request and retry with the same key.\n- The same key with a different body, path or query answers 422 `idempotency_key_reused`.\n- While the first request is still running, a retry answers 409 `idempotency_request_in_progress` with `Retry-After: 1`.\n- GET, PATCH, PUT and DELETE are safe to repeat and need no key.\n\n```bash\ncurl -X POST https://api.leadvexai.com/api/customers/ \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: form-submission-84311\" \\\n  -d '{\"name\": \"Sara Al Mansoori\", \"phone\": \"+971501234567\"}'\n```\n\n## Webhooks\n\nA webhook endpoint is an HTTPS URL of yours that LeadVex calls when something happens. Create one in LeadVex under Integrations > Webhooks, or with `POST /webhook-endpoints/`, and pick its events. Every event is a POST with a JSON body:\n\n```json\n{\n  \"id\": \"<delivery id>\",\n  \"event\": \"lead.created\",\n  \"dealership_id\": \"<uuid>\",\n  \"occurred_at\": \"2026-11-25T08:41:19+00:00\",\n  \"data\": { ... }\n}\n```\n\n| Header | Value |\n|---|---|\n| `X-LeadVex-Event` | The event type, as in the body. |\n| `X-LeadVex-Delivery` | The delivery ID, as `id` in the body. A retry carries the same ID. |\n| `X-LeadVex-Signature` | `t=<unix seconds>,v1=<hex HMAC-SHA256>`. See Signatures. |\n| `User-Agent` | `LeadVex-Webhooks/1.0` |\n\n- Answer with any 2xx status within 10 seconds. Do the real work after you answer.\n- A failed delivery is retried up to 8 times in all, after 30 s, 2 min, 10 min, 30 min, 60 min, 180 min, 360 min (about 11 hours).\n- After 20 deliveries in a row fail, the endpoint is turned off and the owner sees why. Turn it on again from LeadVex or with `PATCH /webhook-endpoints/{id}`.\n- Deliveries can arrive more than once and out of order. Skip an `id` you have already processed, and use `occurred_at` to order events.\n- `data` is a snapshot of the records when the event was queued. Fetch the record through the API when you need its latest state.\n- Send a signed `ping` to check your endpoint: the \"Send test\" button in LeadVex, or `POST /webhook-endpoints/{id}/test`. The delivery log shows every attempt and your answer.\n\nA workflow in LeadVex can also call an endpoint with its \"Send to webhook\" step. Those deliveries have the event `workflow.step`. The Webhooks section lists every event with an example payload.\n\n## Signatures\n\nCheck every delivery before you trust it. The `X-LeadVex-Signature` header is `t=<timestamp>,v1=<signature>`. `v1` is the hex HMAC-SHA256 of the string `<timestamp>.<raw body>` with your endpoint's signing secret (`whsec_...`, shown once when you create the endpoint or rotate the secret) as the key.\n\n- Use the raw request body, byte for byte, before any JSON parsing.\n- Compare in constant time.\n- Reject a timestamp more than 5 minutes from your clock: that stops replays.\n\n```python\nimport hashlib\nimport hmac\nimport time\n\n\ndef verify_leadvex_signature(secret: str, header: str, body: bytes, tolerance: int = 300) -> bool:\n    \"\"\"True when X-LeadVex-Signature matches the raw request body.\"\"\"\n    try:\n        parts = dict(item.split(\"=\", 1) for item in header.split(\",\"))\n        timestamp = int(parts[\"t\"])\n        received = parts[\"v1\"]\n    except (KeyError, ValueError):\n        return False\n    if abs(time.time() - timestamp) > tolerance:\n        return False  # too old, or a replay\n    signed = f\"{timestamp}.\".encode() + body\n    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()\n    return hmac.compare_digest(expected, received)\n\n\n# Flask:\n#   ok = verify_leadvex_signature(SECRET, request.headers[\"X-LeadVex-Signature\"], request.get_data())\n```\n\n```javascript\nconst crypto = require(\"node:crypto\");\n\nfunction verifyLeadVexSignature(secret, header, rawBody, toleranceSeconds = 300) {\n  const parts = {};\n  for (const item of String(header || \"\").split(\",\")) {\n    const at = item.indexOf(\"=\");\n    if (at > 0) parts[item.slice(0, at)] = item.slice(at + 1);\n  }\n  const timestamp = Number(parts.t);\n  if (!Number.isInteger(timestamp) || !parts.v1) return false;\n  if (Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds) return false; // too old, or a replay\n  const expected = crypto.createHmac(\"sha256\", secret)\n    .update(`${timestamp}.`)\n    .update(rawBody) // the raw bytes, before any JSON parsing\n    .digest(\"hex\");\n  const a = Buffer.from(expected);\n  const b = Buffer.from(parts.v1);\n  return a.length === b.length && crypto.timingSafeEqual(a, b);\n}\n\nmodule.exports = { verifyLeadVexSignature };\n\n// Express: read the raw body for this route only.\n//   app.post(\"/leadvex\", express.raw({ type: \"application/json\" }), (req, res) => {\n//     if (!verifyLeadVexSignature(SECRET, req.get(\"X-LeadVex-Signature\"), req.body)) return res.sendStatus(401);\n//     res.sendStatus(200); // then handle JSON.parse(req.body) in the background\n//   });\n```\n\n```bash\n# Send your own endpoint a correctly signed test delivery.\nSECRET='whsec_your_endpoint_secret'\nBODY='{\"id\":\"f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35\",\"event\":\"ping\",\"dealership_id\":\"0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24\",\"occurred_at\":\"2026-11-25T08:45:00+00:00\",\"data\":{\"message\":\"Test event from LeadVex. Your endpoint is reachable.\"}}'\nT=$(date +%s)\nSIG=$(printf '%s.%s' \"$T\" \"$BODY\" | openssl dgst -sha256 -hmac \"$SECRET\" -hex | sed 's/^.* //')\n\ncurl -X POST https://your-server.example.com/leadvex-webhook \\\n  -H \"Content-Type: application/json\" \\\n  -H \"X-LeadVex-Event: ping\" \\\n  -H \"X-LeadVex-Delivery: f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35\" \\\n  -H \"X-LeadVex-Signature: t=$T,v1=$SIG\" \\\n  --data \"$BODY\"\n```\n\n## Versioning\n\nThis is version 1 of the API (1.2.0). Within a version we only make changes that do not break a correct integration, and we list each one in the changelog:\n\n- new endpoints, and new optional request fields and query parameters;\n- new fields in responses and in webhook `data`;\n- new event types, and new values in lists such as lead sources, channels and statuses.\n\nIgnore fields and values you do not know. We never remove or rename a field, change its type, make an optional field required or change what an error means within a version. If we need to, that becomes a new version under a new base path. The current version keeps working for at least 6 months after we announce its successor here and by email to the owners of active tokens. Anything we plan to retire is marked `deprecated` in this reference first.\n",
    "termsOfService": "https://www.leadvexai.com/terms",
    "version": "1.2.0"
  },
  "servers": [
    {
      "url": "https://api.leadvexai.com/api",
      "description": "Production"
    }
  ],
  "paths": {
    "/vehicles/": {
      "get": {
        "tags": [
          "Inventory"
        ],
        "summary": "List vehicles",
        "operationId": "listVehicles",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/VehicleStatus"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "`available`, `reserved`, `sold` or `archived`."
          },
          {
            "name": "price_min",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Lowest price."
          },
          {
            "name": "price_max",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Highest price."
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Part of the make or model."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50
            },
            "description": "Page size, 1 to 200. Default 50."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "How many items to skip. Default 0."
          },
          {
            "name": "branch_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this showroom. Without it you get every branch the token may see."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VehicleList"
                },
                "example": {
                  "items": [
                    {
                      "id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                      "status": "available",
                      "price": 52000,
                      "currency": "USD",
                      "data": {
                        "make": "Nissan",
                        "model": "Patrol",
                        "year": 2023,
                        "condition": "used",
                        "mileage": 42000,
                        "color": "Pearl White",
                        "transmission": "automatic",
                        "fuel": "petrol",
                        "body_type": "SUV",
                        "trim": "LE Platinum",
                        "vin": "JN8AY2NY0P9000001"
                      },
                      "photos": [
                        "https://cdn.example.com/stock/patrol-2023-front.jpg"
                      ],
                      "created_at": "2026-11-18T07:30:00+00:00",
                      "updated_at": "2026-11-24T12:05:31+00:00",
                      "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
                    }
                  ],
                  "total": 214
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Newest first. Every member sees the stock, so `inventory:view` is enough.\n\nScopes: `inventory:view`.",
        "x-scopes": [
          "inventory:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/vehicles/?status=available&search=patrol\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/vehicles/?status=available&search=patrol\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/vehicles/?status=available&search=patrol\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "post": {
        "tags": [
          "Inventory"
        ],
        "summary": "Add a vehicle",
        "operationId": "addVehicle",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VehicleCreate"
              },
              "example": {
                "data": {
                  "make": "Nissan",
                  "model": "Patrol",
                  "year": 2023,
                  "condition": "used",
                  "mileage": 42000,
                  "color": "Pearl White",
                  "transmission": "automatic",
                  "fuel": "petrol",
                  "body_type": "SUV",
                  "trim": "LE Platinum",
                  "vin": "JN8AY2NY0P9000001"
                },
                "price": 52000,
                "currency": "USD",
                "status": "available",
                "photos": [
                  "https://cdn.example.com/stock/patrol-2023-front.jpg"
                ],
                "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedResponse"
                },
                "example": {
                  "id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "description": "A used car without `mileage`, or a missing make, model or year.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": [
                    {
                      "type": "value_error",
                      "loc": [
                        "body",
                        "data"
                      ],
                      "msg": "Value error, mileage is required for used vehicles",
                      "input": {}
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "`data` needs `make`, `model` and `year`. A used car also needs `mileage`. Any other key you add to `data` (`vin`, `trim`, `stock_number`, ...) is kept and returned. `price` is a whole amount in `currency` (default `USD`).\n\nScopes: `inventory:manage`.",
        "x-scopes": [
          "inventory:manage"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/vehicles/\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"data\": {\n    \"make\": \"Nissan\",\n    \"model\": \"Patrol\",\n    \"year\": 2023,\n    \"condition\": \"used\",\n    \"mileage\": 42000,\n    \"color\": \"Pearl White\",\n    \"transmission\": \"automatic\",\n    \"fuel\": \"petrol\",\n    \"body_type\": \"SUV\",\n    \"trim\": \"LE Platinum\",\n    \"vin\": \"JN8AY2NY0P9000001\"\n  },\n  \"price\": 52000,\n  \"currency\": \"USD\",\n  \"status\": \"available\",\n  \"photos\": [\n    \"https://cdn.example.com/stock/patrol-2023-front.jpg\"\n  ],\n  \"branch_id\": \"5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/vehicles/\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"data\": {\n      \"make\": \"Nissan\",\n      \"model\": \"Patrol\",\n      \"year\": 2023,\n      \"condition\": \"used\",\n      \"mileage\": 42000,\n      \"color\": \"Pearl White\",\n      \"transmission\": \"automatic\",\n      \"fuel\": \"petrol\",\n      \"body_type\": \"SUV\",\n      \"trim\": \"LE Platinum\",\n      \"vin\": \"JN8AY2NY0P9000001\"\n    },\n    \"price\": 52000,\n    \"currency\": \"USD\",\n    \"status\": \"available\",\n    \"photos\": [\n      \"https://cdn.example.com/stock/patrol-2023-front.jpg\"\n    ],\n    \"branch_id\": \"5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/vehicles/\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"data\": {\n            \"make\": \"Nissan\",\n            \"model\": \"Patrol\",\n            \"year\": 2023,\n            \"condition\": \"used\",\n            \"mileage\": 42000,\n            \"color\": \"Pearl White\",\n            \"transmission\": \"automatic\",\n            \"fuel\": \"petrol\",\n            \"body_type\": \"SUV\",\n            \"trim\": \"LE Platinum\",\n            \"vin\": \"JN8AY2NY0P9000001\",\n        },\n        \"price\": 52000,\n        \"currency\": \"USD\",\n        \"status\": \"available\",\n        \"photos\": [\"https://cdn.example.com/stock/patrol-2023-front.jpg\"],\n        \"branch_id\": \"5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/vehicles/import": {
      "post": {
        "tags": [
          "Inventory"
        ],
        "summary": "Add vehicles in bulk",
        "operationId": "addVehiclesInBulk",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VehicleImport"
              },
              "example": {
                "items": [
                  {
                    "data": {
                      "make": "Nissan",
                      "model": "Patrol",
                      "year": 2023,
                      "condition": "used",
                      "mileage": 42000,
                      "color": "Pearl White",
                      "transmission": "automatic",
                      "fuel": "petrol",
                      "body_type": "SUV",
                      "trim": "LE Platinum",
                      "vin": "JN8AY2NY0P9000001"
                    },
                    "price": 52000,
                    "currency": "USD"
                  },
                  {
                    "data": {
                      "make": "Toyota",
                      "model": "Land Cruiser",
                      "year": 2025,
                      "condition": "new"
                    },
                    "price": 89000,
                    "currency": "USD",
                    "branch": "Al Quoz"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VehicleImportResponse"
                },
                "example": {
                  "created": 2
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "security": [
          {
            "ApiToken": []
          }
        ],
        "description": "Up to 500 vehicles in one request, for a first stock upload or a nightly sync from your DMS. All rows are checked first: if one is invalid, nothing is added. Each item can name its showroom by `branch` (the branch name, any case) instead of `branch_id`.\n\nScopes: `inventory:manage`.",
        "x-scopes": [
          "inventory:manage"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/vehicles/import\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"items\": [\n    {\n      \"data\": {\n        \"make\": \"Nissan\",\n        \"model\": \"Patrol\",\n        \"year\": 2023,\n        \"condition\": \"used\",\n        \"mileage\": 42000,\n        \"color\": \"Pearl White\",\n        \"transmission\": \"automatic\",\n        \"fuel\": \"petrol\",\n        \"body_type\": \"SUV\",\n        \"trim\": \"LE Platinum\",\n        \"vin\": \"JN8AY2NY0P9000001\"\n      },\n      \"price\": 52000,\n      \"currency\": \"USD\"\n    },\n    {\n      \"data\": {\n        \"make\": \"Toyota\",\n        \"model\": \"Land Cruiser\",\n        \"year\": 2025,\n        \"condition\": \"new\"\n      },\n      \"price\": 89000,\n      \"currency\": \"USD\",\n      \"branch\": \"Al Quoz\"\n    }\n  ]\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/vehicles/import\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"items\": [\n      {\n        \"data\": {\n          \"make\": \"Nissan\",\n          \"model\": \"Patrol\",\n          \"year\": 2023,\n          \"condition\": \"used\",\n          \"mileage\": 42000,\n          \"color\": \"Pearl White\",\n          \"transmission\": \"automatic\",\n          \"fuel\": \"petrol\",\n          \"body_type\": \"SUV\",\n          \"trim\": \"LE Platinum\",\n          \"vin\": \"JN8AY2NY0P9000001\"\n        },\n        \"price\": 52000,\n        \"currency\": \"USD\"\n      },\n      {\n        \"data\": {\n          \"make\": \"Toyota\",\n          \"model\": \"Land Cruiser\",\n          \"year\": 2025,\n          \"condition\": \"new\"\n        },\n        \"price\": 89000,\n        \"currency\": \"USD\",\n        \"branch\": \"Al Quoz\"\n      }\n    ]\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/vehicles/import\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"items\": [\n            {\n                \"data\": {\n                    \"make\": \"Nissan\",\n                    \"model\": \"Patrol\",\n                    \"year\": 2023,\n                    \"condition\": \"used\",\n                    \"mileage\": 42000,\n                    \"color\": \"Pearl White\",\n                    \"transmission\": \"automatic\",\n                    \"fuel\": \"petrol\",\n                    \"body_type\": \"SUV\",\n                    \"trim\": \"LE Platinum\",\n                    \"vin\": \"JN8AY2NY0P9000001\",\n                },\n                \"price\": 52000,\n                \"currency\": \"USD\",\n            },\n            {\n                \"data\": {\n                    \"make\": \"Toyota\",\n                    \"model\": \"Land Cruiser\",\n                    \"year\": 2025,\n                    \"condition\": \"new\",\n                },\n                \"price\": 89000,\n                \"currency\": \"USD\",\n                \"branch\": \"Al Quoz\",\n            },\n        ],\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/vehicles/{id}": {
      "get": {
        "tags": [
          "Inventory"
        ],
        "summary": "Get a vehicle",
        "operationId": "getVehicle",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The vehicle ID."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VehicleResponse"
                },
                "example": {
                  "id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                  "status": "available",
                  "price": 52000,
                  "currency": "USD",
                  "data": {
                    "make": "Nissan",
                    "model": "Patrol",
                    "year": 2023,
                    "condition": "used",
                    "mileage": 42000,
                    "color": "Pearl White",
                    "transmission": "automatic",
                    "fuel": "petrol",
                    "body_type": "SUV",
                    "trim": "LE Platinum",
                    "vin": "JN8AY2NY0P9000001"
                  },
                  "photos": [
                    "https://cdn.example.com/stock/patrol-2023-front.jpg"
                  ],
                  "created_at": "2026-11-18T07:30:00+00:00",
                  "updated_at": "2026-11-24T12:05:31+00:00",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such vehicle in this dealership.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "vehicle not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "One vehicle with all its details and photos.\n\nScopes: `inventory:view`.",
        "x-scopes": [
          "inventory:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "patch": {
        "tags": [
          "Inventory"
        ],
        "summary": "Update a vehicle",
        "operationId": "updateVehicle",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The vehicle ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VehicleUpdate"
              },
              "example": {
                "price": 49500,
                "status": "reserved"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VehicleResponse"
                },
                "example": {
                  "id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                  "status": "reserved",
                  "price": 49500,
                  "currency": "USD",
                  "data": {
                    "make": "Nissan",
                    "model": "Patrol",
                    "year": 2023,
                    "condition": "used",
                    "mileage": 42000,
                    "color": "Pearl White",
                    "transmission": "automatic",
                    "fuel": "petrol",
                    "body_type": "SUV",
                    "trim": "LE Platinum",
                    "vin": "JN8AY2NY0P9000001"
                  },
                  "photos": [
                    "https://cdn.example.com/stock/patrol-2023-front.jpg"
                  ],
                  "created_at": "2026-11-18T07:30:00+00:00",
                  "updated_at": "2026-11-24T12:05:31+00:00",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such vehicle in this dealership.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "vehicle not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Changes only the fields you send. `data` replaces the stored details as a whole: send all of them. Mark a sold car `sold`, so customers and the AI assistant stop offering it.\n\nScopes: `inventory:manage`.",
        "x-scopes": [
          "inventory:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"price\": 49500,\n  \"status\": \"reserved\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\", {\n  method: \"PATCH\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    \"price\": 49500,\n    \"status\": \"reserved\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.patch(\n    \"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    json={\n        \"price\": 49500,\n        \"status\": \"reserved\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "delete": {
        "tags": [
          "Inventory"
        ],
        "summary": "Remove a vehicle",
        "operationId": "removeVehicle",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The vehicle ID."
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No content."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such vehicle in this dealership.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "vehicle not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Removes the car from the stock. Bookings and conversations that mention it keep their history. To keep the car in reports, set its status to `sold` or `archived` instead.\n\nScopes: `inventory:manage`.",
        "x-scopes": [
          "inventory:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\", {\n  method: \"DELETE\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.delete(\n    \"https://api.leadvexai.com/api/vehicles/1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()"
          }
        ]
      }
    },
    "/conversations/": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "summary": "List conversations",
        "operationId": "listConversations",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/ConversationStatus"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "`open`, `pending`, `escalated` or `closed`."
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only threads assigned to this salesperson."
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this customer's threads."
          },
          {
            "name": "unassigned",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only threads nobody is assigned to."
          },
          {
            "name": "unread",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only threads with unread customer messages."
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "`whatsapp`, `instagram`, `messenger`, `telegram`, `email` or `webchat`."
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Part of the customer's name, phone or email."
          },
          {
            "name": "spam",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only threads marked as spam."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50
            },
            "description": "Page size, 1 to 200. Default 50."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "How many items to skip. Default 0."
          },
          {
            "name": "tag_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only threads with this conversation tag."
          },
          {
            "name": "mentioned",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only threads where the token creator was @mentioned in a note."
          },
          {
            "name": "snoozed",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only snoozed threads."
          },
          {
            "name": "lead_status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LeadStatus"
                  }
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only threads whose lead is in one of these statuses (repeat the parameter)."
          },
          {
            "name": "unreplied",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only threads where the customer is waiting for an answer."
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "newest",
                "oldest",
                "waiting_longest"
              ],
              "type": "string",
              "default": "newest"
            },
            "description": "`newest`, `oldest` or `waiting_longest`."
          },
          {
            "name": "branch_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this showroom. Without it you get every branch the token may see."
          },
          {
            "name": "view_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only the threads a saved inbox view lists (its id from the dealership app). Combines with the other filters."
          },
          {
            "name": "filters",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 4000
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "A view definition as JSON, with the same fields as a saved view, to filter without saving it. At most 4,000 characters."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationList"
                },
                "example": {
                  "items": [
                    {
                      "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                      "customer": {
                        "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                        "name": "Sara Al Mansoori",
                        "phone": "+971501234567",
                        "email": "sara@example.com",
                        "username": null
                      },
                      "assigned_agent": {
                        "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                        "name": "Omar Haddad"
                      },
                      "lead_id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                      "channel": "whatsapp",
                      "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02",
                      "email_subject": null,
                      "status": "open",
                      "ai_enabled": true,
                      "effective_mode": "auto",
                      "human_control": false,
                      "mode_reason": null,
                      "context_revision": 7,
                      "last_message_at": "2026-11-24T16:40:05+00:00",
                      "last_message_preview": "Can I come for a test drive on Tuesday?",
                      "unread_count": 1,
                      "created_at": "2026-11-20T09:12:44+00:00",
                      "assigned_at": "2026-11-20T09:13:02+00:00",
                      "first_response_due_at": null,
                      "first_responded_at": "2026-11-20T09:13:10+00:00",
                      "next_response_due_at": "2026-11-24T16:55:05+00:00",
                      "resolution_due_at": null,
                      "human_wait_started_at": null,
                      "human_wait_due_at": null,
                      "resolved_at": null,
                      "outcome": null,
                      "closing_note": null,
                      "loss_reason": null,
                      "automation_revision": 1,
                      "override_value": null,
                      "override_expires_at": null,
                      "next_transition_at": null,
                      "pinned_config_version": null,
                      "clarification_count": 0,
                      "is_spam": false,
                      "spam_at": null,
                      "spam_reason": null,
                      "tags": [
                        {
                          "id": "4a6c8e1b-3d5f-4a7c-9e2b-6d8f1a3c5e70",
                          "name": "VIP"
                        }
                      ],
                      "snoozed_until": null,
                      "waiting_since": "2026-11-24T16:40:05+00:00"
                    }
                  ],
                  "total": 57
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Newest activity first. Spam and snoozed threads are left out unless you ask for them.\n\nScopes: `conversations:view`.",
        "x-scopes": [
          "conversations:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/conversations/?status=open&unread=true\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/conversations/?status=open&unread=true\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/conversations/?status=open&unread=true\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/conversations/{id}": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "summary": "Get a conversation",
        "operationId": "getConversation",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The conversation ID."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationDetail"
                },
                "example": {
                  "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": "sara@example.com",
                    "username": null
                  },
                  "assigned_agent": {
                    "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                    "name": "Omar Haddad"
                  },
                  "lead_id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                  "channel": "whatsapp",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02",
                  "email_subject": null,
                  "status": "open",
                  "ai_enabled": true,
                  "effective_mode": "auto",
                  "human_control": false,
                  "mode_reason": null,
                  "context_revision": 7,
                  "last_message_at": "2026-11-24T16:40:05+00:00",
                  "last_message_preview": "Can I come for a test drive on Tuesday?",
                  "unread_count": 1,
                  "created_at": "2026-11-20T09:12:44+00:00",
                  "assigned_at": "2026-11-20T09:13:02+00:00",
                  "first_response_due_at": null,
                  "first_responded_at": "2026-11-20T09:13:10+00:00",
                  "next_response_due_at": "2026-11-24T16:55:05+00:00",
                  "resolution_due_at": null,
                  "human_wait_started_at": null,
                  "human_wait_due_at": null,
                  "resolved_at": null,
                  "outcome": null,
                  "closing_note": null,
                  "loss_reason": null,
                  "automation_revision": 1,
                  "override_value": null,
                  "override_expires_at": null,
                  "next_transition_at": null,
                  "pinned_config_version": null,
                  "clarification_count": 0,
                  "is_spam": false,
                  "spam_at": null,
                  "spam_reason": null,
                  "tags": [
                    {
                      "id": "4a6c8e1b-3d5f-4a7c-9e2b-6d8f1a3c5e70",
                      "name": "VIP"
                    }
                  ],
                  "snoozed_until": null,
                  "waiting_since": null,
                  "escalation": null,
                  "spam_by": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such conversation, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "conversation not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "One thread with its customer, salesperson, response deadlines and open escalation.\n\nScopes: `conversations:view`.",
        "x-scopes": [
          "conversations:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/conversations/{id}/messages": {
      "get": {
        "tags": [
          "Conversations"
        ],
        "summary": "List messages",
        "operationId": "listMessages",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The conversation ID."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "The `next_cursor` from the previous page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50
            },
            "description": "Page size, 1 to 200. Default 50."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagePage"
                },
                "example": {
                  "items": [
                    {
                      "id": "e7c3a9f1-4b2d-4e8a-a6c5-3f1b9d7e2c84",
                      "conversation_id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                      "sender_type": "customer",
                      "sender_agent_id": null,
                      "direction": "inbound",
                      "body": "Can I come for a test drive on Tuesday?",
                      "media": [],
                      "status": null,
                      "external_id": "wamid.HBgMOTcxNTAxMjM0NTY3FQIAEhgUM0E",
                      "ai_config_id": null,
                      "created_at": "2026-11-24T16:40:05+00:00",
                      "error": null,
                      "origin": null
                    }
                  ],
                  "next_cursor": "eyJiZWZvcmUiOiIyMDI2LTExLTI0VDE2OjQwOjA1In0"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such conversation, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "conversation not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "The newest messages first, `limit` at a time. Pass the `next_cursor` you got back as `cursor` to get the page before them. `next_cursor` is `null` on the oldest page.\n\nScopes: `conversations:view`.",
        "x-scopes": [
          "conversations:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17/messages?limit=50\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17/messages?limit=50\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17/messages?limit=50\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "post": {
        "tags": [
          "Conversations"
        ],
        "summary": "Send a message",
        "operationId": "sendMessage",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The conversation ID."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageSend"
              },
              "example": {
                "body": "Hi Sara, Tuesday at 5 pm works. See you at Al Quoz!"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageResponse"
                },
                "example": {
                  "id": "d3b5f7a9-c2e4-4b6d-8f1a-5c7e9b2d4f68",
                  "conversation_id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                  "sender_type": "agent",
                  "sender_agent_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                  "direction": "outbound",
                  "body": "Hi Sara, Tuesday at 5 pm works. See you at Al Quoz!",
                  "media": [],
                  "status": "queued",
                  "external_id": null,
                  "ai_config_id": null,
                  "created_at": "2026-11-24T16:44:12+00:00",
                  "error": null,
                  "origin": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such conversation, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "conversation not found"
                }
              }
            }
          },
          "409": {
            "description": "The WhatsApp 24-hour window is closed (send a template), or the channel is disconnected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "WhatsApp 24-hour service window is closed; send an approved template"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Queues a reply on the conversation's channel. It is sent within seconds: `status` moves from `queued` to `sent`, `delivered` and `read` as the channel reports back.\n\nWhatsApp accepts free text only within 24 hours of the customer's last message. After that, send an approved template: `{\"template\": {\"name\": \"test_drive_reminder\", \"language\": \"en\", \"components\": [...]}}`. The message is signed with the token creator as the agent and pauses the AI assistant on this thread, as when a salesperson replies.\n\nScopes: `messages:send`.",
        "x-scopes": [
          "messages:send"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17/messages\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"body\": \"Hi Sara, Tuesday at 5 pm works. See you at Al Quoz!\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17/messages\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"body\": \"Hi Sara, Tuesday at 5 pm works. See you at Al Quoz!\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/conversations/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17/messages\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"body\": \"Hi Sara, Tuesday at 5 pm works. See you at Al Quoz!\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/leads/": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "List leads",
        "operationId": "listLeads",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/LeadStatus"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only leads in this status."
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only leads assigned to this salesperson."
          },
          {
            "name": "unassigned",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only leads nobody is assigned to."
          },
          {
            "name": "created_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Created at or after this time (ISO 8601 with a timezone)."
          },
          {
            "name": "created_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Created before this time (ISO 8601 with a timezone)."
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Part of the customer's name or phone."
          },
          {
            "name": "from_ad",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Only leads that came from a Meta ad."
          },
          {
            "name": "ad_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only leads from this ad ID."
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "created",
                "activity",
                "score"
              ],
              "type": "string",
              "default": "created"
            },
            "description": "`created` (newest first), `activity` (latest activity first) or `score` (highest first)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50
            },
            "description": "Page size, 1 to 200. Default 50."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "How many items to skip. Default 0."
          },
          {
            "name": "branch_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this showroom. Without it you get every branch the token may see."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadList"
                },
                "example": {
                  "items": [
                    {
                      "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                      "customer": {
                        "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                        "name": "Sara Al Mansoori",
                        "phone": "+971501234567",
                        "email": "sara@example.com",
                        "username": null
                      },
                      "assigned_agent": {
                        "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                        "name": "Omar Haddad"
                      },
                      "status": "qualified",
                      "source": "website",
                      "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02",
                      "score": 72,
                      "car_interest": [
                        "Nissan Patrol 2025"
                      ],
                      "budget": 75000,
                      "budget_currency": "USD",
                      "budget_kind": "total",
                      "budget_min": null,
                      "budget_max": null,
                      "monthly_payment_budget": null,
                      "preferences": [
                        "white",
                        "4x4"
                      ],
                      "objections": [],
                      "deal_amount": null,
                      "deal_currency": null,
                      "revision": 4,
                      "field_provenance": {},
                      "timeline": "this month",
                      "tags": [
                        "finance"
                      ],
                      "notes": [
                        {
                          "text": "Asked about the 5-year service package",
                          "author_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                          "author_name": "Omar Haddad",
                          "created_at": "2026-11-21T10:02:11+00:00"
                        }
                      ],
                      "score_factors": [
                        {
                          "code": "car_interest",
                          "label": "Knows which car they want",
                          "weight": 25
                        },
                        {
                          "code": "budget",
                          "label": "Shared a budget",
                          "weight": 25
                        }
                      ],
                      "last_activity_at": "2026-11-24T16:40:05+00:00",
                      "created_at": "2026-11-20T09:12:44+00:00",
                      "ad_referral": null,
                      "custom_fields": {},
                      "lead_form": null
                    }
                  ],
                  "total": 128
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Newest first by default. Without `leads:view_all` a token sees the leads assigned to its creator and the unassigned ones.\n\nScopes: `leads:view`.",
        "x-scopes": [
          "leads:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/leads/?status=new&limit=50\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/leads/?status=new&limit=50\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/leads/?status=new&limit=50\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Create a lead",
        "operationId": "createLead",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadCreate"
              },
              "example": {
                "customer_id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                "source": "website",
                "car_interest": [
                  "Nissan Patrol 2025"
                ],
                "budget": 75000,
                "timeline": "this month",
                "tags": [
                  "finance"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedResponse"
                },
                "example": {
                  "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The customer, branch or salesperson is not in this dealership.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "customer not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Creates a lead for an existing customer (create the customer first). The lead starts as `new`. Pass `assigned_agent_id` to assign it, otherwise it stays unassigned. Fires the `lead.created` webhook.\n\n`budget` is a whole amount in US dollars, the currency LeadVex reports in.\n\nScopes: `leads:manage`.",
        "x-scopes": [
          "leads:manage"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/leads/\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"customer_id\": \"6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\",\n  \"source\": \"website\",\n  \"car_interest\": [\n    \"Nissan Patrol 2025\"\n  ],\n  \"budget\": 75000,\n  \"timeline\": \"this month\",\n  \"tags\": [\n    \"finance\"\n  ]\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/leads/\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"customer_id\": \"6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\",\n    \"source\": \"website\",\n    \"car_interest\": [\n      \"Nissan Patrol 2025\"\n    ],\n    \"budget\": 75000,\n    \"timeline\": \"this month\",\n    \"tags\": [\n      \"finance\"\n    ]\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/leads/\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"customer_id\": \"6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\",\n        \"source\": \"website\",\n        \"car_interest\": [\"Nissan Patrol 2025\"],\n        \"budget\": 75000,\n        \"timeline\": \"this month\",\n        \"tags\": [\"finance\"],\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/leads/{id}": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Get a lead",
        "operationId": "getLead",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The lead ID."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadResponse"
                },
                "example": {
                  "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": "sara@example.com",
                    "username": null
                  },
                  "assigned_agent": {
                    "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                    "name": "Omar Haddad"
                  },
                  "status": "qualified",
                  "source": "website",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02",
                  "score": 72,
                  "car_interest": [
                    "Nissan Patrol 2025"
                  ],
                  "budget": 75000,
                  "budget_currency": "USD",
                  "budget_kind": "total",
                  "budget_min": null,
                  "budget_max": null,
                  "monthly_payment_budget": null,
                  "preferences": [
                    "white",
                    "4x4"
                  ],
                  "objections": [],
                  "deal_amount": null,
                  "deal_currency": null,
                  "revision": 4,
                  "field_provenance": {},
                  "timeline": "this month",
                  "tags": [
                    "finance"
                  ],
                  "notes": [
                    {
                      "text": "Asked about the 5-year service package",
                      "author_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "author_name": "Omar Haddad",
                      "created_at": "2026-11-21T10:02:11+00:00"
                    }
                  ],
                  "score_factors": [
                    {
                      "code": "car_interest",
                      "label": "Knows which car they want",
                      "weight": 25
                    },
                    {
                      "code": "budget",
                      "label": "Shared a budget",
                      "weight": 25
                    }
                  ],
                  "last_activity_at": "2026-11-24T16:40:05+00:00",
                  "created_at": "2026-11-20T09:12:44+00:00",
                  "ad_referral": null,
                  "custom_fields": {},
                  "lead_form": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such lead, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "lead not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "One lead with its customer, salesperson, notes, score and the ad that brought it in.\n\nScopes: `leads:view`.",
        "x-scopes": [
          "leads:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "patch": {
        "tags": [
          "Leads"
        ],
        "summary": "Update a lead",
        "operationId": "updateLead",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The lead ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadUpdate"
              },
              "example": {
                "status": "test_drive",
                "budget": 80000,
                "timeline": "next week"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadResponse"
                },
                "example": {
                  "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": "sara@example.com",
                    "username": null
                  },
                  "assigned_agent": {
                    "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                    "name": "Omar Haddad"
                  },
                  "status": "test_drive",
                  "source": "website",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02",
                  "score": 72,
                  "car_interest": [
                    "Nissan Patrol 2025"
                  ],
                  "budget": 80000,
                  "budget_currency": "USD",
                  "budget_kind": "total",
                  "budget_min": null,
                  "budget_max": null,
                  "monthly_payment_budget": null,
                  "preferences": [
                    "white",
                    "4x4"
                  ],
                  "objections": [],
                  "deal_amount": null,
                  "deal_currency": null,
                  "revision": 4,
                  "field_provenance": {},
                  "timeline": "next week",
                  "tags": [
                    "finance"
                  ],
                  "notes": [
                    {
                      "text": "Asked about the 5-year service package",
                      "author_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "author_name": "Omar Haddad",
                      "created_at": "2026-11-21T10:02:11+00:00"
                    }
                  ],
                  "score_factors": [
                    {
                      "code": "car_interest",
                      "label": "Knows which car they want",
                      "weight": 25
                    },
                    {
                      "code": "budget",
                      "label": "Shared a budget",
                      "weight": 25
                    }
                  ],
                  "last_activity_at": "2026-11-24T16:40:05+00:00",
                  "created_at": "2026-11-20T09:12:44+00:00",
                  "ad_referral": null,
                  "custom_fields": {},
                  "lead_form": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such lead, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "lead not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Changes only the fields you send. Moving `status` fires `lead.status_changed`, and moving it to `won` also fires `sale.won`.\n\nA field you set is locked against the AI assistant: it will not overwrite your value from the chat. List a field in `unlock_fields` to let the AI update it again. `deal_amount` is the sale price for a won lead.\n\nScopes: `leads:manage`.",
        "x-scopes": [
          "leads:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"status\": \"test_drive\",\n  \"budget\": 80000,\n  \"timeline\": \"next week\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\", {\n  method: \"PATCH\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    \"status\": \"test_drive\",\n    \"budget\": 80000,\n    \"timeline\": \"next week\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.patch(\n    \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    json={\n        \"status\": \"test_drive\",\n        \"budget\": 80000,\n        \"timeline\": \"next week\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/leads/{id}/notes": {
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Add a note to a lead",
        "operationId": "addNoteToLead",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The lead ID."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadNoteCreate"
              },
              "example": {
                "text": "Customer called back: wants the white Patrol, trade-in a 2018 Land Cruiser."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadResponse"
                },
                "example": {
                  "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": "sara@example.com",
                    "username": null
                  },
                  "assigned_agent": {
                    "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                    "name": "Omar Haddad"
                  },
                  "status": "qualified",
                  "source": "website",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02",
                  "score": 72,
                  "car_interest": [
                    "Nissan Patrol 2025"
                  ],
                  "budget": 75000,
                  "budget_currency": "USD",
                  "budget_kind": "total",
                  "budget_min": null,
                  "budget_max": null,
                  "monthly_payment_budget": null,
                  "preferences": [
                    "white",
                    "4x4"
                  ],
                  "objections": [],
                  "deal_amount": null,
                  "deal_currency": null,
                  "revision": 4,
                  "field_provenance": {},
                  "timeline": "this month",
                  "tags": [
                    "finance"
                  ],
                  "notes": [
                    {
                      "text": "Asked about the 5-year service package",
                      "author_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "author_name": "Omar Haddad",
                      "created_at": "2026-11-21T10:02:11+00:00"
                    },
                    {
                      "text": "Customer called back: wants the white Patrol, trade-in a 2018 Land Cruiser.",
                      "author_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "author_name": "Omar Haddad",
                      "created_at": "2026-11-25T08:40:00+00:00"
                    }
                  ],
                  "score_factors": [
                    {
                      "code": "car_interest",
                      "label": "Knows which car they want",
                      "weight": 25
                    },
                    {
                      "code": "budget",
                      "label": "Shared a budget",
                      "weight": 25
                    }
                  ],
                  "last_activity_at": "2026-11-24T16:40:05+00:00",
                  "created_at": "2026-11-20T09:12:44+00:00",
                  "ad_referral": null,
                  "custom_fields": {},
                  "lead_form": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such lead, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "lead not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Appends an internal note. Customers never see notes. The note is signed with the token creator's name.\n\nScopes: `leads:manage`.",
        "x-scopes": [
          "leads:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43/notes\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"text\": \"Customer called back: wants the white Patrol, trade-in a 2018 Land Cruiser.\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43/notes\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"text\": \"Customer called back: wants the white Patrol, trade-in a 2018 Land Cruiser.\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43/notes\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"text\": \"Customer called back: wants the white Patrol, trade-in a 2018 Land Cruiser.\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/leads/{id}/tags": {
      "put": {
        "tags": [
          "Leads"
        ],
        "summary": "Replace a lead's tags",
        "operationId": "replaceLeadTags",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The lead ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadTagsUpdate"
              },
              "example": {
                "tags": [
                  "finance",
                  "trade-in"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadResponse"
                },
                "example": {
                  "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": "sara@example.com",
                    "username": null
                  },
                  "assigned_agent": {
                    "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                    "name": "Omar Haddad"
                  },
                  "status": "qualified",
                  "source": "website",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02",
                  "score": 72,
                  "car_interest": [
                    "Nissan Patrol 2025"
                  ],
                  "budget": 75000,
                  "budget_currency": "USD",
                  "budget_kind": "total",
                  "budget_min": null,
                  "budget_max": null,
                  "monthly_payment_budget": null,
                  "preferences": [
                    "white",
                    "4x4"
                  ],
                  "objections": [],
                  "deal_amount": null,
                  "deal_currency": null,
                  "revision": 4,
                  "field_provenance": {},
                  "timeline": "this month",
                  "tags": [
                    "finance",
                    "trade-in"
                  ],
                  "notes": [
                    {
                      "text": "Asked about the 5-year service package",
                      "author_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "author_name": "Omar Haddad",
                      "created_at": "2026-11-21T10:02:11+00:00"
                    }
                  ],
                  "score_factors": [
                    {
                      "code": "car_interest",
                      "label": "Knows which car they want",
                      "weight": 25
                    },
                    {
                      "code": "budget",
                      "label": "Shared a budget",
                      "weight": 25
                    }
                  ],
                  "last_activity_at": "2026-11-24T16:40:05+00:00",
                  "created_at": "2026-11-20T09:12:44+00:00",
                  "ad_referral": null,
                  "custom_fields": {},
                  "lead_form": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such lead, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "lead not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Sets the complete list of tags. Send the current tags plus the new one to add a tag. Each new tag fires `lead.tag_added`.\n\nScopes: `leads:manage`.",
        "x-scopes": [
          "leads:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X PUT \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43/tags\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"tags\": [\n    \"finance\",\n    \"trade-in\"\n  ]\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43/tags\", {\n  method: \"PUT\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    \"tags\": [\n      \"finance\",\n      \"trade-in\"\n    ]\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.put(\n    \"https://api.leadvexai.com/api/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43/tags\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    json={\n        \"tags\": [\"finance\", \"trade-in\"],\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/customers/": {
      "get": {
        "tags": [
          "Customers"
        ],
        "summary": "List customers",
        "operationId": "listCustomers",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Part of the name, phone or email."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50
            },
            "description": "Page size, 1 to 200. Default 50."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "How many items to skip. Default 0."
          },
          {
            "name": "branch_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this showroom. Without it you get every branch the token may see."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerList"
                },
                "example": {
                  "items": [
                    {
                      "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                      "name": "Sara Al Mansoori",
                      "phone": "+971501234567",
                      "email": "sara@example.com",
                      "locale": "ar",
                      "channels": {
                        "whatsapp": "971501234567"
                      },
                      "meta": {},
                      "revision": 3,
                      "field_provenance": {},
                      "created_at": "2026-11-20T09:12:44+00:00",
                      "marketing_opt_out_at": null,
                      "marketing_opt_out_source": null,
                      "marketing_opt_in_at": "2026-11-20T09:15:02+00:00",
                      "marketing_opt_in_source": "api",
                      "dncr_at": null,
                      "dncr_source": null,
                      "tags": [
                        "website",
                        "finance"
                      ],
                      "custom_fields": {
                        "emirate": "Dubai"
                      }
                    }
                  ],
                  "total": 342
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Newest first. Without `customers:view_contact_details` phones and emails come back masked (for example `+971 50 ••• ••67` and `s•••@example.com`).\n\nScopes: `customers:view`.",
        "x-scopes": [
          "customers:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/customers/?search=%2B97150&limit=20\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/customers/?search=%2B97150&limit=20\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/customers/?search=%2B97150&limit=20\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "post": {
        "tags": [
          "Customers"
        ],
        "summary": "Create a customer",
        "operationId": "createCustomer",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerCreate"
              },
              "example": {
                "name": "Sara Al Mansoori",
                "phone": "+971501234567",
                "email": "sara@example.com",
                "locale": "ar",
                "tags": [
                  "website"
                ],
                "marketing_opt_in": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedResponse"
                },
                "example": {
                  "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`marketing_opt_in` or `dncr` without the matching scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "changing marketing consent needs customers:manage_consent"
                }
              }
            }
          },
          "409": {
            "description": "Another customer already has this phone number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "customer with this phone already exists"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "A phone or an email is required. Phones are unique within a dealership: look the number up first, or handle the 409.\n\n`marketing_opt_in: true` records the customer's consent to marketing messages with the source `api`. It needs `customers:manage_consent`. Send it only when the customer really agreed, for example with a ticked box on your form. `dncr: true` puts the customer on the Do Not Call Register and needs `customers:manage_dncr`.\n\nScopes: `customers:manage`.",
        "x-scopes": [
          "customers:manage"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/customers/\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"name\": \"Sara Al Mansoori\",\n  \"phone\": \"+971501234567\",\n  \"email\": \"sara@example.com\",\n  \"locale\": \"ar\",\n  \"tags\": [\n    \"website\"\n  ],\n  \"marketing_opt_in\": true\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/customers/\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"name\": \"Sara Al Mansoori\",\n    \"phone\": \"+971501234567\",\n    \"email\": \"sara@example.com\",\n    \"locale\": \"ar\",\n    \"tags\": [\n      \"website\"\n    ],\n    \"marketing_opt_in\": true\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/customers/\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"name\": \"Sara Al Mansoori\",\n        \"phone\": \"+971501234567\",\n        \"email\": \"sara@example.com\",\n        \"locale\": \"ar\",\n        \"tags\": [\"website\"],\n        \"marketing_opt_in\": True,\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/customers/{id}": {
      "get": {
        "tags": [
          "Customers"
        ],
        "summary": "Get a customer",
        "operationId": "getCustomer",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The customer ID."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerResponse"
                },
                "example": {
                  "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                  "name": "Sara Al Mansoori",
                  "phone": "+971501234567",
                  "email": "sara@example.com",
                  "locale": "ar",
                  "channels": {
                    "whatsapp": "971501234567"
                  },
                  "meta": {},
                  "revision": 3,
                  "field_provenance": {},
                  "created_at": "2026-11-20T09:12:44+00:00",
                  "marketing_opt_out_at": null,
                  "marketing_opt_out_source": null,
                  "marketing_opt_in_at": "2026-11-20T09:15:02+00:00",
                  "marketing_opt_in_source": "api",
                  "dncr_at": null,
                  "dncr_source": null,
                  "tags": [
                    "website",
                    "finance"
                  ],
                  "custom_fields": {
                    "emirate": "Dubai"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such customer, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "customer not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "One customer with their channels, consent state, tags and custom fields.\n\nScopes: `customers:view`.",
        "x-scopes": [
          "customers:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/customers/6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/customers/6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/customers/6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "patch": {
        "tags": [
          "Customers"
        ],
        "summary": "Update a customer",
        "operationId": "updateCustomer",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The customer ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerUpdate"
              },
              "example": {
                "name": "Sara Al Mansoori",
                "locale": "en",
                "tags": [
                  "website",
                  "finance"
                ],
                "custom_fields": {
                  "emirate": "Dubai"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerResponse"
                },
                "example": {
                  "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                  "name": "Sara Al Mansoori",
                  "phone": "+971501234567",
                  "email": "sara@example.com",
                  "locale": "en",
                  "channels": {
                    "whatsapp": "971501234567"
                  },
                  "meta": {},
                  "revision": 3,
                  "field_provenance": {},
                  "created_at": "2026-11-20T09:12:44+00:00",
                  "marketing_opt_out_at": null,
                  "marketing_opt_out_source": null,
                  "marketing_opt_in_at": "2026-11-20T09:15:02+00:00",
                  "marketing_opt_in_source": "api",
                  "dncr_at": null,
                  "dncr_source": null,
                  "tags": [
                    "website",
                    "finance"
                  ],
                  "custom_fields": {
                    "emirate": "Dubai"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such customer, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "customer not found"
                }
              }
            }
          },
          "409": {
            "description": "Another customer already has this phone number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "customer with this phone already exists"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Changes only the fields you send. `custom_fields` are merged into the stored values, and a `null` value clears a field. `marketing_opt_out: true` unsubscribes the customer from marketing, and `marketing_opt_in: true` records their consent (needs `customers:manage_consent`). As on leads, the fields you set are locked against the AI assistant until you list them in `unlock_fields`.\n\nScopes: `customers:manage`.",
        "x-scopes": [
          "customers:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.leadvexai.com/api/customers/6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"name\": \"Sara Al Mansoori\",\n  \"locale\": \"en\",\n  \"tags\": [\n    \"website\",\n    \"finance\"\n  ],\n  \"custom_fields\": {\n    \"emirate\": \"Dubai\"\n  }\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/customers/6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\", {\n  method: \"PATCH\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    \"name\": \"Sara Al Mansoori\",\n    \"locale\": \"en\",\n    \"tags\": [\n      \"website\",\n      \"finance\"\n    ],\n    \"custom_fields\": {\n      \"emirate\": \"Dubai\"\n    }\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.patch(\n    \"https://api.leadvexai.com/api/customers/6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    json={\n        \"name\": \"Sara Al Mansoori\",\n        \"locale\": \"en\",\n        \"tags\": [\"website\", \"finance\"],\n        \"custom_fields\": {\n            \"emirate\": \"Dubai\",\n        },\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/bookings/": {
      "get": {
        "tags": [
          "Test drives"
        ],
        "summary": "List bookings",
        "operationId": "listBookings",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/BookingStatus"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "`scheduled`, `rescheduled`, `cancelled` or `done`."
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this salesperson's bookings."
          },
          {
            "name": "mine",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "only bookings assigned to me",
              "default": false
            },
            "description": "Only the token creator's bookings."
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Starts at or after this time (ISO 8601 with a timezone)."
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Starts before this time (ISO 8601 with a timezone)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50
            },
            "description": "Page size, 1 to 200. Default 50."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "description": "How many items to skip. Default 0."
          },
          {
            "name": "branch_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this showroom. Without it you get every branch the token may see."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingList"
                },
                "example": {
                  "items": [
                    {
                      "id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31",
                      "scheduled_at": "2026-12-02T13:00:00+00:00",
                      "ends_at": "2026-12-02T13:30:00+00:00",
                      "duration_min": 30,
                      "status": "scheduled",
                      "title": "Test drive: Nissan Patrol",
                      "location": "Al Quoz showroom",
                      "agent": {
                        "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                        "name": "Omar Haddad"
                      },
                      "customer": {
                        "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                        "name": "Sara Al Mansoori",
                        "phone": "+971501234567",
                        "email": "sara@example.com",
                        "username": null
                      },
                      "lead_id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                      "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                      "template_id": null,
                      "notes": "Bring Emirates ID and driving licence",
                      "created_at": "2026-11-25T08:41:19+00:00",
                      "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
                    }
                  ],
                  "total": 9
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Soonest first. Without `bookings:view_all` a token sees its creator's bookings only.\n\nScopes: `bookings:view`.",
        "x-scopes": [
          "bookings:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/bookings/?date_from=2026-12-01T00:00:00%2B04:00&date_to=2026-12-08T00:00:00%2B04:00\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/bookings/?date_from=2026-12-01T00:00:00%2B04:00&date_to=2026-12-08T00:00:00%2B04:00\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/bookings/?date_from=2026-12-01T00:00:00%2B04:00&date_to=2026-12-08T00:00:00%2B04:00\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "post": {
        "tags": [
          "Test drives"
        ],
        "summary": "Book a test drive",
        "operationId": "bookTestDrive",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingCreate"
              },
              "example": {
                "scheduled_at": "2026-12-02T17:00:00+04:00",
                "lead_id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                "duration_min": 30,
                "notes": "Bring Emirates ID and driving licence"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedResponse"
                },
                "example": {
                  "id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The salesperson or the car is already booked then (`code` is `slot_taken`, `resource` says which).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": {
                    "code": "slot_taken",
                    "resource": "agent",
                    "message": "this agent is already booked during that time"
                  }
                }
              }
            }
          },
          "422": {
            "description": "`scheduled_at` without a timezone, or neither `lead_id` nor `customer_id`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": [
                    {
                      "type": "value_error",
                      "loc": [
                        "body"
                      ],
                      "msg": "Value error, customer_id or lead_id is required",
                      "input": {
                        "scheduled_at": "2026-12-02T17:00:00+04:00"
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Books a time for a lead or a customer. `scheduled_at` must carry a timezone offset (UAE is `+04:00`). Pass `agent_id` to give it to a salesperson. The time may not overlap another booking of that salesperson or of the car, or a busy time in a connected calendar: get free times from `GET /booking-slots/availability` first. Fires `booking.created`, and the customer gets the usual confirmation and reminders. Without `duration_min` a booking lasts 30 minutes.\n\nScopes: `bookings:manage`.",
        "x-scopes": [
          "bookings:manage"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/bookings/\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"scheduled_at\": \"2026-12-02T17:00:00+04:00\",\n  \"lead_id\": \"3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\",\n  \"vehicle_id\": \"1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\",\n  \"duration_min\": 30,\n  \"notes\": \"Bring Emirates ID and driving licence\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/bookings/\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"scheduled_at\": \"2026-12-02T17:00:00+04:00\",\n    \"lead_id\": \"3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\",\n    \"vehicle_id\": \"1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\",\n    \"duration_min\": 30,\n    \"notes\": \"Bring Emirates ID and driving licence\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/bookings/\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"scheduled_at\": \"2026-12-02T17:00:00+04:00\",\n        \"lead_id\": \"3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43\",\n        \"vehicle_id\": \"1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19\",\n        \"duration_min\": 30,\n        \"notes\": \"Bring Emirates ID and driving licence\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/bookings/{id}": {
      "patch": {
        "tags": [
          "Test drives"
        ],
        "summary": "Reschedule or update a booking",
        "operationId": "rescheduleOrUpdateBooking",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The booking ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingUpdate"
              },
              "example": {
                "scheduled_at": "2026-12-03T11:00:00+04:00"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingResponse"
                },
                "example": {
                  "id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31",
                  "scheduled_at": "2026-12-03T07:00:00+00:00",
                  "ends_at": "2026-12-03T07:30:00+00:00",
                  "duration_min": 30,
                  "status": "rescheduled",
                  "title": "Test drive: Nissan Patrol",
                  "location": "Al Quoz showroom",
                  "agent": {
                    "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                    "name": "Omar Haddad"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": "sara@example.com",
                    "username": null
                  },
                  "lead_id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                  "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                  "template_id": null,
                  "notes": "Bring Emirates ID and driving licence",
                  "created_at": "2026-11-25T08:41:19+00:00",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such booking, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "booking not found"
                }
              }
            }
          },
          "409": {
            "description": "The new time is taken.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": {
                    "code": "slot_taken",
                    "resource": "vehicle",
                    "message": "this car is already booked during that time"
                  }
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Changes only the fields you send. A new `scheduled_at` makes the booking `rescheduled` and tells the customer. Set `status` to `done` after the drive.\n\nScopes: `bookings:manage`.",
        "x-scopes": [
          "bookings:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.leadvexai.com/api/bookings/c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"scheduled_at\": \"2026-12-03T11:00:00+04:00\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/bookings/c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31\", {\n  method: \"PATCH\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    \"scheduled_at\": \"2026-12-03T11:00:00+04:00\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.patch(\n    \"https://api.leadvexai.com/api/bookings/c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    json={\n        \"scheduled_at\": \"2026-12-03T11:00:00+04:00\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "delete": {
        "tags": [
          "Test drives"
        ],
        "summary": "Cancel a booking",
        "description": "Marks the booking `cancelled` and returns it. The record stays for reports. Fires `booking.cancelled`.\n\nScopes: `bookings:manage`.",
        "operationId": "cancelBooking",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The booking ID."
          },
          {
            "name": "reason",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 500
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Why it was cancelled, up to 500 characters. Shown to the team."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingResponse"
                },
                "example": {
                  "id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31",
                  "scheduled_at": "2026-12-02T13:00:00+00:00",
                  "ends_at": "2026-12-02T13:30:00+00:00",
                  "duration_min": 30,
                  "status": "cancelled",
                  "title": "Test drive: Nissan Patrol",
                  "location": "Al Quoz showroom",
                  "agent": {
                    "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                    "name": "Omar Haddad"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": "sara@example.com",
                    "username": null
                  },
                  "lead_id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                  "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                  "template_id": null,
                  "notes": "Bring Emirates ID and driving licence",
                  "created_at": "2026-11-25T08:41:19+00:00",
                  "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such booking, or the token may not see it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "booking not found"
                }
              }
            }
          },
          "409": {
            "description": "The booking is already cancelled, or done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "booking is already cancelled"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "x-scopes": [
          "bookings:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.leadvexai.com/api/bookings/c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31?reason=Customer%20postponed\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/bookings/c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31?reason=Customer%20postponed\", {\n  method: \"DELETE\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.delete(\n    \"https://api.leadvexai.com/api/bookings/c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31?reason=Customer%20postponed\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/booking-slots/availability": {
      "get": {
        "tags": [
          "Test drives"
        ],
        "summary": "List free slots",
        "operationId": "listFreeSlots",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "First day (YYYY-MM-DD). Default today."
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Last day (YYYY-MM-DD). Default a week after `date_from`."
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this salesperson's slots."
          },
          {
            "name": "branch_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Only this showroom."
          },
          {
            "name": "vehicle_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Leave out times when this car is already booked."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AvailabilityResponse"
                },
                "example": {
                  "items": [
                    {
                      "agent_id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "start": "2026-12-02T13:00:00+00:00",
                      "end": "2026-12-02T13:30:00+00:00",
                      "branch_id": "5e9c1a7b-8d3f-4e2a-b6c4-1f7d3b9e5a02"
                    }
                  ],
                  "total": 1
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Free start times from the dealership's working hours, its salespeople's existing bookings and their connected calendars. At most 31 days at a time. Times are UTC: convert them for display.\n\nScopes: `bookings:view`.",
        "x-scopes": [
          "bookings:view"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/booking-slots/availability?date_from=2026-12-01&date_to=2026-12-07\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/booking-slots/availability?date_from=2026-12-01&date_to=2026-12-07\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/booking-slots/availability?date_from=2026-12-01&date_to=2026-12-07\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/api-tokens/current": {
      "get": {
        "tags": [
          "Token"
        ],
        "summary": "Check your token",
        "description": "Returns the token you call with: its name, what it may do now and its expiry date. Use it to check a connection, for example in the \"test\" step of a Zapier or Make connection.\n\n`scopes` are the token's scopes capped by its creator's current permissions. If the creator loses a permission, the token loses it too.",
        "operationId": "checkToken",
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiTokenCurrent"
                },
                "example": {
                  "id": "7b9d1f3a-5c7e-4a2b-8d6f-0e2c4a6b8d13",
                  "name": "Zapier",
                  "scopes": [
                    "customers:manage",
                    "customers:view",
                    "leads:manage",
                    "leads:view"
                  ],
                  "expires_at": "2027-02-23T08:00:00+00:00",
                  "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                  "dealership_name": "Al Quoz Motors"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Called with a signed-in session instead of an API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "call this with an API token"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "security": [
          {
            "ApiToken": []
          }
        ],
        "x-scopes": [],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/api-tokens/current\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/api-tokens/current\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/api-tokens/current\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/events": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List event types",
        "operationId": "listEventTypes",
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEventCatalog"
                },
                "example": {
                  "events": [
                    "lead.created",
                    "lead.status_changed",
                    "sale.won",
                    "lead.tag_added",
                    "conversation.opened",
                    "conversation.assigned",
                    "message.received",
                    "booking.created",
                    "booking.cancelled",
                    "conversation.closed",
                    "payment.paid",
                    "call.completed"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "security": [
          {
            "ApiToken": []
          }
        ],
        "description": "The events an endpoint can subscribe to. The Webhooks section below describes each payload.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/webhook-endpoints/events\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/events\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/webhook-endpoints/events\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/events/{event}/sample": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Get sample payloads",
        "description": "Up to three payloads of the newest real events of this type in your dealership, newest first, shaped exactly like the deliveries. Without such an event yet you get the documented example. The Zapier and Make apps show these in their \"test trigger\" step.\n\nScopes: `integrations:manage`.",
        "operationId": "getSamplePayloads",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "event",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "An event name from `GET /webhook-endpoints/events`, for example `lead.created`."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSampleList"
                },
                "example": {
                  "items": [
                    {
                      "id": "sample-0c7f9e2a-3b1d-4c5e-8f6a-7b9d1e3c5a24",
                      "event": "lead.created",
                      "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                      "occurred_at": "2026-11-25T08:41:19+00:00",
                      "data": {
                        "lead": {
                          "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                          "status": "new",
                          "source": "whatsapp",
                          "score": 40,
                          "tags": [],
                          "car_interest": [
                            "Nissan Patrol 2025"
                          ],
                          "budget": 75000,
                          "budget_currency": "USD",
                          "deal_amount": null,
                          "deal_currency": null,
                          "assigned_agent": {
                            "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                            "name": "Omar Haddad"
                          },
                          "created_at": "2026-11-25T08:41:19+00:00",
                          "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                        },
                        "customer": {
                          "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                          "name": "Sara Al Mansoori",
                          "phone": "+971501234567",
                          "email": null,
                          "language": "ar"
                        },
                        "conversation": {
                          "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                          "channel": "whatsapp",
                          "status": "open",
                          "assigned_agent": {
                            "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                            "name": "Omar Haddad"
                          },
                          "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "Not an event name from `GET /webhook-endpoints/events`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "unknown event"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/webhook-endpoints/events/{event}/sample\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/events/{event}/sample\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/webhook-endpoints/events/{event}/sample\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/subscriptions": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Subscribe a REST hook",
        "description": "For no-code platforms: subscribes one URL to one event, as Zapier and Make do when a Zap or scenario is turned on. `source` is `zapier` or `make` and needs that app in your plan. Subscriptions are signed like endpoints, are listed with the endpoints (with their `source`) and do not count against the 10 endpoints; at most 100 per source. Only events after the subscription are sent.\n\nScopes: `integrations:manage`.",
        "operationId": "subscribeRestHook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookSubscriptionCreate"
              },
              "example": {
                "target_url": "https://hooks.zapier.com/hooks/standard/123456/abcdef/",
                "event": "lead.created",
                "source": "zapier"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSubscriptionResponse"
                },
                "example": {
                  "id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                  "event": "lead.created",
                  "target_url": "https://hooks.zapier.com/hooks/standard/123456/abcdef/",
                  "source": "zapier",
                  "created_at": "2026-11-25T08:00:00+00:00"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The dealership already has 100 subscriptions from this source.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "at most 100 zapier subscriptions"
                }
              }
            }
          },
          "422": {
            "description": "The URL is not public HTTPS.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": {
                    "code": "https_required",
                    "message": "this URL cannot receive webhooks"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "security": [
          {
            "ApiToken": []
          }
        ],
        "x-scopes": [
          "integrations:manage"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/webhook-endpoints/subscriptions\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"target_url\": \"https://hooks.zapier.com/hooks/standard/123456/abcdef/\",\n  \"event\": \"lead.created\",\n  \"source\": \"zapier\"\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/subscriptions\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"target_url\": \"https://hooks.zapier.com/hooks/standard/123456/abcdef/\",\n    \"event\": \"lead.created\",\n    \"source\": \"zapier\"\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/webhook-endpoints/subscriptions\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"target_url\": \"https://hooks.zapier.com/hooks/standard/123456/abcdef/\",\n        \"event\": \"lead.created\",\n        \"source\": \"zapier\",\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/subscriptions/{id}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Unsubscribe a REST hook",
        "description": "Stops a subscription made with `POST /webhook-endpoints/subscriptions`. Endpoints made in LeadVex are not removed here (use `DELETE /webhook-endpoints/{id}`).\n\nScopes: `integrations:manage`.",
        "operationId": "unsubscribeRestHook",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The subscription ID that `POST /webhook-endpoints/subscriptions` returned."
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No content."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "subscription not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.leadvexai.com/api/webhook-endpoints/subscriptions/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/subscriptions/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\", {\n  method: \"DELETE\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.delete(\n    \"https://api.leadvexai.com/api/webhook-endpoints/subscriptions/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()"
          }
        ]
      }
    },
    "/webhook-endpoints/": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List endpoints",
        "operationId": "listEndpoints",
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointList"
                },
                "example": {
                  "items": [
                    {
                      "id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                      "name": "Zapier: new leads",
                      "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
                      "events": [
                        "lead.created",
                        "booking.created"
                      ],
                      "is_active": true,
                      "disabled_reason": null,
                      "secret_hint": "Q2xz",
                      "consecutive_failures": 0,
                      "last_success_at": "2026-11-25T08:41:22+00:00",
                      "last_failure_at": null,
                      "delivered_24h": 18,
                      "failed_24h": 0,
                      "pending": 0,
                      "source": "app",
                      "created_at": "2026-11-19T10:00:00+00:00"
                    }
                  ],
                  "total": 1
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "security": [
          {
            "ApiToken": []
          }
        ],
        "description": "Every endpoint with its delivery counts for the last 24 hours. Secrets are never shown again, only their last four characters.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/webhook-endpoints/\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/webhook-endpoints/\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create an endpoint",
        "operationId": "createEndpoint",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointCreate"
              },
              "example": {
                "name": "Zapier: new leads",
                "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
                "events": [
                  "lead.created",
                  "booking.created"
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointCreated"
                },
                "example": {
                  "id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                  "name": "Zapier: new leads",
                  "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
                  "events": [
                    "lead.created",
                    "booking.created"
                  ],
                  "is_active": true,
                  "disabled_reason": null,
                  "secret_hint": "Q2xz",
                  "consecutive_failures": 0,
                  "last_success_at": null,
                  "last_failure_at": null,
                  "delivered_24h": 0,
                  "failed_24h": 0,
                  "pending": 0,
                  "source": "app",
                  "created_at": "2026-11-19T10:00:00+00:00",
                  "secret": "whsec_3pWm7Yk2bQ9sV4xT8nL1cR6fJ0hG5dA2zE7uK9iO4Q2xz"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The dealership already has 10 endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "at most 10 webhook endpoints"
                }
              }
            }
          },
          "422": {
            "description": "The URL is not public HTTPS.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": {
                    "code": "https_required",
                    "message": "this URL cannot receive webhooks"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "security": [
          {
            "ApiToken": []
          }
        ],
        "description": "Subscribes an HTTPS URL to events. The response carries the signing `secret` once: store it to check signatures. The URL must be public HTTPS (no private or local addresses). At most 10 endpoints per dealership. Only events after the endpoint was created are sent.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/webhook-endpoints/\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: $(uuidgen)\" \\\n  -d '{\n  \"name\": \"Zapier: new leads\",\n  \"url\": \"https://hooks.zapier.com/hooks/catch/123456/abcdef/\",\n  \"events\": [\n    \"lead.created\",\n    \"booking.created\"\n  ]\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n  body: JSON.stringify({\n    \"name\": \"Zapier: new leads\",\n    \"url\": \"https://hooks.zapier.com/hooks/catch/123456/abcdef/\",\n    \"events\": [\n      \"lead.created\",\n      \"booking.created\"\n    ]\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/webhook-endpoints/\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    json={\n        \"name\": \"Zapier: new leads\",\n        \"url\": \"https://hooks.zapier.com/hooks/catch/123456/abcdef/\",\n        \"events\": [\"lead.created\", \"booking.created\"],\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/{id}": {
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Update an endpoint",
        "operationId": "updateEndpoint",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The webhook endpoint ID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointUpdate"
              },
              "example": {
                "events": [
                  "lead.created",
                  "lead.status_changed",
                  "sale.won"
                ],
                "is_active": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointResponse"
                },
                "example": {
                  "id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                  "name": "Zapier: new leads",
                  "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
                  "events": [
                    "lead.created",
                    "lead.status_changed",
                    "sale.won"
                  ],
                  "is_active": true,
                  "disabled_reason": null,
                  "secret_hint": "Q2xz",
                  "consecutive_failures": 0,
                  "last_success_at": "2026-11-25T08:41:22+00:00",
                  "last_failure_at": null,
                  "delivered_24h": 18,
                  "failed_24h": 0,
                  "pending": 0,
                  "source": "app",
                  "created_at": "2026-11-19T10:00:00+00:00"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "webhook endpoint not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Change the name, URL or events, or turn the endpoint off (`is_active: false`) and on again. Events from while it was off are not sent later. Turning it on also clears an automatic switch-off after 20 failed deliveries in a row.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X PATCH \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n  \"events\": [\n    \"lead.created\",\n    \"lead.status_changed\",\n    \"sale.won\"\n  ],\n  \"is_active\": true\n}'"
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\", {\n  method: \"PATCH\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    \"events\": [\n      \"lead.created\",\n      \"lead.status_changed\",\n      \"sale.won\"\n    ],\n    \"is_active\": true\n  }),\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.patch(\n    \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    json={\n        \"events\": [\"lead.created\", \"lead.status_changed\", \"sale.won\"],\n        \"is_active\": True,\n    },\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete an endpoint",
        "operationId": "deleteEndpoint",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The webhook endpoint ID."
          }
        ],
        "responses": {
          "204": {
            "description": "Done. No content."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "webhook endpoint not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Stops all deliveries to the endpoint and removes it.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X DELETE \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\", {\n  method: \"DELETE\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.delete(\n    \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()"
          }
        ]
      }
    },
    "/webhook-endpoints/{id}/rotate-secret": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Rotate the signing secret",
        "operationId": "rotateSigningSecret",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The webhook endpoint ID."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointCreated"
                },
                "example": {
                  "id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                  "name": "Zapier: new leads",
                  "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
                  "events": [
                    "lead.created",
                    "booking.created"
                  ],
                  "is_active": true,
                  "disabled_reason": null,
                  "secret_hint": "k7Rm",
                  "consecutive_failures": 0,
                  "last_success_at": "2026-11-25T08:41:22+00:00",
                  "last_failure_at": null,
                  "delivered_24h": 18,
                  "failed_24h": 0,
                  "pending": 0,
                  "source": "app",
                  "created_at": "2026-11-19T10:00:00+00:00",
                  "secret": "whsec_8sJd2Lq9Vx4Ty7Ue1Wb6Nc3Pf0Mh5Zg2Ak7Rm"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "webhook endpoint not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Issues a new secret and returns it once. Deliveries from now on are signed with the new secret only, so update your receiver right away.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/rotate-secret\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/rotate-secret\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/rotate-secret\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/{id}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Send a test event",
        "description": "Queues a signed `ping` event to the endpoint. It goes out within seconds. Check the result in the delivery log (`GET /webhook-endpoints/{id}/deliveries`).\n\nScopes: `integrations:manage`.",
        "operationId": "sendTestEvent",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The webhook endpoint ID."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted: queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryResponse"
                },
                "example": {
                  "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                  "endpoint_id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                  "event_type": "ping",
                  "status": "pending",
                  "attempts": 0,
                  "response_status": null,
                  "response_ms": null,
                  "last_error": null,
                  "next_attempt_at": "2026-11-25T08:45:00+00:00",
                  "last_attempt_at": null,
                  "delivered_at": null,
                  "created_at": "2026-11-25T08:45:00+00:00",
                  "payload": {
                    "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                    "event": "ping",
                    "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                    "occurred_at": "2026-11-25T08:45:00+00:00",
                    "data": {
                      "message": "Test event from LeadVex. Your endpoint is reachable."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "webhook endpoint not found"
                }
              }
            }
          },
          "409": {
            "description": "The endpoint is turned off.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "turn the endpoint on to send a test"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/test\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/test\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/test\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/{id}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List deliveries",
        "operationId": "listDeliveries",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The webhook endpoint ID."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(pending|delivering|succeeded|failed)$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "`pending`, `delivering`, `succeeded` or `failed`."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50
            },
            "description": "How many, 1 to 200. Default 50."
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryList"
                },
                "example": {
                  "items": [
                    {
                      "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                      "endpoint_id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                      "event_type": "ping",
                      "status": "succeeded",
                      "attempts": 1,
                      "response_status": 200,
                      "response_ms": 182,
                      "last_error": null,
                      "next_attempt_at": "2026-11-25T08:45:00+00:00",
                      "last_attempt_at": "2026-11-25T08:45:03+00:00",
                      "delivered_at": "2026-11-25T08:45:03+00:00",
                      "created_at": "2026-11-25T08:45:00+00:00",
                      "payload": {
                        "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                        "event": "ping",
                        "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                        "occurred_at": "2026-11-25T08:45:00+00:00",
                        "data": {
                          "message": "Test event from LeadVex. Your endpoint is reachable."
                        }
                      }
                    }
                  ],
                  "total": 1
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "webhook endpoint not found"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "The latest deliveries to the endpoint, newest first, with the exact payload and your server's answer. Deliveries are kept 30 days.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/deliveries?status=failed\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/deliveries?status=failed\", {\n  method: \"GET\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\n\nimport requests\n\nresponse = requests.get(\n    \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/deliveries?status=failed\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/webhook-endpoints/{id}/deliveries/{delivery_id}/redeliver": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Send a delivery again",
        "operationId": "sendDeliveryAgain",
        "security": [
          {
            "ApiToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The webhook endpoint ID."
          },
          {
            "name": "delivery_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID (X-LeadVex-Delivery)."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string up to 255 characters. A retry with the same key returns the first answer instead of doing the work twice. See Idempotency.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "form-submission-84311"
          }
        ],
        "responses": {
          "200": {
            "description": "OK.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryResponse"
                },
                "example": {
                  "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                  "endpoint_id": "a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46",
                  "event_type": "ping",
                  "status": "pending",
                  "attempts": 0,
                  "response_status": 200,
                  "response_ms": 182,
                  "last_error": null,
                  "next_attempt_at": "2026-11-25T08:45:00+00:00",
                  "last_attempt_at": "2026-11-25T08:45:03+00:00",
                  "delivered_at": "2026-11-25T08:45:03+00:00",
                  "created_at": "2026-11-25T08:45:00+00:00",
                  "payload": {
                    "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                    "event": "ping",
                    "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                    "occurred_at": "2026-11-25T08:45:00+00:00",
                    "data": {
                      "message": "Test event from LeadVex. Your endpoint is reachable."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No such endpoint or delivery.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "delivery not found"
                }
              }
            }
          },
          "409": {
            "description": "The delivery is still being sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "detail": "this delivery is still being sent"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "description": "Queues a finished delivery again with the same `id` and payload, for example after fixing your receiver. Your receiver should skip ids it has already processed.\n\nScopes: `integrations:manage`.",
        "x-scopes": [
          "integrations:manage"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "curl",
            "source": "curl -X POST \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/deliveries/f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35/redeliver\" \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Idempotency-Key: $(uuidgen)\""
          },
          {
            "lang": "javascript",
            "label": "Node",
            "source": "const response = await fetch(\"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/deliveries/f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35/redeliver\", {\n  method: \"POST\",\n  headers: {\n    Authorization: `Bearer ${process.env.LEADVEX_TOKEN}`,\n    \"Idempotency-Key\": crypto.randomUUID(),\n  },\n});\nif (!response.ok) throw new Error(`LeadVex ${response.status}: ${await response.text()}`);\nconst data = await response.json();"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport uuid\n\nimport requests\n\nresponse = requests.post(\n    \"https://api.leadvexai.com/api/webhook-endpoints/a1b3c5d7-e9f2-4a6c-8e1b-3d5f7a9c2e46/deliveries/f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35/redeliver\",\n    headers={\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\", \"Idempotency-Key\": str(uuid.uuid4())},\n    timeout=30,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AdReferralSummary": {
        "properties": {
          "platform": {
            "type": "string",
            "title": "Platform"
          },
          "source_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source Type"
          },
          "source_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source Id"
          },
          "source_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source Url"
          },
          "headline": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Headline"
          },
          "body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Body"
          },
          "media_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Media Type"
          },
          "campaign_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Campaign Name"
          },
          "adset_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Adset Name"
          },
          "form_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Form Name"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "platform",
          "created_at"
        ],
        "title": "AdReferralSummary",
        "description": "The ad or post click that first brought this lead in."
      },
      "AgentSummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "AgentSummary"
      },
      "ApiTokenCurrent": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "scopes": {
            "items": {
              "$ref": "#/components/schemas/Permission"
            },
            "type": "array",
            "title": "Scopes"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "title": "Expires At"
          },
          "dealership_id": {
            "type": "string",
            "format": "uuid",
            "title": "Dealership Id"
          },
          "dealership_name": {
            "type": "string",
            "title": "Dealership Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "scopes",
          "expires_at",
          "dealership_id",
          "dealership_name"
        ],
        "title": "ApiTokenCurrent",
        "description": "GET /api-tokens/current: the token a request is made with."
      },
      "AvailabilityResponse": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/AvailableSlot"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "AvailabilityResponse"
      },
      "AvailableSlot": {
        "properties": {
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "start": {
            "type": "string",
            "format": "date-time",
            "title": "Start"
          },
          "end": {
            "type": "string",
            "format": "date-time",
            "title": "End"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          }
        },
        "type": "object",
        "required": [
          "agent_id",
          "start",
          "end"
        ],
        "title": "AvailableSlot"
      },
      "BookingCreate": {
        "properties": {
          "scheduled_at": {
            "type": "string",
            "format": "date-time",
            "title": "Scheduled At"
          },
          "template_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Template Id"
          },
          "duration_min": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 480.0,
                "minimum": 5.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration Min"
          },
          "title": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Title"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Location"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "customer_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Customer Id"
          },
          "lead_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lead Id"
          },
          "vehicle_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vehicle Id"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          }
        },
        "type": "object",
        "required": [
          "scheduled_at"
        ],
        "title": "BookingCreate"
      },
      "BookingList": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/BookingResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "BookingList"
      },
      "BookingResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "scheduled_at": {
            "type": "string",
            "format": "date-time",
            "title": "Scheduled At"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time",
            "title": "Ends At"
          },
          "duration_min": {
            "type": "integer",
            "title": "Duration Min"
          },
          "status": {
            "$ref": "#/components/schemas/BookingStatus"
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Title"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Location"
          },
          "agent": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "customer": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CustomerSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "lead_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lead Id"
          },
          "vehicle_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vehicle Id"
          },
          "template_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Template Id"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          }
        },
        "type": "object",
        "required": [
          "id",
          "scheduled_at",
          "ends_at",
          "duration_min",
          "status",
          "title",
          "location",
          "agent",
          "customer",
          "lead_id",
          "vehicle_id",
          "template_id",
          "notes",
          "created_at"
        ],
        "title": "BookingResponse"
      },
      "BookingStatus": {
        "type": "string",
        "enum": [
          "scheduled",
          "rescheduled",
          "cancelled",
          "done"
        ],
        "title": "BookingStatus"
      },
      "BookingUpdate": {
        "properties": {
          "scheduled_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Scheduled At"
          },
          "duration_min": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 480.0,
                "minimum": 5.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration Min"
          },
          "title": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Title"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Location"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "vehicle_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vehicle Id"
          },
          "status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/BookingStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          }
        },
        "type": "object",
        "title": "BookingUpdate"
      },
      "ConversationDetail": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerSummary"
          },
          "assigned_agent": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "lead_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lead Id"
          },
          "channel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Channel"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          },
          "email_subject": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email Subject"
          },
          "status": {
            "$ref": "#/components/schemas/ConversationStatus"
          },
          "ai_enabled": {
            "type": "boolean",
            "title": "Ai Enabled"
          },
          "effective_mode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Effective Mode"
          },
          "human_control": {
            "type": "boolean",
            "title": "Human Control",
            "default": false
          },
          "mode_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mode Reason"
          },
          "context_revision": {
            "type": "integer",
            "title": "Context Revision",
            "default": 0
          },
          "last_message_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Message At"
          },
          "last_message_preview": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Message Preview"
          },
          "unread_count": {
            "type": "integer",
            "title": "Unread Count"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "assigned_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Assigned At"
          },
          "first_response_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Response Due At"
          },
          "first_responded_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Responded At"
          },
          "next_response_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Response Due At"
          },
          "resolution_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resolution Due At"
          },
          "human_wait_started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Human Wait Started At"
          },
          "human_wait_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Human Wait Due At"
          },
          "resolved_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resolved At"
          },
          "outcome": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Outcome"
          },
          "closing_note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Closing Note"
          },
          "loss_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Loss Reason"
          },
          "automation_revision": {
            "type": "integer",
            "title": "Automation Revision",
            "default": 1
          },
          "override_value": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Override Value"
          },
          "override_expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Override Expires At"
          },
          "next_transition_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Transition At"
          },
          "pinned_config_version": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pinned Config Version"
          },
          "clarification_count": {
            "type": "integer",
            "title": "Clarification Count",
            "default": 0
          },
          "is_spam": {
            "type": "boolean",
            "title": "Is Spam",
            "default": false
          },
          "spam_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Spam At"
          },
          "spam_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Spam Reason"
          },
          "tags": {
            "items": {
              "$ref": "#/components/schemas/TagSummary"
            },
            "type": "array",
            "title": "Tags"
          },
          "snoozed_until": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Snoozed Until"
          },
          "waiting_since": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Waiting Since"
          },
          "escalation": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EscalationInfo"
              },
              {
                "type": "null"
              }
            ]
          },
          "spam_by": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentSummary"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "id",
          "customer",
          "assigned_agent",
          "lead_id",
          "channel",
          "status",
          "ai_enabled",
          "last_message_at",
          "last_message_preview",
          "unread_count",
          "created_at",
          "escalation"
        ],
        "title": "ConversationDetail"
      },
      "ConversationList": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/ConversationResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "ConversationList"
      },
      "ConversationResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerSummary"
          },
          "assigned_agent": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "lead_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lead Id"
          },
          "channel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Channel"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          },
          "email_subject": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email Subject"
          },
          "status": {
            "$ref": "#/components/schemas/ConversationStatus"
          },
          "ai_enabled": {
            "type": "boolean",
            "title": "Ai Enabled"
          },
          "effective_mode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Effective Mode"
          },
          "human_control": {
            "type": "boolean",
            "title": "Human Control",
            "default": false
          },
          "mode_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mode Reason"
          },
          "context_revision": {
            "type": "integer",
            "title": "Context Revision",
            "default": 0
          },
          "last_message_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Message At"
          },
          "last_message_preview": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Message Preview"
          },
          "unread_count": {
            "type": "integer",
            "title": "Unread Count"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "assigned_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Assigned At"
          },
          "first_response_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Response Due At"
          },
          "first_responded_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Responded At"
          },
          "next_response_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Response Due At"
          },
          "resolution_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resolution Due At"
          },
          "human_wait_started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Human Wait Started At"
          },
          "human_wait_due_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Human Wait Due At"
          },
          "resolved_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resolved At"
          },
          "outcome": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Outcome"
          },
          "closing_note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Closing Note"
          },
          "loss_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Loss Reason"
          },
          "automation_revision": {
            "type": "integer",
            "title": "Automation Revision",
            "default": 1
          },
          "override_value": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Override Value"
          },
          "override_expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Override Expires At"
          },
          "next_transition_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Transition At"
          },
          "pinned_config_version": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pinned Config Version"
          },
          "clarification_count": {
            "type": "integer",
            "title": "Clarification Count",
            "default": 0
          },
          "is_spam": {
            "type": "boolean",
            "title": "Is Spam",
            "default": false
          },
          "spam_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Spam At"
          },
          "spam_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Spam Reason"
          },
          "tags": {
            "items": {
              "$ref": "#/components/schemas/TagSummary"
            },
            "type": "array",
            "title": "Tags"
          },
          "snoozed_until": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Snoozed Until"
          },
          "waiting_since": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Waiting Since"
          }
        },
        "type": "object",
        "required": [
          "id",
          "customer",
          "assigned_agent",
          "lead_id",
          "channel",
          "status",
          "ai_enabled",
          "last_message_at",
          "last_message_preview",
          "unread_count",
          "created_at"
        ],
        "title": "ConversationResponse"
      },
      "ConversationStatus": {
        "type": "string",
        "enum": [
          "open",
          "pending",
          "escalated",
          "closed"
        ],
        "title": "ConversationStatus"
      },
      "CreatedResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          }
        },
        "type": "object",
        "required": [
          "id"
        ],
        "title": "CreatedResponse"
      },
      "CustomerCreate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 5
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "locale": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 10,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "Locale"
          },
          "tags": {
            "items": {
              "type": "string",
              "maxLength": 50,
              "minLength": 1
            },
            "type": "array",
            "maxItems": 50,
            "title": "Tags"
          },
          "custom_fields": {
            "additionalProperties": true,
            "type": "object",
            "title": "Custom Fields"
          },
          "marketing_opt_in": {
            "type": "boolean",
            "title": "Marketing Opt In",
            "default": false
          },
          "dncr": {
            "type": "boolean",
            "title": "Dncr",
            "default": false
          }
        },
        "type": "object",
        "title": "CustomerCreate"
      },
      "CustomerList": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/CustomerResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "CustomerList"
      },
      "CustomerResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "locale": {
            "type": "string",
            "title": "Locale"
          },
          "channels": {
            "additionalProperties": true,
            "type": "object",
            "title": "Channels"
          },
          "meta": {
            "additionalProperties": true,
            "type": "object",
            "title": "Meta"
          },
          "revision": {
            "type": "integer",
            "title": "Revision",
            "default": 1
          },
          "field_provenance": {
            "additionalProperties": true,
            "type": "object",
            "title": "Field Provenance"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "marketing_opt_out_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketing Opt Out At"
          },
          "marketing_opt_out_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketing Opt Out Source"
          },
          "marketing_opt_in_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketing Opt In At"
          },
          "marketing_opt_in_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketing Opt In Source"
          },
          "dncr_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Dncr At"
          },
          "dncr_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Dncr Source"
          },
          "tags": {
            "items": {},
            "type": "array",
            "title": "Tags"
          },
          "custom_fields": {
            "additionalProperties": true,
            "type": "object",
            "title": "Custom Fields"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "phone",
          "email",
          "locale",
          "channels",
          "meta",
          "created_at"
        ],
        "title": "CustomerResponse"
      },
      "CustomerSummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "username": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Username"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "phone"
        ],
        "title": "CustomerSummary"
      },
      "CustomerUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 5
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "locale": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 10,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "Locale"
          },
          "marketing_opt_out": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketing Opt Out"
          },
          "marketing_opt_in": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketing Opt In"
          },
          "dncr": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Dncr"
          },
          "tags": {
            "anyOf": [
              {
                "items": {
                  "type": "string",
                  "maxLength": 50,
                  "minLength": 1
                },
                "type": "array",
                "maxItems": 50
              },
              {
                "type": "null"
              }
            ],
            "title": "Tags"
          },
          "custom_fields": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Custom Fields"
          },
          "unlock_fields": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Unlock Fields"
          }
        },
        "type": "object",
        "title": "CustomerUpdate"
      },
      "EscalationInfo": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "reason": {
            "type": "string",
            "title": "Reason"
          },
          "triggered_by": {
            "type": "string",
            "title": "Triggered By"
          },
          "sla_deadline": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sla Deadline"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "reason",
          "triggered_by",
          "sla_deadline",
          "created_at"
        ],
        "title": "EscalationInfo"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "LeadCreate": {
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "title": "Customer Id"
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          },
          "car_interest": {
            "items": {},
            "type": "array",
            "title": "Car Interest"
          },
          "budget": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget"
          },
          "timeline": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timeline"
          },
          "assigned_agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Assigned Agent Id"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags"
          }
        },
        "type": "object",
        "required": [
          "customer_id"
        ],
        "title": "LeadCreate"
      },
      "LeadFormAnswer": {
        "properties": {
          "label": {
            "type": "string",
            "title": "Label"
          },
          "value": {
            "type": "string",
            "title": "Value"
          }
        },
        "type": "object",
        "required": [
          "label",
          "value"
        ],
        "title": "LeadFormAnswer"
      },
      "LeadFormSubmission": {
        "properties": {
          "form_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Form Name"
          },
          "submitted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Submitted At"
          },
          "answers": {
            "items": {
              "$ref": "#/components/schemas/LeadFormAnswer"
            },
            "type": "array",
            "title": "Answers"
          },
          "consent": {
            "type": "boolean",
            "title": "Consent",
            "default": false
          },
          "first_touch": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Touch"
          },
          "first_touch_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Touch Reason"
          }
        },
        "type": "object",
        "title": "LeadFormSubmission",
        "description": "The lead form the customer sent last (services/lead_ads.py); contact fields left out."
      },
      "LeadList": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/LeadResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "LeadList"
      },
      "LeadNoteCreate": {
        "properties": {
          "text": {
            "type": "string",
            "minLength": 1,
            "title": "Text"
          }
        },
        "type": "object",
        "required": [
          "text"
        ],
        "title": "LeadNoteCreate"
      },
      "LeadResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerSummary"
          },
          "assigned_agent": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AgentSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "$ref": "#/components/schemas/LeadStatus"
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          },
          "score": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Score"
          },
          "car_interest": {
            "items": {},
            "type": "array",
            "title": "Car Interest"
          },
          "budget": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget"
          },
          "budget_currency": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Currency"
          },
          "budget_kind": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Kind"
          },
          "budget_min": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Min"
          },
          "budget_max": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Max"
          },
          "monthly_payment_budget": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Monthly Payment Budget"
          },
          "preferences": {
            "items": {},
            "type": "array",
            "title": "Preferences"
          },
          "objections": {
            "items": {},
            "type": "array",
            "title": "Objections"
          },
          "deal_amount": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Deal Amount"
          },
          "deal_currency": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Deal Currency"
          },
          "revision": {
            "type": "integer",
            "title": "Revision",
            "default": 1
          },
          "field_provenance": {
            "additionalProperties": true,
            "type": "object",
            "title": "Field Provenance"
          },
          "timeline": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timeline"
          },
          "tags": {
            "items": {},
            "type": "array",
            "title": "Tags"
          },
          "notes": {
            "items": {},
            "type": "array",
            "title": "Notes"
          },
          "score_factors": {
            "items": {},
            "type": "array",
            "title": "Score Factors"
          },
          "last_activity_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Activity At"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "ad_referral": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AdReferralSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "custom_fields": {
            "additionalProperties": true,
            "type": "object",
            "title": "Custom Fields"
          },
          "lead_form": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LeadFormSubmission"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "id",
          "customer",
          "assigned_agent",
          "status",
          "source",
          "score",
          "car_interest",
          "budget",
          "timeline",
          "tags",
          "notes",
          "score_factors",
          "last_activity_at",
          "created_at"
        ],
        "title": "LeadResponse"
      },
      "LeadStatus": {
        "type": "string",
        "enum": [
          "new",
          "contacted",
          "qualified",
          "test_drive",
          "negotiation",
          "won",
          "lost"
        ],
        "title": "LeadStatus"
      },
      "LeadTagsUpdate": {
        "properties": {
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags"
          }
        },
        "type": "object",
        "required": [
          "tags"
        ],
        "title": "LeadTagsUpdate"
      },
      "LeadUpdate": {
        "properties": {
          "status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LeadStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source"
          },
          "car_interest": {
            "anyOf": [
              {
                "items": {},
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Car Interest"
          },
          "budget": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget"
          },
          "budget_currency": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 3,
                "minLength": 3
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Currency"
          },
          "budget_kind": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Kind"
          },
          "budget_min": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Min"
          },
          "budget_max": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Max"
          },
          "monthly_payment_budget": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Monthly Payment Budget"
          },
          "preferences": {
            "anyOf": [
              {
                "items": {},
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Preferences"
          },
          "objections": {
            "anyOf": [
              {
                "items": {},
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Objections"
          },
          "timeline": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timeline"
          },
          "deal_amount": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 2147483647.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Deal Amount"
          },
          "deal_currency": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 3,
                "minLength": 3
              },
              {
                "type": "null"
              }
            ],
            "title": "Deal Currency"
          },
          "custom_fields": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Custom Fields"
          },
          "unlock_fields": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Unlock Fields"
          }
        },
        "type": "object",
        "title": "LeadUpdate"
      },
      "MessageDirection": {
        "type": "string",
        "enum": [
          "inbound",
          "outbound"
        ],
        "title": "MessageDirection"
      },
      "MessageMediaItem": {
        "properties": {
          "asset_id": {
            "type": "string",
            "title": "Asset Id"
          },
          "download_url": {
            "type": "string",
            "title": "Download Url"
          },
          "content_type": {
            "type": "string",
            "title": "Content Type"
          },
          "size_bytes": {
            "type": "integer",
            "title": "Size Bytes"
          },
          "transfer_status": {
            "type": "string",
            "enum": [
              "pending",
              "available",
              "failed"
            ],
            "title": "Transfer Status"
          },
          "understanding_status": {
            "type": "string",
            "enum": [
              "pending",
              "done",
              "failed",
              "skipped"
            ],
            "title": "Understanding Status"
          },
          "transcript": {
            "type": "string",
            "title": "Transcript"
          },
          "transcript_language": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transcript Language"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "understanding_error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Understanding Error"
          },
          "duration_seconds": {
            "type": "number",
            "title": "Duration Seconds"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "MessageMediaItem",
        "description": "One `message.media` entry. Provider fields pass through untouched; these are ours."
      },
      "MessagePage": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/MessageResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor"
          }
        },
        "type": "object",
        "required": [
          "items",
          "next_cursor"
        ],
        "title": "MessagePage"
      },
      "MessageResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "conversation_id": {
            "type": "string",
            "format": "uuid",
            "title": "Conversation Id"
          },
          "sender_type": {
            "$ref": "#/components/schemas/SenderType"
          },
          "sender_agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sender Agent Id"
          },
          "direction": {
            "$ref": "#/components/schemas/MessageDirection"
          },
          "body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Body"
          },
          "media": {
            "items": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/MessageMediaItem"
                },
                {}
              ]
            },
            "type": "array",
            "title": "Media"
          },
          "status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MessageStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "external_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "External Id"
          },
          "ai_config_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Config Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "origin": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Origin"
          }
        },
        "type": "object",
        "required": [
          "id",
          "conversation_id",
          "sender_type",
          "sender_agent_id",
          "direction",
          "body",
          "media",
          "status",
          "external_id",
          "created_at"
        ],
        "title": "MessageResponse"
      },
      "MessageSend": {
        "properties": {
          "body": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Body"
          },
          "media": {
            "items": {
              "$ref": "#/components/schemas/OutboundMediaSend"
            },
            "type": "array",
            "maxItems": 5,
            "title": "Media"
          },
          "template": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/WhatsAppTemplateSend"
              },
              {
                "type": "null"
              }
            ]
          },
          "snippet_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Snippet Id"
          },
          "original_body": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 5000,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Original Body"
          }
        },
        "type": "object",
        "title": "MessageSend"
      },
      "MessageStatus": {
        "type": "string",
        "enum": [
          "queued",
          "sent",
          "delivered",
          "read",
          "failed"
        ],
        "title": "MessageStatus"
      },
      "OutboundMediaSend": {
        "properties": {
          "asset_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Asset Id"
          },
          "library_file_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Library File Id"
          },
          "caption": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "title": "Caption"
          },
          "filename": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Filename"
          }
        },
        "type": "object",
        "title": "OutboundMediaSend"
      },
      "Permission": {
        "type": "string",
        "enum": [
          "leads:view",
          "leads:view_all",
          "leads:manage",
          "conversations:view",
          "conversations:manage",
          "messages:send",
          "customers:view",
          "customers:manage",
          "customers:view_contact_details",
          "bookings:view",
          "bookings:view_all",
          "bookings:manage",
          "inventory:view",
          "inventory:manage",
          "members:view",
          "members:invite",
          "members:manage_permissions",
          "ai_config:view",
          "ai_config:manage",
          "ai_assist:use",
          "billing:view",
          "billing:manage",
          "broadcasts:manage",
          "branches:manage",
          "branches:view_all",
          "broadcasts:send",
          "customers:manage_consent",
          "customers:manage_dncr",
          "workflows:manage",
          "workflows:run",
          "integrations:manage",
          "reports:export",
          "ai_calls:start",
          "ai_quality:rate",
          "ai_quality:view",
          "trade_ins:view",
          "trade_ins:appraise",
          "lead_ads:manage",
          "ai_console:use",
          "security:manage",
          "channels:manage",
          "privacy:manage",
          "csat:manage",
          "inbox_views:manage",
          "whatsapp_flows:manage",
          "reviews:manage",
          "payments:request",
          "payments:manage",
          "call_follow_ups:manage"
        ],
        "title": "Permission"
      },
      "SenderType": {
        "type": "string",
        "enum": [
          "customer",
          "ai",
          "agent",
          "system"
        ],
        "title": "SenderType"
      },
      "TagSummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "TagSummary"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "VehicleCreate": {
        "properties": {
          "data": {
            "$ref": "#/components/schemas/VehicleData"
          },
          "price": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Price"
          },
          "currency": {
            "type": "string",
            "maxLength": 3,
            "minLength": 3,
            "title": "Currency",
            "default": "USD"
          },
          "status": {
            "$ref": "#/components/schemas/VehicleStatus",
            "default": "available"
          },
          "photos": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Photos"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          },
          "branch": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 120
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch"
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "VehicleCreate"
      },
      "VehicleData": {
        "properties": {
          "make": {
            "type": "string",
            "minLength": 1,
            "title": "Make"
          },
          "model": {
            "type": "string",
            "minLength": 1,
            "title": "Model"
          },
          "year": {
            "type": "integer",
            "maximum": 2035.0,
            "minimum": 1950.0,
            "title": "Year"
          },
          "condition": {
            "type": "string",
            "enum": [
              "new",
              "used"
            ],
            "title": "Condition",
            "default": "new"
          },
          "mileage": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Mileage"
          },
          "color": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Color"
          },
          "transmission": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transmission"
          },
          "fuel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Fuel"
          },
          "body_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Body Type"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "required": [
          "make",
          "model",
          "year"
        ],
        "title": "VehicleData"
      },
      "VehicleImport": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/VehicleCreate"
            },
            "type": "array",
            "maxItems": 500,
            "minItems": 1,
            "title": "Items"
          }
        },
        "type": "object",
        "required": [
          "items"
        ],
        "title": "VehicleImport"
      },
      "VehicleImportResponse": {
        "properties": {
          "created": {
            "type": "integer",
            "title": "Created"
          }
        },
        "type": "object",
        "required": [
          "created"
        ],
        "title": "VehicleImportResponse"
      },
      "VehicleList": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/VehicleResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "VehicleList"
      },
      "VehicleResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "status": {
            "$ref": "#/components/schemas/VehicleStatus"
          },
          "price": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Price"
          },
          "currency": {
            "type": "string",
            "title": "Currency"
          },
          "data": {
            "additionalProperties": true,
            "type": "object",
            "title": "Data"
          },
          "photos": {
            "items": {},
            "type": "array",
            "title": "Photos"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "price",
          "currency",
          "data",
          "photos",
          "created_at",
          "updated_at"
        ],
        "title": "VehicleResponse"
      },
      "VehicleStatus": {
        "type": "string",
        "enum": [
          "available",
          "reserved",
          "sold",
          "archived"
        ],
        "title": "VehicleStatus"
      },
      "VehicleUpdate": {
        "properties": {
          "data": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VehicleData"
              },
              {
                "type": "null"
              }
            ]
          },
          "price": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Price"
          },
          "currency": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 3,
                "minLength": 3
              },
              {
                "type": "null"
              }
            ],
            "title": "Currency"
          },
          "status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VehicleStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "photos": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Photos"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          }
        },
        "type": "object",
        "title": "VehicleUpdate"
      },
      "WebhookDeliveryList": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/WebhookDeliveryResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "WebhookDeliveryList"
      },
      "WebhookDeliveryResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "endpoint_id": {
            "type": "string",
            "format": "uuid",
            "title": "Endpoint Id"
          },
          "event_type": {
            "type": "string",
            "title": "Event Type"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "attempts": {
            "type": "integer",
            "title": "Attempts"
          },
          "response_status": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Response Status"
          },
          "response_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Response Ms"
          },
          "last_error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Error"
          },
          "next_attempt_at": {
            "type": "string",
            "format": "date-time",
            "title": "Next Attempt At"
          },
          "last_attempt_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Attempt At"
          },
          "delivered_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Delivered At"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "payload": {
            "additionalProperties": true,
            "type": "object",
            "title": "Payload"
          }
        },
        "type": "object",
        "required": [
          "id",
          "endpoint_id",
          "event_type",
          "status",
          "attempts",
          "response_status",
          "response_ms",
          "last_error",
          "next_attempt_at",
          "last_attempt_at",
          "delivered_at",
          "created_at",
          "payload"
        ],
        "title": "WebhookDeliveryResponse"
      },
      "WebhookEndpointCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120,
            "minLength": 1,
            "title": "Name"
          },
          "url": {
            "type": "string",
            "maxLength": 2048,
            "minLength": 9,
            "title": "Url"
          },
          "events": {
            "items": {
              "type": "string",
              "enum": [
                "lead.created",
                "lead.status_changed",
                "sale.won",
                "lead.tag_added",
                "conversation.opened",
                "conversation.assigned",
                "message.received",
                "booking.created",
                "booking.cancelled",
                "conversation.closed",
                "payment.paid",
                "call.completed"
              ]
            },
            "type": "array",
            "maxItems": 20,
            "minItems": 1,
            "title": "Events"
          }
        },
        "type": "object",
        "required": [
          "name",
          "url",
          "events"
        ],
        "title": "WebhookEndpointCreate"
      },
      "WebhookEndpointCreated": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "url": {
            "type": "string",
            "title": "Url"
          },
          "events": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Events"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "disabled_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Disabled Reason"
          },
          "secret_hint": {
            "type": "string",
            "title": "Secret Hint"
          },
          "consecutive_failures": {
            "type": "integer",
            "title": "Consecutive Failures"
          },
          "last_success_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Success At"
          },
          "last_failure_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Failure At"
          },
          "delivered_24h": {
            "type": "integer",
            "title": "Delivered 24H",
            "default": 0
          },
          "failed_24h": {
            "type": "integer",
            "title": "Failed 24H",
            "default": 0
          },
          "pending": {
            "type": "integer",
            "title": "Pending",
            "default": 0
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "app"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "secret": {
            "type": "string",
            "title": "Secret"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "url",
          "events",
          "is_active",
          "disabled_reason",
          "secret_hint",
          "consecutive_failures",
          "last_success_at",
          "last_failure_at",
          "created_at",
          "secret"
        ],
        "title": "WebhookEndpointCreated"
      },
      "WebhookEndpointList": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/WebhookEndpointResponse"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "title": "WebhookEndpointList"
      },
      "WebhookEndpointResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "url": {
            "type": "string",
            "title": "Url"
          },
          "events": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Events"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "disabled_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Disabled Reason"
          },
          "secret_hint": {
            "type": "string",
            "title": "Secret Hint"
          },
          "consecutive_failures": {
            "type": "integer",
            "title": "Consecutive Failures"
          },
          "last_success_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Success At"
          },
          "last_failure_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Failure At"
          },
          "delivered_24h": {
            "type": "integer",
            "title": "Delivered 24H",
            "default": 0
          },
          "failed_24h": {
            "type": "integer",
            "title": "Failed 24H",
            "default": 0
          },
          "pending": {
            "type": "integer",
            "title": "Pending",
            "default": 0
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "app"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "url",
          "events",
          "is_active",
          "disabled_reason",
          "secret_hint",
          "consecutive_failures",
          "last_success_at",
          "last_failure_at",
          "created_at"
        ],
        "title": "WebhookEndpointResponse"
      },
      "WebhookEndpointUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 120,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048,
                "minLength": 9
              },
              {
                "type": "null"
              }
            ],
            "title": "Url"
          },
          "events": {
            "anyOf": [
              {
                "items": {
                  "type": "string",
                  "enum": [
                    "lead.created",
                    "lead.status_changed",
                    "sale.won",
                    "lead.tag_added",
                    "conversation.opened",
                    "conversation.assigned",
                    "message.received",
                    "booking.created",
                    "booking.cancelled",
                    "conversation.closed",
                    "payment.paid",
                    "call.completed"
                  ]
                },
                "type": "array",
                "maxItems": 20,
                "minItems": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Events"
          },
          "is_active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Is Active"
          }
        },
        "type": "object",
        "title": "WebhookEndpointUpdate"
      },
      "WebhookEventCatalog": {
        "properties": {
          "events": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Events"
          }
        },
        "type": "object",
        "required": [
          "events"
        ],
        "title": "WebhookEventCatalog"
      },
      "WebhookSampleList": {
        "properties": {
          "items": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Items"
          }
        },
        "type": "object",
        "required": [
          "items"
        ],
        "title": "WebhookSampleList"
      },
      "WebhookSubscriptionCreate": {
        "properties": {
          "target_url": {
            "type": "string",
            "maxLength": 2048,
            "minLength": 9,
            "title": "Target Url"
          },
          "event": {
            "type": "string",
            "enum": [
              "lead.created",
              "lead.status_changed",
              "sale.won",
              "lead.tag_added",
              "conversation.opened",
              "conversation.assigned",
              "message.received",
              "booking.created",
              "booking.cancelled",
              "conversation.closed",
              "payment.paid",
              "call.completed"
            ],
            "title": "Event"
          },
          "source": {
            "type": "string",
            "enum": [
              "zapier",
              "make"
            ],
            "title": "Source"
          }
        },
        "type": "object",
        "required": [
          "target_url",
          "event",
          "source"
        ],
        "title": "WebhookSubscriptionCreate",
        "description": "A REST hook from a no-code platform: one event to one URL."
      },
      "WebhookSubscriptionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "event": {
            "type": "string",
            "title": "Event"
          },
          "target_url": {
            "type": "string",
            "title": "Target Url"
          },
          "source": {
            "type": "string",
            "title": "Source"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "event",
          "target_url",
          "source",
          "created_at"
        ],
        "title": "WebhookSubscriptionResponse"
      },
      "WhatsAppTemplateSend": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 512,
            "minLength": 1,
            "title": "Name"
          },
          "language": {
            "type": "string",
            "maxLength": 10,
            "minLength": 2,
            "title": "Language",
            "default": "en"
          },
          "components": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Components"
          },
          "preview": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 4096
              },
              {
                "type": "null"
              }
            ],
            "title": "Preview"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "WhatsAppTemplateSend"
      },
      "Error": {
        "title": "Error",
        "type": "object",
        "required": [
          "detail"
        ],
        "description": "`detail` is a sentence, an object with a stable `code` and a `message`, or a list of field problems (422).",
        "properties": {
          "detail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "additionalProperties": true
              },
              {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            ]
          },
          "correlation_id": {
            "type": "string",
            "description": "On 500 answers: quote it to our support team."
          }
        }
      },
      "WebhookDelivery": {
        "title": "WebhookDelivery",
        "type": "object",
        "required": [
          "id",
          "event",
          "dealership_id",
          "occurred_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The delivery ID, as X-LeadVex-Delivery."
          },
          "event": {
            "type": "string",
            "description": "The event type, as X-LeadVex-Event."
          },
          "dealership_id": {
            "type": "string",
            "format": "uuid"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "A snapshot of the records behind the event."
          }
        }
      }
    },
    "securitySchemes": {
      "ApiToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "lvx_…",
        "description": "An API token from Integrations > API tokens, sent as `Authorization: Bearer lvx_…`."
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "The token is missing, wrong, expired or revoked.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "detail": "invalid token"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The token lacks a scope this request needs, or the plan does not include API access.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "detail": "missing required permission"
            }
          }
        }
      },
      "NotFound": {
        "description": "No such record in this dealership, or the token may not see it.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "detail": "lead not found"
            }
          }
        }
      },
      "ValidationError": {
        "description": "A field is missing or invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HTTPValidationError"
            },
            "example": {
              "detail": [
                {
                  "type": "missing",
                  "loc": [
                    "body",
                    "customer_id"
                  ],
                  "msg": "Field required",
                  "input": {}
                }
              ]
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too many requests for this token. Wait `Retry-After` seconds.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "detail": "too many requests, try again later"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before the next request.",
            "schema": {
              "type": "integer"
            }
          }
        }
      },
      "ServerError": {
        "description": "Something went wrong on our side.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "detail": "Something went wrong on our side. Our team has the details.",
              "correlation_id": "5f0c2a9e4b7d4c1e"
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Token",
      "description": "Check the token an integration uses."
    },
    {
      "name": "Leads",
      "description": "Sales opportunities: one per customer interest, with a status from new to won or lost."
    },
    {
      "name": "Customers",
      "description": "The people behind leads and conversations. A customer is unique by phone number."
    },
    {
      "name": "Conversations",
      "description": "WhatsApp, Instagram, Messenger, Telegram, email and website chat threads, and their messages."
    },
    {
      "name": "Test drives",
      "description": "Bookings with a salesperson, usually a test drive, and the free slots to book."
    },
    {
      "name": "Inventory",
      "description": "The cars in stock. Customers and the AI assistant see what you list here."
    },
    {
      "name": "Webhooks",
      "description": "Endpoints that receive signed event notifications from LeadVex."
    }
  ],
  "webhooks": {
    "lead.created": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A new lead",
        "description": "A lead was created in LeadVex, whatever its source (see `lead.source`). `conversation` is there when the lead came from a chat.",
        "operationId": "webhookLeadCreated",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "lead.created",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "lead.status_changed": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A lead moved to another status",
        "description": "`change.from` and `change.to` are lead statuses: `new`, `contacted`, `qualified`, `test_drive`, `negotiation`, `won` or `lost`.",
        "operationId": "webhookLeadStatusChanged",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "lead.status_changed",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "test_drive",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "change": {
                    "from": "qualified",
                    "to": "test_drive"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "sale.won": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A sale",
        "description": "A lead moved to `won`. Use it to count sales or to send them to your accounting or DMS. `lead.deal_amount` is the sale price when the team recorded it.",
        "operationId": "webhookSaleWon",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "sale.won",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "won",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": 51000,
                    "deal_currency": "USD",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "change": {
                    "from": "negotiation",
                    "to": "won"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "lead.tag_added": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A tag on a lead",
        "description": "A tag was added to a lead. `tag` is the new tag; `lead.tags` has them all.",
        "operationId": "webhookLeadTagAdded",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "lead.tag_added",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [
                      "finance"
                    ],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "tag": "finance"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "conversation.opened": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A new conversation",
        "description": "A customer started a new conversation. `source` is how they came: `ad`, `link` (a LeadVex link or QR code) or `organic`.",
        "operationId": "webhookConversationOpened",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "conversation.opened",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "source": "ad"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "conversation.assigned": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A conversation or lead was assigned",
        "description": "Routing or a person gave the conversation or the lead to a salesperson.",
        "operationId": "webhookConversationAssigned",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "conversation.assigned",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "message.received": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A customer message",
        "description": "A customer sent a message on any channel. Messages from the team and the AI are not sent.",
        "operationId": "webhookMessageReceived",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "message.received",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "message": {
                    "id": "e7c3a9f1-4b2d-4e8a-a6c5-3f1b9d7e2c84",
                    "text": "Can I come for a test drive on Tuesday?",
                    "channel": "whatsapp"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "booking.created": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A test drive was booked",
        "description": "A booking was made by the team, the AI assistant or the API.",
        "operationId": "webhookBookingCreated",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "booking.created",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "booking": {
                    "id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31",
                    "status": "scheduled",
                    "scheduled_at": "2026-12-02T13:00:00+00:00",
                    "ends_at": "2026-12-02T13:30:00+00:00",
                    "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                    "agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    }
                  },
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "booking.cancelled": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A test drive was cancelled",
        "description": "A booking was cancelled. The booking stays in LeadVex with the status `cancelled`.",
        "operationId": "webhookBookingCancelled",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "booking.cancelled",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "booking": {
                    "id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31",
                    "status": "cancelled",
                    "scheduled_at": "2026-12-02T13:00:00+00:00",
                    "ends_at": "2026-12-02T13:30:00+00:00",
                    "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                    "agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    }
                  },
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "conversation.closed": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A conversation was closed",
        "description": "The team, or auto-close after a quiet period (`closed.automatic`), closed the conversation. `closed.outcome` is `won`, `lost` or `no_outcome`; `closed.loss_reason` says why a lost one was lost.",
        "operationId": "webhookConversationClosed",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "conversation.closed",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "closed",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "closed": {
                    "outcome": "lost",
                    "loss_reason": "price",
                    "automatic": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "payment.paid": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A payment link was paid",
        "description": "A customer paid a deposit or reservation fee link on your payment provider's page, and the provider confirmed it. `payment.amount` is in `payment.currency` (AED); `payment.purpose` is `deposit`, `reservation` or `other`; `payment.provider_reference` is the id in your provider account. The money is in your own merchant account.",
        "operationId": "webhookPaymentPaid",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "payment.paid",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "payment": {
                    "id": "8c1e3a5b-7d9f-4b2c-a6e8-0f2d4b6c8e1a",
                    "status": "paid",
                    "purpose": "deposit",
                    "amount": 5000.0,
                    "currency": "AED",
                    "provider": "tap",
                    "provider_reference": "chg_TS02A5720231234Xy9K2811443",
                    "description": null,
                    "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                    "paid_at": "2026-11-25T08:41:19+00:00",
                    "created_at": "2026-11-25T08:02:44+00:00"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "call.completed": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A phone call ended",
        "description": "A call finished: answered by the AI phone agent, an outbound AI call, or a call your team logged. Missed and failed calls are sent too (`call.status` is `completed`, `missed`, `no_answer` or `failed`). `call.summary` is what the call was about and what was agreed; `call.outcome` is `test_drive_booked`, `lead_updated`, `transferred`, `callback_requested`, `info_only`, `spam` or `unknown`; `call.handled_by` is `ai` or `human`. `call.agent` is the salesperson the call was passed to, or who logged it. `call.url_path` opens the chat with the transcript. Test calls are not sent.",
        "operationId": "webhookCallCompleted",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "call.completed",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "voice",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "booking": {
                    "id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31",
                    "status": "scheduled",
                    "scheduled_at": "2026-12-02T13:00:00+00:00",
                    "ends_at": "2026-12-02T13:30:00+00:00",
                    "vehicle_id": "1d5f8b3e-7a2c-4c9e-8b4f-6e0a2d4c8f19",
                    "agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    }
                  },
                  "call": {
                    "id": "3e5a7c9b-2d4f-4a6b-8c1e-5f7a9b2d4c61",
                    "direction": "inbound",
                    "status": "completed",
                    "outcome": "test_drive_booked",
                    "end_reason": "caller_hangup",
                    "started_at": "2026-11-25T08:36:02+00:00",
                    "ended_at": "2026-11-25T08:41:19+00:00",
                    "duration_sec": 317,
                    "summary": "Asked about the Nissan Patrol 2025 in white, budget about 75,000 USD. Booked a test drive for Tuesday 17:00 at the Al Quoz showroom.",
                    "handled_by": "ai",
                    "transferred": false,
                    "transfer_connected": false,
                    "agent": null,
                    "from_number": "+971501234567",
                    "to_number": "+97142345678",
                    "language": "ar",
                    "booking_id": "c8a2e6f4-3d1b-4a7c-9e5d-8b2f0a6c4e31",
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "ping": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A test event",
        "description": "Sent by \"Send test\" in LeadVex or `POST /webhook-endpoints/{id}/test`, whatever events the endpoint subscribes to. Answer 2xx.",
        "operationId": "webhookPing",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "ping",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "message": "Test event from LeadVex. Your endpoint is reachable."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    },
    "workflow.step": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "A workflow step",
        "description": "Sent by the \"Send to webhook\" step of a LeadVex workflow, whatever events the endpoint subscribes to. `trigger` is the event that started the workflow.",
        "operationId": "webhookWorkflowStep",
        "parameters": [
          {
            "name": "X-LeadVex-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event type."
          },
          {
            "name": "X-LeadVex-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The delivery ID; a retry carries the same one."
          },
          {
            "name": "X-LeadVex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">`. See Signatures.",
            "example": "t=1764060300,v1=3a4f…"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookDelivery"
              },
              "example": {
                "id": "f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35",
                "event": "workflow.step",
                "dealership_id": "0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24",
                "occurred_at": "2026-11-25T08:41:19+00:00",
                "data": {
                  "lead": {
                    "id": "3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43",
                    "status": "new",
                    "source": "whatsapp",
                    "score": 40,
                    "tags": [],
                    "car_interest": [
                      "Nissan Patrol 2025"
                    ],
                    "budget": 75000,
                    "budget_currency": "USD",
                    "deal_amount": null,
                    "deal_currency": null,
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "created_at": "2026-11-25T08:41:19+00:00",
                    "url_path": "/leads/3f2b7c1e-8a4d-4e6b-9c2f-1a7d5e9b0c43"
                  },
                  "customer": {
                    "id": "6c1e9a24-5b7f-4d3a-8e2c-0f4b9d7a1e58",
                    "name": "Sara Al Mansoori",
                    "phone": "+971501234567",
                    "email": null,
                    "language": "ar"
                  },
                  "conversation": {
                    "id": "b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17",
                    "channel": "whatsapp",
                    "status": "open",
                    "assigned_agent": {
                      "id": "9a7d3c15-2e8b-4f6a-b1d4-7c0e5a8f3b26",
                      "name": "Omar Haddad"
                    },
                    "url_path": "/inbox/b4e8f2a6-1c3d-4b7e-9a5f-2d8c6e0b4a17"
                  },
                  "workflow": {
                    "id": "2b4d6f8a-1c3e-4a5b-8d7f-9e1a3c5b7d92",
                    "name": "Hot lead to CRM",
                    "step_id": "s3",
                    "run_id": "6f8a1c3e-5b7d-4e9a-a2c4-6e8b0d2f4a13"
                  },
                  "trigger": {
                    "event": "lead.status_changed",
                    "occurred_at": "2026-11-25T08:41:19+00:00"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received. Any 2xx status counts."
          }
        }
      }
    }
  },
  "x-guides": [
    {
      "id": "introduction",
      "title": "Introduction",
      "blocks": [
        {
          "p": "The LeadVex API lets your systems work with a dealership's LeadVex workspace: push leads from your website or DMS, keep the stock in sync, book test drives, read and answer conversations, and get notified the moment something happens. It is the same API the LeadVex apps use."
        },
        {
          "p": "Base URL: `https://api.leadvexai.com/api`. Send and receive JSON (UTF-8). IDs are UUIDs. Times are ISO 8601 with a timezone offset; responses use UTC. A token belongs to one dealership, so you never pass a dealership ID."
        },
        {
          "samples": [
            {
              "lang": "bash",
              "label": "curl",
              "source": "curl https://api.leadvexai.com/api/api-tokens/current \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\""
            }
          ]
        },
        {
          "p": "With Zapier or Make you need no code: use \"Webhooks by Zapier\" (or Make's HTTP module) with the requests below to send data, and a \"Catch Hook\" (or Make's custom webhook) URL as a LeadVex webhook endpoint to receive it."
        }
      ]
    },
    {
      "id": "authentication",
      "title": "Authentication",
      "blocks": [
        {
          "p": "Every request carries an API token in the `Authorization` header: `Authorization: Bearer lvx_...`. The dealership owner, or a member with the Integrations permission, creates tokens in LeadVex under Integrations > API tokens. A token is shown once, expires after at most 366 days and can be revoked there at any time. Keep it on your server: never put it in a website or a mobile app."
        },
        {
          "p": "API access and webhooks are part of the Enterprise plan. Without them every call answers 403 with `\"code\": \"feature_not_in_plan\"`."
        },
        {
          "p": "A token can do only what its scopes allow, and never more than the person who created it may do today. Pick the fewest scopes your integration needs:"
        },
        {
          "table": {
            "columns": [
              "Scope",
              "Allows"
            ],
            "rows": [
              [
                "`leads:view`",
                "Read leads assigned to the token creator and unassigned leads."
              ],
              [
                "`leads:view_all`",
                "Read every lead, also other salespeople's."
              ],
              [
                "`leads:manage`",
                "Create and update leads, their notes and tags."
              ],
              [
                "`customers:view`",
                "Read customers."
              ],
              [
                "`customers:view_contact_details`",
                "See phones and emails unmasked."
              ],
              [
                "`customers:manage`",
                "Create and update customers."
              ],
              [
                "`customers:manage_consent`",
                "Record a customer's marketing opt-in."
              ],
              [
                "`customers:manage_dncr`",
                "Put a customer on the Do Not Call Register or take them off it."
              ],
              [
                "`conversations:view`",
                "Read conversations and their messages."
              ],
              [
                "`messages:send`",
                "Send messages to customers."
              ],
              [
                "`bookings:view`",
                "Read the token creator's bookings and free slots."
              ],
              [
                "`bookings:view_all`",
                "Read every salesperson's bookings."
              ],
              [
                "`bookings:manage`",
                "Book, reschedule and cancel test drives."
              ],
              [
                "`inventory:view`",
                "Read the stock."
              ],
              [
                "`inventory:manage`",
                "Add, update and remove vehicles."
              ],
              [
                "`integrations:manage`",
                "Manage webhook endpoints."
              ]
            ]
          }
        },
        {
          "p": "A token acts for an integration, not as a person. It cannot sign in, change passwords or 2FA, create tokens, invite people or change their permissions, change the plan or payment, or connect a calendar: those answer 403 `interactive user session required`."
        }
      ]
    },
    {
      "id": "errors",
      "title": "Errors",
      "blocks": [
        {
          "p": "Errors use HTTP status codes and a JSON body with a `detail` field. `detail` is a sentence, an object with a stable `code` you can branch on and a `message`, or (422) a list of field problems."
        },
        {
          "samples": [
            {
              "lang": "json",
              "label": "403",
              "source": "{\"detail\": \"missing required permission\"}"
            },
            {
              "lang": "json",
              "label": "409 with a code",
              "source": "{\"detail\": {\"code\": \"slot_taken\", \"resource\": \"agent\",\n            \"message\": \"this agent is already booked during that time\"}}"
            },
            {
              "lang": "json",
              "label": "422",
              "source": "{\"detail\": [{\"type\": \"missing\", \"loc\": [\"body\", \"customer_id\"],\n             \"msg\": \"Field required\", \"input\": {}}]}"
            }
          ]
        },
        {
          "table": {
            "columns": [
              "Status",
              "Meaning"
            ],
            "rows": [
              [
                "`400`",
                "The request is malformed, for example an invalid `Idempotency-Key`."
              ],
              [
                "`401`",
                "The token is missing, wrong, expired or revoked."
              ],
              [
                "`403`",
                "The token lacks a scope, the plan does not include the feature, or the action needs a person."
              ],
              [
                "`404`",
                "The record does not exist in this dealership, or the token may not see it."
              ],
              [
                "`409`",
                "The request conflicts with the current state: a duplicate phone, a taken slot, a closed WhatsApp window, an `Idempotency-Key` still in use."
              ],
              [
                "`422`",
                "A field is missing or invalid. `detail` lists each problem with its location."
              ],
              [
                "`429`",
                "Too many requests. Wait the number of seconds in `Retry-After`."
              ],
              [
                "`500`",
                "Our fault. `correlation_id` identifies the error for our support team."
              ],
              [
                "`503`",
                "A provider the request needs (a calendar, a channel) is unavailable. Retry later."
              ]
            ]
          }
        },
        {
          "p": "Every response has an `X-Correlation-ID` header. Quote it when you contact support about a request."
        }
      ]
    },
    {
      "id": "rate-limits",
      "title": "Rate limits",
      "blocks": [
        {
          "p": "Each token may make 300 requests per minute. Over that the API answers 429 with a `Retry-After` header: wait that many seconds and continue. Limits are per token, so one busy integration does not slow down another."
        },
        {
          "list": [
            "Pages hold at most 200 items.",
            "`POST /vehicles/import` takes up to 500 vehicles at once: use it instead of one call per car.",
            "A dealership can have up to 10 webhook endpoints. Prefer webhooks to polling for changes."
          ]
        }
      ]
    },
    {
      "id": "pagination",
      "title": "Pagination",
      "blocks": [
        {
          "p": "Lists take `limit` (1 to 200, default 50) and `offset`, and answer `{\"items\": [...], \"total\": n}`. Fetch pages until `offset` reaches `total`."
        },
        {
          "p": "Messages in a conversation are paged with a cursor instead, newest first: pass the `next_cursor` you got back as `cursor` to get older messages. `next_cursor` is `null` on the oldest page."
        },
        {
          "samples": [
            {
              "lang": "python",
              "label": "Python",
              "source": "import os\n\nimport requests\n\nAPI = \"https://api.leadvexai.com/api\"\nHEADERS = {\"Authorization\": f\"Bearer {os.environ['LEADVEX_TOKEN']}\"}\n\nleads, offset = [], 0\nwhile True:\n    page = requests.get(f\"{API}/leads/\", headers=HEADERS,\n                        params={\"status\": \"new\", \"limit\": 200, \"offset\": offset}, timeout=30)\n    page.raise_for_status()\n    body = page.json()\n    leads += body[\"items\"]\n    offset += len(body[\"items\"])\n    if not body[\"items\"] or offset >= body[\"total\"]:\n        break\n"
            }
          ]
        }
      ]
    },
    {
      "id": "idempotency",
      "title": "Idempotency",
      "blocks": [
        {
          "p": "A network error can leave you unsure whether a POST went through. Send an `Idempotency-Key` header (any unique string up to 255 characters, a UUID works well) with every POST. If you retry with the same key, LeadVex returns the first answer again with `Idempotent-Replayed: true` instead of creating a second lead, customer, booking or message."
        },
        {
          "list": [
            "Keys belong to your token and are kept for 24 hours after the first successful request.",
            "Only successful (2xx) answers are kept. After an error you can fix the request and retry with the same key.",
            "The same key with a different body, path or query answers 422 `idempotency_key_reused`.",
            "While the first request is still running, a retry answers 409 `idempotency_request_in_progress` with `Retry-After: 1`.",
            "GET, PATCH, PUT and DELETE are safe to repeat and need no key."
          ]
        },
        {
          "samples": [
            {
              "lang": "bash",
              "label": "curl",
              "source": "curl -X POST https://api.leadvexai.com/api/customers/ \\\n  -H \"Authorization: Bearer $LEADVEX_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: form-submission-84311\" \\\n  -d '{\"name\": \"Sara Al Mansoori\", \"phone\": \"+971501234567\"}'"
            }
          ]
        }
      ]
    },
    {
      "id": "webhooks",
      "title": "Webhooks",
      "blocks": [
        {
          "p": "A webhook endpoint is an HTTPS URL of yours that LeadVex calls when something happens. Create one in LeadVex under Integrations > Webhooks, or with `POST /webhook-endpoints/`, and pick its events. Every event is a POST with a JSON body:"
        },
        {
          "samples": [
            {
              "lang": "json",
              "label": "Body",
              "source": "{\n  \"id\": \"<delivery id>\",\n  \"event\": \"lead.created\",\n  \"dealership_id\": \"<uuid>\",\n  \"occurred_at\": \"2026-11-25T08:41:19+00:00\",\n  \"data\": { ... }\n}"
            }
          ]
        },
        {
          "table": {
            "columns": [
              "Header",
              "Value"
            ],
            "rows": [
              [
                "`X-LeadVex-Event`",
                "The event type, as in the body."
              ],
              [
                "`X-LeadVex-Delivery`",
                "The delivery ID, as `id` in the body. A retry carries the same ID."
              ],
              [
                "`X-LeadVex-Signature`",
                "`t=<unix seconds>,v1=<hex HMAC-SHA256>`. See Signatures."
              ],
              [
                "`User-Agent`",
                "`LeadVex-Webhooks/1.0`"
              ]
            ]
          }
        },
        {
          "list": [
            "Answer with any 2xx status within 10 seconds. Do the real work after you answer.",
            "A failed delivery is retried up to 8 times in all, after 30 s, 2 min, 10 min, 30 min, 60 min, 180 min, 360 min (about 11 hours).",
            "After 20 deliveries in a row fail, the endpoint is turned off and the owner sees why. Turn it on again from LeadVex or with `PATCH /webhook-endpoints/{id}`.",
            "Deliveries can arrive more than once and out of order. Skip an `id` you have already processed, and use `occurred_at` to order events.",
            "`data` is a snapshot of the records when the event was queued. Fetch the record through the API when you need its latest state.",
            "Send a signed `ping` to check your endpoint: the \"Send test\" button in LeadVex, or `POST /webhook-endpoints/{id}/test`. The delivery log shows every attempt and your answer."
          ]
        },
        {
          "p": "A workflow in LeadVex can also call an endpoint with its \"Send to webhook\" step. Those deliveries have the event `workflow.step`. The Webhooks section lists every event with an example payload."
        }
      ]
    },
    {
      "id": "signatures",
      "title": "Signatures",
      "blocks": [
        {
          "p": "Check every delivery before you trust it. The `X-LeadVex-Signature` header is `t=<timestamp>,v1=<signature>`. `v1` is the hex HMAC-SHA256 of the string `<timestamp>.<raw body>` with your endpoint's signing secret (`whsec_...`, shown once when you create the endpoint or rotate the secret) as the key."
        },
        {
          "list": [
            "Use the raw request body, byte for byte, before any JSON parsing.",
            "Compare in constant time.",
            "Reject a timestamp more than 5 minutes from your clock: that stops replays."
          ]
        },
        {
          "samples": [
            {
              "lang": "python",
              "label": "Python",
              "source": "import hashlib\nimport hmac\nimport time\n\n\ndef verify_leadvex_signature(secret: str, header: str, body: bytes, tolerance: int = 300) -> bool:\n    \"\"\"True when X-LeadVex-Signature matches the raw request body.\"\"\"\n    try:\n        parts = dict(item.split(\"=\", 1) for item in header.split(\",\"))\n        timestamp = int(parts[\"t\"])\n        received = parts[\"v1\"]\n    except (KeyError, ValueError):\n        return False\n    if abs(time.time() - timestamp) > tolerance:\n        return False  # too old, or a replay\n    signed = f\"{timestamp}.\".encode() + body\n    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()\n    return hmac.compare_digest(expected, received)\n\n\n# Flask:\n#   ok = verify_leadvex_signature(SECRET, request.headers[\"X-LeadVex-Signature\"], request.get_data())\n"
            },
            {
              "lang": "javascript",
              "label": "Node",
              "source": "const crypto = require(\"node:crypto\");\n\nfunction verifyLeadVexSignature(secret, header, rawBody, toleranceSeconds = 300) {\n  const parts = {};\n  for (const item of String(header || \"\").split(\",\")) {\n    const at = item.indexOf(\"=\");\n    if (at > 0) parts[item.slice(0, at)] = item.slice(at + 1);\n  }\n  const timestamp = Number(parts.t);\n  if (!Number.isInteger(timestamp) || !parts.v1) return false;\n  if (Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds) return false; // too old, or a replay\n  const expected = crypto.createHmac(\"sha256\", secret)\n    .update(`${timestamp}.`)\n    .update(rawBody) // the raw bytes, before any JSON parsing\n    .digest(\"hex\");\n  const a = Buffer.from(expected);\n  const b = Buffer.from(parts.v1);\n  return a.length === b.length && crypto.timingSafeEqual(a, b);\n}\n\nmodule.exports = { verifyLeadVexSignature };\n\n// Express: read the raw body for this route only.\n//   app.post(\"/leadvex\", express.raw({ type: \"application/json\" }), (req, res) => {\n//     if (!verifyLeadVexSignature(SECRET, req.get(\"X-LeadVex-Signature\"), req.body)) return res.sendStatus(401);\n//     res.sendStatus(200); // then handle JSON.parse(req.body) in the background\n//   });\n"
            },
            {
              "lang": "bash",
              "label": "curl",
              "source": "# Send your own endpoint a correctly signed test delivery.\nSECRET='whsec_your_endpoint_secret'\nBODY='{\"id\":\"f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35\",\"event\":\"ping\",\"dealership_id\":\"0c2e4a6b-8d1f-4b3e-a5c7-9e1b3d5f7a24\",\"occurred_at\":\"2026-11-25T08:45:00+00:00\",\"data\":{\"message\":\"Test event from LeadVex. Your endpoint is reachable.\"}}'\nT=$(date +%s)\nSIG=$(printf '%s.%s' \"$T\" \"$BODY\" | openssl dgst -sha256 -hmac \"$SECRET\" -hex | sed 's/^.* //')\n\ncurl -X POST https://your-server.example.com/leadvex-webhook \\\n  -H \"Content-Type: application/json\" \\\n  -H \"X-LeadVex-Event: ping\" \\\n  -H \"X-LeadVex-Delivery: f2d4b6a8-c1e3-4f5a-9b7d-2e4c6a8f1b35\" \\\n  -H \"X-LeadVex-Signature: t=$T,v1=$SIG\" \\\n  --data \"$BODY\"\n"
            }
          ]
        }
      ]
    },
    {
      "id": "versioning",
      "title": "Versioning",
      "blocks": [
        {
          "p": "This is version 1 of the API (1.2.0). Within a version we only make changes that do not break a correct integration, and we list each one in the changelog:"
        },
        {
          "list": [
            "new endpoints, and new optional request fields and query parameters;",
            "new fields in responses and in webhook `data`;",
            "new event types, and new values in lists such as lead sources, channels and statuses."
          ]
        },
        {
          "p": "Ignore fields and values you do not know. We never remove or rename a field, change its type, make an optional field required or change what an error means within a version. If we need to, that becomes a new version under a new base path. The current version keeps working for at least 6 months after we announce its successor here and by email to the owners of active tokens. Anything we plan to retire is marked `deprecated` in this reference first."
        }
      ]
    }
  ],
  "x-changelog": [
    {
      "version": "1.2.0",
      "date": "2026-11-27",
      "changes": [
        "New webhook event `call.completed`: a phone call ended, with its summary, outcome, length, who handled it and links to the lead and the chat. Zapier and Make have it as \"Phone Call Ended\"."
      ]
    },
    {
      "version": "1.1.0",
      "date": "2026-11-27",
      "changes": [
        "REST hooks for no-code platforms: `POST /webhook-endpoints/subscriptions` and `DELETE /webhook-endpoints/subscriptions/{id}`, used by the LeadVex apps for Zapier and Make.",
        "`GET /webhook-endpoints/events/{event}/sample`: real or example payloads for a test step.",
        "New webhook event `conversation.closed`. Endpoints list their `source` (`app`, `zapier` or `make`)."
      ]
    },
    {
      "version": "1.0.0",
      "date": "2026-11-25",
      "changes": [
        "First public release: token check, leads, customers, conversations and messages, test drives, inventory and webhook endpoints.",
        "`Idempotency-Key` on every POST made with an API token.",
        "300 requests per minute per API token."
      ]
    }
  ]
}
