{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/samva-dev/json-schema/samva-dev-journey-run-page-schema.json",
  "title": "JourneyRunPage",
  "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/JourneyRunPage",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/JourneyRun"
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "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
    },
    "JourneyRun": {
      "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"
            }
          ]
        }
      },
      "required": [
        "id",
        "journeyId",
        "version",
        "contactId",
        "status",
        "exitReason",
        "failureReason",
        "currentNodeId",
        "holdReason",
        "holdUntil",
        "trigger",
        "enteredAt",
        "endedAt"
      ],
      "additionalProperties": false
    },
    "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"
      ]
    },
    "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"
          }
        }
      ]
    }
  }
}