# CBP AD/CVD + HTS Duty Alert (`mikechiou/cbp-adcvd-hts-duty-alert`) Actor

Track CBP antidumping/countervailing duty messages and emit structured watchlist events by case, country, product, supplier, message type, and optional HTS mapping for import teams, customs brokers, and AI agents.

- **URL**: https://apify.com/mikechiou/cbp-adcvd-hts-duty-alert.md
- **Developed by:** [Mike Chiou](https://apify.com/mikechiou) (community)
- **Categories:** Agents, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $30.00 / 1,000 ad/cvd message matches

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## CBP AD/CVD + HTS Duty Alert

Monitor CBP antidumping and countervailing duty AD/CVD public messages and turn case, country, product, supplier, message-type, and optional HTS watchlists into structured compliance-risk events for customs brokers, import teams, consultants, and AI agents.

### What This Actor Does

- Fetches the latest public CBP AD/CVD messages from the CBP AD/CVD public portal.
- Matches new messages against user-provided watchlists.
- Normalizes matches into event records with source URLs, dates, entities, match terms, confidence, and raw source payloads.
- Persists event fingerprints in a named key-value store so repeat runs do not re-emit the same event.
- Supports pay-per-event charging with a safe no-op fallback for local or unpublished runs.

### Inputs

- `caseNumbers`: AD/CVD case numbers such as `A-570-983` or `A570983`.
- `countries`: country names such as `China`, `Kazakhstan`, or `Canada`.
- `productKeywords`: product phrases such as `silicon metal` or `wind towers`.
- `supplierNames`: supplier, exporter, importer, or company terms when present in source data.
- `messageTypes`: CBP message type prefixes or labels such as `CD` or `ALI`.
- `htsPrefixes`: HTS prefixes such as `7308` or `8502.31`. In v1, HTS matching requires `caseReferenceUrl`.
- `sinceDate`: optional ISO date. If empty, the Actor uses a 7-day lookback.
- `maxEvents`: safety cap for one run.
- `caseReferenceUrl`: optional public CSV or JSON case table containing case number and HTS fields. Use this to enable HTS matching in v1; a built-in Federal Register source is planned for v1.1.
- `stateStoreName`: named key-value store for dedupe and case snapshots. Default: `cbp-adcvd-state`.

### Output

Each dataset item uses this event shape:

```json
{
  "source_url": "https://trade.cbp.dhs.gov/ace/adcvd/adcvd-public/#/message/6183414",
  "source_api_url": "https://trade.cbp.dhs.gov/ace/adcvd/service-messages/messages/public/getLatestMessages",
  "event_type": "high_confidence_catalog_hit",
  "entities": {
    "case_number": "C463811",
    "normalized_case_number": "C463811",
    "message_number": "6183414",
    "product": "Silicon Metal",
    "countries": ["The Republic of Kazakhstan"],
    "hts_numbers": []
  },
  "match_terms": ["country:Kazakhstan", "product:silicon metal"],
  "confidence": 0.85
}
````

### Event Pricing Plan

The code is ready for pay-per-event pricing, but monetization must be configured manually in Apify Console before publication.

- `adcvd_message_match`: `$0.03`
- `case_status_change`: `$0.04`
- `high_confidence_catalog_hit`: `$0.05`

Use all-inclusive pay-per-event pricing. Do not enable pay-per-event plus usage unless the margin model changes.

### Local Development

```bash
npm install
npm run build
npm test
npm run lint
npm run canary
apify run --purge
```

The local smoke input lives at `storage/key_value_stores/default/INPUT.json`.

### Data Sources

- CBP AD/CVD public portal: `https://trade.cbp.dhs.gov/ace/adcvd/adcvd-public/`
- Latest messages API discovered from the public app shell: `https://trade.cbp.dhs.gov/ace/adcvd/service-messages/messages/public/getLatestMessages`
- Data.gov AD/CVD case metadata: `https://catalog.data.gov/dataset/cbp-active-dumping-and-active-countervailing-ad-cvd-cases`
- Federal Register API for planned v1.1 case-to-HTS mapping: `https://www.federalregister.gov/api/v1/documents.json`

### Limitations

- In v1, default matching covers case number, country, product keyword, supplier, message type, and date. HTS-prefix matching is active only when you provide a public `caseReferenceUrl` table.
- The Data.gov AD/CVD case record exposes metadata but no downloadable distribution. Authenticated CBP `/service-cases` endpoints are intentionally out of scope.
- Built-in HTS-prefix matching is planned for v1.1 using public Federal Register order notices.
- HTS matches are indicative only. AD/CVD scope is controlled by the written scope language in the order notice and related official instructions, not by HTSUS codes alone.
- This Actor reports source facts and watchlist matches. It is not legal advice and does not determine whether merchandise is in scope for an AD/CVD order.
- This Actor is not affiliated with, endorsed by, or sponsored by CBP, DHS, Data.gov, or the U.S. government.

### Maintenance

Run the canary daily:

```bash
npm run canary
```

Open a fix ticket if the endpoint returns login HTML, records are empty twice, required fields disappear, or known-token matching stops producing one normalized event.

### Kill / Scale Gate

After 60 days listed on Apify, continue only if the Actor reaches at least 5 paid-plan users or about `$25` in charged events. Otherwise archive/freeze and move to the next finalist.

# Actor input Schema

## `htsPrefixes` (type: `array`):

HTS prefixes such as 7308 or 8502.31. In v1 these only match when a public case reference table is supplied via caseReferenceUrl.

## `caseNumbers` (type: `array`):

Case numbers to watch. Hyphenated and compact forms are treated as equivalent, for example A-570-983 and A570983.

## `countries` (type: `array`):

Country names to match in case names and message text.

## `productKeywords` (type: `array`):

Product or commodity phrases to match with word boundaries in message titles and joined case fields.

## `supplierNames` (type: `array`):

Supplier, exporter, importer, or company names to match when present.

## `messageTypes` (type: `array`):

CBP message type or subtype text to match, such as CD or ALI.

## `sinceDate` (type: `string`):

Optional ISO date. If empty, the Actor uses a 7-day lookback.

## `maxEvents` (type: `integer`):

Safety cap for normalized events emitted in one run.

## `caseReferenceUrl` (type: `string`):

Optional public CSV or JSON case table with case number and HTS fields. Use this to enable HTS-prefix matching in v1; a built-in Federal Register source is planned for v1.1.

## `stateStoreName` (type: `string`):

Named key-value store used for dedupe and case snapshots. Use **RUN\_DEFAULT** to keep state in the default store for each run.

## Actor input object example

```json
{
  "htsPrefixes": [
    "2804"
  ],
  "caseNumbers": [
    "C-463-811"
  ],
  "countries": [
    "Kazakhstan"
  ],
  "productKeywords": [
    "silicon metal"
  ],
  "maxEvents": 10,
  "stateStoreName": "cbp-adcvd-state"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

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

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "htsPrefixes": [
        "2804"
    ],
    "caseNumbers": [
        "C-463-811"
    ],
    "countries": [
        "Kazakhstan"
    ],
    "productKeywords": [
        "silicon metal"
    ],
    "maxEvents": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("mikechiou/cbp-adcvd-hts-duty-alert").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "htsPrefixes": ["2804"],
    "caseNumbers": ["C-463-811"],
    "countries": ["Kazakhstan"],
    "productKeywords": ["silicon metal"],
    "maxEvents": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("mikechiou/cbp-adcvd-hts-duty-alert").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "htsPrefixes": [
    "2804"
  ],
  "caseNumbers": [
    "C-463-811"
  ],
  "countries": [
    "Kazakhstan"
  ],
  "productKeywords": [
    "silicon metal"
  ],
  "maxEvents": 10
}' |
apify call mikechiou/cbp-adcvd-hts-duty-alert --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mikechiou/cbp-adcvd-hts-duty-alert",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "CBP AD/CVD + HTS Duty Alert",
        "description": "Track CBP antidumping/countervailing duty messages and emit structured watchlist events by case, country, product, supplier, message type, and optional HTS mapping for import teams, customs brokers, and AI agents.",
        "version": "0.1",
        "x-build-id": "mpQpUJBfjbHngiFIL"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/mikechiou~cbp-adcvd-hts-duty-alert/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-mikechiou-cbp-adcvd-hts-duty-alert",
                "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/mikechiou~cbp-adcvd-hts-duty-alert/runs": {
            "post": {
                "operationId": "runs-sync-mikechiou-cbp-adcvd-hts-duty-alert",
                "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/mikechiou~cbp-adcvd-hts-duty-alert/run-sync": {
            "post": {
                "operationId": "run-sync-mikechiou-cbp-adcvd-hts-duty-alert",
                "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": {
                    "htsPrefixes": {
                        "title": "HTS prefixes",
                        "type": "array",
                        "description": "HTS prefixes such as 7308 or 8502.31. In v1 these only match when a public case reference table is supplied via caseReferenceUrl.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "caseNumbers": {
                        "title": "AD/CVD case numbers",
                        "type": "array",
                        "description": "Case numbers to watch. Hyphenated and compact forms are treated as equivalent, for example A-570-983 and A570983.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "countries": {
                        "title": "Countries",
                        "type": "array",
                        "description": "Country names to match in case names and message text.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "productKeywords": {
                        "title": "Product keywords",
                        "type": "array",
                        "description": "Product or commodity phrases to match with word boundaries in message titles and joined case fields.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "supplierNames": {
                        "title": "Supplier names",
                        "type": "array",
                        "description": "Supplier, exporter, importer, or company names to match when present.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "messageTypes": {
                        "title": "Message types",
                        "type": "array",
                        "description": "CBP message type or subtype text to match, such as CD or ALI.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "sinceDate": {
                        "title": "Since date",
                        "type": "string",
                        "description": "Optional ISO date. If empty, the Actor uses a 7-day lookback."
                    },
                    "maxEvents": {
                        "title": "Maximum events",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Safety cap for normalized events emitted in one run.",
                        "default": 25
                    },
                    "caseReferenceUrl": {
                        "title": "Case reference CSV/JSON URL",
                        "type": "string",
                        "description": "Optional public CSV or JSON case table with case number and HTS fields. Use this to enable HTS-prefix matching in v1; a built-in Federal Register source is planned for v1.1."
                    },
                    "stateStoreName": {
                        "title": "State store name",
                        "type": "string",
                        "description": "Named key-value store used for dedupe and case snapshots. Use __RUN_DEFAULT__ to keep state in the default store for each run.",
                        "default": "cbp-adcvd-state"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
