{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sendraven-ai/json-schema/sendraven-ai-thread-schema.json",
  "title": "Thread",
  "description": "A conversation, joined on Message-ID headers, never on subject.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sendraven-ai-threads-api-openapi.yml#/components/schemas/Thread",
  "type": "object",
  "required": [
    "id",
    "subject",
    "participants",
    "message_count",
    "tags",
    "awaiting_reply",
    "pending_reply",
    "handled_at",
    "last_message_at",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "subject": {
      "type": "string",
      "description": "The first message's subject with any leading Re:, Fwd: or Fw: removed."
    },
    "participants": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Every address seen on the thread, lowercased."
    },
    "message_count": {
      "type": "integer",
      "minimum": 0,
      "description": "Sent messages once the provider accepted them, plus received messages. Held drafts, unsent scheduled messages and failed sends are not counted but do appear in the transcript."
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "value"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      },
      "description": "The tags passed on every message sent on this thread, each pair once, as the sender wrote them. Received mail adds none. [] when none."
    },
    "awaiting_reply": {
      "type": "boolean",
      "description": "True when the latest counted message came from outside. A received message sets it; a sent message or POST /v1/threads/{id}/handled clears it. Automated mail (bounces, out-of-office) leaves it unchanged. It clears when a reply is sent, not while one is held for approval or scheduled; see pending_reply."
    },
    "pending_reply": {
      "type": "boolean",
      "description": "True when a message written on this thread after the latest received message has not been sent yet: held for approval or scheduled. awaiting_reply stays true until it goes, so a thread with both true already has its answer on the way; draft one only when awaiting_reply is true and pending_reply false. Automated received mail is ignored here too."
    },
    "handled_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the thread was last marked handled. Not cleared when new mail arrives."
    },
    "last_message_at": {
      "type": "string",
      "format": "date-time",
      "description": "Time of the latest counted message (a received message's own Date header, which the sender controls). The list is sorted by this."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  }
}