{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/rivery/main/json-schema/rivery-river-activity-run-schema.json",
  "title": "RiverActivityRun",
  "description": "A run",
  "x-generated": "2026-10-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rivery-openapi.json#/components/schemas/RiverActivityRun",
  "properties": {
    "run_id": {
      "type": "string",
      "title": "Run Id",
      "description": "The run ID"
    },
    "river_cross_id": {
      "type": "string",
      "title": "River Cross Id",
      "description": "The river cross ID"
    },
    "datasource_id": {
      "type": "string",
      "title": "Datasource Id",
      "description": "The datasource ID"
    },
    "error_description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error Description",
      "description": "The error description if any"
    },
    "units": {
      "type": "number",
      "title": "Units",
      "description": "Total RPU (units)"
    },
    "rpu": {
      "type": "number",
      "title": "Rpu",
      "description": "Total RPU"
    },
    "run_group_id": {
      "type": "string",
      "title": "Run Group Id",
      "description": "The run group id"
    },
    "status": {
      "$ref": "#/$defs/ActivityStatusEnum"
    },
    "source_name": {
      "type": "string",
      "title": "Source Name",
      "description": "The name of the source"
    },
    "target_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Target Name",
      "description": "The target table name"
    },
    "start_date_utc": {
      "type": "string",
      "format": "date-time",
      "title": "Start Date Utc",
      "description": "The start date time in UTC timezone.Time format YYYY-MM-DDThh:mm:ss.ms"
    },
    "start_date_in_milliseconds": {
      "type": "integer",
      "title": "Start Date In Milliseconds",
      "description": "The start epoch in milliseconds."
    },
    "end_date_utc": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "End Date Utc",
      "description": "The end date time in UTC timezone.Time format YYYY-MM-DDThh:mm:ss.ms"
    },
    "end_date_in_milliseconds": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "End Date In Milliseconds",
      "description": "The end epoch in milliseconds."
    },
    "sub_river_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Sub River Id",
      "description": "The sub river id"
    },
    "is_sub_river_run": {
      "type": "boolean",
      "title": "Is Sub River Run",
      "description": "A flag that indicates whether this run is of a sub river or not"
    },
    "is_high_frequency": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Is High Frequency",
      "description": "A flag that indicates whether this run is high frequency or not",
      "default": false
    },
    "pricing_category": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Pricing Category",
      "description": "The RPU policy rule object for calculating an RPU"
    },
    "trigger_name": {
      "anyOf": [
        {
          "$ref": "#/$defs/TriggerName"
        },
        {
          "type": "null"
        }
      ],
      "description": "The mechanism that started the run. Empty for runs of an account that does not track triggers"
    },
    "triggered_by_run_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Triggered By Run Id",
      "description": "The run that triggered this one. Empty when the run is the root of its tree"
    },
    "trigger_chain": {
      "anyOf": [
        {
          "$ref": "#/$defs/TriggerChain"
        },
        {
          "type": "null"
        }
      ],
      "description": "The trigger events leading back to the act that started the whole run tree, oldest first"
    }
  },
  "type": "object",
  "required": [
    "run_id",
    "river_cross_id",
    "datasource_id",
    "error_description",
    "units",
    "rpu",
    "run_group_id",
    "status",
    "source_name",
    "start_date_utc",
    "start_date_in_milliseconds",
    "end_date_utc",
    "end_date_in_milliseconds",
    "is_sub_river_run"
  ],
  "$defs": {
    "ActivityStatusEnum": {
      "type": "string",
      "enum": [
        "pending",
        "canceled",
        "succeeded",
        "failed",
        "running",
        "skipped"
      ],
      "title": "ActivityStatusEnum",
      "description": "The external status of a run (being used in the api)"
    },
    "TriggerChain": {
      "items": {
        "$ref": "#/$defs/TriggerEvent"
      },
      "type": "array",
      "title": "TriggerChain",
      "description": "The trigger events leading back to the act that started the whole run tree, oldest first.\n\nSerializes as a bare list. Whoever triggers a run appends its own event and ships the\nwhole chain, so every run's row is self contained and the tree reconstructs without joins."
    },
    "TriggerEvent": {
      "properties": {
        "trigger_name": {
          "allOf": [
            {
              "$ref": "#/$defs/TriggerName"
            }
          ],
          "description": "The mechanism that performed this trigger"
        },
        "run_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Run Id",
          "description": "The run that performed this trigger, empty at the root"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "trigger_name"
      ],
      "title": "TriggerEvent",
      "description": "One act of triggering: the mechanism, and the run that performed it.\n\n``run_id`` is empty for the first event of a chain, where a person, a cron or an API\nclient performed the act and no upstream run exists."
    },
    "TriggerName": {
      "type": "string",
      "enum": [
        "ui",
        "api",
        "scheduled",
        "rescheduled",
        "logic"
      ],
      "title": "TriggerName",
      "description": "The mechanism that started a river run"
    }
  }
}