{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/popp/json-schema/popp-bulk-create-conversations-input-schema.json",
  "title": "BulkCreateConversationsInput",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/popp-conversations-api-openapi.yml#/components/schemas/BulkCreateConversationsInput",
  "type": "object",
  "properties": {
    "campaignId": {
      "type": "string",
      "title": "Campaign ID",
      "description": "The unique identifier for the campaign."
    },
    "externalCampaignId": {
      "type": "string",
      "title": "External Campaign ID",
      "description": "The unique identifier for the campaign in the external system."
    },
    "shouldSendDuringBusinessHours": {
      "type": "boolean",
      "title": "Should Send During Business Hours",
      "description": "Whether to send messages during business hours. Applies to all contacts in the batch. The timezone is inferred from each contact's phone number."
    },
    "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. Applies to all contacts in the batch.",
      "default": false
    },
    "contacts": {
      "type": "array",
      "title": "Contacts",
      "description": "Array of contacts to create conversations for.",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "pattern": "^\\+[1-9]\\d{1,14}$",
            "title": "Phone Number",
            "description": "The phone number of the contact, 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."
          },
          "countryCode": {
            "type": "string",
            "title": "Country Code",
            "description": "The country code in ISO 3166-1 alpha-2 format."
          },
          "firstName": {
            "type": "string",
            "title": "First Name",
            "description": "The first name of the contact."
          },
          "lastName": {
            "type": "string",
            "title": "Last Name",
            "description": "The last name of the contact."
          },
          "emailAddress": {
            "type": "string",
            "title": "Email Address",
            "description": "The email address of the contact. For SMS and WHATSAPP campaigns, an email-only contact is accepted only when the campaign's email fallback resolves to enabled; otherwise the contact is rejected."
          },
          "externalId": {
            "type": "string",
            "title": "External ID",
            "description": "The unique identifier for the conversation in the external system."
          },
          "applicationSource": {
            "type": "string",
            "title": "Application Source",
            "description": "The source where the application was submitted from."
          },
          "closePreviousConversations": {
            "type": "boolean",
            "title": "Close Previous Conversations",
            "description": "When true, closes all ongoing conversations with the same contact identifier across ALL CAMPAIGNS before creating the new conversation.",
            "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."
          },
          "additionalContext": {
            "type": "string",
            "minLength": 1,
            "title": "Additional Context",
            "description": "Custom context to provide to the AI agent for this specific conversation."
          },
          "calendarMeetingTemplateId": {
            "type": "string",
            "title": "Calendar Meeting Template ID",
            "description": "The calendar meeting template identifier."
          }
        },
        "required": [
          "firstName"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "contacts"
  ],
  "oneOf": [
    {
      "title": "Campaign ID Required",
      "required": [
        "campaignId"
      ]
    },
    {
      "title": "External Campaign ID Required",
      "required": [
        "externalCampaignId"
      ]
    }
  ],
  "additionalProperties": false
}