# Customs Broker India: Mumbai & Kolkata CB Licence Check — 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 | Kolkata 2026, ≤ 5 notice PDFs, AI off — no other Actor runs | `storage-example/INPUT.live.json` |
| Full live read | Mumbai + Kolkata, the years given (empty = last 2) | `{"sourceMode": "live", "commissionerates": ["mumbai", "kolkata"], "years": [2026]}` |
| Look-up | brokers with these licence numbers only, read from the licence → notice index (cache + list subjects) first; every number in `queries[]`, `found: false` when not in the notices read | `{"licenceNumbers": ["11/1708", "U-19"], "commissionerates": ["mumbai", "kolkata"]}` |
| Not covered | refused[] with the reasons (`reasonCode: not_supported`), no request, `ok: false` | `{"sourceMode": "live", "ports": ["INDEL4", "INMUN1"]}` |
| Port / zone aliases | ports / zones mapped to the offices | `{"ports": ["INNSA1", "INCCU1"], "zones": ["Mumbai Zone II"]}` |
| 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 — no `llmModel`: a Gemini key runs `google:gemini-3.5-flash-lite`, an Anthropic / OpenAI / Groq key its provider's model | `{"enableAi": true, "llmProvider": "byok", "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>"}` |


## Free tier and the AI reserve

Your first 25 brokers on this Actor are free, whatever the tier. While the AI is unavailable (no model access, no key, a failed call), 5 of the 25 are kept for your first AI-assessed brokers — the AI reserve — so a run that falls back to rules never spends the free brokers you meant to see with the AI hire check.

## 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 |
|---|---|---|
| `ports` | — | UN/LOCODE → office (`INNSA1`, `INBOM1`, `INBOM4` → Mumbai; `INCCU1`, `INCCU4` → Kolkata); other codes are refused (`port_not_covered`) — union with `commissionerates`, no cost effect beyond the offices read |
| `zones` | — | zone names → office (`Mumbai Zone II` → Mumbai) — union with `commissionerates` |
| `maxToProcess` | 3 × `maxQualified` | brokers scored per run — no cost effect (only delivered rows are charged) |
| `allowList` | — | names / keys no free filter drops (they still need `minScore`) |
| `llmModel` | `anthropic/claude-haiku-4.5` | the AI model (OpenRouter slug, or `provider:model` with your own key) — changes the token cost |
| `discoveryInput` | — | raw keys passed to the built-in reader (`offices`, `years`, `maxNotices`), overriding the fields — no cost effect; leave it empty |
| `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 | how long the built-in reader may read notices (cut to 60 % of the run's time left); notices not fetched by then give subject-only rows (`from_title_only`) — no cost effect |
| `dedupeStoreName` | `customs-broker-directory-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 |

## 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 broker:

```json
{
  "event": "broker.qualified",
  "runId": "a1B2c3D4e5F6g7H8i",
  "redelivery": false,
  "broker": {"itemId": "cochin:7/06", "dedupeKey": "cochin:7/06", "name": "Global Agencies — 7/06 (revalidated)", "status": "revalidated", "hireVerdict": "ok_to_engage", "url": "https://mumbaicustomszone1.gov.in/writereaddata/images/publicnotice/Notice_232.pdf", "score": 70, "label": "hot"},
  "item": {"itemId": "cochin:7/06", "dedupeKey": "cochin:7/06", "name": "Global Agencies — 7/06 (revalidated)", "status": "revalidated", "hireVerdict": "ok_to_engage", "url": "https://mumbaicustomszone1.gov.in/writereaddata/images/publicnotice/Notice_232.pdf", "score": 70, "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": "brokers.qualified",
  "runId": "a1B2c3D4e5F6g7H8i",
  "redelivery": false,
  "brokers": [{"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

Global Agencies (Mumbai notice 232/2026-27), the AI example run of 2026-11-24 — every field:

```json
{
 "itemId": "cochin:7/06",
 "rowId": "de4bcca9a493",
 "name": "Global Agencies — 7/06 (revalidated)",
 "url": "https://mumbaicustomszone1.gov.in/writereaddata/images/publicnotice/Notice_232.pdf",
 "firmName": "Global Agencies",
 "licenceNumber": "7/06",
 "licenceIssuedBy": "Cochin",
 "localLicenceNumber": "11/1574",
 "cbCode": null,
 "status": "revalidated",
 "statusScope": "Mumbai Zones I–III",
 "statusSince": "2026-10-21",
 "statusHistory": [
  {
   "status": "revalidated",
   "date": "2026-10-21",
   "noticeNo": "232/2026-27",
   "kind": "revalidation",
   "url": "https://mumbaicustomszone1.gov.in/writereaddata/images/publicnotice/Notice_232.pdf",
   "scope": "Mumbai Zones I–III"
  }
 ],
 "licenceValidUntil": "lifetime",
 "commissionerate": "Mumbai Zone I",
 "commissionerates": [
  "Mumbai Zone I",
  "Mumbai Zone II (JNCH)",
  "Mumbai Zone III (ACC Sahar)"
 ],
 "ports": [
  "INBOM1",
  "INNSA1",
  "INBOM4"
 ],
 "address": null,
 "lastNoticeNo": "232/2026-27",
 "lastNoticeDate": "2026-10-21",
 "lastNoticeUrl": "https://mumbaicustomszone1.gov.in/writereaddata/images/publicnotice/Notice_232.pdf",
 "notices": [
  {
   "no": "232/2026-27",
   "date": "2026-10-21",
   "kind": "revalidation",
   "url": "https://mumbaicustomszone1.gov.in/writereaddata/images/publicnotice/Notice_232.pdf",
   "office": "mumbai"
  }
 ],
 "sources": [
  "mumbai_cbs"
 ],
 "phone": null,
 "email": null,
 "website": null,
 "companyKey": "global agencies",
 "hireVerdict": "ok_to_engage",
 "hireQuestions": [
  "What is your current KYC status?",
  "At which ports do you currently file customs declarations?",
  "Have you been subject to any penalties in the last 12 months?"
 ],
 "sample": true,
 "flags": [
  "out_of_zone_licence",
  "lifetime_validity"
 ],
 "targetFlagsMatched": [],
 "ruleScore": 100,
 "score": 70,
 "label": "hot",
 "fitScore": 70,
 "scoreReasons": [
  "revalidated on 21 Oct 2026 by notice 232/2026-27"
 ],
 "summary": "Licensed by Cochin, permitted in Mumbai Zones I–III since 21 Oct 2026, lifetime validity since 21 Oct 2026",
 "generatedText": "Ok to engage Licensed by Cochin, permitted in Mumbai Zones I–III since 21 Oct 2026, lifetime validity since 21 Oct 2026",
 "recommendedNextStep": "confirm on CBLMS",
 "aiModel": "llm-gateway:reasoning",
 "assessedBy": "ai",
 "chargedEvent": "demo",
 "billedAs": "qualified-broker-ai",
 "dedupeKey": "cochin:7/06",
 "source": {
  "mode": "list",
  "query": "232/2026-27"
 },
 "fetchedAt": "2026-11-24T07:21:08+00:00",
 "checkedAt": "2026-11-24",
 "auditTrail": "checked on 2026-11-24 against 1 notice (Mumbai Zone I, Mumbai Zone II (JNCH), Mumbai Zone III (ACC Sahar)): https://mumbaicustomszone1.gov.in/writereaddata/images/publicnotice/Notice_232.pdf"
}
```

## `OUTPUT` record keys

From the AI example run, the 2026 live read and the not-covered run (2026-11-24), one line per key:

- `rows` — int: dataset rows written (PortLess contract)
- `refused` — array: `{source, commissionerate?, url?, noticeNo?, reason}` — `reason` one of `not_reachable_timeout` ·
  `dns_unresolved` · `tls_certificate_expired` · `publishes_no_licence_notices` · `port_not_covered` ·
  `zone_not_covered` · `not_covered` · `scanned_untitled` · `robots_disallowed` · `tls_error` · `http_<code>`
- `queries` — array: one `{office, year, url, notices, kept, dropped, noBrokerNamed, fetched, cached, scanned, feed?,
  section?}` per list request, `{office, year, note: "year_out_of_range"}`, `{office, url, note: "list_now_published"}`,
  `{office, url, note: "pdf_<reason>"}` and one `{lookup, found, matchedDedupeKey, foundBy, noticesRead, scope, note}`
  per looked-up licence number, found or not — `found: false` = not in the notices of `scope` ("Mumbai Zones I–III,
  Kolkata 2025–2026"), never charged, check CBLMS; a failed read is `outcome: source_failed` instead
- `costUsd` — float: what this run charged (events × prices)
- `offices` — object | null: `{"mumbai": {brokers, statusBreakdown, oldestNotice, newestNotice}, "kolkata": {…}}`
- `lookup` — object | null (with `licenceNumbers`): `numbers`, `foundBy` (`cache` · `list subject` · `notice PDF` per
  number), `pdfsRead`, `stoppedEarly`, `officesSkipped`, `secs` — how the licence → notice index answered

- `ok` — bool: `false` only when the source was refused / failed and nothing loaded
- `outcome` — str, one of `ok` · `empty` · `not_covered` · `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`
- `withStatusCharged` — int: brokers with a status billed (charged or free tier) · `unknownStatusFree` — int: brokers with no status (flag `status_unknown`) delivered free, `chargedEvent: none`, `billedAs: free-status-unknown` · `chargeSummary` — str | null: "77 brokers with a status charged · 137 with an unknown status free"
- `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

## Refused sources — `OUTPUT.refused[]`

Each entry carries `reason` (the detail: `not_reachable_timeout`, `dns_unresolved`, `tls_certificate_expired`,
`publishes_no_licence_notices`, `not_covered`, `port_not_covered`, `zone_not_covered`, `scanned_untitled`,
`robots_disallowed`; at run time `tls_error`, `not_reachable_timeout`, `http_<code>`) and a stable
`reasonCode`: `not_supported` — a source this version never reads, present on every run; `failed` — an office that
should have answered and did not this run. Alert on `reasonCode == "failed"` only.

## Licence validity

`licenceValidUntil` is an ISO date (`format: date`) or null; `licenceValidUntilText` keeps the notice's wording —
`lifetime` (valid unless revoked) or the date as issued. Rows of a list-mode paste with `"licenceValidUntil":
"lifetime"` are split the same way.
