{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/popp/json-schema/popp-start-workflow-runs-response-schema.json",
  "title": "StartWorkflowRunsResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/popp-workflows-api-openapi.yml#/components/schemas/StartWorkflowRunsResponse",
  "type": "object",
  "properties": {
    "summary": {
      "type": "object",
      "title": "Summary",
      "description": "Counts for every entry in the request. `received` is the sum of the other four. `errors`, `alreadyEnrolled` and `duplicatesInRequest` list the entries not counted in `queued`.",
      "properties": {
        "received": {
          "type": "integer",
          "minimum": 0,
          "title": "Received",
          "description": "Total input entries across candidateProfileIds, candidateProfileExternalIds, and contacts."
        },
        "queued": {
          "type": "integer",
          "minimum": 0,
          "title": "Queued",
          "description": "Entries accepted for enrolment."
        },
        "alreadyEnrolled": {
          "type": "integer",
          "minimum": 0,
          "title": "Already Enrolled",
          "description": "Entries skipped because the candidate already has a run for this workflow."
        },
        "duplicatesInRequest": {
          "type": "integer",
          "minimum": 0,
          "title": "Duplicates In Request",
          "description": "Entries skipped because an earlier entry in the same request already covered the same contact."
        },
        "rejected": {
          "type": "integer",
          "minimum": 0,
          "title": "Rejected",
          "description": "Entries Popp rejected. `errors` gives each reason."
        }
      },
      "required": [
        "received",
        "queued",
        "alreadyEnrolled",
        "duplicatesInRequest",
        "rejected"
      ],
      "additionalProperties": false
    },
    "queued": {
      "type": "integer",
      "minimum": 0,
      "title": "Queued",
      "description": "Same as `summary.queued`."
    },
    "errors": {
      "type": [
        "array",
        "null"
      ],
      "title": "Errors",
      "description": "Entries Popp rejected, or `null` when there are none.",
      "items": {
        "type": "object",
        "properties": {
          "candidateProfileId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "title": "Candidate Profile ID",
            "description": "Candidate profile identifier, when one could be resolved before the failure."
          },
          "contactIndex": {
            "type": [
              "integer",
              "null"
            ],
            "title": "Contact Index",
            "description": "Zero-based index of the offending entry in the input `contacts[]` array, when applicable."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "title": "Email",
            "description": "Email of the offending contact, when applicable."
          },
          "phoneNumber": {
            "type": [
              "string",
              "null"
            ],
            "title": "Phone Number",
            "description": "Phone number of the offending contact, when applicable."
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ],
            "title": "External ID",
            "description": "External identifier of the offending entry, when applicable."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "INVALID_CONTACT_FIELDS",
              "INVALID_EXTERNAL_ID_FORMAT",
              "EXTERNAL_ID_CONFLICT",
              "EXTERNAL_ID_NOT_FOUND",
              "ENQUEUE_FAILED"
            ],
            "title": "Reason",
            "description": "Machine-readable rejection reason. Pair with `error` for the human-readable explanation."
          },
          "error": {
            "type": "string",
            "title": "Error",
            "description": "Human-readable explanation of why this entry could not be enrolled."
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      }
    },
    "alreadyEnrolled": {
      "type": [
        "array",
        "null"
      ],
      "title": "Already Enrolled",
      "description": "Entries skipped because the candidate already has a run for this workflow. `null` when none were skipped for this reason.",
      "items": {
        "type": "object",
        "properties": {
          "candidateProfileId": {
            "type": "string",
            "format": "uuid",
            "title": "Candidate Profile ID",
            "description": "Candidate profile already enrolled in this workflow."
          },
          "contactIndex": {
            "type": [
              "integer",
              "null"
            ],
            "title": "Contact Index",
            "description": "Zero-based index of the entry in the input `contacts[]` array, when applicable."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "title": "Email",
            "description": "Email of the contact, when applicable."
          },
          "phoneNumber": {
            "type": [
              "string",
              "null"
            ],
            "title": "Phone Number",
            "description": "Phone number of the contact, when applicable."
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ],
            "title": "External ID",
            "description": "External identifier of the entry, when applicable."
          },
          "existingRunId": {
            "type": "string",
            "format": "uuid",
            "title": "Existing Run ID",
            "description": "Identifier of the run the candidate is already enrolled in."
          },
          "existingRunStatus": {
            "type": "string",
            "enum": [
              "RUNNING",
              "COMPLETED",
              "FAILED",
              "CANCELLED"
            ],
            "title": "Existing Run Status",
            "description": "Status of the existing run."
          }
        },
        "required": [
          "candidateProfileId",
          "existingRunId",
          "existingRunStatus"
        ],
        "additionalProperties": false
      }
    },
    "duplicatesInRequest": {
      "type": [
        "array",
        "null"
      ],
      "title": "Duplicates In Request",
      "description": "Entries skipped because an earlier entry in the same request already covered the same contact. `null` when the request had no in-request duplicates.",
      "items": {
        "type": "object",
        "properties": {
          "contactIndex": {
            "type": "integer",
            "title": "Contact Index",
            "description": "Zero-based index of the duplicate entry in the input."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "title": "Email",
            "description": "Email of the duplicate contact, when applicable."
          },
          "phoneNumber": {
            "type": [
              "string",
              "null"
            ],
            "title": "Phone Number",
            "description": "Phone number of the duplicate contact, when applicable."
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ],
            "title": "External ID",
            "description": "External identifier of the duplicate entry, when applicable."
          },
          "firstSeenAtIndex": {
            "type": "integer",
            "title": "First Seen At Index",
            "description": "Index of the earlier entry that first covered this contact and was accepted."
          }
        },
        "required": [
          "contactIndex",
          "firstSeenAtIndex"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "summary",
    "queued"
  ],
  "additionalProperties": false
}