{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/popp/json-schema/popp-create-conversation-input-schema.json",
  "title": "CreateConversationInput",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/popp-conversations-api-openapi.yml#/components/schemas/CreateConversationInput",
  "type": "object",
  "properties": {
    "phoneNumber": {
      "type": "string",
      "pattern": "^\\+[1-9]\\d{1,14}$",
      "title": "Phone Number",
      "description": "The phone number of the candidate, in E.164 format. For SMS and WHATSAPP campaigns, required unless the campaign's email fallback resolves to enabled (emailChannelFallbackEnabled on the campaign, inheriting the organization setting when unset) and an emailAddress is provided."
    },
    "shouldSendDuringBusinessHours": {
      "type": "boolean",
      "title": "Should Send During Business Hours",
      "description": "Whether to send the message during business hours. The timezone is inferred from the phone number."
    },
    "countryCode": {
      "type": "string",
      "title": "Country Code",
      "description": "The country code in ISO 3166-1 alpha-2 format. This is used to format the phone number if it is not in E.164 format."
    },
    "firstName": {
      "type": "string",
      "title": "First Name",
      "description": "The first name of the candidate."
    },
    "lastName": {
      "type": "string",
      "title": "Last Name",
      "description": "The last name of the candidate."
    },
    "emailAddress": {
      "type": "string",
      "title": "Email Address",
      "description": "The email address of the candidate. Required for EMAIL channel campaigns. For SMS and WHATSAPP campaigns, an email-only request is accepted only when the campaign's email fallback resolves to enabled; otherwise the request is rejected with 400."
    },
    "campaignId": {
      "type": "string",
      "title": "Campaign ID",
      "description": "The unique identifier for the campaign."
    },
    "externalId": {
      "type": "string",
      "title": "External ID",
      "description": "The unique identifier for the conversation in the external system."
    },
    "externalCampaignId": {
      "type": "string",
      "title": "External Campaign ID",
      "description": "The unique identifier for the campaign in the external system."
    },
    "applicationSource": {
      "type": "string",
      "title": "Application Source",
      "description": "The source where the application was submitted from (e.g., 'careers-page', 'job-board', 'referral')."
    },
    "skipDuplicationCheck": {
      "type": "boolean",
      "title": "Skip Duplication Check",
      "description": "When true, closes ongoing conversation with the same phone number/email in the SAME CAMPAIGN, then creates a new one. Use for re-engaging a candidate within the same campaign. Note: queuing behavior is still respected if conversations exist in other campaigns.",
      "default": false
    },
    "closePreviousConversations": {
      "type": "boolean",
      "title": "Close Previous Conversations",
      "description": "When true, closes all ongoing conversations (CREATED, QUEUED, ONGOING) with the same contact identifier (phone number for SMS/WhatsApp, email address for Email) and channel across ALL CAMPAIGNS before creating the new conversation. This completely disables queuing behavior. Applies to SMS, WhatsApp, and Email channels.",
      "default": false
    },
    "openingMessage": {
      "type": "string",
      "maxLength": 600,
      "title": "Opening Message",
      "description": "A custom opening message that overrides the campaign's default opening message. Must be 600 characters or less. Additional validation: For SMS campaigns, must include the 'STOP' keyword (uppercase) for opt-out compliance. Not supported for WhatsApp campaigns (will return 400 error)."
    },
    "additionalContext": {
      "type": "string",
      "minLength": 1,
      "title": "Additional Context",
      "description": "Custom context to provide to the AI agent for this specific conversation. This context is used alongside campaign-level and organization-level context when generating replies. Useful for passing candidate-specific information that should influence the conversation."
    }
  },
  "required": [
    "firstName"
  ],
  "oneOf": [
    {
      "title": "Campaign ID Required",
      "description": "Either campaignId or externalCampaignId is required.",
      "required": [
        "campaignId"
      ]
    },
    {
      "title": "External Campaign ID Required",
      "description": "Either externalCampaignId or campaignId is required.",
      "required": [
        "externalCampaignId"
      ]
    }
  ],
  "additionalProperties": false
}