{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/meetdarwin-ai/json-schema/meetdarwin-ai-conversation-schema.json",
  "title": "Conversation",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/meetdarwin-ai-openapi.json#/components/schemas/Conversation",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^conv_"
    },
    "object": {
      "type": "string",
      "const": "conversation"
    },
    "created_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        {
          "type": "null"
        }
      ]
    },
    "updated_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        {
          "type": "null"
        }
      ]
    },
    "page_url": {
      "type": [
        "string",
        "null"
      ]
    },
    "page_path": {
      "type": [
        "string",
        "null"
      ]
    },
    "outcome": {
      "type": "string",
      "enum": [
        "meeting",
        "lead",
        "handoff",
        "none"
      ]
    },
    "message_count": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "preview": {
      "description": "The visitor's first message, up to 160 characters.",
      "type": [
        "string",
        "null"
      ]
    },
    "contact": {
      "description": "The contact's id. Needs contacts:read.",
      "type": [
        "string",
        "null"
      ]
    },
    "lead": {
      "type": "object",
      "properties": {
        "first_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": [
            "string",
            "null"
          ]
        },
        "captured_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "first_name",
        "last_name",
        "email",
        "captured_at"
      ]
    },
    "booking": {
      "type": "object",
      "properties": {
        "started_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        },
        "booked_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        },
        "booker_email": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "started_at",
        "booked_at",
        "booker_email"
      ]
    },
    "handoff": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "requested_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "reason": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "requested_at",
            "reason"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "visitor": {
      "type": "object",
      "properties": {
        "device": {
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "type": [
            "string",
            "null"
          ]
        },
        "region": {
          "type": [
            "string",
            "null"
          ]
        },
        "city": {
          "type": [
            "string",
            "null"
          ]
        },
        "referrer": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": [
            "string",
            "null"
          ]
        },
        "utm": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        },
        "ai_referred": {
          "type": "boolean",
          "description": "Arrived from an AI assistant (ChatGPT, Perplexity, Claude, Gemini, Copilot…)."
        },
        "returning": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "first_seen_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        },
        "last_seen_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "device",
        "country",
        "region",
        "city",
        "referrer",
        "source",
        "utm",
        "ai_referred",
        "returning",
        "first_seen_at",
        "last_seen_at"
      ]
    },
    "attribution": {
      "type": "object",
      "properties": {
        "visit": {
          "anyOf": [
            {
              "$ref": "#/$defs/Touch"
            },
            {
              "type": "null"
            }
          ],
          "description": "The visit this conversation started in."
        },
        "first_touch": {
          "anyOf": [
            {
              "$ref": "#/$defs/Touch"
            },
            {
              "type": "null"
            }
          ],
          "description": "The person's first visit, across every browser joined to their email."
        },
        "last_touch": {
          "anyOf": [
            {
              "$ref": "#/$defs/Touch"
            },
            {
              "type": "null"
            }
          ],
          "description": "The latest visit before this conversation that came from somewhere (tagged, an ad click or another site); the latest visit when none did."
        },
        "visits": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "visit",
        "first_touch",
        "last_touch",
        "visits"
      ],
      "description": "Where this conversation's visitor came from, first and last touch."
    },
    "opening": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "experiment": {
              "type": "string"
            },
            "variant": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "experiment",
            "variant"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "evaluation": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "intent": {
              "type": [
                "string",
                "null"
              ]
            },
            "buying_stage": {
              "type": [
                "string",
                "null"
              ]
            },
            "qualification_score": {
              "description": "0 to 10.",
              "type": [
                "number",
                "null"
              ]
            },
            "meeting_intent": {
              "description": "0 to 10.",
              "type": [
                "number",
                "null"
              ]
            },
            "understood": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "failure_category": {
              "type": [
                "string",
                "null"
              ]
            },
            "abandonment_reason": {
              "type": [
                "string",
                "null"
              ]
            },
            "recommended_improvement": {
              "type": [
                "string",
                "null"
              ]
            },
            "evaluated_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "intent",
            "buying_stage",
            "qualification_score",
            "meeting_intent",
            "understood",
            "failure_category",
            "abandonment_reason",
            "recommended_improvement",
            "evaluated_at"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Darwin's grading, once the conversation has gone quiet."
    },
    "test": {
      "type": "boolean"
    },
    "admin_url": {
      "type": "string",
      "description": "This conversation in the Darwin admin, for a link in Slack or a CRM note."
    },
    "messages": {
      "description": "With expand[]=messages.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant",
              "system"
            ]
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What the agent did in this turn, in words (searched the website, offered a meeting…)."
          }
        },
        "required": [
          "id",
          "role",
          "text",
          "created_at",
          "tools"
        ]
      }
    }
  },
  "required": [
    "id",
    "object",
    "created_at",
    "updated_at",
    "page_url",
    "page_path",
    "outcome",
    "message_count",
    "preview",
    "contact",
    "lead",
    "booking",
    "handoff",
    "visitor",
    "attribution",
    "opening",
    "evaluation",
    "test",
    "admin_url"
  ],
  "$defs": {
    "Touch": {
      "type": "object",
      "properties": {
        "visit_id": {
          "description": "Null for a first arrival recorded before visits had ids.",
          "type": [
            "string",
            "null"
          ]
        },
        "started_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        },
        "landing_url": {
          "description": "The full address the visit landed on, query included.",
          "type": [
            "string",
            "null"
          ]
        },
        "referrer": {
          "description": "The outside site that sent the visitor, when there was one.",
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": "string",
          "description": "utm_source, else the network an ad-click id names (gclid: google), else the referring site, else direct."
        },
        "medium": {
          "type": "string",
          "description": "utm_medium, else cpc for an ad click, referral or (none)."
        },
        "campaign": {
          "type": [
            "string",
            "null"
          ]
        },
        "term": {
          "type": [
            "string",
            "null"
          ]
        },
        "content": {
          "type": [
            "string",
            "null"
          ]
        },
        "utm": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        },
        "click_ids": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          },
          "description": "gclid, gbraid, wbraid, dclid, fbclid, msclkid, li_fat_id, ttclid, twclid, epik, rdt_cid, sccid, qclid, yclid, irclickid."
        },
        "other_params": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          },
          "description": "gclsrc, gad_source, gad_campaignid, HubSpot hsa_*, mc_cid, ref, via."
        },
        "device": {
          "description": "desktop, mobile or tablet.",
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "type": [
            "string",
            "null"
          ]
        },
        "region": {
          "type": [
            "string",
            "null"
          ]
        },
        "city": {
          "type": [
            "string",
            "null"
          ]
        },
        "backfilled": {
          "type": "boolean",
          "description": "A first arrival reconstructed from before visits were recorded: no click ids, no landing page."
        }
      },
      "required": [
        "visit_id",
        "started_at",
        "landing_url",
        "referrer",
        "source",
        "medium",
        "campaign",
        "term",
        "content",
        "utm",
        "click_ids",
        "other_params",
        "device",
        "country",
        "region",
        "city",
        "backfilled"
      ]
    }
  }
}