# Food Import Refusals: Japan MHLW Violations by Exporter — API reference

The detail an integrator needs and a buyer does not, linked from the README's Integrations section.

## Tested combinations

Every row is an input the test suite and the review runs start.

| Call | What runs | Input |
|---|---|---|
| Daily test / first agent call | the free demo on 7 real sample refusals, nothing charged | `{}` |
| Demo, as the form opens | the same free demo | the form's prefill (`sourceMode: list` + the 7 sample rows) |
| Live read | MHLW's files, every origin, AI off, 5 rows | `{"sourceMode": "live", "originCountries": [], "enableAi": false, "maxQualified": 5}` |
| A product from India | MHLW, product filter | `{"products": ["chickpea"], "originCountries": ["IN"]}` |
| Supplier check | MHLW, supplier filter, every file since April 2024 when `since` is empty | `{"exporterName": "FOODS", "originCountries": ["IN"]}` |
| Supplier list screen | MHLW, every name, one summary each | `{"exporterNames": ["SONYA FOODS", "ZEEL PACKAGING"], "since": "2024-04-01"}` |
| Supplier sheet | the names in column A of your sheet, every file since April 2024 | `{"exporterListUrl": "https://docs.google.com/spreadsheets/d/<id>/edit"}` |
| HS codes | MHLW, rows whose `hsCode` starts with a code | `{"hsCodes": ["0904", "0713"]}` |
| A ready search | one of the 9 presets | `{"preset": "aflatoxin-all"}` |
| AI on | the AI note on the same rows | `{"enableAi": true, "goalDescription": "…"}` + any of the above |
| AI with your own key | the AI through your Gemini key | `{"enableAi": true, "llmProvider": "byok", "llmApiKey": "…"}` (model `google:gemini-3.5-flash-lite`) |
| Your own list | your rows, filtered and scored | `{"sourceMode": "list", "itemsList": [ … ]}` (fields: README → List-mode rows) |
| A dataset you have | a dataset's items | `{"sourceMode": "dataset", "datasetId": "<id>"}` |
| RASFF / FDA | reported, not read | `{"authorities": ["mhlw", "rasff", "fda"], "products": ["shrimp"]}` → `OUTPUT.refused` |

## Which call runs what — demo, live search or your own rows

| Input shape | `OUTPUT.mode` | Can it charge? |
|---|---|---|
| `{}` or the untouched form | `demo` | no |
| sample + a product, supplier or goal typed | `live` | per refusal |
| `products` / `exporterName(s)` / `exporterListUrl` / `hsCodes` / `hazards` / `since` / origins | `live` | per refusal |
| `list` + `itemsList` · `dataset` + `datasetId` | `list` · `dataset` | per refusal, no source run |

## One dataset item

A real item from the live run of 2026-11-22 (AI off):

```json
{
  "itemId": "deb01cdad3f2",
  "name": "PEANUT BUTTER CREAMY — SONYA FOODS PVT LTD. (India)",
  "url": "https://api.apify.com/v2/key-value-stores/<run store>/records/REPORT#r-57ac1f32f4ebceba",
  "authority": "mhlw", "importingCountry": "JP", "publishedOn": "2026-06-25",
  "country": "IN", "countryName": "India",
  "product": "PEANUT BUTTER CREAMY", "productEn": "PEANUT BUTTER CREAMY", "productEnSource": "mhlw",
  "productJa": "ピーナッツバター(PEANUT BUTTER CREAMY)",
  "exporterName": "SONYA FOODS PVT LTD.", "manufacturer": "SONYA FOODS PVT LTD.", "shipper": null,
  "hazard": "aflatoxin", "hazardDetail": "aflatoxin 129 μg/kg",
  "violationJa": "アフラトキシン 129 μg/kg(B1:23.6 μg/kg、B2:5.3 μg/kg)、222 μg/kg(B1:17.8 μg/kg、B2:4.0 μg/kg)、322 μg/kg(B1:17.5 μg/kg、B2:4.1 μg/kg)検出",
  "legalArticle": "第6条第2号", "action": "returned", "actionJa": "積み戻し", "inspection": "inspection_order",
  "port": "Osaka", "importer": "株式会社 トマトコーポレーション", "cause": "原料ピーナッツの不適切な管理",
  "reference": "MHLW 令和8年4月~令和8年11月 row 139",
  "flags": ["named_exporter", "inspection_order", "health_hazard", "destroyed_or_returned"], "targetFlagsMatched": [],
  "ruleScore": 90, "score": 90, "label": "hot", "fitScore": null, "scoreReasons": [], "summary": "",
  "generatedText": "Japan (MHLW) on 2026-06-25: PEANUT BUTTER CREAMY from SONYA FOODS PVT LTD. (India) — aflatoxin 129 μg/kg; consignment returned; under inspection order.",
  "recommendedNextStep": "Before the next order from SONYA FOODS PVT LTD., ask for a lab report covering aflatoxin 129 μg/kg, and screen the company (https://apify.com/rich_minds/counterparty-check-ai).",
  "aiModel": null, "assessedBy": "rules",
  "chargedEvent": "qualified-import-refusal-basic", "billedAs": "qualified-import-refusal-basic",
  "dedupeKey": "id:57ac1f32f4ebceba",
  "source": "mhlw", "sourceUrl": "https://www.mhlw.go.jp/content/001768784.xlsx",
  "feedUrl": "https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/kenkou_iryou/shokuhin/yunyu_kanshi/ihan/index.html",
  "rowId": "57ac1f32f4ebceba", "fetchedAt": "2026-11-21T19:01:26+00:00",
  "sourceRun": {"mode": "actor", "actorId": "own-source", "reader": "built-in reader of Japan's MHLW import-violation files"},
  "scrapedAt": "2026-11-21T19:01:28+00:00"
}
```

## Every field of a row

| Field | Description |
|---|---|
| `itemId`, `name`, `url` | Identity; `url` = MHLW's violations list page + `#r-<rowId>`, unique per row and stable — it never points into the run's storage, which expires |
| `authority`, `importingCountry`, `source` | `mhlw`, `JP` (`source` repeats the authority) |
| `publishedOn` | MHLW's publication date of the refusal (not our download — that is `fetchedAt`) |
| `country`, `countryName` | Origin ISO-2 and English name |
| `product`, `productEn`, `productEnSource`, `productJa` | English name (MHLW / dictionary / AI / list) and the Japanese original |
| `hsCode` | HS-4 heading of the product (`0904` pepper / chilli, `0713` pulses …) from our dictionary of MHLW's product names or the AI's English name; null when it cannot be placed (additives, food-contact materials) |
| `exporterName`, `manufacturer`, `shipper` | Who made and who shipped it |
| `manufacturerLookupUrl` | A web search of the quoted exporter name + origin country (MHLW publishes no company page); null without a name |
| `hazard`, `hazardDetail`, `violationJa`, `legalArticle` | Hazard code, substance + level, MHLW's text, the Food Sanitation Act article |
| `action`, `actionJa`, `inspection`, `port`, `importer`, `cause` | What happened, how it was caught, where, the Japanese importer (companies only), the cause |
| `reference`, `sourceUrl`, `feedUrl`, `rowId`, `fetchedAt` | File + row, the MHLW Excel file, MHLW's list page, the stable id, when this run read the file |
| `flags`, `targetFlagsMatched` | Rule findings |
| `ruleScore`, `fitScore`, `score`, `label`, `assessedBy` | Rule / AI / final score, relevance band, which scale — sort by `score`, trend on `ruleScore` |
| `scoreReasons`, `summary`, `generatedText`, `recommendedNextStep` | AI reasons, summary; the file note and next step (AI, else rules) |
| `aiModel`, `chargedEvent`, `billedAs`, `dedupeKey`, `sourceRun`, `scrapedAt` | Model, billing, run provenance; `scrapedAt` = when this run produced the row |

## Flags (`targetFlags` values)

| Flag | Meaning |
|---|---|
| `named_exporter` | names the manufacturer or shipper |
| `inspection_order` | under Japan's inspection order (検査命令) — every lot tested |
| `health_hazard` | aflatoxin, Salmonella, Listeria, cyanide, a veterinary drug or radioactivity |
| `pesticide_residue` | a pesticide residue over Japan's limit |
| `recent` | published in the last 90 days |
| `destroyed_or_returned` | destroyed, returned or re-exported |
| `no_english_product` | MHLW gave no English product name |

## `OUTPUT` record keys

- `ok` — bool: `false` only when every authority failed and nothing loaded
- `outcome` — str, one of `ok` · `empty` · `source_failed` · `error`
- `mode` — str: `demo` · `live` · `list` · `dataset`
- `qualified` — int, e.g. `35`
- `authorities` — object | null (live runs): `{"mhlw": {"ok": true, "filesRead": 2, "filesFailed": 0, "rows": 1196, "matched": 35, "latestPublished": "2026-10-28", "oldestAvailable": "2024-04-01"}}`
- `refused` — array | null (live runs): `[{"authority": "rasff", "reason": "not_supported" | "failed", "detail": "…"}]`
- `termsFromGoal` — array | null: the product words taken from your goal when "Products" was empty, e.g. `["chilli", "sesame"]`
- `queriesLocalized` — object | null: your product words → the Japanese words matched, e.g. `{"chilli": ["とうがらし", "唐辛子"]}`
- `stats` — object: the funnel, `discovered`, `skipped_<reason>` counts, `ai_assessed`, `capped_by_max_qualified`
- `skips` — object | null: `{"other_origin": ["<name>", …]}` — list / dataset rows the free filters dropped
- `chargedEvents` — object: `{"<event>": <count>}`; `chargeSplit` — object: `demo`, `free`, `basic`, `ai`, `freeKeptForAi`
- `sourceStatus` — object | null: `status`, `partial`, `reader`, `authorities`, `refused`
- `sourceError` — str | null
- `aiCoverage` — object | null: `aiAssessed`, `ruleScored`, `fallbackReasons`, `sampleVerdicts`; `aiError` — str | null
- `aiTokens` — object | null: `inputPerUnit` (≈ 1,117), `outputPerUnit` (≈ 191), `model`
- `webhook` — object | null: `sent`, `failed`, `failedKeys`, `redelivered`, `pendingNextRun`, `signed`
- `trend` — object | null (second run on): `qualified: {from, to}`, `hot: {from, to}`
- `history` — array | null: one `{at, qualified, hot}` per run of this search, oldest first
- `digestEmailed` — bool | null; `scheduleTaskUrl` — str | null; `reportUrl` — str | null
- `timing` — object: `sourceSecs` (3.7 s live), `aiSecs`, `aiSecsPerUnit`, `aiBackoffSecs`, `totalSecs`
- `nextSteps` — array | null: the status steps that did not fit the 200-character status
- `supplierScreen` — array | null (a supplier name or list): one `{supplier, refusals, found, lastPublishedOn, lastHazard, riskBand (high · medium · none found), nearMatches, checked}` per name — `found: false` is not a clearance, MHLW lists only refused lots
- `nearMatches` — object | null: `{"<typed name>": ["<close name that did not match>", …]}`
- `sinceApplied` — str | null (live runs): the date the read started from — `2024-04-01` (every file) for a supplier lookup with no `since`, else `since` or 12 months back
- `supplierSheet` — object | null: `{"read": <names read from exporterListUrl>, "error": "<why it could not be read>" | null}`
- `reportUrl` — the run's REPORT page, kept with your plan's data retention (each row has an anchor `#r-<rowId>` there); every row's `url` is MHLW's list page + the same anchor, which never expires

## Free tier and the AI reserve

Your first 25 import refusals are free, whatever the tier. While the AI is unavailable on a run (no model access, no key), rule-scored rows use the free units down to an AI reserve of 5: those 5 are kept for your first AI-assessed refusals, so the free tier also shows the AI note once it runs. `OUTPUT.chargeSplit.freeKeptForAi` says how many are kept; the status only says how many free refusals are left.

## Webhook bodies

- Per refusal: `{"event": "import_refusal.qualified", "import_refusal": {…one dataset item…}, "runId": "…"}`
- `webhookBatchSize` > 1: `{"event": "import_refusals.qualified", "import_refusals": [{…}], "runId": "…"}`
- A 429 / 5xx is retried once, then re-sent next run (`OUTPUT.webhook.pendingNextRun`), never charged twice; a failed POST never fails the run. Each URL is posted once: **Send alerts to** fills every chat service you did not set (a per-service API field wins), `webhookUrl` gets the rows, chat services and `notifyEmail` the digest.
