{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mvp-cc.local/contracts/events/ivr.completed.json",
  "title": "ivr.completed",
  "type": "object",
  "required": ["event_type", "call_id", "payload"],
  "properties": {
    "event_type": {
      "const": "ivr.completed"
    },
    "call_id": {
      "type": "string",
      "minLength": 1
    },
    "interaction_id": {
      "type": ["string", "null"]
    },
    "payload": {
      "type": "object",
      "required": ["session_id", "flow_id", "outcome_code", "resolved_queue_id", "digits", "terminal_node_id"],
      "properties": {
        "session_id": {
          "type": "string",
          "minLength": 1
        },
        "flow_id": {
          "type": "string",
          "minLength": 1
        },
        "outcome_code": {
          "type": "string",
          "minLength": 1
        },
        "resolved_queue_id": {
          "type": "string",
          "minLength": 1
        },
        "digits": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9]$"
          }
        },
        "terminal_node_id": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
