{
  "openapi": "3.0.0",
  "info": {
    "title": "Job Management API",
    "version": "1",
    "description": "Export VisitReport participants to a file, track background jobs, and request cancellation of jobs or workflow groups."
  },
  "servers": [
    {
      "url": "https://backend.snapaddy.com/job-management"
    }
  ],
  "paths": {
    "/jobs/vr-download": {
      "post": {
        "operationId": "VRDownloadJobController_createVRDownloadJob",
        "summary": "Create a VisitReport file export",
        "description": "Queue a file export for one event. Send an empty participantIds array with no filter to export every non-deleted participant. To export selected leads, supply their participant IDs. Use the returned job ID to check its state.",
        "parameters": [],
        "responses": {
          "201": {
            "description": "Details of the created VisitReport download job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VRDownloadJobResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "In case of invalid or unprocessable data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VRDownloadJobPostRequestDto"
              },
              "example": {
                "questionnaireId": "ExampleEvent0001",
                "participantIds": [
                  "ExamplePerson001"
                ],
                "downloadType": "EXCEL"
              }
            }
          }
        }
      }
    },
    "/jobs/vr-download/{id}/result": {
      "get": {
        "operationId": "VRDownloadJobController_getVRDownloadResultById",
        "summary": "Get the export download link",
        "description": "After the export completes, retrieve the signed URL from the JSON response and download the file in a separate request.",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Unique UUIDv4 identifier of the requested job.",
            "schema": {
              "type": "string",
              "example": "33333333-3333-4333-8333-333333333333"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Contains the signed URL to download the result file.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VRDownloadJobResultResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "In case either the job has not been completed yet or the provided job id does not belong to a VisitReport download job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          },
          "403": {
            "description": "The account cannot access the requested job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          },
          "404": {
            "description": "In case the job with the provided id was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          },
          "410": {
            "description": "In case the user attempts to download a job result of a job which is older than 30 days.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/jobs/vr-download/{id}": {
      "delete": {
        "operationId": "VRDownloadJobController_deleteVRDownloadJob",
        "summary": "Delete an export and its result",
        "description": "Delete a VisitReport export job and its stored result file.",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Unique UUIDv4 identifier of the requested job.",
            "schema": {
              "type": "string",
              "example": "33333333-3333-4333-8333-333333333333"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "VisitReport download job successfully deleted."
          },
          "400": {
            "description": "In case either the provided job id does not belong to a VisitReport download job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          },
          "403": {
            "description": "The account cannot access the requested job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          },
          "404": {
            "description": "In case the job with the provided id was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/jobs": {
      "get": {
        "operationId": "JobManagementController_getJobs",
        "summary": "List your recent jobs",
        "description": "List jobs submitted by your account in the current organization. The default time range covers the last 30 days.",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Amount of items that should be fetched at once.\n    - Default: 50.\n    - Maximum:  1000. ",
            "schema": {
              "minimum": 1,
              "maximum": 1000,
              "default": 50,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Amount of items that should be skipped, defaults to 0.",
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "description": "Type of the job.",
            "schema": {
              "type": "string",
              "enum": [
                "data_enrichment",
                "vr_download",
                "workflow",
                "digital_card",
                "crm_inventory_data_download"
              ]
            }
          },
          {
            "name": "state",
            "required": false,
            "in": "query",
            "description": "State of the job.",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "canceled",
                "completed",
                "failed",
                "waiting"
              ]
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "description": "Optional parameter for defining the start of the timespan of jobs to show. Defaults to 30 days ago.",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Optional parameter for defining the timespan of jobs to show. Defaults to now.",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns a list of recent jobs of a user (back to 30 days ago if not specified otherwise).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/DataEnrichmentJobResponseDto"
                      },
                      {
                        "$ref": "#/components/schemas/VRDownloadJobResponseDto"
                      },
                      {
                        "$ref": "#/components/schemas/WorkflowJobResponseDto"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/jobs/{id}": {
      "get": {
        "operationId": "getJobById",
        "summary": "Get a job and its status",
        "description": "Returns the details of an existing job matching the given id.",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Unique UUIDv4 identifier of the requested job.",
            "schema": {
              "type": "string",
              "example": "33333333-3333-4333-8333-333333333333"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Details of the requested job.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/DataEnrichmentJobResponseDto"
                    },
                    {
                      "$ref": "#/components/schemas/VRDownloadJobResponseDto"
                    },
                    {
                      "$ref": "#/components/schemas/WorkflowJobResponseDto"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The account cannot access the requested job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          },
          "404": {
            "description": "In case the job with the provided id was not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      },
      "delete": {
        "operationId": "JobManagementController_cancelJob",
        "summary": "Request job cancellation",
        "description": "Requests the cancellation of a job matching the given id.",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Unique UUIDv4 identifier of the requested job.",
            "schema": {
              "type": "string",
              "example": "33333333-3333-4333-8333-333333333333"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The cancellation was requested, or the job was already being canceled or has finished."
          },
          "403": {
            "description": "The account cannot cancel this job."
          },
          "404": {
            "description": "In case the job with provided id was not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorArrayException"
                }
              }
            }
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/jobs/groups": {
      "get": {
        "operationId": "JobGroupController_getJobGroups",
        "summary": "List workflow job groups",
        "description": "Get workflow job group progress for the current organization.",
        "parameters": [
          {
            "name": "groupType",
            "required": false,
            "in": "query",
            "description": "Type of grouped jobs to return. If not specified, returns all types.",
            "schema": {
              "type": "string",
              "enum": [
                "default",
                "dataagents_excel_upload",
                "lead_scoring"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Aggregated progress entries for job groups of the current organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetJobGroupsSearchResponseDto"
                }
              }
            }
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/jobs/groups/{groupId}/status": {
      "get": {
        "operationId": "JobGroupController_getJobGroup",
        "summary": "Get job group status",
        "description": "Get the status of a single job group.",
        "parameters": [
          {
            "name": "groupId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string",
              "example": "33333333-3333-4333-8333-333333333333"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status of the requested job group.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobGroupsStatusResponseDto"
                }
              }
            }
          },
          "403": {
            "description": "Your account lacks access to this operation."
          },
          "404": {
            "description": "Job group not found."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/jobs/groups/{groupId}": {
      "delete": {
        "operationId": "JobGroupController_cancelJobGroup",
        "summary": "Request job group cancellation",
        "description": "Requests cancellation of every active or waiting job in a job group. The request is recorded for all of these jobs at once, so either all or none are marked. Each job then stops on its own, a waiting job right away and a running job before its next workflow step.",
        "parameters": [
          {
            "name": "groupId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string",
              "example": "33333333-3333-4333-8333-333333333333"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The cancellation was requested, or the group was already being canceled or has no active or waiting jobs."
          },
          "403": {
            "description": "The account cannot cancel this job group."
          },
          "404": {
            "description": "Job group not found."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "VRDownloadJobResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the job (UUIDv4)."
          },
          "type": {
            "type": "string",
            "description": "Type of the job.",
            "enum": [
              "data_enrichment",
              "vr_download",
              "workflow",
              "digital_card",
              "crm_inventory_data_download"
            ]
          },
          "state": {
            "type": "string",
            "description": "Current lifecycle state of the job.",
            "enum": [
              "active",
              "canceled",
              "completed",
              "failed",
              "waiting"
            ],
            "default": "waiting"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was created."
          },
          "lastUpdatedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was last updated."
          },
          "processedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was processed."
          },
          "finishedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was completed, failed, or canceled."
          },
          "cancellationRequested": {
            "type": "boolean",
            "description": "Whether or not the worker was requested to cancel processing the job",
            "default": false
          },
          "canceledByUserId": {
            "type": "string",
            "description": "Unique identifier of the user who requested cancellation.",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "description": "Unique identifier of the organization the job belongs to"
          },
          "userId": {
            "type": "string",
            "description": "Unique identifier of the user the job belongs to",
            "nullable": true
          },
          "data": {
            "description": "Data that was passed to the VisitReport download job worker to process the job.",
            "allOf": [
              {
                "$ref": "#/components/schemas/VRDownloadJobDataPostResponseDto"
              }
            ]
          },
          "returnValue": {
            "description": "Result of the vCard download job.",
            "allOf": [
              {
                "$ref": "#/components/schemas/VRDownloadJobReturnValueResponseDto"
              }
            ]
          },
          "failedReason": {
            "type": "string",
            "description": "Probably the error of the vCard download job, if failed",
            "nullable": true
          },
          "downloadType": {
            "type": "string",
            "description": "Type of the download."
          },
          "progress": {
            "description": "Current progress of the vr download job.",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/VRDownloadJobProgressDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "type",
          "state",
          "createdAt",
          "lastUpdatedAt",
          "cancellationRequested",
          "canceledByUserId",
          "organizationId",
          "userId",
          "data",
          "returnValue",
          "downloadType",
          "progress"
        ],
        "title": "VisitReport export job"
      },
      "VRDownloadJobDataPostResponseDto": {
        "type": "object",
        "properties": {
          "participantIds": {
            "description": "Array of unique identifiers of participants whose data should get downloaded.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "defaultLanguage": {
            "type": "string",
            "description": "Default language of the questionnaire",
            "default": "en"
          },
          "titles": {
            "type": "object",
            "properties": {
              "af": {
                "type": "string"
              },
              "be": {
                "type": "string"
              },
              "bg": {
                "type": "string"
              },
              "bs": {
                "type": "string"
              },
              "ca": {
                "type": "string"
              },
              "cnr": {
                "type": "string"
              },
              "cs": {
                "type": "string"
              },
              "da": {
                "type": "string"
              },
              "de": {
                "type": "string"
              },
              "el": {
                "type": "string"
              },
              "en": {
                "type": "string"
              },
              "es": {
                "type": "string"
              },
              "es-sa": {
                "type": "string"
              },
              "et": {
                "type": "string"
              },
              "fi": {
                "type": "string"
              },
              "fr": {
                "type": "string"
              },
              "hi": {
                "type": "string"
              },
              "hr": {
                "type": "string"
              },
              "hu": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "is": {
                "type": "string"
              },
              "it": {
                "type": "string"
              },
              "ja": {
                "type": "string"
              },
              "kk": {
                "type": "string"
              },
              "ko": {
                "type": "string"
              },
              "lb": {
                "type": "string"
              },
              "lt": {
                "type": "string"
              },
              "lv": {
                "type": "string"
              },
              "mk": {
                "type": "string"
              },
              "mt": {
                "type": "string"
              },
              "nl": {
                "type": "string"
              },
              "no": {
                "type": "string"
              },
              "pl": {
                "type": "string"
              },
              "pt": {
                "type": "string"
              },
              "pt-sa": {
                "type": "string"
              },
              "ro": {
                "type": "string"
              },
              "ru": {
                "type": "string"
              },
              "sk": {
                "type": "string"
              },
              "sl": {
                "type": "string"
              },
              "sq": {
                "type": "string"
              },
              "sr": {
                "type": "string"
              },
              "sv": {
                "type": "string"
              },
              "th": {
                "type": "string"
              },
              "tr": {
                "type": "string"
              },
              "uk": {
                "type": "string"
              },
              "vi": {
                "type": "string"
              },
              "zh-Hans": {
                "type": "string"
              },
              "zh-Hant": {
                "type": "string"
              }
            },
            "description": "Title of the questionnaire in different languages. Maps title-locales to their corresponding i18n-values.",
            "default": {}
          },
          "questionnaireId": {
            "type": "string",
            "description": "Unique identifier of the questionnaire the participants who's data will be processed belong to."
          },
          "downloadType": {
            "type": "string",
            "description": "Type of the download."
          }
        },
        "required": [
          "participantIds",
          "defaultLanguage",
          "titles",
          "questionnaireId",
          "downloadType"
        ],
        "title": "VR Download Job Data Post Response"
      },
      "VRDownloadJobReturnValueResponseDto": {
        "type": "object",
        "properties": {
          "resultDownloadUrl": {
            "type": "string",
            "description": "URL to download the result in case the job completed successfully."
          },
          "totalQuantity": {
            "type": "number",
            "description": "Total quantity of participants to be downloaded."
          },
          "errors": {
            "description": "If this array contains any elements there occurred some errors while processing the given input which means that the job might have partially failed for at least some participants.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VRDownloadJobRowErrorResponseDto"
            }
          },
          "successQuantity": {
            "type": "number",
            "description": "Quantity of reports that where successfully processed."
          }
        },
        "required": [
          "totalQuantity",
          "successQuantity"
        ],
        "title": "VR Download Job Return Value Response"
      },
      "VRDownloadJobRowErrorResponseDto": {
        "type": "object",
        "properties": {
          "participantId": {
            "type": "string",
            "description": "Encoded participant identifier of the input data where the error occurred."
          },
          "message": {
            "type": "string",
            "description": "Message of the error.",
            "enum": [
              "UNABLE_TO_CONVERT_DATA",
              "UNABLE_TO_GET_PARTICIPANT_DATA",
              "UNABLE_TO_GET_ATTACHMENTS",
              "UNABLE_TO_GET_REPORT",
              "VR_DOWNLOAD_DEFAULT_ERROR_MESSAGE"
            ]
          }
        },
        "required": [
          "participantId",
          "message"
        ],
        "title": "VR Download Job Row Error Response"
      },
      "VRDownloadJobProgressDto": {
        "type": "object",
        "properties": {
          "progress": {
            "type": "number",
            "description": "The progress as number between 0 and 1 representing the completion percentage"
          },
          "processedRows": {
            "type": "number",
            "description": "The number of currently processed contacts/reports"
          },
          "totalQuantity": {
            "type": "number",
            "description": "The number of total contacts/reports supposed to be processed"
          },
          "estimatedRemainingSeconds": {
            "type": "number",
            "description": "The estimated number of seconds remaining until completion of the job"
          }
        },
        "required": [
          "progress",
          "processedRows",
          "totalQuantity",
          "estimatedRemainingSeconds"
        ],
        "title": "VR Download Job Progress"
      },
      "ErrorArrayException": {
        "type": "object",
        "properties": {}
      },
      "VRDownloadJobPostRequestDto": {
        "type": "object",
        "properties": {
          "participantIds": {
            "description": "Array of unique identifiers of participants whose data should be processed. If you want to get all (or some restricted by filters) participants of a certain questionnaire this needs to be undefined or empty.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "questionnaireId": {
            "type": "string",
            "description": "Unique identifier of questionnaire which the participants belong to."
          },
          "language": {
            "type": "string",
            "description": "Language of the user session."
          },
          "order": {
            "description": "Array of order objects, each containing a field name and sort direction by which the reports should be ordered.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParticipantOrderDto"
            }
          },
          "filter": {
            "description": "Object that contains filter information. This includes a possible search string or other custom filters for columns of a report.",
            "allOf": [
              {
                "$ref": "#/components/schemas/ParticipantFilterDto"
              }
            ]
          },
          "downloadType": {
            "type": "string",
            "description": "Type of the download."
          },
          "timezone": {
            "type": "string",
            "description": "Optional timezone override for report generation. If omitted, the questionnaire timezone is used."
          },
          "documentStrategy": {
            "type": "string",
            "description": "Optional enum indicating the strategy to use when merging documents. If not provided, the default strategy will be used.",
            "default": "individual",
            "enum": [
              "individual",
              "merged"
            ]
          }
        },
        "required": [
          "questionnaireId",
          "downloadType"
        ],
        "title": "VR Download Job Post Request"
      },
      "ParticipantOrderDto": {
        "type": "object",
        "properties": {
          "fieldName": {
            "type": "string",
            "description": "Name of the field or column that should be used for ordering."
          },
          "sortDirection": {
            "type": "string",
            "default": "DESC",
            "description": "Direction in which the ordering should be made.",
            "enum": [
              "ASC",
              "DESC"
            ]
          }
        },
        "required": [
          "fieldName",
          "sortDirection"
        ],
        "title": "Participant Order"
      },
      "ParticipantFilterDto": {
        "type": "object",
        "properties": {
          "search": {
            "type": "string",
            "description": "String value which will be used for the search to filter the participants."
          },
          "customFilters": {
            "description": "Array of objects containing filter key, values array, type of the optional id (in case of a question)",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomFilterDto"
            }
          }
        },
        "title": "Participant Filter"
      },
      "CustomFilterDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Key of a column."
          },
          "id": {
            "type": "string",
            "description": "Optional encoded id of the filter column (e.g. in case of a question filter)"
          },
          "values": {
            "description": "Array containing the different values which will suite the filter.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "type": {
            "type": "string",
            "description": "Type of the column or contact value."
          }
        },
        "required": [
          "key",
          "values",
          "type"
        ],
        "title": "Custom Filter"
      },
      "VRDownloadJobResultResponseDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Signed download URL of the result file."
          }
        },
        "required": [
          "url"
        ],
        "title": "VR Download Job Result Response"
      },
      "DataEnrichmentJobResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the job (UUIDv4)."
          },
          "type": {
            "type": "string",
            "description": "Type of the job.",
            "enum": [
              "data_enrichment",
              "vr_download",
              "workflow",
              "digital_card",
              "crm_inventory_data_download"
            ]
          },
          "state": {
            "type": "string",
            "description": "Current lifecycle state of the job.",
            "enum": [
              "active",
              "canceled",
              "completed",
              "failed",
              "waiting"
            ],
            "default": "waiting"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was created."
          },
          "lastUpdatedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was last updated."
          },
          "processedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was processed."
          },
          "finishedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was completed, failed, or canceled."
          },
          "cancellationRequested": {
            "type": "boolean",
            "description": "Whether or not the worker was requested to cancel processing the job",
            "default": false
          },
          "canceledByUserId": {
            "type": "string",
            "description": "Unique identifier of the user who requested cancellation.",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "description": "Unique identifier of the organization the job belongs to"
          },
          "userId": {
            "type": "string",
            "description": "Unique identifier of the user the job belongs to",
            "nullable": true
          },
          "data": {
            "description": "Data that was passed to the data enrichment job worker to process the job.",
            "allOf": [
              {
                "$ref": "#/components/schemas/DataEnrichmentJobDataResponseDto"
              }
            ]
          },
          "returnValue": {
            "description": "Result of the data enrichment job.",
            "allOf": [
              {
                "$ref": "#/components/schemas/DataEnrichmentJobReturnValueResponseDto"
              }
            ]
          },
          "failedReason": {
            "type": "string",
            "description": "Probably the error of the enrichment job, if failed",
            "nullable": true
          },
          "progress": {
            "description": "Current progress of the data enrichment job.",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/DataEnrichmentJobProgressDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "type",
          "state",
          "createdAt",
          "lastUpdatedAt",
          "cancellationRequested",
          "canceledByUserId",
          "organizationId",
          "userId",
          "data",
          "failedReason",
          "progress"
        ],
        "title": "Data Enrichment Job Response"
      },
      "DataEnrichmentJobDataResponseDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (most certainly a filename) of the job"
          },
          "strategy": {
            "type": "string",
            "description": "Defines whether to use company data search or email finder to enrich the input data",
            "default": "COMPANY_DATA_SEARCH",
            "enum": [
              "COMPANY_DATA_SEARCH",
              "EMAIL_FINDER"
            ]
          },
          "numRequests": {
            "type": "number",
            "description": "Amount of credits that were charged for the job. Note: the amount can change after the job has finished because we do only charge successfully enriched data rows but lock the amount of credits beforehand."
          }
        },
        "required": [
          "name",
          "strategy",
          "numRequests"
        ],
        "title": "Data Enrichment Job Data Response"
      },
      "DataEnrichmentJobReturnValueResponseDto": {
        "type": "object",
        "properties": {
          "resultDownloadUrl": {
            "type": "string",
            "description": "URL to download the result in case the job completed successfully."
          },
          "totalRows": {
            "type": "number",
            "description": "Total count of rows of the input file (excluding header)"
          },
          "successRows": {
            "type": "number",
            "description": "Rows that where successfully processed."
          },
          "errors": {
            "description": "If this array contains any elements there occurred some errors while processing the given input file which means that the job might have partially failed for at least some records.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DataEnrichmentRowErrorResponseDto"
            }
          }
        },
        "required": [
          "totalRows",
          "successRows"
        ],
        "title": "Data Enrichment Job Return Value Response"
      },
      "DataEnrichmentRowErrorResponseDto": {
        "type": "object",
        "properties": {
          "row": {
            "type": "number",
            "description": "Row number within the input excel file where the error occurred."
          },
          "message": {
            "type": "string",
            "description": "Message of the error.",
            "enum": [
              "EMAIL_PATTERN_NOT_FOUND",
              "INVALID_INPUT_DATA",
              "UNKNOWN_ERROR"
            ]
          }
        },
        "required": [
          "row",
          "message"
        ],
        "title": "Data Enrichment Row Error Response"
      },
      "DataEnrichmentJobProgressDto": {
        "type": "object",
        "properties": {
          "progress": {
            "type": "number",
            "description": "The progress as number between 0 and 1 representing the completion percentage"
          },
          "processedRows": {
            "type": "number",
            "description": "The number of currently processed rows"
          },
          "totalRows": {
            "type": "number",
            "description": "The number of total rows supposed to be processed"
          },
          "estimatedRemainingSeconds": {
            "type": "number",
            "description": "The estimated number of seconds remaining until completion of the job"
          }
        },
        "required": [
          "progress",
          "processedRows",
          "totalRows",
          "estimatedRemainingSeconds"
        ],
        "title": "Data Enrichment Job Progress"
      },
      "WorkflowJobResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the job (UUIDv4)."
          },
          "type": {
            "type": "string",
            "description": "Type of the job.",
            "enum": [
              "data_enrichment",
              "vr_download",
              "workflow",
              "digital_card",
              "crm_inventory_data_download"
            ]
          },
          "state": {
            "type": "string",
            "description": "Current lifecycle state of the job.",
            "enum": [
              "active",
              "canceled",
              "completed",
              "failed",
              "waiting"
            ],
            "default": "waiting"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was created."
          },
          "lastUpdatedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was last updated."
          },
          "processedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was processed."
          },
          "finishedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date on which the job was completed, failed, or canceled."
          },
          "cancellationRequested": {
            "type": "boolean",
            "description": "Whether or not the worker was requested to cancel processing the job",
            "default": false
          },
          "canceledByUserId": {
            "type": "string",
            "description": "Unique identifier of the user who requested cancellation.",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "description": "Unique identifier of the organization the job belongs to"
          },
          "userId": {
            "type": "string",
            "description": "Unique identifier of the user the job belongs to",
            "nullable": true
          },
          "data": {
            "description": "Data that was passed to the workflow job worker to process the job.",
            "allOf": [
              {
                "$ref": "#/components/schemas/WorkflowJobDataResponseDto"
              }
            ]
          },
          "returnValue": {
            "description": "Result of the workflow job.",
            "allOf": [
              {
                "$ref": "#/components/schemas/EmptyReturnValueResponseDto"
              }
            ]
          },
          "failedReason": {
            "type": "string",
            "description": "The error of the workflow job, if failed",
            "nullable": true
          },
          "progress": {
            "description": "The progress information of the job",
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/WorkflowJobProgressDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "type",
          "state",
          "createdAt",
          "lastUpdatedAt",
          "cancellationRequested",
          "canceledByUserId",
          "organizationId",
          "userId",
          "data",
          "returnValue",
          "failedReason",
          "progress"
        ],
        "title": "Workflow run"
      },
      "WorkflowJobDataResponseDto": {
        "type": "object",
        "properties": {
          "trigger": {
            "type": "string",
            "description": "The trigger that caused this workflow job to be executed"
          },
          "data": {
            "type": "object",
            "description": " The data that was passed to the workflow job. This depends on the configured workflow and can be different depending on the customers needs. We have some predefined workflows where the structure is always the same (email-via-webhook, suggestion-accept) but we also support arbitrary workflows where we don't know what the data looks like. ",
            "nullable": true,
            "additionalProperties": true
          },
          "groupIndex": {
            "type": "number",
            "description": " Group index assigned to this workflow job within the grouped upload. Only set for workflow jobs created with a job group. "
          }
        },
        "required": [
          "trigger",
          "data"
        ],
        "title": "Workflow Job Data Response"
      },
      "EmptyReturnValueResponseDto": {
        "type": "object",
        "properties": {},
        "title": "Empty Return Value Response"
      },
      "WorkflowJobProgressDto": {
        "type": "object",
        "properties": {
          "progress": {
            "type": "number",
            "description": " Always 0 for workflow jobs because we can't determine how long it will take / how many nodes will be executed while the workflow is running. "
          }
        },
        "required": [
          "progress"
        ],
        "title": "Workflow Job Progress"
      },
      "GetJobGroupsSearchResponseDto": {
        "type": "object",
        "properties": {
          "groups": {
            "description": "List of job groups with their progress data.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JobGroupsSearchResponseDto"
            }
          }
        },
        "required": [
          "groups"
        ],
        "title": "Get Job Groups Search Response"
      },
      "JobGroupsSearchResponseDto": {
        "type": "object",
        "properties": {
          "canCancel": {
            "type": "boolean",
            "description": "Whether the current user can request cancellation."
          },
          "groupId": {
            "type": "string",
            "description": "Group id for grouped workflow jobs."
          },
          "groupName": {
            "type": "string",
            "description": "Display name of the job group (for example, a filename or custom label)."
          },
          "groupType": {
            "type": "string",
            "description": "Type of the job group.",
            "enum": [
              "default",
              "dataagents_excel_upload",
              "lead_scoring"
            ]
          },
          "current": {
            "type": "number",
            "description": "Amount of processed jobs in this group."
          },
          "total": {
            "type": "number",
            "description": "Total amount of jobs in this group."
          },
          "errors": {
            "type": "number",
            "description": "Amount of failed jobs in this group."
          },
          "state": {
            "type": "string",
            "description": "Current aggregate state of this group.",
            "enum": [
              "canceled",
              "canceling",
              "finished",
              "finished_with_errors",
              "pending",
              "running"
            ]
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Creation date of the earliest job in this group."
          }
        },
        "required": [
          "canCancel",
          "groupId",
          "groupName",
          "groupType",
          "current",
          "total",
          "errors",
          "state",
          "createdAt"
        ],
        "title": "Job Groups Search Response"
      },
      "JobGroupsStatusResponseDto": {
        "type": "object",
        "properties": {
          "canCancel": {
            "type": "boolean",
            "description": "Whether the current user can request cancellation."
          },
          "groupId": {
            "type": "string",
            "description": "Group id for grouped workflow jobs."
          },
          "groupType": {
            "type": "string",
            "description": "Type of the job group.",
            "enum": [
              "default",
              "dataagents_excel_upload",
              "lead_scoring"
            ]
          },
          "current": {
            "type": "number",
            "description": "Amount of processed jobs in this group."
          },
          "total": {
            "type": "number",
            "description": "Total amount of jobs in this group."
          },
          "errors": {
            "type": "number",
            "description": "Amount of failed jobs in this group."
          },
          "state": {
            "type": "string",
            "description": "Current aggregate state of this group.",
            "enum": [
              "canceled",
              "canceling",
              "finished",
              "finished_with_errors",
              "pending",
              "running"
            ]
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Creation date of the earliest job in this group."
          }
        },
        "required": [
          "canCancel",
          "groupId",
          "groupType",
          "current",
          "total",
          "errors",
          "state",
          "createdAt"
        ],
        "title": "Job Groups Status Response"
      }
    },
    "securitySchemes": {
      "x-api-key": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Use a [personal API token](/authentication/#personal-api-token)."
      }
    }
  }
}
