{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/samva-dev/json-schema/samva-dev-journey-run-detail-schema.json",
  "title": "JourneyRunDetail",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/samva-dev-journeys-api-openapi.yml#/components/schemas/JourneyRunDetail",
  "type": "object",
  "properties": {
    "id": {
      "$ref": "#/$defs/JourneyRunId"
    },
    "journeyId": {
      "$ref": "#/$defs/JourneyId"
    },
    "version": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "contactId": {
      "$ref": "#/$defs/ContactId"
    },
    "status": {
      "$ref": "#/$defs/JourneyRunStatus"
    },
    "exitReason": {
      "anyOf": [
        {
          "$ref": "#/$defs/JourneyRunExitReason"
        },
        {
          "type": "null"
        }
      ]
    },
    "failureReason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "currentNodeId": {
      "anyOf": [
        {
          "$ref": "#/$defs/JourneyNodeId"
        },
        {
          "type": "null"
        }
      ]
    },
    "holdReason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "holdUntil": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "trigger": {
      "$ref": "#/$defs/JourneyRunTrigger"
    },
    "enteredAt": {
      "type": "string"
    },
    "endedAt": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/JourneyRunStep"
      }
    }
  },
  "required": [
    "id",
    "journeyId",
    "version",
    "contactId",
    "status",
    "exitReason",
    "failureReason",
    "currentNodeId",
    "holdReason",
    "holdUntil",
    "trigger",
    "enteredAt",
    "endedAt",
    "steps"
  ],
  "additionalProperties": false,
  "$defs": {
    "ContactId": {
      "type": "string",
      "pattern": "^contact_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "ContactId"
    },
    "JourneyId": {
      "type": "string",
      "pattern": "^jrny_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "JourneyId"
    },
    "JourneyNodeId": {
      "type": "string",
      "minLength": 1
    },
    "JourneyRunExitReason": {
      "type": "string",
      "enum": [
        "completed",
        "goal",
        "archived"
      ]
    },
    "JourneyRunId": {
      "type": "string",
      "pattern": "^jrun_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "JourneyRunId"
    },
    "JourneyRunStatus": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "exited",
        "failed"
      ]
    },
    "JourneyRunStep": {
      "type": "object",
      "properties": {
        "nodeId": {
          "$ref": "#/$defs/JourneyNodeId"
        },
        "type": {
          "type": "string"
        },
        "enteredAt": {
          "type": "string"
        },
        "completedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "outcome": {
          "anyOf": [
            {
              "$ref": "#/$defs/JourneyRunStepOutcome"
            },
            {
              "type": "null"
            }
          ]
        },
        "nextNodeId": {
          "anyOf": [
            {
              "$ref": "#/$defs/JourneyNodeId"
            },
            {
              "type": "null"
            }
          ]
        },
        "messageId": {
          "anyOf": [
            {
              "$ref": "#/$defs/MessageId"
            },
            {
              "type": "null"
            }
          ]
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "nodeId",
        "type",
        "enteredAt",
        "completedAt",
        "outcome",
        "nextNodeId",
        "messageId",
        "error"
      ],
      "additionalProperties": false
    },
    "JourneyRunStepOutcome": {
      "type": "string",
      "enum": [
        "completed",
        "matched",
        "timed_out",
        "goal",
        "archived",
        "failed"
      ]
    },
    "JourneyRunTrigger": {
      "type": "object",
      "properties": {
        "eventId": {
          "type": "string"
        },
        "eventName": {
          "type": "string"
        },
        "properties": {
          "$ref": "#/$defs/JsonObject"
        }
      },
      "required": [
        "eventId",
        "eventName",
        "properties"
      ],
      "additionalProperties": false
    },
    "JsonObject": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      }
    },
    "JsonValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/JsonValue"
          }
        },
        {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/JsonValue"
          }
        }
      ]
    },
    "MessageId": {
      "type": "string",
      "pattern": "^msg_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "MessageId"
    }
  }
}