{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Email Report — Email Results as Excel/CSV + HTML Table",
    "description": "Email any Apify dataset or run's results as a clean HTML table with summary stats and an Excel or CSV attachment. Attach it as an integration to any Actor or schedule; filter, sort, rename columns, only new rows. $0.01 per report sent + $0.01 per 1,000 rows.",
    "version": "0.1",
    "x-build-id": "e3xkWdr58sQbXNDh8"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/actor-forge~dataset-email-report/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-actor-forge-dataset-email-report",
        "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/actor-forge~dataset-email-report/runs": {
      "post": {
        "operationId": "runs-sync-actor-forge-dataset-email-report",
        "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/actor-forge~dataset-email-report/run-sync": {
      "post": {
        "operationId": "run-sync-actor-forge-dataset-email-report",
        "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": {
          "datasetId": {
            "title": "Dataset",
            "type": "string",
            "description": "The Apify dataset to report on. As an integration after another Actor or task, set this to {{resource.defaultDatasetId}} in the integration form: the triggering run's dataset is then used and this run gets read access to it. Picking a dataset gives this run read access to that dataset only."
          },
          "recipients": {
            "title": "Recipients",
            "maxItems": 10,
            "type": "array",
            "description": "Email addresses to send the report to (up to 10). Leave empty to only preview the report (saved in the run's key-value store, no email). On the Apify free plan, Apify's mailer only delivers to your own account email address; paid plans can email up to 10 addresses here.",
            "items": {
              "type": "string"
            }
          },
          "subject": {
            "title": "Subject",
            "type": "string",
            "description": "Email subject and report title. Placeholders: {{rowCount}} (rows in the report), {{totalRows}} (rows in the dataset), {{date}}, {{time}}, {{datasetId}}, {{runId}}.",
            "default": "Dataset report: {{rowCount}} rows — {{date}}"
          },
          "message": {
            "title": "Message",
            "type": "string",
            "description": "Optional plain-text note shown above the table (no HTML; line breaks are kept)."
          },
          "fields": {
            "title": "Columns",
            "type": "array",
            "description": "Fields to include, in this order. Dot paths reach nested values (e.g. address.city, price.value). Leave empty for every top-level field. Nested objects and lists are written as text.",
            "items": {
              "type": "string"
            }
          },
          "columnNames": {
            "title": "Column names",
            "type": "object",
            "description": "Optional renames: { \"field\": \"Column title\" }, e.g. { \"price.value\": \"Price (USD)\", \"url\": \"Link\" }."
          },
          "sortBy": {
            "title": "Sort by field",
            "type": "string",
            "description": "Optional field to sort by (dot paths allowed). Numbers sort numerically, text naturally; empty values go last."
          },
          "sortDescending": {
            "title": "Sort descending",
            "type": "boolean",
            "description": "Largest / latest first.",
            "default": false
          },
          "filterField": {
            "title": "Filter: field",
            "type": "string",
            "description": "Optional: keep only rows where this field passes the condition below."
          },
          "filterOperator": {
            "title": "Filter: condition",
            "enum": [
              "equals",
              "notEquals",
              "contains",
              "notContains",
              "greaterThan",
              "lessThan",
              "isEmpty",
              "isNotEmpty"
            ],
            "type": "string",
            "description": "Numbers compare numerically; text comparisons ignore case.",
            "default": "equals"
          },
          "filterValue": {
            "title": "Filter: value",
            "type": "string",
            "description": "The value to compare with (not used by 'is empty' / 'is not empty')."
          },
          "maxRows": {
            "title": "Max rows",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Most rows in the report and its attachment (after filtering and sorting). Each included row is charged report-row.",
            "default": 1000
          },
          "tableRows": {
            "title": "Rows shown in the email",
            "minimum": 0,
            "maximum": 200,
            "type": "integer",
            "description": "How many rows appear in the email's HTML table (the first 12 columns). The attachment always has every report row and column. 0 = summary only.",
            "default": 25
          },
          "attachmentFormat": {
            "title": "Attachment",
            "enum": [
              "xlsx",
              "csv",
              "both",
              "none"
            ],
            "type": "string",
            "description": "File(s) attached to the email and saved in the run's key-value store. Attachments over 5 MB in total are not attached; the email links to the dataset instead.",
            "default": "xlsx"
          },
          "onlyIfRows": {
            "title": "Only send when there are rows",
            "type": "boolean",
            "description": "Skip the email (free) when no rows match. Turn off to always get an email, even an empty one.",
            "default": true
          },
          "onlyNewRows": {
            "title": "Only rows not in earlier reports",
            "type": "boolean",
            "description": "Remember which rows were emailed (a key-value store on your own account) and report only rows not sent before with the same history name. Ideal for scheduled scrapers: get only the new listings, jobs or leads.",
            "default": false
          },
          "uniqueKeyFields": {
            "title": "Row identity fields",
            "type": "array",
            "description": "For 'only new rows': the field(s) that identify a row, e.g. url or id. Empty = the whole row.",
            "items": {
              "type": "string"
            }
          },
          "historyKey": {
            "title": "History name",
            "type": "string",
            "description": "Keep separate 'only new rows' memories per report, e.g. jobs-weekly. Letters, digits, - and _.",
            "default": "default"
          },
          "sampleRows": {
            "title": "Sample rows (JSON)",
            "type": "array",
            "description": "Rows to use when no dataset is given, e.g. to try the layout. Ignored when a dataset is set or the Actor runs as an integration."
          },
          "dryRun": {
            "title": "Preview only (don't send)",
            "type": "boolean",
            "description": "Render the report into the key-value store (REPORT_HTML plus the attachment) without emailing anyone. Charged as a preview.",
            "default": false
          },
          "mockSend": {
            "title": "Mock send (test the mailer)",
            "type": "boolean",
            "description": "Run apify/send-mail in its mock mode: the whole delivery runs but the email is only logged, not sent. Charged as a preview.",
            "default": false
          },
          "payload": {
            "title": "Integration payload",
            "type": "object",
            "description": "Filled automatically by Apify integrations with the triggering run (its default dataset is reported)."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}