{
  "openapi": "3.0.1",
  "info": {
    "title": "Cumulative Spending Monitor",
    "version": "0.0",
    "x-build-id": "UdEBSIqabzmOU97Dy"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/tri_angle~cumulative-spending-monitor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-tri_angle-cumulative-spending-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/tri_angle~cumulative-spending-monitor/runs": {
      "post": {
        "operationId": "runs-sync-tri_angle-cumulative-spending-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/tri_angle~cumulative-spending-monitor/run-sync": {
      "post": {
        "operationId": "run-sync-tri_angle-cumulative-spending-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",
        "required": [
          "periods"
        ],
        "properties": {
          "periods": {
            "title": "Monitoring Periods",
            "minItems": 1,
            "type": "array",
            "description": "Define one or more time periods to monitor spending. Each period can have its own spending threshold and will be tracked independently.",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "title": "Period Label",
                  "description": "A friendly name to identify this period in reports and notifications (e.g., \"Daily Morning Check\", \"Monthly Billing\").",
                  "type": "string",
                  "editor": "textfield"
                },
                "period": {
                  "title": "Time Period",
                  "description": "Specify \"billing\" to track your Apify billing cycle, or use 24-hour time format (e.g., \"09:00\", \"18:30\") to monitor a rolling 24-hour window starting at that time (UTC). Each time-based period covers 24 hours from the specified start time.",
                  "type": "string",
                  "editor": "textfield",
                  "pattern": "^(([0-1][0-9]|2[0-3]):[0-5][0-9]|billing)$"
                },
                "thresholdUsd": {
                  "title": "Spending Threshold (USD)",
                  "description": "The maximum amount you want to spend during this period, in US dollars. When cumulative spending exceeds this amount, you'll receive a notification. Leave empty to monitor without alerting.",
                  "type": "number",
                  "editor": "number",
                  "minimum": 0
                }
              },
              "required": [
                "label",
                "period"
              ]
            }
          },
          "actors": {
            "title": "Actors to Monitor",
            "type": "array",
            "description": "List of specific Actors to monitor (use Actor IDs or username/name format like \"apify/web-scraper\"). Leave empty to monitor ALL Actors in your account.",
            "items": {
              "type": "string"
            }
          },
          "instanceName": {
            "title": "Instance Name",
            "type": "string",
            "description": "A unique name for this monitoring setup (e.g., \"production-monitor\"). This prevents duplicate notifications—once a threshold is reached for a period, you won't be notified again for that same period, even if the Actor runs multiple times. Choose a descriptive name and keep it consistent between runs."
          },
          "enableSlackNotifications": {
            "title": "Enable Slack Notifications",
            "type": "boolean",
            "description": "Turn on to receive Slack messages when any monitored period exceeds its spending threshold.",
            "default": false
          },
          "slackToken": {
            "title": "Slack Bot Token",
            "type": "string",
            "description": "Your Slack bot token (starts with xoxb-). Required if Slack notifications are enabled. Keep this secret! Get one by creating a Slack App with chat:write permissions."
          },
          "slackChannels": {
            "title": "Slack Channels",
            "minItems": 1,
            "type": "array",
            "description": "List of Slack channel names or IDs to post notifications to (e.g., #spending-alerts, C1234567890). Required if Slack notifications are enabled. Your bot must be added to these channels.",
            "items": {
              "type": "string"
            }
          },
          "enableEmailNotifications": {
            "title": "Enable Email Notifications",
            "type": "boolean",
            "description": "Turn on to receive email messages when any monitored period exceeds its spending threshold.",
            "default": false
          },
          "emailRecipients": {
            "title": "Email Recipients",
            "minItems": 1,
            "type": "array",
            "description": "Comma-separated email addresses for each notification group. Each entry creates a separate email, and recipients in the same entry can see each other. Example: \"user1@example.com,user2@example.com\" (one group) or separate entries for individual emails. Required if email notifications are enabled.",
            "items": {
              "type": "string",
              "pattern": "^[^@\\s,]+@[^@\\s,]+(,[^@\\s,]+@[^@\\s,]+)*$"
            }
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}