{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/simple-ai/json-schema/simple-ai-journey-enroll-request-schema.json",
  "title": "Enroll in Journey Request",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/simple-ai-openapi.json#/components/schemas/JourneyEnrollRequest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "idempotencyKey",
    "contact"
  ],
  "properties": {
    "idempotencyKey": {
      "type": "string",
      "maxLength": 255,
      "description": "Your key for this enrollment, such as a lead or appointment id. Sending it again returns the same enrollment."
    },
    "externalId": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "description": "Another id to cancel by later. Defaults to idempotencyKey. It is also used as the contact's external id when the contact is created or updated."
    },
    "contact": {
      "description": "An existing contact by id, or contact details that are created or updated by phone number.",
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "contactId"
          ],
          "properties": {
            "contactId": {
              "type": "string",
              "format": "uuid",
              "description": "The contact's id."
            }
          },
          "title": "Existing contact"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "phoneNumber"
          ],
          "properties": {
            "phoneNumber": {
              "type": "string",
              "description": "The contact's phone number, ideally in E.164 format."
            },
            "name": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The contact's name."
            },
            "email": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "email"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The contact's email address."
            },
            "timezone": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The contact's IANA time zone, such as America/Chicago. Used for calling hours ahead of the address or area code."
            },
            "attributes": {
              "type": "object",
              "additionalProperties": true,
              "description": "Contact fields to set."
            }
          },
          "title": "Contact details"
        }
      ]
    },
    "subject": {
      "type": "object",
      "additionalProperties": true,
      "description": "The record this enrollment is about, such as an appointment. The journey's conditions and texts can read these fields, and calls receive them."
    },
    "params": {
      "type": "object",
      "additionalProperties": true,
      "description": "Extra parameters passed to every call the journey places for this enrollment. They are also merged into subject."
    },
    "subjectKey": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "description": "Identifies the subject. Defaults to idempotencyKey."
    },
    "anchorAt": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "description": "The date the journey's steps are timed from, in ISO 8601 with an offset. Overrides the anchor the journey would read from subject."
    },
    "notBefore": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "description": "The earliest time the first call or text may go out. Null means as soon as calling hours allow."
    }
  }
}