{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/postlake-dev/json-schema/postlake-dev-conversation-schema.json",
  "title": "Conversation",
  "description": "A direct-message thread. inboxAccount names the connected profile receiving messages and sending replies, so callers never infer it from account.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/postlake-dev-messages-api-openapi.yml#/components/schemas/Conversation",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "platform": {
      "type": "string"
    },
    "account": {
      "type": "string"
    },
    "inboxAccount": {
      "allOf": [
        {
          "$ref": "#/$defs/InboxAccountIdentity"
        }
      ],
      "nullable": true
    },
    "participants": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SocialActor"
      }
    },
    "lastMessage": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "text": {
          "type": "string"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "fromMe": {
          "type": "boolean"
        },
        "content": {
          "$ref": "#/$defs/MessageContent"
        }
      }
    },
    "unreadCount": {
      "type": "integer"
    }
  },
  "$defs": {
    "InboxAccountIdentity": {
      "type": "object",
      "description": "The connected profile that receives this conversation and sends its replies.",
      "properties": {
        "id": {
          "type": "string"
        },
        "handle": {
          "type": "string"
        },
        "displayName": {
          "type": [
            "string",
            "null"
          ]
        },
        "avatarUrl": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "handle",
        "displayName",
        "avatarUrl"
      ]
    },
    "MessageContent": {
      "type": "object",
      "description": "A meaningful non-text direct-message payload. This is present for attachments, shared media, and message types the network does not expose in readable form. Do not treat an empty text field with this object as an empty message.",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "attachment",
            "shared_media",
            "unsupported"
          ]
        },
        "label": {
          "type": "string"
        },
        "url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "Provider URL when available. Null means the provider withheld a destination."
        }
      },
      "required": [
        "kind",
        "label",
        "url"
      ]
    },
    "SocialActor": {
      "type": "object",
      "properties": {
        "handle": {
          "type": "string"
        },
        "displayName": {
          "type": [
            "string",
            "null"
          ]
        },
        "avatarUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "id": {
          "type": [
            "string",
            "null"
          ],
          "description": "The network's own id, for follow/block/mute"
        }
      }
    }
  }
}