# Container Number Extractor & Validator (ISO 6346) (`veltrixo/container-number-extractor-validator`) Actor

Extract every shipping container number from emails, spreadsheets or text. Validates the ISO 6346 check digit, removes duplicates and adds the carrier or lessor. No scraping, instant.

- **URL**: https://apify.com/veltrixo/container-number-extractor-validator.md
- **Developed by:** [Ryan Lems](https://apify.com/veltrixo) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 container results

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Container Number Extractor & Validator (ISO 6346)

Turn messy emails, booking confirmations, packing lists and spreadsheets into a **clean, deduplicated list of valid shipping container numbers** — in one run, in seconds.

### What it does

- **Finds** every container number in free text, CSV cells or a plain list — also when written as `MSKU 123456-5`, `msku1234565` or `MSKU-123-456-5`.
- **Validates** the ISO 6346 check digit and tells you the correct digit when a number has a typo.
- **Deduplicates** and counts how often each container appears and in which source line.
- **Identifies the owner**: carrier (Maersk, MSC, CMA CGM, Hapag-Lloyd, ONE, COSCO, Evergreen, …) or leasing company (Textainer, Triton, CAI, …) — best-effort hint from the owner code.
- **Decodes ISO size/type codes** such as `22G1`, `45G1`, `45R1`.

No websites are scraped and no third-party data is fetched: results are instant, private and stable.

### Who uses it

Freight forwarders, customs brokers, shippers and logistics developers who want to:

- clean container lists before sending them to a tracking tool or TMS;
- catch typos before they cause failed bookings or customs declarations;
- automate inbox processing with Make, Zapier, n8n or the Apify API.

### Input

| Field | Example |
|---|---|
| `text` | `Please load CSQU 305438-3 and MSKU1234565.` |
| `containerNumbers` | `["CSQU3054383", "HLCU1234560"]` |
| `csvText` | `ref,container\nA1,HLCU1234560` |
| `includeInvalid` | `true` |
| `sizeTypeCodes` | `["45G1"]` |

### Output (one row per unique container)

```json
{
  "container_number": "CSQU3054384",
  "formatted": "CSQU 305438-4",
  "is_valid": false,
  "expected_check_digit": 3,
  "owner_code": "CSQU",
  "category": "freight container",
  "carrier_hint": null,
  "owner_type": null,
  "occurrences": 1,
  "raw_matches": ["CSQU3054384"],
  "source_ids": ["list:1"]
}
```

A `SUMMARY` record in the key-value store gives totals and the decoded size/type codes. Export as JSON, CSV or Excel.

### Pricing

Pay per result: you only pay for unique containers returned. Text without container numbers costs nothing beyond the run start.

### Limitations

- The carrier/lessor hint covers the largest owners only. The official owner-code registry is maintained by BIC; unknown codes return `null`.
- A valid check digit proves the number is well-formed, not that the container exists or is in service.

### Feedback

Missing an owner code or a format? Open an issue on the Actor page.

# Actor input Schema

## `text` (type: `string`):

Paste emails, booking confirmations, packing lists or any text. All container numbers are found, including ones written with spaces or dashes (e.g. MSKU 123456-5).

## `containerNumbers` (type: `array`):

A list of container numbers to validate.

## `csvText` (type: `string`):

Paste CSV rows; every cell is scanned.

## `includeInvalid` (type: `boolean`):

Keep invalid numbers in the output (flagged is_valid=false) so you can fix typos.

## `sizeTypeCodes` (type: `array`):

E.g. 22G1, 45G1, 45R1. Decoded into the run SUMMARY.

## `maxResults` (type: `integer`):

0 = no limit.

## Actor input object example

```json
{
  "text": "Please load CSQU 305438-3 and MSKU1234565 on the next vessel.",
  "includeInvalid": true,
  "maxResults": 0
}
```

# Actor output Schema

## `results` (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 = {
    "text": "Please load CSQU 305438-3 and MSKU1234565 on the next vessel."
};

// Run the Actor and wait for it to finish
const run = await client.actor("veltrixo/container-number-extractor-validator").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 = { "text": "Please load CSQU 305438-3 and MSKU1234565 on the next vessel." }

# Run the Actor and wait for it to finish
run = client.actor("veltrixo/container-number-extractor-validator").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "text": "Please load CSQU 305438-3 and MSKU1234565 on the next vessel."
}' |
apify call veltrixo/container-number-extractor-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,veltrixo/container-number-extractor-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/HJvpchkdhl2BxyKj5/builds/SSCcFG9PaGRLoNFSZ/openapi.json
