{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/talktohumans-app/json-schema/talktohumans-app-create-message-draft-request-schema.json",
  "title": "CreateMessageDraftRequest",
  "description": "Provide exactly one target: `conversation_id` or `contact_id`. Provide exactly one of `draft_message` (with or without `attachments`), `steps`, `template_id`, `connection_request`, or `clear`.\n",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/talktohumans-app-openapi.yml#/components/schemas/CreateMessageDraftRequest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "account_id"
  ],
  "oneOf": [
    {
      "required": [
        "conversation_id"
      ]
    },
    {
      "required": [
        "contact_id"
      ]
    }
  ],
  "properties": {
    "account_id": {
      "type": "string",
      "description": "LinkedIn account ID returned by `GET /v1/accounts`.",
      "pattern": "^[1-9][0-9]*$"
    },
    "conversation_id": {
      "type": "string",
      "minLength": 1,
      "description": "Existing conversation ID returned by `GET /v1/conversations`. Provide exactly one target."
    },
    "contact_id": {
      "type": "string",
      "pattern": "^[1-9][0-9]*$",
      "description": "Contact ID returned by `GET /v1/contacts` or a contact import's results. Provide exactly one target."
    },
    "draft_message": {
      "type": "string",
      "minLength": 1,
      "description": "Plain-text draft. Surrounding whitespace is trimmed and the existing draft for the selected compose context is replaced. Provide exactly one of `draft_message`, `steps`, `template_id`, `connection_request`, or `clear`."
    },
    "attachments": {
      "type": "array",
      "minItems": 1,
      "description": "Files the `draft_message` sends, in order, each written as `{\"file_id\": ...}` from `POST /v1/files`. Can stand without `draft_message`, like a voice message. A message carries up to 20 MB of files and one audio file; InMail carries none. Sequence steps carry their own attachments.",
      "items": {
        "$ref": "#/$defs/LinkedInFile"
      }
    },
    "steps": {
      "type": "array",
      "minItems": 1,
      "description": "Ordered sequence steps staged in the conversation for the user to launch in TalkToHumans. Provide exactly one of `draft_message`, `steps`, `template_id`, `connection_request`, or `clear`.",
      "items": {
        "$ref": "#/$defs/TemplateStep"
      }
    },
    "template_id": {
      "type": "string",
      "minLength": 1,
      "description": "Template ID returned by `GET /v1/templates`. Writes the draft from a message or sequence template. Provide exactly one of `draft_message`, `steps`, `template_id`, `connection_request`, or `clear`."
    },
    "connection_request": {
      "$ref": "#/$defs/ConnectionRequestDraft"
    },
    "clear": {
      "type": "boolean",
      "description": "Set to `true` to delete the draft of the selected conversation or contact instead of writing one. Succeeds when there is no draft. Provide exactly one of `draft_message`, `steps`, `template_id`, `connection_request`, or `clear`."
    },
    "variables": {
      "type": "object",
      "description": "Values for the template's own `{{key}}` variables, keyed by variable key. Only with `template_id`.\nVariables can be left unfilled by omitting them or passing an empty value; they stay in the draft for the user to fill in TalkToHumans. Keys the template does not use return `400 bad_request` listing them.\n",
      "additionalProperties": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "ConnectionRequestDraft": {
      "type": "object",
      "additionalProperties": false,
      "description": "A connection request drafted on its own, without a sequence. The user sends it with the Connect button in TalkToHumans. Send `{}` for an invite without a note.",
      "properties": {
        "note": {
          "type": "string",
          "maxLength": 200,
          "description": "Optional invitation note. Contact variables such as `{{first_name}}` are filled when it is sent."
        }
      }
    },
    "LinkedInFile": {
      "type": "object",
      "additionalProperties": false,
      "description": "An uploaded file. Writes read only `file_id`.",
      "required": [
        "file_id"
      ],
      "properties": {
        "file_id": {
          "type": "string",
          "description": "File ID returned by `POST /v1/files`."
        },
        "kind": {
          "type": "string",
          "description": "`file` is a PDF.",
          "enum": [
            "image",
            "video",
            "audio",
            "file"
          ]
        },
        "file_name": {
          "type": "string"
        },
        "mime_type": {
          "type": "string"
        },
        "size_bytes": {
          "type": "integer"
        },
        "duration_ms": {
          "type": "integer",
          "description": "Length of a video or audio file in milliseconds, when known."
        },
        "width": {
          "type": "integer"
        },
        "height": {
          "type": "integer"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Link to open the file, valid for an hour."
        }
      }
    },
    "TemplateStep": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "delay_minutes"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "message",
            "connection_request"
          ]
        },
        "delay_minutes": {
          "type": "integer",
          "minimum": 0,
          "description": "Minutes to wait after the previous step, or after launch for the first step."
        },
        "content": {
          "type": "string",
          "description": "Plain-text message, required for message steps without attachments. For connection requests, the optional note, up to 200 characters."
        },
        "attachments": {
          "type": "array",
          "description": "Files a message step sends, in order, each written as `{\"file_id\": ...}` from `POST /v1/files`. Reads also give each file's details and a link to open it. Writing steps replaces their attachments too, so keep the ones to send. Message steps only.",
          "items": {
            "$ref": "#/$defs/LinkedInFile"
          }
        }
      }
    }
  }
}