{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dpf-it-com/json-schema/dpf-it-com-get-triggers-response-schema.json",
  "title": "GetTriggersResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dpf-it-com-job-triggers-api-openapi.yml#/components/schemas/GetTriggersResponse",
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean"
    },
    "data": {
      "type": "object",
      "properties": {
        "triggers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/JobTrigger"
          }
        },
        "count": {
          "type": "integer"
        }
      }
    }
  },
  "$defs": {
    "JobTrigger": {
      "type": "object",
      "description": "A workspace ingestion trigger. `preCode`/`postCode` are the JavaScript\ngenerated from `preRules`/`postRules`; they are read-only (regenerated when\nthe rules change) and are always included in responses.\n\n`spec_success` triggers fire when another spec's job completes successfully\n(`upstreamSpecId`/`upstreamSpecName`) instead of polling a connection — they\nhave no `connectionId`/`frequency`/`preRules`/`postRules`/s3 fields. `schedule`\ntriggers fire a spec directly on a plain cron-like schedule (`frequency`,\nsame as sftp/aws_s3) with no connection and no upstream spec. Both\n`spec_success` and `schedule` require the trigger's own `specId`/`specName`\n(the spec fired) to be a table-source (`sourceType: 'tables'`) or compaction\n(`sourceType: 'compaction'`) spec, since neither supplies a new file for a\nfile-source spec to load — a table-source spec re-runs its generated query,\nwindowed to rows since its last successful run, and a compaction spec re-compacts\nits tables, so both are just different ways to decide *when* to re-run them.\n",
      "properties": {
        "triggerId": {
          "type": "string",
          "format": "uuid"
        },
        "workspaceId": {
          "type": "string",
          "format": "uuid"
        },
        "type": {
          "type": "string",
          "enum": [
            "sftp",
            "aws_s3",
            "spec_success",
            "schedule"
          ]
        },
        "specId": {
          "type": "string",
          "format": "uuid",
          "description": "The (downstream) spec this trigger fires."
        },
        "specName": {
          "type": "string"
        },
        "connectionId": {
          "type": "string",
          "format": "uuid",
          "description": "sftp/aws_s3 only."
        },
        "s3Bucket": {
          "type": "string",
          "description": "aws_s3 only, required for that type. The bucket this trigger polls."
        },
        "s3Prefix": {
          "type": "string",
          "description": "aws_s3 only. Optional key prefix; defaults to the whole bucket."
        },
        "upstreamSpecId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid",
          "description": "spec_success only — the spec whose successful job completion fires this trigger."
        },
        "upstreamSpecName": {
          "type": [
            "string",
            "null"
          ],
          "description": "spec_success only — denormalized name of upstreamSpecId, for display."
        },
        "frequency": {
          "$ref": "#/$defs/TriggerFrequency"
        },
        "preRules": {
          "type": "string",
          "description": "Natural-language \"which files to process\" prompt (may be empty)."
        },
        "postRules": {
          "type": "string",
          "description": "Natural-language \"what to do after upload\" prompt (may be empty)."
        },
        "preCode": {
          "type": "string",
          "description": "Generated body of async selectFiles(files, ctx). Read-only."
        },
        "postCode": {
          "type": "string",
          "description": "Generated body of async postProcess(sftp, files, ctx). Read-only."
        },
        "dedupe": {
          "type": "boolean",
          "description": "Skip files already loaded into this spec (per-spec, matched by file name)."
        },
        "enabled": {
          "type": "boolean"
        },
        "createdBy": {
          "type": "string",
          "format": "uuid"
        },
        "createdAt": {
          "type": "integer",
          "format": "int64",
          "description": "Unix timestamp in milliseconds"
        },
        "updatedAt": {
          "type": "integer",
          "format": "int64",
          "description": "Unix timestamp in milliseconds"
        },
        "lastRunAt": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int64",
          "description": "Unix timestamp in milliseconds of the last run (absent if never run)."
        },
        "lastRunStatus": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "running",
            "success",
            "failed",
            "no-files",
            null
          ]
        },
        "lastJobId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "create-trigger only, aws_s3 only. Advisory notes about the created trigger — currently just the 5000-object S3 listing cap. Absent on get/update/delete responses and on other types."
        }
      }
    },
    "TriggerFrequency": {
      "type": "object",
      "description": "Polling cadence, evaluated in UTC by the hourly dispatcher.\n`hourOfDay` is required for `daily`/`monthly`; `dayOfMonth` for `monthly`.\n",
      "required": [
        "unit"
      ],
      "properties": {
        "unit": {
          "type": "string",
          "enum": [
            "hourly",
            "daily",
            "monthly"
          ]
        },
        "hourOfDay": {
          "type": "integer",
          "minimum": 0,
          "maximum": 23,
          "description": "Hour of day (UTC). Required for daily and monthly."
        },
        "dayOfMonth": {
          "type": "integer",
          "minimum": 1,
          "maximum": 31,
          "description": "Day of month. Required for monthly."
        }
      }
    }
  }
}