{
  "openapi": "3.0.1",
  "info": {
    "title": "openFDA Enforcement (Recall) Monitor",
    "description": "Monitor FDA recall (enforcement) reports across drug, device and food. One normalized record per recall (number, Class I/II/III, status, firm, product, reason, dates), with type/class filters, a new-since-last-run mode, and change-detection flagging classification escalations. openFDA, CC0.",
    "version": "0.1",
    "x-build-id": "97sh4izuTSFDXuqcb"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/bytehavenstudios~openfda-enforcement-monitor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-bytehavenstudios-openfda-enforcement-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/bytehavenstudios~openfda-enforcement-monitor/runs": {
      "post": {
        "operationId": "runs-sync-bytehavenstudios-openfda-enforcement-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/bytehavenstudios~openfda-enforcement-monitor/run-sync": {
      "post": {
        "operationId": "run-sync-bytehavenstudios-openfda-enforcement-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": {
          "recallCategories": {
            "title": "Recall categories",
            "type": "array",
            "description": "Which openFDA enforcement endpoints to query. drug = /drug/enforcement.json, device = /device/enforcement.json, food = /food/enforcement.json. Empty = all three (the cross-category moat).",
            "items": {
              "type": "string",
              "enum": [
                "drug",
                "device",
                "food"
              ],
              "enumTitles": [
                "Drug recalls",
                "Device recalls",
                "Food recalls"
              ]
            }
          },
          "classifications": {
            "title": "Classifications",
            "type": "array",
            "description": "Restrict to these FDA recall classifications. Class I = most serious (reasonable probability of serious harm/death), Class II = temporary/reversible harm, Class III = unlikely to cause harm. Empty = all classes.",
            "items": {
              "type": "string",
              "enum": [
                "Class I",
                "Class II",
                "Class III"
              ],
              "enumTitles": [
                "Class I (most serious)",
                "Class II",
                "Class III (least serious)"
              ]
            }
          },
          "statuses": {
            "title": "Recall statuses",
            "type": "array",
            "description": "Restrict to these recall statuses (openFDA `status` field). Typical values: On-Going, Completed, Terminated, Pending. Empty = all statuses.",
            "items": {
              "type": "string"
            }
          },
          "reportedSince": {
            "title": "Reported on/after (YYYY-MM-DD)",
            "type": "string",
            "description": "Only return recalls whose report_date is on/after this date (maps to search=report_date:[YYYYMMDD+TO+today]). Leave empty to default to a recent trailing window. Ignored if 'Only new since last run' is on (the stored watermark drives the window instead)."
          },
          "monitorNewOnly": {
            "title": "Only new since last run",
            "type": "boolean",
            "description": "Persist the set of recall_numbers already reported (in the Actor's key-value store) and, on the next run, return only recalls not seen before. Turns this Actor into a new-recall monitor across scheduled runs.",
            "default": false
          },
          "detectChanges": {
            "title": "Detect classification / status changes",
            "type": "boolean",
            "description": "Persist each recall's prior classification and status (in the Actor's key-value store) and, on later runs, flag recalls whose classification escalated (Class III→II→I) or whose status changed (e.g. On-Going→Terminated). Changed records carry a `change` object. This is the change-detection edge over a weekly-refreshed corpus.",
            "default": true
          },
          "fields": {
            "title": "Fields to keep",
            "type": "array",
            "description": "Optional. Override the set of recall fields kept on each output record. Empty = a sensible default set (see README). Example extras: code_info, distribution_pattern, product_quantity, more_code_info.",
            "items": {
              "type": "string"
            }
          },
          "maxResults": {
            "title": "Max recalls per run",
            "minimum": 0,
            "type": "integer",
            "description": "Cap the total number of recalls returned (across all selected categories). 0 = no cap (paginate to the API's limit).",
            "default": 0
          },
          "apiKey": {
            "title": "openFDA API key (optional)",
            "type": "string",
            "description": "Optional free openFDA api_key. Keyless access allows 240 requests/min and 1000/day per IP; a key raises the daily limit to 120,000. Not required for typical scheduled runs. Get one at https://open.fda.gov/apis/authentication/."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Optional. The openFDA API is a clean, open, public endpoint and needs NO proxy. You may enable Apify Proxy only to distribute requests if you run very large historical pulls. Default: no proxy.",
            "default": {
              "useApifyProxy": false
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}