{
  "openapi": "3.0.1",
  "info": {
    "title": "Apify Run Monitor - Failed Run Alerts to Slack & Email",
    "description": "Scheduled health check for your Apify Actors and tasks: alerts on FAILED, TIMED-OUT or ABORTED runs, runs that never started, missed schedules, empty datasets, cost spikes and success-rate drops via Slack, Discord, Telegram, e-mail or webhook. Daily digest and HTML report.",
    "version": "0.1",
    "x-build-id": "PKLxd2NrK1hPDcbRn"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/gazidev~apify-run-monitor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-gazidev-apify-run-monitor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/gazidev~apify-run-monitor/runs": {
      "post": {
        "operationId": "runs-sync-gazidev-apify-run-monitor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/gazidev~apify-run-monitor/run-sync": {
      "post": {
        "operationId": "run-sync-gazidev-apify-run-monitor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "apifyToken": {
            "title": "Apify API token",
            "type": "string",
            "description": "Your personal API token (Console > Settings > API & Integrations), stored encrypted and never logged or sent anywhere except api.apify.com. A scoped token with read access to Actors, Actor runs, datasets and schedules is enough. Leave empty to use this run's own token: with the default limited permissions it usually sees only this run's own resources, so the check would find nothing."
          },
          "actorIds": {
            "title": "Actors to monitor",
            "type": "array",
            "description": "Actor IDs, `username/actor-name` or Console URLs. Empty = all runs in your account (all Actors and tasks you ran, including Store Actors).",
            "items": {
              "type": "string"
            }
          },
          "taskIds": {
            "title": "Tasks to monitor",
            "type": "array",
            "description": "Saved task IDs or Console task URLs. Empty = no task filter.",
            "items": {
              "type": "string"
            }
          },
          "lookbackHours": {
            "title": "Look back (hours)",
            "minimum": 1,
            "maximum": 2160,
            "type": "integer",
            "description": "Runs started in this window are checked. Use the schedule interval or more (e.g. 24 for a daily check); already-alerted findings are not repeated.",
            "default": 24
          },
          "excludeOrigins": {
            "title": "Ignore runs started from",
            "type": "array",
            "description": "E.g. ignore manual Console runs and only watch scheduled / API production runs.",
            "items": {
              "type": "string",
              "enum": [
                "DEVELOPMENT",
                "WEB",
                "API",
                "CLI",
                "SCHEDULER",
                "WEBHOOK",
                "ACTOR",
                "STANDBY"
              ],
              "enumTitles": [
                "Development (Web IDE)",
                "Console (manual)",
                "API",
                "CLI",
                "Schedule",
                "Webhook",
                "Another Actor",
                "Standby"
              ]
            }
          },
          "maxRuns": {
            "title": "Max runs to scan",
            "minimum": 50,
            "type": "integer",
            "description": "Safety cap for very busy accounts.",
            "default": 3000
          },
          "alertOnAborted": {
            "title": "Alert on ABORTED runs",
            "type": "boolean",
            "description": "FAILED and TIMED-OUT runs are always reported.",
            "default": true
          },
          "minItems": {
            "title": "Minimum dataset items",
            "minimum": 0,
            "type": "integer",
            "description": "SUCCEEDED runs whose default dataset has fewer items are reported (0 items = critical). Catches scrapers that silently return nothing.",
            "default": 1
          },
          "maxCostUsd": {
            "title": "Max cost per run (USD)",
            "type": "string",
            "description": "Report any run that cost more than this, e.g. `0.50`. 0 = off.",
            "default": "0"
          },
          "costSpikeFactor": {
            "title": "Cost spike factor",
            "minimum": 0,
            "type": "integer",
            "description": "Report a run that cost N times the median of the same Actor's successful runs in the window (needs 3+ runs, ignores differences under $0.01). 0 = off.",
            "default": 3
          },
          "maxDurationMin": {
            "title": "Max run duration (minutes)",
            "minimum": 0,
            "type": "integer",
            "description": "Report runs that took longer, including runs still RUNNING. 0 = off.",
            "default": 0
          },
          "notStartedAfterMin": {
            "title": "Not started after (minutes)",
            "minimum": 0,
            "type": "integer",
            "description": "Report runs stuck in READY (never started - usually the account memory limit or no credit). 0 = off.",
            "default": 15
          },
          "minSuccessRate": {
            "title": "Minimum success rate (%)",
            "minimum": 0,
            "maximum": 100,
            "type": "integer",
            "description": "Report an Actor/task whose share of SUCCEEDED runs in the window is below this, e.g. 80. 0 = off.",
            "default": 0
          },
          "minRunsForSuccessRate": {
            "title": "Runs needed for success rate",
            "minimum": 1,
            "type": "integer",
            "description": "Success rate is only judged with at least this many finished runs.",
            "default": 3
          },
          "expectedEveryHours": {
            "title": "Expect a run every N hours (missed schedule)",
            "minimum": 0,
            "type": "integer",
            "description": "Report Actors/tasks with no run started in the last N hours. Applies to the listed Actors/tasks, or - when the lists are empty - to every target of your enabled schedules. 0 = off.",
            "default": 0
          },
          "slackWebhookUrl": {
            "title": "Slack incoming webhook URL",
            "type": "string",
            "description": "https://hooks.slack.com/services/... Nothing is sent unless you fill in a channel."
          },
          "discordWebhookUrl": {
            "title": "Discord webhook URL",
            "type": "string",
            "description": "https://discord.com/api/webhooks/..."
          },
          "telegramBotToken": {
            "title": "Telegram bot token",
            "type": "string",
            "description": "From @BotFather (123456:ABC...). Send /start to your bot first."
          },
          "telegramChatId": {
            "title": "Telegram chat ID",
            "type": "string",
            "description": "Your user, group or channel chat ID."
          },
          "webhookUrl": {
            "title": "Webhook URL (JSON POST)",
            "type": "string",
            "description": "Receives {subject, text, summary, findings[]} - for Make, Zapier, n8n, PagerDuty/Opsgenie bridges or your own endpoint."
          },
          "webhookAuthHeader": {
            "title": "Webhook Authorization header",
            "type": "string",
            "description": "Optional, e.g. `Bearer abc123`."
          },
          "emailTo": {
            "title": "E-mail recipients",
            "type": "array",
            "description": "Requires the SMTP settings below.",
            "items": {
              "type": "string"
            }
          },
          "smtpHost": {
            "title": "SMTP host",
            "type": "string",
            "description": "E.g. smtp.gmail.com, smtp.office365.com, smtp.sendgrid.net."
          },
          "smtpPort": {
            "title": "SMTP port",
            "type": "integer",
            "description": "587 (STARTTLS) or 465 (SSL).",
            "default": 587
          },
          "smtpSecurity": {
            "title": "SMTP security",
            "enum": [
              "starttls",
              "ssl"
            ],
            "type": "string",
            "description": "Match the port: STARTTLS for 587, SSL for 465.",
            "default": "starttls"
          },
          "smtpUser": {
            "title": "SMTP username",
            "type": "string",
            "description": "Usually your full e-mail address."
          },
          "smtpPassword": {
            "title": "SMTP password / app password",
            "type": "string",
            "description": "For Gmail/Outlook use an app password."
          },
          "emailFrom": {
            "title": "From address",
            "type": "string",
            "description": "Defaults to the SMTP username."
          },
          "alertMinSeverity": {
            "title": "Alert on",
            "enum": [
              "info",
              "warning",
              "critical"
            ],
            "type": "string",
            "description": "Critical: failed, timed-out, missed schedule, empty dataset, low success rate. Warning: aborted, not started, slow, cost, low item count.",
            "default": "warning"
          },
          "onlyNewFindings": {
            "title": "Alert only on new findings",
            "type": "boolean",
            "description": "Remember what was already alerted (per state key, 30 days) so an hourly schedule does not repeat the same failed run.",
            "default": true
          },
          "digestOnly": {
            "title": "Digest mode",
            "type": "boolean",
            "description": "Send one summary message every run - per-Actor runs, success rate, cost and all issues - even when everything is healthy. Schedule it daily for a morning report.",
            "default": false
          },
          "maxFindingsPerMessage": {
            "title": "Max findings per message",
            "minimum": 1,
            "type": "integer",
            "description": "Longer lists are cut; the dataset and REPORT always have all findings.",
            "default": 20
          },
          "dryRun": {
            "title": "Dry run (do not send)",
            "type": "boolean",
            "description": "Build the alert and save it to the ALERT_PREVIEW record instead of sending it.",
            "default": false
          },
          "includeSummaryRows": {
            "title": "Add per-Actor summary rows",
            "type": "boolean",
            "description": "One extra dataset row per Actor/task with runs, success rate and cost.",
            "default": true
          },
          "stateKey": {
            "title": "State key",
            "type": "string",
            "description": "Separate alert memory for different monitors (e.g. one per client).",
            "default": "default"
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}