{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/politicalcomms-com/json-schema/politicalcomms-com-conversation-schema.json",
  "title": "Conversation",
  "description": "One thread between one of the organization's sending numbers and one contact. Created by a project send (broadcast, survey, or test); never by the API.",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/politicalcomms-com-openapi.json#/components/schemas/Conversation",
  "type": "object",
  "properties": {
    "conversation_id": {
      "type": "string",
      "format": "uuid"
    },
    "project_id": {
      "type": "string",
      "format": "uuid"
    },
    "from": {
      "type": "string",
      "description": "The organization's sending number (E.164). Every reply goes out from this number."
    },
    "to": {
      "type": "string",
      "description": "The contact's number (E.164)."
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "inactive",
        "opted_out"
      ]
    },
    "opted_out": {
      "type": "boolean",
      "description": "True once the contact replied STOP. Replies to an opted-out thread are refused with `409 CONTACT_OPTED_OUT`."
    },
    "is_test": {
      "type": "boolean"
    },
    "contact": {
      "type": "object",
      "properties": {
        "phone_number": {
          "type": "string"
        }
      },
      "required": [
        "phone_number"
      ],
      "additionalProperties": true
    },
    "inbound_messages": {
      "type": "integer"
    },
    "outbound_messages": {
      "type": "integer"
    },
    "first_message_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_inbound_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the contact last texted in. The list endpoint sorts and filters on this."
    },
    "last_outbound_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "conversation_id",
    "project_id",
    "from",
    "to",
    "status",
    "opted_out",
    "is_test",
    "contact",
    "inbound_messages",
    "outbound_messages",
    "created_at"
  ],
  "additionalProperties": true
}