{
  "openapi": "3.0.1",
  "info": {
    "title": "⚖️ FDA Warning Letters Scraper",
    "description": "Extract public FDA warning letters to discover actionable legal and consulting leads. Build targeted watchlists for compliance subjects and track enforcement dates.",
    "version": "0.1",
    "x-build-id": "hbTugrNevLgs9avZ6"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/taroyamada~fda-warning-letter-digest/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-taroyamada-fda-warning-letter-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~fda-warning-letter-digest/runs": {
      "post": {
        "operationId": "runs-sync-taroyamada-fda-warning-letter-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~fda-warning-letter-digest/run-sync": {
      "post": {
        "operationId": "run-sync-taroyamada-fda-warning-letter-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 or watchlist. Leave empty to use the default public warning_letters_latest feed. import_alerts and govdelivery are optional advanced feeds and are not enabled by default in v1.",
            "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 digest row.",
                  "type": "string"
                },
                "source": {
                  "title": "Source",
                  "description": "warning_letters is the recommended v1 default. import_alerts and govdelivery are optional advanced sources for later expansion.",
                  "type": "string",
                  "enum": [
                    "warning_letters",
                    "import_alerts",
                    "govdelivery"
                  ]
                },
                "searchQuery": {
                  "title": "Search query",
                  "description": "Optional feed-scope query. For warning letters this is sent to the FDA datatables search endpoint; for other sources it is matched against parsed text.",
                  "type": "string"
                },
                "watchTerms": {
                  "title": "Feed watch terms (comma-separated)",
                  "description": "Optional per-feed watchlist used to trigger action_needed when a new/changed item matches.",
                  "type": "string"
                },
                "lookbackDays": {
                  "title": "Lookback window (days, per-feed override)",
                  "description": "Overrides the global lookbackDays for this feed only.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 365
                },
                "maxItems": {
                  "title": "Max items for this feed",
                  "description": "Upper bound on normalized items included for this feed in one run.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                },
                "maxPages": {
                  "title": "Max warning-letter pages for this feed",
                  "description": "Only used for warning_letters feeds. Each datatables page fetches up to 100 rows.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 50
                },
                "issuingOffices": {
                  "title": "Warning-letter issuing offices (comma-separated)",
                  "description": "Optional exact-match filter for warning letter issuing offices, e.g. Center for Drug Evaluation and Research (CDER).",
                  "type": "string"
                },
                "alertNumbers": {
                  "title": "Import alert numbers (comma-separated)",
                  "description": "Optional exact-match filter for import alerts, e.g. 66-40,99-41.",
                  "type": "string"
                },
                "bulletinUrls": {
                  "title": "GovDelivery bulletin URLs",
                  "description": "Required for govdelivery feeds. Provide one or more public bulletin page URLs from content.govdelivery.com.",
                  "type": "array",
                  "editor": "json",
                  "items": {
                    "type": "string"
                  }
                },
                "includeDetailPages": {
                  "title": "Fetch import alert detail pages",
                  "description": "When true, import_alerts feeds fetch and parse alert detail pages for reason/guidance excerpts. Recommended for watchlists.",
                  "type": "boolean"
                },
                "detailFetchLimit": {
                  "title": "Import alert detail page cap",
                  "description": "Maximum number of import alert detail pages to fetch for this feed.",
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100
                }
              },
              "required": [
                "source"
              ]
            }
          },
          "watchTerms": {
            "title": "Global watch terms (comma-separated)",
            "type": "string",
            "description": "Applied to every feed in addition to any feed-level watchTerms. Matching new/changed items trigger action_needed."
          },
          "lookbackDays": {
            "title": "Global lookback window (days)",
            "minimum": 1,
            "maximum": 365,
            "type": "integer",
            "description": "How far back to look for warning-letter posting dates, import-alert publish dates, or bulletin send dates.",
            "default": 30
          },
          "maxItemsPerFeed": {
            "title": "Max items per feed",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Upper bound on normalized items per feed. Lower values keep recurring runs maintenance-light.",
            "default": 50
          },
          "maxPagesPerFeed": {
            "title": "Max warning-letter datatables pages",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Only used for warning_letters feeds. Stop after this many public datatables requests even if the lookback window is broader.",
            "default": 5
          },
          "maxDetailFetchesPerFeed": {
            "title": "Max import alert detail pages per feed",
            "minimum": 0,
            "maximum": 100,
            "type": "integer",
            "description": "Cap on detail-page enrichment for import_alerts feeds.",
            "default": 25
          },
          "delivery": {
            "title": "Delivery mode",
            "enum": [
              "dataset",
              "webhook"
            ],
            "type": "string",
            "description": "dataset writes digest rows to the Apify dataset; webhook POSTs the digest payload to webhookUrl.",
            "default": "dataset"
          },
          "webhookUrl": {
            "title": "Webhook URL (required when delivery=webhook)",
            "type": "string",
            "description": "POST target for the digest payload."
          },
          "datasetMode": {
            "title": "Dataset output mode",
            "enum": [
              "all",
              "action_needed",
              "changed_only"
            ],
            "type": "string",
            "description": "all emits every digest row. action_needed emits only feeds with changed items matching watch terms (plus errors). changed_only emits only feeds with new or updated items (plus errors).",
            "default": "all"
          },
          "snapshotKey": {
            "title": "Snapshot key for recurring state",
            "type": "string",
            "description": "Stable key used to persist prior signatures per record so new and updated warning letters/import alerts can be detected across scheduled runs.",
            "default": "fda-warning-letter-digest-state"
          },
          "notifyOnNoNew": {
            "title": "Emit stable digest rows in delivery outputs",
            "type": "boolean",
            "description": "When false, delivery outputs omit feeds with no new or updated items unless the feed errored. Local output/results.json still contains the full payload.",
            "default": true
          },
          "requestTimeoutSeconds": {
            "title": "HTTP request timeout (seconds)",
            "minimum": 5,
            "maximum": 120,
            "type": "integer",
            "description": "Timeout for each public source request.",
            "default": 30
          },
          "batchDelayMs": {
            "title": "Delay between feeds (ms)",
            "minimum": 0,
            "maximum": 10000,
            "type": "integer",
            "description": "Milliseconds to wait between feed fetches.",
            "default": 0
          },
          "warningLettersApiUrl": {
            "title": "Warning letters datatables API URL",
            "type": "string",
            "description": "Advanced override for the public FDA warning letters datatables endpoint.",
            "default": "https://www.fda.gov/datatables/views/ajax"
          },
          "importAlertsIndexUrl": {
            "title": "Import alerts index URL",
            "type": "string",
            "description": "Advanced override for the public import alerts by publish date page.",
            "default": "https://www.accessdata.fda.gov/cms_ia/iapublishdate.html"
          },
          "dryRun": {
            "title": "Dry run (skip snapshot writes and delivery)",
            "type": "boolean",
            "description": "Fetch and assemble the digest without persisting state or posting webhooks.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}