# India Export Tariffs & Market Access: MFN, FTA, Rules of Origin — API reference

The detail an integrator needs and a buyer does not: linked from the README's Integrations section. `/actor-deploy
--assets` hosts this file next to the images (any other repo file 404s on the Store).

## Tested combinations

Every row is an input the test suite and the review runs start — the combinations that are supported. An input
outside this table is accepted by the schema but not tested; keep the table in sync with `storage-example/` and
`tests/` (gate `check_tested_combinations`, 2026-10-23 company-contact-finder-ai V-27).

| Call | What runs | Input |
|---|---|---|
| Daily test / first agent call | the free demo on the sample records, nothing charged | `{}` |
| Demo, as the form opens | the same free demo | `storage-example/INPUT.json` |
| Live read, capped | the built-in Indian Trade Portal reader, 1 HS code × 1 country, AI off | `storage-example/INPUT.live.json` |
| The acceptance read | 2 HS codes × 5 countries, every national line | `{"sourceMode": "live", "hsCodes": ["090411", "100630"], "countries": ["AE", "SA", "US", "GB", "JP"]}` |
| Monthly change check | only the markets that changed since the last read | `{"hsCodes": ["090411"], "countries": ["AE", "US"], "forceRefresh": true, "onlyChanged": true}` |
| AI on | the same records with the AI verdict | `storage-example/INPUT.ai.json` |
| AI with your own key | the AI through your provider key | `{"enableAi": true, "llmProvider": "byok", "llmModel": "google:gemini-3.5-flash-lite", "llmApiKey": "…"}` + your records |
| Your own list | your rows, no source run | `{"sourceMode": "list", "itemsList": [ … ]}` (fields: README → List-mode rows) |
| A dataset you have | a dataset's items, no source run | `{"sourceMode": "dataset", "datasetId": "<id>"}` |

Add one row per mode the Actor adds (a light mode, a file input, an add-on), with its input JSON.

## API-only inputs

Hidden from the Console form, read from the API. Every hidden input the Actor adds gets a row with its effect on cost
and time — an integrator must not find "doubles AI time" by trying (gate `check_api_only_effects`, 2026-11-23
b2b-directory-companies-ai V-27). Drop a hidden field no buyer uses instead of documenting it.

| Field | Default | Effect on cost and time |
|---|---|---|
| `aiCandidateMultiplier` | 2 | AI shortlist = this × `maxQualified`: × 2 means up to twice the AI calls, time and tokens (only qualified rows are charged) |
| `autoSwitchToLive` | true | a typed search next to the sample starts the paid live search; `false` keeps the free demo |
| `discoveryTimeoutSecs` | 3600 | not used by the built-in reader — it stops at the run's own time budget and serves the rest from the cache |
| `discoveryInput` | {} | `{"hsCodes": [...]}` works like `hsCodes` |
| `suppressionList` / `allowList` | [] | market ids (`090411-AE-090411000000`) never output / always kept — no cost effect |
| `dedupeTtlDays` | 0 | with `dedupeAcrossRuns` on: days before a market is delivered (and charged) again |
| `maxToProcess` | 3 × `maxQualified` | markets read per run: ≈ 22 s each when fresh (measured) |
| `dedupeStoreName` | `india-trade-portal-ai-seen` | one named memory per client; a new name re-delivers (and re-charges) units delivered under another |
| `webhookBatchSize` | 1 | 1 = one POST per row; N = batched POSTs — no cost effect |
| `webhookHeaders` / `webhookSecret` | — | headers / HMAC signing of the webhook POST — no cost effect |
| `slackWebhookUrl` / `teamsWebhookUrl` / `googleChatWebhookUrl` / `discordWebhookUrl` / `telegramUrl` | — | per-service aliases of **Send alerts to** — no cost effect |

## Which delivery field wins (merge rule)

**Send alerts to** (`sendAlertsTo`) is the one public field; `slackWebhookUrl`, `discordWebhookUrl`, `teamsWebhookUrl`, `googleChatWebhookUrl` and `telegramUrl` are API aliases. Which wins: an alias sent for a service wins for that service, `sendAlertsTo` fills every service the aliases left empty (pinned by `tests/test_settings.py::test_one_send_alerts_to_field_routes_every_url_by_host`).

## Webhook body

What `webhookUrl` receives — the receiving end is built from this, never by trial run (gate
`check_webhook_body_example`, 2026-11-23 destination-rule-watch-ai V-205). Replace `{…}` with one real dataset item
from the first live run. Signed with `webhookSecret`: header `X-Signature: sha256=<HMAC-SHA256 of the raw body>`.

`webhookBatchSize: 1` — one POST per market:

```json
{
  "event": "market.qualified",
  "runId": "a1B2c3D4e5F6g7H8i",
  "redelivery": false,
  "market": {"itemId": "…", "dedupeKey": "…", "url": "https://…", "score": 82, "label": "hot"},
  "item": {"itemId": "…", "dedupeKey": "…", "url": "https://…", "score": 82, "label": "hot"}
}
```

`item` / `items` carry the same row(s) as the Actor's own key in every body — one receiver serves all of the
developer's Actors, and no hyphenated key needs bracket access.

`webhookBatchSize: N` — one POST per batch (the last one may be shorter):

```json
{
  "event": "markets.qualified",
  "runId": "a1B2c3D4e5F6g7H8i",
  "redelivery": false,
  "markets": [{"itemId": "…", "dedupeKey": "…"}, {"itemId": "…", "dedupeKey": "…"}],
  "items": [{"itemId": "…", "dedupeKey": "…"}, {"itemId": "…", "dedupeKey": "…"}]
}
```

A 429 / 5xx / network error is retried once after 2 s (15 s timeout); a POST that still fails is re-sent first on the
next run with `"redelivery": true` — upsert on `dedupeKey`.

## One dataset item

Paste one real item from the first live run here — every field, `dedupeKey` included — and the `OUTPUT` record's keys
with their types (gate `check_api_reference_sample`).

## `OUTPUT` record keys

Generate this list from THREE runs merged — list mode with AI on, a scheduled second run of the same search (trend,
history, seeds, scheduled sizing filled) and a refused live run (`outcome: source_refused`) — never from the demo
alone: a demo-generated list typed 30 of 48 keys `null` and listed no `outcome` value, so the Run-outcomes contract
could not be coded against from the page (gate `check_api_reference_output_typed`, 2026-10-23 us-importer-finder-ai
V-206). One line per key: type, one example, and the sub-keys of every nested record.

- `ok` — bool: `false` only when the source was refused / failed and nothing loaded
- `outcome` — str, one of `ok` · `empty` · `source_refused` · `source_failed` · `error`
- `mode` — str: `demo` · `live` · `list` · `dataset`
- `qualified` — int, e.g. `12`
- `stats` — object: the funnel, `discovered`, `skipped_<reason>` counts, `ai_assessed`, `capped_by_max_qualified`
- `skips` — object | null: `{"<reason>": ["<name>", …]}` — the names each Actor-specific rule dropped
- `chargedEvents` — object: `{"<event>": <count>}`; `chargeSplit` — object: `demo`, `free`, `basic`, `ai`, `freeKeptForAi`
- `sourceStatus` — object | null: `status`, `partial`, `timeCapped`, `itemsRead`
- `sourceError` — str | null · `sourceRefused` — `"plan"` | null · `sampleFallback` — bool | null
- `aiCoverage` — object | null: `aiAssessed`, `ruleScored`, `fallbackReasons`, `sampleVerdicts`; `aiError` — str | null
- `aiTokens` — object | null: `inputPerUnit`, `outputPerUnit`, `model`
- `webhook` — object | null: `sent`, `failed`, `failedKeys`, `redelivered`, `pendingNextRun`, `signed`
- `trend` — object | null (second run on): `qualified: {from, to}`, `hot: {from, to}`, the Actor's own series
- `history` — array | null: one `{at, qualified, hot, …}` per run of this search, oldest first
- `scheduledSizing`, `firstRunBackfill`, `seedsRolled`, `scanCapHit` — object | null: what a scheduled run resized
- `digestEmailed` — bool | null; `scheduleTaskUrl` — str | null; `reportUrl` — str | null
- `timing` — object: `sourceSecs`, `aiSecs`, `aiSecsPerUnit`, `aiBackoffSecs`, `totalSecs`
- `nextSteps` — array | null: the status steps that did not fit the 200-character status

## Flags

`flags` on every row; `targetFlags` keeps only markets with one of them.

| Flag | Meaning |
|---|---|
| `duty_free_mfn` | the MFN tariff is 0 % |
| `preference_available` | a preferential (FTA) rate below MFN |
| `preference_zero` | a preferential rate of 0 % |
| `additional_duty` | an additional duty (Section 232 / 301 …) with a rate |
| `rate_not_numeric` | a specific / compound duty or text |
| `many_ntm_documents` | 40 or more documents to check |
| `changed` | a section changed since your last read |
| `stale_data` | the portal's tariff data is older than 90 days (`dataAgeDays`) |
| `from_cache` | served from the month cache |

## Every output field

| Field | What it is |
|---|---|
| `itemId`, `dedupeKey` | market id `<hs6>-<ISO2>-<nationalLine>`, stable across runs; the same with `mk:` |
| `rowId` | per read: `itemId@<date>`, the date being `readOn` (our download), not the portal's `dataAsOf` |
| `name`, `url`, `pageUrl` | the market and its portal page (`pageUrl`: deprecated alias of `url`, removed in 0.3, 2027-06-01) |
| `hsCode`, `hs6`, `itcHsCode`, `productDescription` | your code, its HS6, the 8-digit ITC-HS line, the product |
| `nationalLine`, `nationalDescription`, `country`, `countryName` | the importing country's line and its description |
| `mfnTariffPct`, `mfnRateText` | MFN duty as printed on the tariff page (% or the specific duty's text) |
| `preferentialTariffs` | `agreement`, `agreementShort`, `ratePct`, `rateText`, `rulesOfOrigin`, `rulesOfOriginText`, `rulesOfOriginPdf` |
| `bestRatePct`, `bestAgreement`, `marginOfPreferencePct`, `rulesOfOriginText` | lowest rate computed from the same page, its agreement, `mfnTariffPct − bestRatePct`, its rule spelled out |
| `additionalDuties` | `name`, `effectiveFrom`, `ratePct`, `rateText` |
| `spsMeasures`, `tbtMeasures`, `otherNtm`, `borderDocuments`, `importLicensing`, `ntmDocumentCount`, `spsTbtUrl` | documents `{title, type, url}`; border documents / licensing derived from titles (`derived: true`) |
| `dataAsOf`, `readOn`, `fetchedAt`, `fromCache`, `cacheNote`, `sample` | the portal's publication date of the tariff data; when read; when this run wrote the row; cache flag / note; demo flag |
| `sectionHashes`, `changedSections`, `changes` | hashes of tariff / sps / tbt / documents, what changed, in words |
| `flags`, `targetFlagsMatched`, `ruleScore`, `score`, `label`, `assessedBy` | rule findings and scores |
| `fitScore`, `scoreReasons`, `summary`, `documentsToOpenFirst`, `changeMeaning`, `aiModel` | the AI tier (rule picks for documents and change meaning without it) |
| `generatedText`, `recommendedNextStep`, `chargedEvent`, `billedAs`, `source` | the market note, what to open next, billing, provenance |

## Run outcomes

| Outcome | Run status | Dataset | `OUTPUT` | Charged? | What to do |
|---|---|---|---|---|---|
| Free demo | SUCCEEDED | sample markets | `demo: true` | no | type your HS codes |
| Success | SUCCEEDED | markets, best first | `rows`, `refused[]`, `counts` | per market | — |
| Some markets not read | SUCCEEDED | the read markets | `refused[]` with `reason`, `kind` | read markets only | alert on `refused[].kind == "failed"`; `not_supported` = no such market |
| Nothing covered | SUCCEEDED | empty | `ok: false`, `outcome: not_covered` | no | fix the codes the status names |
| Nothing matched | SUCCEEDED | empty | `qualified: 0` | no | nothing moved |
| Demo text still in place | SUCCEEDED | empty | `inputNeeded` | no | type your own HS codes |
| Invalid input | FAILED | empty | — | no | fix the field the status names |
| Source failed | FAILED | empty | `ok: false`, `outcome: source_failed` | no | re-run later |
| Source partial | SUCCEEDED | markets read + cached | `sourceStatus`, `stopReason` | per market delivered | re-run later for the rest |
| Crashed (rare) | FAILED | rows delivered before it | `ok: false`, `outcome: error` | delivered rows only | re-run |
| AI unavailable | SUCCEEDED | rule-scored markets | `aiError`, `aiCoverage` | basic price | your own key (`llmProvider: byok`) |

## Webhook in short

- **Webhook** — `webhookUrl` gets `{"event": "market.qualified", "market": {…}, "runId": "…"}`; with `webhookBatchSize`
  > 1 a batch `{"event": "markets.qualified", "markets": [{…}], "runId": "…"}`. A 429 / 5xx is retried once; a failed
  POST never fails the run, is listed in `OUTPUT.webhook.failedKeys` and re-POSTed first next run. `webhookSecret`
  signs it: `X-Signature: sha256=<HMAC-SHA256 of the raw body>`.
- **Which delivery field wins** — every URL is posted once; an explicit per-service field wins over **Send alerts to**
  for its service; `webhookUrl` gets the markets as JSON, chat services the digest, `notifyEmail` the e-mail.

## The same call in JavaScript

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_API_TOKEN>' });
const run = await client.actor('<your-apify-username>/india-trade-portal-ai').call({
    // free first call instead: {} (the demo) or { sourceMode: 'list', itemsList: [...] } (your rows)
    sourceMode: 'live', // the mode you send is the mode that runs (autoSwitchToLive is Console-only)
    hsCodes: ['090411', '100630'],
    countries: ['AE', 'SA', 'US', 'GB', 'JP'],
    maxQualified: 25,
    failOnSourceError: true,
}, { timeout: 1800 /* , build: '0.1.1' — pin the build number your pipeline was tested with */ });
if (run.status !== 'SUCCEEDED') throw new Error(`${run.status}: ${run.statusMessage}`);
const rec = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT');
const out = rec ? rec.value : {};
if (out.ok === false) throw new Error(`${out.outcome}: ${out.sourceError}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((i) => [i.url, i.score, i.label, i.changes]));
```

## Which call runs what

| Input shape | `OUTPUT.mode` | Can it charge? |
|---|---|---|
| `{}` or the untouched form | `demo` | no |
| the sample + your HS codes typed on the Console form | `live` | yes — per market |
| the same over the API (or `autoSwitchToLive: false`) | `demo` | no — the mode you send runs |
| a Console input copied into a schedule, a saved task or an API call | the `sourceMode` it carries | as that mode — no auto-switch |
| `sourceMode: "live"` + `hsCodes` | `live` | yes — per market |
| `sourceMode: "list"` + `itemsList` / `"dataset"` + `datasetId` | `list` / `dataset` | yes — per market, nothing read live |

## List-mode rows

`sourceMode: "list"` re-scores market rows you already have (earlier dataset rows work as-is) — [template](list-template.json).

| Field | Needed? | What it enables |
|---|---|---|
| `name` (or `title`) | required | the row's title |
| `country`, `hs6` (or `hsCode`), `nationalLine` | required | the market id (`itemId`) |
| `url` / `pageUrl` | optional | the link |
| `mfnTariffPct`, `mfnRateText`, `preferentialTariffs`, `bestRatePct`, `bestAgreement`, `marginOfPreferencePct`, `rulesOfOriginText` | optional | tariff flags, the score |
| `additionalDuties` | optional | `additional_duty` |
| `spsMeasures`, `tbtMeasures`, `otherNtm`, `borderDocuments`, `importLicensing`, `ntmDocumentCount`, `spsTbtUrl` | optional | document flags, documents to open first |
| `itcHsCode`, `productDescription`, `nationalDescription`, `countryName`, `dataAsOf`, `readOn`, `fromCache`, `cacheNote`, `sample` | optional | name, `stale_data`, `from_cache` |
| `sectionHashes`, `changedSections`, `changes` | optional | `changed`, **Only markets that changed** |

## Run time per mode

| Mode | Measured time | `timeoutSecs` |
|---|---|---|
| Free demo | 3 s | 120 |
| Your own rows, rules only | ≈ 1 s per 100 | 300 |
| Live read, rules only | ≈ 22 s per fresh market (measured 2026-11-24) | 1800 for 25 |
| Repeat within the month cache | seconds | 300 |
| AI via Apify's model access | not measured on the platform yet (estimate ≈ 6 s per market) | + 300 |
| AI with your own key | measured 2026-11-24 (free Gemini key): ≈ 30 s per market, ≈ 2 a minute; a free key: 1–3 per run | + 900 for 25 |

## Free markets and the AI reserve

Your first 5 markets are free whatever the tier. While the AI is unavailable (no model access, a refused own key), a few of the 5 are kept back so your first AI-assessed markets are free too — the number is in `OUTPUT.chargeSplit.freeKeptForAi`; the status only says how many free markets are left.

## Other tariff Actors on the Store

| Actor | Covers | Price | 100 markets |
|---|---|---|---|
| [`dogmatic_eyepiece/uk-import-tariff`](https://apify.com/dogmatic_eyepiece/uk-import-tariff) | UK duty + VAT | pay per event | UK only, no SPS / TBT |
| [`kaitoeasyapi/us-tariff-hts-customs-duty-rates-scraper`](https://apify.com/kaitoeasyapi/us-tariff-hts-customs-duty-rates-scraper) | US HTS + Section 301 | $0.70–1.00 / 1,000 | ≈ $0.10, US only, no NTMs |
