{
  "openapi": "3.0.1",
  "info": {
    "title": "Product Safety Recall Digest | CPSC + openFDA Alerts",
    "description": "Monitor CPSC saferproducts.gov and openFDA food/drug/device enforcement APIs for new product safety recalls — one summary-first digest row per configured feed without dumping raw recall rows.",
    "version": "0.1",
    "x-build-id": "tGtvb4kTFC7M1Db8p"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/taroyamada~product-safety-recall-digest/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-taroyamada-product-safety-recall-digest",
        "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/taroyamada~product-safety-recall-digest/runs": {
      "post": {
        "operationId": "runs-sync-taroyamada-product-safety-recall-digest",
        "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/taroyamada~product-safety-recall-digest/run-sync": {
      "post": {
        "operationId": "run-sync-taroyamada-product-safety-recall-digest",
        "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": {
          "feeds": {
            "title": "Feeds to monitor",
            "type": "array",
            "description": "One entry per monitored feed/source. Each produces one digest row. Leave empty to use all 4 default feeds (CPSC, FDA food, FDA drug, FDA device).",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "title": "Feed ID",
                  "description": "Stable identifier used in snapshots and output rows.",
                  "type": "string"
                },
                "name": {
                  "title": "Feed name",
                  "description": "Human-readable label for this feed in the digest output.",
                  "type": "string"
                },
                "source": {
                  "title": "Data source",
                  "description": "Which recall API to query. Valid values: cpsc, fda_food, fda_drug, fda_device.",
                  "type": "string",
                  "enum": [
                    "cpsc",
                    "fda_food",
                    "fda_drug",
                    "fda_device"
                  ]
                },
                "lookbackDays": {
                  "title": "Lookback window (days, per-feed override)",
                  "description": "Overrides the global lookbackDays for this feed only. Omit this field to use the global setting.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 365
                },
                "recallClasses": {
                  "title": "Recall class filter (per-feed override, openFDA only)",
                  "description": "Filter to specific FDA recall classes for this feed. Valid values: I, II, III. Does not apply to CPSC. Omit this field to use the global recallClasses setting.",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "maxRecalls": {
                  "title": "Max recalls per feed (per-feed override)",
                  "description": "Upper bound on recalls fetched for this feed. Omit this field to use the global maxRecallsPerFeed setting.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                }
              },
              "required": [
                "source"
              ]
            }
          },
          "lookbackDays": {
            "title": "Lookback window (days)",
            "minimum": 1,
            "maximum": 365,
            "type": "integer",
            "description": "Number of days back to search for recalls. Applies to all feeds unless overridden per feed.",
            "default": 30
          },
          "recallClasses": {
            "title": "FDA recall classes to include",
            "type": "array",
            "description": "Filter openFDA results to specific recall classes. Valid values: I (most serious), II, III. Does not apply to CPSC (which uses a different classification scheme).",
            "items": {
              "type": "string"
            },
            "default": [
              "I",
              "II"
            ]
          },
          "maxRecallsPerFeed": {
            "title": "Max recalls per feed",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Upper bound on recall records fetched per feed per run. Lower = faster and less data; keep ≤ 50 for recurring digests.",
            "default": 50
          },
          "delivery": {
            "title": "Delivery mode",
            "enum": [
              "dataset",
              "webhook"
            ],
            "type": "string",
            "description": "dataset stores digest rows in the Apify dataset. webhook posts the digest JSON to webhookUrl.",
            "default": "dataset"
          },
          "webhookUrl": {
            "title": "Webhook URL (required when delivery=webhook)",
            "type": "string",
            "description": "POST target for the recall digest payload. Leave empty for dataset delivery."
          },
          "datasetMode": {
            "title": "Dataset output mode",
            "enum": [
              "all",
              "action_needed",
              "new_only"
            ],
            "type": "string",
            "description": "all emits every feed digest row. action_needed emits only feeds with new or first-run recalls. new_only emits only feeds with new recall IDs not seen in the previous run.",
            "default": "all"
          },
          "snapshotKey": {
            "title": "Snapshot key for recurring state",
            "type": "string",
            "description": "Stable key used to persist seen recall IDs across recurring runs so new_only and action_needed modes stay comparable. Use the same key across scheduled runs.",
            "default": "product-safety-recall-digest-state"
          },
          "notifyOnNoNew": {
            "title": "Emit digest even when no new recalls found",
            "type": "boolean",
            "description": "When true (default), every feed always produces a digest row even if no new recalls were found. When false, feeds with no new recalls are omitted from webhook payloads.",
            "default": true
          },
          "requestTimeoutSeconds": {
            "title": "HTTP request timeout (seconds)",
            "minimum": 5,
            "maximum": 120,
            "type": "integer",
            "description": "Timeout for each API request.",
            "default": 30
          },
          "batchDelayMs": {
            "title": "Delay between feeds (ms)",
            "minimum": 0,
            "maximum": 10000,
            "type": "integer",
            "description": "Milliseconds to wait between feed fetches. Keeps keyless openFDA usage well below the 40 req/min rate limit.",
            "default": 800
          },
          "dryRun": {
            "title": "Dry run (skip snapshot writes and webhook delivery)",
            "type": "boolean",
            "description": "Validate, fetch, and assemble without persisting state or posting webhooks. Safe for testing input shapes.",
            "default": false
          },
          "nowIso": {
            "title": "Override current time (ISO string, for testing)",
            "type": "string",
            "description": "Set to a fixed ISO timestamp to make runs deterministic against fixture data."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}