{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elocuenti-com/json-schema/elocuenti-com-lead-response-schema.json",
  "title": "LeadResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elocuenti-com-pipelines-api-openapi.yml#/components/schemas/LeadResponse",
  "type": "object",
  "properties": {
    "data": {
      "$ref": "#/$defs/Lead"
    },
    "request_id": {
      "type": "string",
      "description": "The identifier of this request. Give it to support if you need help.",
      "title": "Request Id"
    }
  },
  "required": [
    "data",
    "request_id"
  ],
  "$defs": {
    "Lead": {
      "type": "object",
      "properties": {
        "conversation_id": {
          "type": "string",
          "description": "The conversation.",
          "title": "Conversation Id"
        },
        "pipeline": {
          "$ref": "#/$defs/LeadPipeline"
        },
        "stage": {
          "$ref": "#/$defs/LeadStage"
        },
        "stage_fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LeadStageField"
          },
          "description": "What the current stage asks for, with what the AI already captured and what is still pending, in the stage's order.",
          "title": "Stage Fields"
        },
        "other_fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LeadField"
          },
          "description": "Information the AI captured that the current stage does not ask for (for example, from an earlier stage). At most 200.",
          "title": "Other Fields"
        },
        "progress": {
          "$ref": "#/$defs/LeadProgress"
        }
      },
      "required": [
        "conversation_id",
        "pipeline",
        "stage",
        "stage_fields",
        "other_fields",
        "progress"
      ],
      "description": "What the AI captured about the customer in this conversation.",
      "title": "Lead"
    },
    "LeadField": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "The identifier of the attribute.",
          "title": "Key"
        },
        "label": {
          "type": "string",
          "description": "The name of the attribute as your team sees it in the dashboard.",
          "title": "Label"
        },
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "What kind of value it holds (`string`, `number`, `integer`, `boolean`, `date`, `datetime`, `enum` or `media`), or `null` if your catalog does not define it.",
          "title": "Type"
        },
        "status": {
          "type": "string",
          "enum": [
            "captured",
            "pending"
          ],
          "description": "`captured` when the AI already has the value; `pending` when it is still missing.",
          "title": "Status"
        },
        "value": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "What the customer said, as text. `null` while it is pending. It is the customer's own information: treat it as personal data.",
          "title": "Value"
        },
        "confidence": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "high",
                "medium",
                "low"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "How sure the AI is about the value. `null` while it is pending.",
          "title": "Confidence"
        },
        "captured_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "When the AI captured it (UTC, ISO 8601). `null` while it is pending.",
          "title": "Captured At"
        },
        "has_file": {
          "type": "boolean",
          "description": "`true` when the customer sent a file for this field (a photo or a document). The file itself is only available in the dashboard.",
          "title": "Has File"
        }
      },
      "required": [
        "key",
        "label",
        "type",
        "status",
        "value",
        "confidence",
        "captured_at",
        "has_file"
      ],
      "description": "One piece of information of the lead.",
      "title": "LeadField"
    },
    "LeadPipeline": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "The funnel.",
              "title": "Id"
            },
            "name": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Its name.",
              "title": "Name"
            }
          },
          "required": [
            "id",
            "name"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The funnel the conversation is in, or `null` if it is in none.",
      "title": "LeadPipeline"
    },
    "LeadProgress": {
      "type": "object",
      "properties": {
        "required_total": {
          "type": "integer",
          "description": "How many fields the stage requires.",
          "title": "Required Total"
        },
        "required_captured": {
          "type": "integer",
          "description": "How many of those are already captured.",
          "title": "Required Captured"
        }
      },
      "required": [
        "required_total",
        "required_captured"
      ],
      "description": "How complete the required information is.",
      "title": "LeadProgress"
    },
    "LeadStage": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "The stage.",
              "title": "Id"
            },
            "name": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Its name.",
              "title": "Name"
            }
          },
          "required": [
            "id",
            "name"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The stage the conversation is in, or `null` if it is in none.",
      "title": "LeadStage"
    },
    "LeadStageField": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "The identifier of the attribute.",
          "title": "Key"
        },
        "label": {
          "type": "string",
          "description": "The name of the attribute as your team sees it in the dashboard.",
          "title": "Label"
        },
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "What kind of value it holds (`string`, `number`, `integer`, `boolean`, `date`, `datetime`, `enum` or `media`), or `null` if your catalog does not define it.",
          "title": "Type"
        },
        "status": {
          "type": "string",
          "enum": [
            "captured",
            "pending"
          ],
          "description": "`captured` when the AI already has the value; `pending` when it is still missing.",
          "title": "Status"
        },
        "value": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "What the customer said, as text. `null` while it is pending. It is the customer's own information: treat it as personal data.",
          "title": "Value"
        },
        "confidence": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "high",
                "medium",
                "low"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "How sure the AI is about the value. `null` while it is pending.",
          "title": "Confidence"
        },
        "captured_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "When the AI captured it (UTC, ISO 8601). `null` while it is pending.",
          "title": "Captured At"
        },
        "has_file": {
          "type": "boolean",
          "description": "`true` when the customer sent a file for this field (a photo or a document). The file itself is only available in the dashboard.",
          "title": "Has File"
        },
        "required": {
          "type": "boolean",
          "description": "`true` when the stage needs this value to be considered complete.",
          "title": "Required"
        }
      },
      "required": [
        "key",
        "label",
        "type",
        "status",
        "value",
        "confidence",
        "captured_at",
        "has_file",
        "required"
      ],
      "description": "A field the current stage asks for.",
      "title": "LeadStageField"
    }
  }
}