{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "Zeller AI API",
    "version": "1.0.0",
    "description": "The public REST API for the Zeller AI real-estate platform.\n\n**Versioning.** `v1` is stable. Additive changes (new endpoints, new response fields, new\nevent types) ship without notice; a breaking change gets a new version and a 12-month\ndeprecation window on the old one.\n\n**Compliance.** Sends made through this API pass the same server-side gates as the product —\nconsent, suppression, opt-out, A2P registration and TCPA quiet hours. A refused send returns\n422 `compliance_blocked` with the reason. There is no flag that turns this off.\n\n**IDs** are opaque strings (cuid). They are never numeric, so no precision handling is needed.",
    "contact": {
      "name": "Zeller AI developer support",
      "url": "https://zellerai.co/contact"
    }
  },
  "servers": [
    {
      "url": "https://app.zellerai.co/api/v1",
      "description": "Production"
    }
  ],
  "paths": {
    "/ping": {
      "get": {
        "operationId": "ping",
        "summary": "Verify a credential",
        "description": "Echoes back which workspace and scopes your credential resolves to. The first call every integration should make.",
        "tags": [
          "Meta"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/contacts": {
      "get": {
        "operationId": "listContacts",
        "summary": "List contacts",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "LEAD",
                "HOT_LEAD",
                "NURTURE",
                "ACTIVE_CLIENT",
                "PAST_CLIENT",
                "SPHERE",
                "TRASH"
              ]
            }
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "owner_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "contacts:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "createContact",
        "summary": "Create a contact",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "first_name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "last_name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 32
                  },
                  "stage": {
                    "type": "string",
                    "enum": [
                      "LEAD",
                      "HOT_LEAD",
                      "NURTURE",
                      "ACTIVE_CLIENT",
                      "PAST_CLIENT",
                      "SPHERE",
                      "TRASH"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "tags": {
                    "maxItems": 30,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 40
                    }
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 20000
                  },
                  "owner_id": {
                    "type": "string",
                    "maxLength": 40
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "contacts:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/contacts/{id}": {
      "get": {
        "operationId": "getContact",
        "summary": "Retrieve a contact",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "contacts:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "operationId": "updateContact",
        "summary": "Update a contact",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "first_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 80
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "last_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 80
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 32
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "stage": {
                    "type": "string",
                    "enum": [
                      "LEAD",
                      "HOT_LEAD",
                      "NURTURE",
                      "ACTIVE_CLIENT",
                      "PAST_CLIENT",
                      "SPHERE",
                      "TRASH"
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 80
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tags": {
                    "maxItems": 30,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 40
                    }
                  },
                  "notes": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 20000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "owner_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 40
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "contacts:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "delete": {
        "operationId": "eraseContact",
        "summary": "Erase a contact's personal data",
        "description": "ANONYMIZES in place — it does not delete the row. A contact is referenced by deals, commissions and messages a brokerage is required to keep, so a true delete would either cascade those away or leave them dangling. Names, addresses, message bodies and activity titles are scrubbed; the structural records survive pointing at an anonymized contact.",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "contacts:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/contacts/{id}/events": {
      "get": {
        "operationId": "listContactEvents",
        "summary": "List a contact's timeline",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Event"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "events:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/contacts/{id}/notes": {
      "get": {
        "operationId": "listContactNotes",
        "summary": "List a contact's notes",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Event"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "events:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "createContactNote",
        "summary": "Add a note",
        "description": "Adding a note pauses the contact's AI auto-response, exactly as it does in the product — a human (or an integration) touching a conversation is the signal that the AI should stop talking over them.",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000
                  }
                },
                "required": [
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "contacts:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/leads": {
      "get": {
        "operationId": "listLeads",
        "summary": "List leads",
        "tags": [
          "Leads"
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "unlinked_only",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Lead"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "leads:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "createLead",
        "summary": "Create and route a lead",
        "description": "Creates the lead and routes it through the assignment engine unless `skip_routing` is set. A lead created WITHOUT a `consent` object carries no consent artifact, so the pre-dial and pre-send gates will refuse AI outbound to it — the response says so in `ai_outbound_allowed`.",
        "tags": [
          "Leads"
        ],
        "parameters": [
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone": {
                    "type": "string",
                    "minLength": 5,
                    "maxLength": 32
                  },
                  "first_name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "last_name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "source": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "source_ref": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "context": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "consent": {
                    "type": "object",
                    "properties": {
                      "captured_at": {},
                      "source_url": {
                        "type": "string",
                        "maxLength": 2048,
                        "format": "uri"
                      },
                      "ip": {
                        "type": "string",
                        "maxLength": 64
                      },
                      "form_snapshot": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "skip_routing": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "phone",
                  "source"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "leads:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/leads/{id}": {
      "get": {
        "operationId": "getLead",
        "summary": "Retrieve a lead",
        "tags": [
          "Leads"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "leads:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/leads/{id}/assign": {
      "post": {
        "operationId": "assignLead",
        "summary": "Route or re-route a lead",
        "tags": [
          "Leads"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "default": {},
                "type": "object",
                "properties": {
                  "assignee_id": {
                    "type": "string",
                    "maxLength": 40
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "leads:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/leads/routing-preview": {
      "post": {
        "operationId": "previewRouting",
        "summary": "Preview where a lead would be routed",
        "description": "A dry run: creates nothing, assigns nothing, notifies nobody. Returns the rule that would win, the assignee, and the full considered set with the failing conditions spelled out. For round-robin methods the rotation cursor is NOT advanced, so the live pick may be a different member of the same pool — `reason` says so.",
        "tags": [
          "Leads"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "zip": {
                    "type": "string",
                    "maxLength": 16
                  },
                  "city": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "price": {
                    "type": "number",
                    "minimum": 0
                  },
                  "has_phone": {
                    "type": "boolean"
                  },
                  "tags": {
                    "maxItems": 30,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 40
                    }
                  },
                  "stage": {
                    "type": "string",
                    "maxLength": 32
                  },
                  "office_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "team_id": {
                    "type": "string",
                    "maxLength": 40
                  }
                },
                "required": [
                  "source"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "leads:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/messages": {
      "get": {
        "operationId": "listMessages",
        "summary": "List messages",
        "tags": [
          "Messaging"
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "SMS",
                "WHATSAPP",
                "EMAIL"
              ]
            }
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "INBOUND",
                "OUTBOUND"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "messages:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "sendMessage",
        "summary": "Send a text, WhatsApp message or email",
        "description": "Routes through the same send path the product uses, so every compliance check applies: suppression, opt-out, A2P registration, TCPA quiet hours and consent. A refused send returns **422 `compliance_blocked`** with the reason — never a silent success — and the attempt is still recorded in the workspace's inbox.",
        "tags": [
          "Messaging"
        ],
        "parameters": [
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "channel": {
                        "type": "string",
                        "const": "sms"
                      },
                      "to": {
                        "type": "string",
                        "minLength": 5,
                        "maxLength": 32
                      },
                      "body": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 4000
                      },
                      "contact_id": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "purpose": {
                        "type": "string",
                        "enum": [
                          "outbound",
                          "reply"
                        ]
                      }
                    },
                    "required": [
                      "channel",
                      "to",
                      "body"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "channel": {
                        "type": "string",
                        "const": "whatsapp"
                      },
                      "to": {
                        "type": "string",
                        "minLength": 5,
                        "maxLength": 32
                      },
                      "body": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 4000
                      },
                      "contact_id": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "purpose": {
                        "type": "string",
                        "enum": [
                          "outbound",
                          "reply"
                        ]
                      }
                    },
                    "required": [
                      "channel",
                      "to",
                      "body"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "channel": {
                        "type": "string",
                        "const": "email"
                      },
                      "to": {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      "subject": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "body": {
                        "type": "string",
                        "minLength": 1
                      },
                      "from": {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      "contact_id": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "purpose": {
                        "type": "string",
                        "enum": [
                          "outbound",
                          "reply"
                        ]
                      }
                    },
                    "required": [
                      "channel",
                      "to",
                      "subject",
                      "body"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The send was refused by the compliance gate. `error.code` is `compliance_blocked` and `error.message` names the reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "messages:send"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/calls": {
      "get": {
        "operationId": "listCalls",
        "summary": "List calls",
        "description": "Includes AI-handled calls with their summaries. `handled_by` distinguishes AI from human.",
        "tags": [
          "Calls"
        ],
        "parameters": [
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "voicemail",
                "recorded",
                "missed"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Call"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "calls:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/calls/{id}": {
      "get": {
        "operationId": "getCall",
        "summary": "Retrieve a call with transcript and recording",
        "description": "`recording_url` is a five-minute signed link to our own proxy, never the carrier's URL (which is credential-protected and would 401 for you).",
        "tags": [
          "Calls"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Call"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "calls:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/deals": {
      "get": {
        "operationId": "listDeals",
        "summary": "List deals",
        "tags": [
          "Deals"
        ],
        "parameters": [
          {
            "name": "pipeline_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "stage_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "owner_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "OPEN",
                "WON",
                "LOST"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Deal"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "deals:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "createDeal",
        "summary": "Create a deal",
        "tags": [
          "Deals"
        ],
        "parameters": [
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "BUYER",
                      "SELLER",
                      "DUAL",
                      "LANDLORD",
                      "TENANT"
                    ]
                  },
                  "pipeline_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "stage_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "owner_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "property_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "value": {
                    "type": "number",
                    "minimum": 0
                  },
                  "commission_rate": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "expected_close_date": {},
                  "notes": {
                    "type": "string",
                    "maxLength": 20000
                  }
                },
                "required": [
                  "contact_id",
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "deals:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/deals/{id}": {
      "get": {
        "operationId": "getDeal",
        "summary": "Retrieve a deal",
        "tags": [
          "Deals"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "deals:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "operationId": "updateDeal",
        "summary": "Update a deal",
        "tags": [
          "Deals"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "BUYER",
                      "SELLER",
                      "DUAL",
                      "LANDLORD",
                      "TENANT"
                    ]
                  },
                  "stage_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "owner_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 40
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "value": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "commission_rate": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "expected_close_date": {
                    "anyOf": [
                      {},
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "notes": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 20000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lost_reason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "deals:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/pipelines": {
      "get": {
        "operationId": "listPipelines",
        "summary": "List pipelines and their stages",
        "tags": [
          "Deals"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Pipeline"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "deals:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/listings": {
      "get": {
        "operationId": "listListings",
        "summary": "List the workspace's own listings",
        "description": "These are listings the workspace authored, NOT MLS inventory. MLS data is governed by per-board display rules that a general-purpose REST feed cannot honour.",
        "tags": [
          "Listings"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "DRAFT",
                "ACTIVE",
                "PENDING",
                "SOLD",
                "OFF_MARKET",
                "ARCHIVED"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "SINGLE_FAMILY",
                "CONDO",
                "TOWNHOUSE",
                "MULTI_FAMILY",
                "LAND",
                "COMMERCIAL",
                "OTHER"
              ]
            }
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Listing"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "listings:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/appointments": {
      "get": {
        "operationId": "listAppointments",
        "summary": "List appointments",
        "tags": [
          "Calendar"
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {}
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {}
          },
          {
            "name": "outcome",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "SHOWED",
                "NO_SHOW",
                "CANCELED",
                "RESCHEDULED"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Appointment"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "appointments:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "createAppointment",
        "summary": "Book an appointment",
        "description": "Pushes the event out to the creator's connected calendar when one exists, exactly as an in-product booking does.",
        "tags": [
          "Calendar"
        ],
        "parameters": [
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  },
                  "starts_at": {},
                  "ends_at": {},
                  "timezone": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "contact_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "appointment_type_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "location": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "lead_source": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "created_by_user_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "sync_to_calendar": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "title",
                  "starts_at",
                  "ends_at"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "appointments:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/appointments/{id}": {
      "get": {
        "operationId": "getAppointment",
        "summary": "Retrieve an appointment",
        "tags": [
          "Calendar"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "appointments:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "operationId": "updateAppointment",
        "summary": "Reschedule an appointment or record its outcome",
        "description": "Send `starts_at` AND `ends_at` together to move it; send `outcome` to record what happened. Both are separate domain writes, and moving with only one end is refused.",
        "tags": [
          "Calendar"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "starts_at": {},
                  "ends_at": {},
                  "timezone": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "outcome": {
                    "type": "string",
                    "enum": [
                      "PENDING",
                      "SHOWED",
                      "NO_SHOW",
                      "CANCELED",
                      "RESCHEDULED"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Appointment"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "appointments:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/tasks": {
      "get": {
        "operationId": "listTasks",
        "summary": "List tasks",
        "tags": [
          "Calendar"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "OPEN",
                "DONE"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Task"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "appointments:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "createTask",
        "summary": "Create a follow-up task",
        "description": "Deduped within 60 seconds, so a retried webhook does not produce two identical follow-ups. `created: false` means an identical task already existed.",
        "tags": [
          "Calendar"
        ],
        "parameters": [
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  },
                  "contact_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "deal_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "lead_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "assignee_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "due_at": {}
                },
                "required": [
                  "title"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "appointments:write"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/automations": {
      "get": {
        "operationId": "listAutomations",
        "summary": "List automations",
        "tags": [
          "Automations"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Automation"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "automations:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/automations/{id}/enroll": {
      "post": {
        "operationId": "enrollInAutomation",
        "summary": "Start an automation for a contact",
        "description": "Returns **202**: the enrolment is durable immediately, and the automation runs on the next engine tick. Enrolling into a disabled automation is refused rather than silently dropped.",
        "tags": [
          "Automations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  }
                },
                "required": [
                  "contact_id"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "automations:manage"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/personas": {
      "get": {
        "operationId": "listPersonas",
        "summary": "List AI personas",
        "tags": [
          "Automations"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Persona"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "automations:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/campaigns": {
      "get": {
        "operationId": "listCampaigns",
        "summary": "List outbound campaigns",
        "tags": [
          "Automations"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Campaign"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "automations:read"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "summary": "List webhook subscriptions",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`. Omit for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor",
                    "has_more"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "webhooks:manage"
            ]
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "operationId": "createWebhook",
        "summary": "Subscribe to events",
        "description": "The signing secret is returned exactly once, here. Every delivery carries `X-Webhook-Signature: sha256=<hmac>` over the exact request body.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "name": "fields",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated field allow-list, e.g. `fields=id,email,stage`. `id` is always included."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "maxLength": 2048,
                    "format": "uri"
                  },
                  "event_types": {
                    "default": [],
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    }
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "400": {
            "description": "The request body or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "webhooks:manage"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/webhooks/{id}": {
      "delete": {
        "operationId": "deleteWebhook",
        "summary": "Unsubscribe",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "The credential is missing, expired or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The credential is valid but lacks the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object for this workspace. Returned instead of 403 for another workspace's id, so the API is not an existence oracle.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. See `X-RateLimit-*` and `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "webhooks:manage"
            ]
          },
          {
            "apiKey": []
          }
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Meta",
      "description": "Credential verification."
    },
    {
      "name": "Contacts",
      "description": "People and their timelines."
    },
    {
      "name": "Leads",
      "description": "Inbound leads and routing."
    },
    {
      "name": "Messaging",
      "description": "Texts, WhatsApp and email — all through the compliance gate."
    },
    {
      "name": "Calls",
      "description": "Call records, including AI-handled calls with summaries."
    },
    {
      "name": "Deals",
      "description": "Pipelines and transactions."
    },
    {
      "name": "Listings",
      "description": "The workspace's own property listings."
    },
    {
      "name": "Calendar",
      "description": "Appointments and tasks."
    },
    {
      "name": "Automations",
      "description": "Automations, personas and campaigns."
    },
    {
      "name": "Webhooks",
      "description": "Event subscriptions, HMAC-signed."
    }
  ],
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "invalid_client",
                  "invalid_grant",
                  "unauthorized_client",
                  "unsupported_grant_type",
                  "invalid_scope",
                  "access_denied",
                  "unauthenticated",
                  "insufficient_scope",
                  "not_found",
                  "conflict",
                  "unprocessable",
                  "compliance_blocked",
                  "rate_limited",
                  "server_error"
                ]
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "contact"
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "stage": {
            "type": "string"
          },
          "source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "owner_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "owner_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "organization_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "score": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "score_tier": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "seller_cohort": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "preferred_language": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "budget_min": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "budget_max": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "leads_count": {
            "type": "number"
          },
          "activity_count": {
            "type": "number"
          },
          "last_activity_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string"
          },
          "pii_masked": {
            "type": "boolean"
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "first_name",
          "last_name",
          "email",
          "phone",
          "stage",
          "source",
          "tags",
          "owner_id",
          "owner_name",
          "organization_name",
          "score",
          "score_tier",
          "seller_cohort",
          "preferred_language",
          "budget_min",
          "budget_max",
          "leads_count",
          "activity_count",
          "last_activity_at",
          "created_at",
          "pii_masked"
        ]
      },
      "Lead": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "lead"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "attempts_total": {
            "type": "number"
          },
          "last_attempt_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "owner_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "intent": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "property_interest": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "price_range": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "timeline": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_at": {
            "type": "string"
          },
          "pii_masked": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "object",
          "phone",
          "first_name",
          "last_name",
          "email",
          "source",
          "status",
          "attempts_total",
          "last_attempt_at",
          "contact_id",
          "owner_name",
          "intent",
          "property_interest",
          "price_range",
          "timeline",
          "tags",
          "created_at",
          "pii_masked"
        ]
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "message"
          },
          "channel": {
            "type": "string"
          },
          "direction": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "subject": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "ai_generated": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string"
          },
          "sent_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "object",
          "channel",
          "direction",
          "status",
          "body",
          "subject",
          "contact_id",
          "ai_generated",
          "created_at",
          "sent_at"
        ]
      },
      "Call": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "call"
          },
          "direction": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "duration_sec": {
            "type": "number"
          },
          "disposition": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "summary": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "handled_by": {
            "type": "string",
            "enum": [
              "AI",
              "HUMAN"
            ]
          },
          "has_recording": {
            "type": "boolean"
          },
          "has_voicemail": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string"
          },
          "recording_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "transcript": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "object",
          "direction",
          "status",
          "duration_sec",
          "disposition",
          "summary",
          "contact_name",
          "phone",
          "handled_by",
          "has_recording",
          "has_voicemail",
          "created_at"
        ]
      },
      "Deal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "deal"
          },
          "name": {
            "type": "string"
          },
          "side": {
            "type": "string"
          },
          "pipeline_id": {
            "type": "string"
          },
          "stage_id": {
            "type": "string"
          },
          "stage_name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "commission_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "commission_amount": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "contact_id": {
            "type": "string"
          },
          "contact_name": {
            "type": "string"
          },
          "owner_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "owner_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "property_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "expected_close_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "closed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "side",
          "pipeline_id",
          "stage_id",
          "stage_name",
          "status",
          "value",
          "commission_rate",
          "commission_amount",
          "contact_id",
          "contact_name",
          "owner_id",
          "owner_name",
          "property_id",
          "expected_close_date",
          "closed_at",
          "created_at"
        ]
      },
      "Appointment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "appointment"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "assignee_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "starts_at": {
            "type": "string"
          },
          "ends_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "outcome": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "appointment_type_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "lead_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "object",
          "title",
          "status",
          "contact_id",
          "assignee_id",
          "location",
          "starts_at",
          "ends_at",
          "outcome",
          "appointment_type_id",
          "timezone",
          "lead_source"
        ]
      },
      "Task": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "task"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "deal_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "lead_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "due_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "position": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "object",
          "title",
          "status",
          "kind",
          "contact_id",
          "deal_id",
          "lead_id",
          "due_at",
          "completed_at",
          "position"
        ]
      },
      "Listing": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "listing"
          },
          "title": {
            "type": "string"
          },
          "slug": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "price": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "beds": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "baths": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "sqft": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "cover_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "listing_agent_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "published": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "title",
          "slug",
          "status",
          "type",
          "city",
          "state",
          "price",
          "beds",
          "baths",
          "sqft",
          "cover_url",
          "contact_id",
          "listing_agent_id",
          "published",
          "created_at"
        ]
      },
      "Automation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "automation"
          },
          "name": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "triggers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "times_run": {
            "type": "number"
          },
          "run_once_per_person": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "enabled",
          "triggers",
          "times_run",
          "run_once_per_person",
          "created_at"
        ]
      },
      "Persona": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "persona"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "kind",
          "status",
          "created_at"
        ]
      },
      "Campaign": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "campaign"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "channel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "enrolled": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "status",
          "channel",
          "enrolled",
          "created_at"
        ]
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "webhook"
          },
          "url": {
            "type": "string"
          },
          "event_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string"
          },
          "secret": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "url",
          "event_types",
          "enabled",
          "description",
          "created_at"
        ]
      },
      "Pipeline": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "pipeline"
          },
          "name": {
            "type": "string"
          },
          "stages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "phase": {
                  "type": "string"
                },
                "position": {
                  "type": "number"
                }
              },
              "required": [
                "id",
                "name",
                "phase",
                "position"
              ]
            }
          }
        },
        "required": [
          "id",
          "object",
          "name",
          "stages"
        ]
      },
      "Event": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "event"
          },
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "actor_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "occurred_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "title",
          "body",
          "actor_label",
          "occurred_at"
        ]
      }
    },
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth2 for applications acting on a workspace's behalf. All three flows are supported.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://app.zellerai.co/api/oauth/authorize",
            "tokenUrl": "https://app.zellerai.co/api/oauth/token",
            "refreshUrl": "https://app.zellerai.co/api/oauth/token",
            "scopes": {
              "contacts:read": "See your contacts and their details",
              "contacts:read:pii": "See full phone numbers and email addresses instead of masked ones",
              "contacts:write": "Create and update contacts, and add notes and tags",
              "leads:read": "See incoming leads and how they were routed",
              "leads:write": "Create leads and assign them to people on your team",
              "events:read": "See activity timelines — calls, messages, notes and status changes",
              "messages:read": "Read your texts and emails with contacts",
              "messages:send": "Send texts and emails to your contacts on your behalf",
              "calls:read": "See call records, recordings, transcripts and AI summaries",
              "deals:read": "See your pipelines and the deals in them",
              "deals:write": "Create and update deals and move them between stages",
              "listings:read": "See the properties in your workspace",
              "appointments:read": "See appointments and tasks",
              "appointments:write": "Book, reschedule and cancel appointments, and create tasks",
              "automations:read": "See your automations and the campaigns and personas they use",
              "automations:manage": "Start automations for a contact",
              "webhooks:manage": "Create and remove webhook subscriptions that receive your workspace's events"
            }
          },
          "clientCredentials": {
            "tokenUrl": "https://app.zellerai.co/api/oauth/token",
            "refreshUrl": "https://app.zellerai.co/api/oauth/token",
            "scopes": {
              "contacts:read": "See your contacts and their details",
              "contacts:read:pii": "See full phone numbers and email addresses instead of masked ones",
              "contacts:write": "Create and update contacts, and add notes and tags",
              "leads:read": "See incoming leads and how they were routed",
              "leads:write": "Create leads and assign them to people on your team",
              "events:read": "See activity timelines — calls, messages, notes and status changes",
              "messages:read": "Read your texts and emails with contacts",
              "messages:send": "Send texts and emails to your contacts on your behalf",
              "calls:read": "See call records, recordings, transcripts and AI summaries",
              "deals:read": "See your pipelines and the deals in them",
              "deals:write": "Create and update deals and move them between stages",
              "listings:read": "See the properties in your workspace",
              "appointments:read": "See appointments and tasks",
              "appointments:write": "Book, reschedule and cancel appointments, and create tasks",
              "automations:read": "See your automations and the campaigns and personas they use",
              "automations:manage": "Start automations for a contact",
              "webhooks:manage": "Create and remove webhook subscriptions that receive your workspace's events"
            }
          }
        }
      },
      "apiKey": {
        "type": "http",
        "scheme": "token",
        "description": "A workspace's own API key, sent as `Authorization: token <key>`. Per-key scoped and expiring by default."
      }
    }
  },
  "security": [
    {
      "oauth2": []
    },
    {
      "apiKey": []
    }
  ],
  "x-webhooks": {
    "contact.created": {
      "post": {
        "summary": "A contact was added to the workspace.",
        "description": "Delivered with `X-Webhook-Event: contact.created` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `contacts:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "contact.created"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "contact.updated": {
      "post": {
        "summary": "A contact's details changed.",
        "description": "Delivered with `X-Webhook-Event: contact.updated` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `contacts:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "contact.updated"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "contact.stage_changed": {
      "post": {
        "summary": "A contact moved to a different lifecycle stage.",
        "description": "Delivered with `X-Webhook-Event: contact.stage_changed` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `contacts:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "contact.stage_changed"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "contact.tag_added": {
      "post": {
        "summary": "A tag was added to a contact.",
        "description": "Delivered with `X-Webhook-Event: contact.tag_added` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `contacts:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "contact.tag_added"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "lead.created": {
      "post": {
        "summary": "A new lead was captured from any source.",
        "description": "Delivered with `X-Webhook-Event: lead.created` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `leads:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "lead.created"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "lead.assigned": {
      "post": {
        "summary": "A lead was routed to an agent.",
        "description": "Delivered with `X-Webhook-Event: lead.assigned` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `leads:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "lead.assigned"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "message.received": {
      "post": {
        "summary": "An inbound text, WhatsApp message or email arrived.",
        "description": "Delivered with `X-Webhook-Event: message.received` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `messages:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "message.received"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "message.sent": {
      "post": {
        "summary": "An outbound text, WhatsApp message or email was sent — INCLUDING ones our AI composed (`ai_generated: true`).",
        "description": "Delivered with `X-Webhook-Event: message.sent` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `messages:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "message.sent"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "call.completed": {
      "post": {
        "summary": "A call finished — including AI-handled calls, with the summary and disposition.",
        "description": "Delivered with `X-Webhook-Event: call.completed` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `calls:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "call.completed"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "appointment.booked": {
      "post": {
        "summary": "An appointment was booked.",
        "description": "Delivered with `X-Webhook-Event: appointment.booked` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `appointments:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "appointment.booked"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "appointment.rescheduled": {
      "post": {
        "summary": "An appointment moved.",
        "description": "Delivered with `X-Webhook-Event: appointment.rescheduled` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `appointments:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "appointment.rescheduled"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "appointment.outcome": {
      "post": {
        "summary": "An appointment was marked showed/no-show/cancelled.",
        "description": "Delivered with `X-Webhook-Event: appointment.outcome` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `appointments:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "appointment.outcome"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "deal.stage_changed": {
      "post": {
        "summary": "A deal moved to a different pipeline stage.",
        "description": "Delivered with `X-Webhook-Event: deal.stage_changed` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `deals:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "deal.stage_changed"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "automation.run": {
      "post": {
        "summary": "An automation started for a contact.",
        "description": "Delivered with `X-Webhook-Event: automation.run` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `automations:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "automation.run"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "document.signed": {
      "post": {
        "summary": "A document came back signed.",
        "description": "Delivered with `X-Webhook-Event: document.signed` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `deals:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "document.signed"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    },
    "saved_search.sent": {
      "post": {
        "summary": "A listing alert digest went out to a contact.",
        "description": "Delivered with `X-Webhook-Event: saved_search.sent` and `X-Webhook-Signature: sha256=<hmac>`. Subscribe with the `contacts:read` scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "const": "saved_search.sent"
                  },
                  "tenantId": {
                    "type": "string"
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Return any 2xx to acknowledge. Non-2xx is retried with exponential backoff, up to 6 attempts."
          }
        }
      }
    }
  }
}
