> ## Documentation Index
> Fetch the complete documentation index at: https://terminal49.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Document processing workflows

> Submit shipping documents by email or API, then consume structured extraction results via webhooks in your Terminal49 document processing workflow.

Shipping documents (House Bills of Lading, Master Bills of Lading, arrival notices, delivery orders, and more) arrive in shared inboxes and have traditionally required manual classification, data entry, and filing. This integration automates that workflow: Terminal49 receives each document by email, classifies it, extracts structured fields, and delivers the results to your system via webhook.

The outcome is less manual re-keying, faster time-to-file, and fewer errors from misfiled or delayed documents, freeing your team from routine data entry to focus on true exceptions.

Submit documents by emailing attachments to your account docs alias. Terminal49 then handles the rest: classify -> extract -> webhook result.

## Coming soon

* **`email_submission.created` event:** a webhook fired immediately on email receipt, before classification and extraction complete.
* **Action required flow:** documentation in progress.

## Before you start

Make sure you have the following in place before building:

**1. Terminal49 account access**

Confirm you can log in and switch between the test and production accounts (see [Environments](#environments) below).

**2. API key**

Generate an API key from **User > Developers > API Keys**. You'll need this to register your webhook and call the API.

**3. A publicly accessible HTTPS endpoint**

Your server needs a reachable HTTPS URL to receive webhook POST requests from Terminal49. For local development, use a tool like [ngrok](https://ngrok.com) to expose a local port.

**4. Webhook subscription**

Register your endpoint and subscribe to `document_representation.created` and `document_representation.failed` (see [Subscribing to events](#subscribing-to-events) below).

## Environments

Your Terminal49 account may have separate test and production environments, accessible from the account switcher in the top-left corner when you log in.

> [!WARNING]
>
> Both environments make live calls. Terminal49 processes documents submitted under either account, and you incur costs for each one. There is no free sandbox for document processing at this time.

## Authentication

All API calls require an API key passed as a Bearer token:

```
Authorization: Token YOUR_API_KEY
```

To get your API key, go to **User > Developers > API Keys** (click your username in the bottom-left corner of the navigation). For more detail, see [Start Here](https://terminal49.com/docs/api-docs/getting-started/start-here.md).

## Subscribing to events

Register a webhook endpoint to receive document processing notifications:

```bash theme={null}
curl -X POST https://api.terminal49.com/v2/webhooks \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "webhook",
      "attributes": {
        "url": "https://your-server.com/webhooks/t49-documents",
        "active": true,
        "events": [
          "document_representation.created",
          "document_representation.failed"
        ]
      }
    }
  }'
```

You can also configure webhooks from the Terminal49 dashboard:

1. Click your username in the bottom-left corner of the navigation.
2. Go to **User > Developers > Webhooks**.
3. To add a new endpoint, click **Create Webhook**, fill in your URL, and select the relevant events under **Document Events**.
4. To update an existing endpoint, click into it and toggle on the document events you need.

## Webhook endpoint requirements

Your endpoint must meet the following requirements to reliably receive webhook notifications:

**Response codes:** Return HTTP `200`, `201`, `202`, or `204`. Any other response (including a timeout) is treated as a delivery failure and will trigger retries.

**Retries:** Terminal49 will retry failed deliveries multiple times. Design your endpoint to be idempotent. Use `data.id` (the `webhook_notification` UUID) as your idempotency key to avoid processing the same event twice.

**HTTPS:** Your endpoint must be accessible over HTTPS.

**IP allowlist:** Webhook notifications are sent from the following IP addresses. Allowlist these if your infrastructure restricts inbound traffic:

```
35.222.62.171
3.230.67.145
44.217.15.129
```

**Signature verification (recommended):** Each webhook is signed using HMAC SHA-256. The signature is included in the `X-T49-Webhook-Signature` header. To verify, retrieve the `secret` from your webhook configuration and compute the HMAC digest of the raw request body; it should match the header value.

```ruby theme={null}
secret = ENV.fetch('T49_WEBHOOK_SECRET')
hmac = OpenSSL::HMAC.hexdigest('SHA256', secret, request.body.read)
verified = request.headers['X-T49-Webhook-Signature'] == hmac
```

## Workflow diagrams

```mermaid theme={null}
flowchart LR
    A[Email sent to docs alias] --> B[Terminal49 receives document]
    B --> C{Duplicate?}
    C -- Yes --> Z[Ignored, no webhook fired]
    C -- No --> D[Terminal49 classifies document]
    D --> E[Terminal49 extracts structured data]
    E --> F{Extraction outcome}
    F -- Success --> G[document_representation.created]
    F -- Failure --> H[document_representation.failed]
```

## Workflow: step-by-step

**1. Submit document**

Email attachments to your account's unique docs alias (for example, `youraccount-42@docs.terminal49.com`). Find your alias under **User > Developers > API Keys**.

**Supported file types:** PDF, PNG, JPEG, XLSX, XLS, CSV, Word (.doc, .docx).

**Multiple attachments:** Each attachment in a single email is processed independently and generates its own webhook event. All resulting webhooks reference the same `email_submission`.

**Unsupported files:** Encrypted or password-protected files cannot be processed and will result in a `document_representation.failed` event.

**2. Terminal49 processes document**

Terminal49 classifies and extracts structured data asynchronously. Processing typically completes within seconds to a few minutes depending on document complexity.

**3. Receive webhook result**

You receive `document_representation.created` (extraction succeeded) or `document_representation.failed` (extraction could not complete). Parse the payload, route by `document_type`, store the extracted fields, and trigger your downstream processes.

> [!TIP]
>
> Treat submission as fire-and-forget. Do not poll or wait for a response after sending the email. The webhook is the signal that processing is complete.

> [!NOTE]
>
> If the same file content has already been processed for your account, it is treated as a duplicate and ignored. No webhook is fired.

## Webhooks you should handle

A `document_representation` is the structured extraction result for a document. `document_representation.created` means extraction succeeded and structured data is available in the payload. `document_representation.failed` means Terminal49 could not produce an extraction result.

| Event | Meaning | Signal |
| - | - | - |
| `document_representation.created` | Extraction completed successfully | `document_type` is set; `payload` contains extracted fields |
| `document_representation.failed` | Extraction did not complete | `document_type` is `"unknown"`; `last_document_representation` is `null` |

## Webhook payload structure

Every document webhook follows the same envelope structure. The `payload` object inside `document_representation` contains the extracted fields and varies by document type. See [Document Types in Scope](#document-types-in-scope) for full examples.

`document_representation.created` envelope:

```json theme={null}
{
  "data": {
    "id": "e80ca7f4-064a-4598-b642-bddb06a003af",
    "type": "webhook_notification",
    "attributes": {
      "event": "document_representation.created",
      "delivery_status": "pending",
      "created_at": "2026-03-27T20:05:39Z"
    },
    "relationships": {
      "reference_object": {
        "data": {
          "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996",
          "type": "document"
        }
      }
    }
  },
  "included": [
    {
      "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094",
      "type": "document_representation",
      "attributes": {
        "schema_version": "draft_house_bill_of_lading@2026-03-23",
        "payload": {},
        "created_at": "2026-03-27T20:05:39Z",
        "updated_at": "2026-03-27T20:05:39Z"
      }
    },
    {
      "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996",
      "type": "document",
      "attributes": {
        "document_type": "draft_house_bill_of_lading",
        "source": "email",
        "file_name": "invoice.pdf",
        "file_url": "https://t49-documents-prod.s3.amazonaws.com/..."
      },
      "relationships": {
        "email_submission": {
          "data": {
            "id": "83bae977-c0e8-454c-b630-c8e43bc365f7",
            "type": "email_submission"
          }
        },
        "last_document_representation": {
          "data": {
            "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094",
            "type": "document_representation"
          }
        }
      }
    }
  ]
}
```

When the webhook document is a child document (split from a larger packet), the document include also contains `attributes.parsed.packetSegment` and a `parent_document` relationship:

```json theme={null}
{
  "id": "child-document-id",
  "type": "document",
  "attributes": {
    "document_type": "arrival_notice",
    "file_name": "packet_child_1.pdf",
    "file_url": "https://t49-documents-prod.s3.amazonaws.com/...",
    "parsed": {
      "packetSegment": {
        "startPage": 3,
        "endPage": 7
      }
    }
  },
  "relationships": {
    "parent_document": {
      "data": {
        "id": "parent-document-id",
        "type": "document"
      }
    },
    "last_document_representation": {
      "data": {
        "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094",
        "type": "document_representation"
      }
    }
  }
}
```

> [!NOTE]
>
> `file_url` is a pre-signed S3 URL and expires after 1 hour. Download the file promptly after receiving the webhook, or fetch a fresh URL using the endpoint below.

### Fetching a fresh download URL

If the `file_url` from the webhook has expired, request a new one:

```bash theme={null}
curl -X GET https://api.terminal49.com/v2/documents/{id}/download_url \
  -H "Authorization: Token YOUR_API_KEY"
```

Replace `{id}` with the document `id` from the webhook payload. Response:

```json theme={null}
{
  "download_url": "https://t49-documents-prod.s3.amazonaws.com/..."
}
```

### Schema versioning

Every webhook payload includes a `schema_version` field that identifies the document type and the schema date in use:

```
"schema_version": "draft_house_bill_of_lading@2026-03-23"
```

Your account is pinned to a specific schema date. All document types will use the latest schema version up to and including that date. Terminal49 can update your pinned version when you are ready to migrate.

**What changes the version:**

* Breaking changes (fields removed, renamed, or restructured) increment the date. Terminal49 will either support parallel versions during a migration window or coordinate a cutover date with you.
* Non-breaking additions (new optional fields) do not change the version.

Use `schema_version` to route your parsing logic. If you support multiple versions, branch on this field.

### Persisting extracted data

Use the `document_type` and `schema_version` to look up the expected `payload` fields for that document type, then store the extracted data in your system.

### Handling a failed extraction

If extraction fails, you will receive `document_representation.failed` instead. The key signal is `"document_type": "unknown"` means the document was received but could not be classified or extracted. There is no `document_representation` in `included` and `last_document_representation` will be `null`.

```json theme={null}
{
  "data": {
    "id": "2358fdd4-4489-48e7-b134-32cbb613d886",
    "type": "webhook_notification",
    "attributes": {
      "event": "document_representation.failed",
      "delivery_status": "pending",
      "created_at": "2026-03-27T20:46:56Z"
    },
    "relationships": {
      "reference_object": {
        "data": {
          "id": "1d658b46-e169-4a3d-a835-8edd0f7d3f95",
          "type": "document"
        }
      }
    }
  },
  "included": [
    {
      "id": "15f50a1d-7b1a-466c-b3ae-92bdf9989b8d",
      "type": "email_submission",
      "attributes": {
        "subject": "Shipping documents: MBL 6880954035 / HBL CVPSHA79657669",
        "from": ["export.docs@example.net"],
        "sent_at": "2026-03-27T13:46:32-07:00"
      }
    },
    {
      "id": "1d658b46-e169-4a3d-a835-8edd0f7d3f95",
      "type": "document",
      "attributes": {
        "document_type": "unknown",
        "file_name": "ccae7e3c9acb59009f7a44c5178cdf86_fail-8946.pdf",
        "file_url": "https://t49-documents-prod.s3.amazonaws.com/..."
      },
      "relationships": {
        "last_document_representation": {
          "data": null
        },
        "email_submission": {
          "data": {
            "id": "15f50a1d-7b1a-466c-b3ae-92bdf9989b8d",
            "type": "email_submission"
          }
        }
      }
    }
  ]
}
```

> [!WARNING]
>
> `document_type: "unknown"` means Terminal49 could not classify or extract the document. Log the document `id` and `file_url` for investigation. If failures recur on the same document type, contact Terminal49 support.

## Document types in scope

The table below lists the document types Terminal49 currently classifies and extracts, along with the `document_type` value returned by the API.

| Document type | `document_type` value | Notes |
| - | - | - |
| Draft House Bill of Lading | `draft_house_bill_of_lading` | `hbl_type: "DRAFT"` in payload |
| Final House Bill of Lading | `final_house_bill_of_lading` | `hbl_type: "TELEX"` in payload; often issued as a Sea Waybill |
| Importer Security Filing | `importer_security_filing` | |
| Master Bill of Lading | `master_bill_of_lading` | Often issued as a Sea Waybill |
| Delivery Order | `dray_delivery_order` | |
| Arrival Notice | `arrival_notice` | |
| General Notice | `general_notice` | Includes container available notices |
| Customs Entry | `customs_entry` | Includes in-bond documents |
| Other | `other` | Used when no dedicated schema exists yet, e.g. freight invoices |

Additional document types will be added in future phases.

> [!NOTE]
>
> **Null fields are intentional.** A `null` value means Terminal49 looked for that field in the source document but did not find it. Treat `null` as "checked, not present" rather than "field not supported" or "not checked".

### Draft House Bill of Lading: full webhook payload

`schema_version: draft_house_bill_of_lading@2026-03-23`

```json theme={null}
{
  "data": {
    "id": "d6042ddb-c694-4c94-9934-1bfe300403b1",
    "type": "webhook_notification",
    "attributes": {
      "event": "document_representation.created",
      "delivery_status": "pending",
      "created_at": "2026-03-27T20:05:03Z"
    },
    "relationships": {
      "reference_object": {
        "data": { "id": "2354e6ad-5ef6-433c-aa74-c5b3e6c479fd", "type": "document" }
      }
    }
  },
  "included": [
    {
      "id": "430dd964-af36-4996-afc1-e37521880e3d",
      "type": "document_representation",
      "attributes": {
        "schema_version": "draft_house_bill_of_lading@2026-03-23",
        "created_at": "2026-03-27T20:05:03Z",
        "updated_at": "2026-03-27T20:05:03Z",
        "payload": {
          "hbl_type": "DRAFT",
          "hbl_number": "CVPSHA79657669",
          "carrier_booking_number": "6880954035",
          "reference_number_isf": "CVPSHA79657669",
          "fmc_oti_number": "038277N",
          "date_of_issue": "01-02-2026",
          "shipped_on_board_date": "07-Feb-26",
          "freight_payment_terms": "PREPAID",
          "service_mode": "CFS/CY",
          "vessel_name": "CAPE VELLMAR",
          "voyage_number": "951E",
          "port_of_loading": "SHANGHAI,CHINA",
          "port_of_discharge": "LOS ANGELES, CALIFORNIA, USA",
          "place_of_receipt": "SHANGHAI,CHINA",
          "place_of_delivery": "ONTARIO, CALIFORNIA, USA",
          "point_and_country_of_origin": "SHANGHAI,CHINA",
          "signed_at": "SHANGHAI",
          "signed_by": "CORVANE PACIFIC LOGISTICS LTD. as agent of the Carrier",
          "shipper": {
            "name": "SHANGHAI QIAOLAN SOFT FURNISHINGS CO., LTD",
            "address": "NO. 318 LANGCHEN ROAD, SONGJIANG DISTRICT, SHANGHAI, CHINA"
          },
          "consignee": {
            "name": "LINDEN & HALE HOME GOODS LLC",
            "address": "C/O CORVANE PACIFIC LOGISTICS (USA) INC, 4127 HALVERN AVE, ONTARIO, CA 91761"
          },
          "notify_party": {
            "name": "BRIGHTMOOR CUSTOMS BROKERAGE INC.",
            "email": "entries@example.com",
            "phone": "732-555-0148",
            "address": "1450 CALLOWAY RD, SUITE 210, ISELIN, NJ 08830"
          },
          "containers": [
            {
              "container_number": "CSNU3771803",
              "seal_number": "CN7928018",
              "container_size": "40HIGH",
              "gross_weight": "1499.11",
              "weight_unit": "KGS",
              "measurement": "8.364",
              "measurement_unit": "CBM",
              "number_of_packages": "36",
              "package_unit": "CARTONS",
              "cargo_references": ["LH-166695", "LH-776026"]
            }
          ],
          "line_items": [
            {
              "description": "THE SOFA",
              "quantity": "36",
              "quantity_unit": "CARTONS",
              "weight": "1499.11",
              "weight_unit": "KGS",
              "measurement": "8.364",
              "measurement_unit": "CBM",
              "hts_codes": ["9401616031"],
              "cargo_references": ["LH-166695", "LH-776026"]
            }
          ],
          "totals": {
            "number_of_packages": "36",
            "package_unit": "CARTONS",
            "gross_weight": "1499.11 KGS",
            "weight_unit": "KGS",
            "measurement": "8.364 CBM",
            "measurement_unit": "CBM"
          }
        }
      }
    },
    {
      "id": "1701fbf0-1407-45e8-8fce-5d1ad7e2d2f2",
      "type": "email_submission",
      "attributes": {
        "subject": "Shipping documents: MBL 6880954035 / HBL CVPSHA79657669",
        "from": ["export.docs@example.net"],
        "sent_at": "2026-03-27T13:03:05-07:00"
      }
    },
    {
      "id": "2354e6ad-5ef6-433c-aa74-c5b3e6c479fd",
      "type": "document",
      "attributes": {
        "document_type": "draft_house_bill_of_lading",
        "source": "email",
        "file_name": "ccae7e3c9acb59009f7a44c5178cdf86.pdf",
        "file_url": "https://t49-documents-prod.s3.amazonaws.com/..."
      },
      "relationships": {
        "last_document_representation": {
          "data": { "id": "430dd964-af36-4996-afc1-e37521880e3d", "type": "document_representation" }
        },
        "email_submission": {
          "data": { "id": "1701fbf0-1407-45e8-8fce-5d1ad7e2d2f2", "type": "email_submission" }
        }
      }
    }
  ]
}
```

### Final House Bill of Lading: full webhook payload

`schema_version: final_house_bill_of_lading@2026-03-23`

```json theme={null}
{
  "data": {
    "id": "e80ca7f4-064a-4598-b642-bddb06a003af",
    "type": "webhook_notification",
    "attributes": {
      "event": "document_representation.created",
      "delivery_status": "pending",
      "created_at": "2026-03-27T20:05:39Z"
    },
    "relationships": {
      "reference_object": {
        "data": { "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996", "type": "document" }
      }
    }
  },
  "included": [
    {
      "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094",
      "type": "document_representation",
      "attributes": {
        "schema_version": "final_house_bill_of_lading@2026-03-23",
        "created_at": "2026-03-27T20:05:39Z",
        "updated_at": "2026-03-27T20:05:39Z",
        "payload": {
          "hbl_type": "TELEX",
          "hbl_number": "CVPXMN05166597",
          "carrier_booking_number": "ZIMUXIA2956643",
          "reference_number_isf": "CVPXMN05166597",
          "fmc_oti_number": "038277N",
          "date_of_issue": "29-01-2026",
          "shipped_on_board_date": "22-Jan-26",
          "freight_payment_terms": "PREPAID",
          "service_mode": "CFS/CY",
          "vessel_name": "NORDIC TAMARIND",
          "voyage_number": "547N",
          "port_of_loading": "XIAMEN,CHINA",
          "port_of_discharge": "JACKSONVILLE,FLORIDA,USA",
          "place_of_receipt": "XIAMEN,CHINA",
          "place_of_delivery": "JACKSONVILLE,FLORIDA,USA",
          "point_and_country_of_origin": "XIAMEN,CHINA",
          "signed_at": "XIAMEN",
          "signed_by": "CORVANE PACIFIC LOGISTICS LTD. as agent of the Carrier",
          "shipper": {
            "name": "DONGGUAN HEXIN HOMEWARE CO., LTD",
            "address": "NO. 27 XINGHE 3RD ROAD, CHASHAN TOWN, DONGGUAN, GUANGDONG, CHINA"
          },
          "consignee": {
            "name": "CASCADE RIDGE HOME FURNISHINGS INC.",
            "address": "22810 FERNCLIFF WAY S, KENT, WA 98032, UNITED STATES"
          },
          "notify_party": {
            "name": "BRIGHTMOOR CUSTOMS BROKERAGE INC.",
            "email": "entries@example.com",
            "phone": "732-555-0148",
            "address": "1450 CALLOWAY RD, SUITE 210, ISELIN, NJ 08830"
          },
          "containers": [
            {
              "container_number": "ZIMU0934383",
              "seal_number": "ZS8770969",
              "container_size": "40HIGH",
              "gross_weight": "565.0",
              "weight_unit": "KGS",
              "measurement": "2.552",
              "measurement_unit": "CBM",
              "number_of_packages": "41",
              "package_unit": "CARTONS",
              "cargo_references": ["CR0822422"]
            },
            {
              "container_number": "ZIMU0934383",
              "seal_number": "ZS8770969",
              "container_size": "40HIGH",
              "gross_weight": "534",
              "weight_unit": "KGS",
              "measurement": "2.818",
              "measurement_unit": "CBM",
              "number_of_packages": "16",
              "package_unit": "CARTONS",
              "cargo_references": ["CR1294318"]
            }
          ],
          "line_items": [
            {
              "description": "PET GATE",
              "weight": "1099.0",
              "weight_unit": "KGS",
              "measurement": "5.370",
              "measurement_unit": "CBM",
              "hts_codes": ["442199"]
            },
            {
              "description": "PET RAMP",
              "hts_codes": ["442199"],
              "cargo_references": ["CR1509129"]
            },
            {
              "description": "DOG HOUSE",
              "hts_codes": ["442199"]
            },
            {
              "description": "COMMODITY SHELF",
              "hts_codes": ["442199"],
              "cargo_references": ["CR3469170"]
            }
          ],
          "totals": {
            "number_of_packages": "57",
            "package_unit": "CARTONS",
            "gross_weight": "1099.0 KGS",
            "weight_unit": "KGS",
            "measurement": "5.370 CBM",
            "measurement_unit": "CBM"
          }
        }
      }
    },
    {
      "id": "3fc27047-54ab-49ac-ab3a-36c8a7a6536d",
      "type": "email_submission",
      "attributes": {
        "subject": null,
        "from": ["export.docs@example.net"],
        "sent_at": "2026-03-27T23:03:18+03:00"
      }
    },
    {
      "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996",
      "type": "document",
      "attributes": {
        "document_type": "final_house_bill_of_lading",
        "source": "email",
        "file_name": "8b1aa25a1decce7380d75b124c0b373e.pdf",
        "file_url": "https://t49-documents-prod.s3.amazonaws.com/..."
      },
      "relationships": {
        "last_document_representation": {
          "data": { "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094", "type": "document_representation" }
        },
        "email_submission": {
          "data": { "id": "3fc27047-54ab-49ac-ab3a-36c8a7a6536d", "type": "email_submission" }
        }
      }
    }
  ]
}
```

### ISF (Importer Security Filing): full webhook payload

`schema_version: importer_security_filing@2026-03-30`

```json theme={null}
{
  "data": {
    "id": "e80ca7f4-064a-4598-b642-bddb06a003af",
    "type": "webhook_notification",
    "attributes": {
      "event": "document_representation.created",
      "delivery_status": "pending",
      "created_at": "2026-03-27T20:05:39Z"
    },
    "relationships": {
      "reference_object": {
        "data": { "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996", "type": "document" }
      }
    }
  },
  "included": [
    {
      "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094",
      "type": "document_representation",
      "attributes": {
        "schema_version": "importer_security_filing@2026-03-30",
        "created_at": "2026-03-27T20:05:39Z",
        "updated_at": "2026-03-27T20:05:39Z",
        "payload": {
          "importer_name": "Linden & Hale Home Goods LLC",
          "importer_of_record_number": null,
          "po_numbers": ["LH-018501"],
          "description_of_goods": null,
          "bol_type": null,
          "hbl_number": "CVPSHA52236347",
          "mbl_number": "COSU6032584794",
          "etd": "07-Feb-26",
          "eta": "25-Feb-26",
          "consignee_name": "Linden & Hale Home Goods LLC",
          "consignee_address_1": "C/O CORVANE PACIFIC LOGISTICS (USA) INC, 4127 HALVERN AVE, ONTARIO, CA 91761",
          "consignee_address_2": null,
          "consignee_city": null,
          "consignee_state": null,
          "consignee_postal_code": null,
          "consignee_country": "US",
          "consignee_irs_tax_id": null,
          "buyer_name": "Linden & Hale Home Goods LLC",
          "buyer_address_1": "C/O CORVANE PACIFIC LOGISTICS (USA) INC, 4127 HALVERN AVE, ONTARIO, CA 91761",
          "buyer_address_2": null,
          "buyer_city": null,
          "buyer_state": null,
          "buyer_postal_code": null,
          "buyer_country": "US",
          "buyer_duns": null,
          "buyer_duns4": null,
          "ship_to_name": "Linden & Hale Fontana DC",
          "ship_to_address_1": "15820 Arrowcrest Blvd, Fontana, CA 92335",
          "ship_to_address_2": null,
          "ship_to_city": null,
          "ship_to_state": null,
          "ship_to_postal_code": null,
          "ship_to_country": "US",
          "seller_name": "Shenyang Beiluo Furniture Trading Co., Ltd",
          "seller_address_1": "No. 76 Beiluo Street, Yuhong District, Shenyang, Liaoning, 110141",
          "seller_address_2": null,
          "seller_city": null,
          "seller_state_province": null,
          "seller_postal_code": "110141",
          "seller_country": "China",
          "seller_duns": null,
          "seller_duns4": null,
          "consolidator_name": "Chengdu Yunqiao Supply Chain Co., Ltd",
          "consolidator_address_1": "Room 1207, No. 9 Yunqiao Road, Shuangliu District, Chengdu, China, 610200",
          "consolidator_address_2": null,
          "consolidator_city": null,
          "consolidator_province": null,
          "consolidator_postal_code": "610200",
          "consolidator_country": "China",
          "consolidator_duns": null,
          "consolidator_duns4": null,
          "stuffing_location_name": "Shanghai Songhao Warehousing Co., Ltd",
          "stuffing_location_address_1": "No. 468 Haoyuan Road, Songjiang District, Shanghai",
          "stuffing_location_address_2": null,
          "stuffing_location_city": null,
          "stuffing_location_province": null,
          "stuffing_location_postal_code": "201600",
          "stuffing_location_country": "China",
          "stuffing_location_duns": null,
          "stuffing_location_duns4": null,
          "manufacturer_name": "HUZHOU QINGSHAO FURNITURE MANUFACTURING CO., LTD",
          "manufacturer_address_1": "NO. 12 QINGSHAO INDUSTRIAL PARK, CHANGXING COUNTY, HUZHOU, ZHEJIANG, CHINA",
          "manufacturer_address_2": null,
          "manufacturer_city": null,
          "manufacturer_province": null,
          "manufacturer_postal_code": "313100",
          "manufacturer_country": "China",
          "manufacturer_duns": null,
          "manufacturer_duns4": null,
          "hts_code": "9401719000",
          "country_of_origin": "China"
        }
      }
    },
    {
      "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996",
      "type": "document",
      "attributes": {
        "document_type": "importer_security_filing",
        "source": "email",
        "file_name": "isf.pdf",
        "file_url": "https://t49-documents-prod.s3.amazonaws.com/..."
      },
      "relationships": {
        "last_document_representation": {
          "data": { "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094", "type": "document_representation" }
        },
        "email_submission": {
          "data": { "id": "3fc27047-54ab-49ac-ab3a-36c8a7a6536d", "type": "email_submission" }
        }
      }
    }
  ]
}
```

### Master Bill of Lading: full webhook payload

`schema_version: master_bill_of_lading@2026-03-23`

```json theme={null}
{
  "data": {
    "id": "e80ca7f4-064a-4598-b642-bddb06a003af",
    "type": "webhook_notification",
    "attributes": {
      "event": "document_representation.created",
      "delivery_status": "pending",
      "created_at": "2026-03-27T20:05:39Z"
    },
    "relationships": {
      "reference_object": {
        "data": { "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996", "type": "document" }
      }
    }
  },
  "included": [
    {
      "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094",
      "type": "document_representation",
      "attributes": {
        "schema_version": "master_bill_of_lading@2026-03-23",
        "created_at": "2026-03-27T20:05:39Z",
        "updated_at": "2026-03-27T20:05:39Z",
        "payload": {
          "document_state": "NON-NEGOTIABLE",
          "waybill_number": "EGLV387305226462",
          "booking_number": "387305226462",
          "carrier_reference": null,
          "carrier_name": "Evergreen Line",
          "scac_code": "EGLV",
          "export_references": null,
          "service_contract_number": null,
          "service_type": "FCL/FCL",
          "movement_type": "O/O",
          "number_of_original_waybills": "NIL (0)",
          "rider_pages": null,
          "shipper": {
            "name": "VINAREACH FREIGHT (VIETNAM) CO., LTD",
            "address": "LOT B4, 61 DAO TRI VIEN STREET, TAN THUAN WARD, HO CHI MINH CITY, VIETNAM",
            "email": null,
            "phone": null
          },
          "consignee": {
            "name": "NORTHGATE HARBOR LOGISTICS INC",
            "address": "75 LARKSPUR INDUSTRIAL DR, CANTON, MA 02021 UNITED STATES",
            "email": "ocean.imports@example.net",
            "phone": "1 781-555-0176"
          },
          "notify_party": {
            "name": "NORTHGATE HARBOR LOGISTICS INC.",
            "address": "75 LARKSPUR INDUSTRIAL DR, CANTON, MA 02021 UNITED STATES",
            "email": "ocean.imports@example.net",
            "phone": "1 781-555-0176"
          },
          "also_notify": null,
          "actual_shipper": null,
          "forwarding_agent_references": null,
          "point_and_country_of_origin": null,
          "pre_carriage_by": null,
          "place_of_receipt": "HO CHI MINH CITY",
          "date_of_receipt": null,
          "ocean_vessel": "AURORA SOLENNE",
          "voyage_number": "5326-603E",
          "port_of_loading": "CAI MEP",
          "transshipment_port": null,
          "port_of_discharge": "LOS ANGELES, CA",
          "place_of_delivery": "LOS ANGELES, CA",
          "onward_inland_routing": null,
          "marks_and_numbers": "N/M",
          "containers": [
            {
              "container_number": "EGHU1661369",
              "seal_number": "EMCPYK7132",
              "container_size": "40H",
              "slac": null,
              "gross_weight": null,
              "weight_unit": null,
              "measurement": null,
              "measurement_unit": null,
              "number_of_packages": null,
              "package_unit": null
            }
          ],
          "description_of_goods": "SOFA",
          "hts_codes": ["9401616011"],
          "invoice_references": [],
          "hbl_reference": null,
          "cargo_references": ["PO#44867"],
          "total_packages": 133,
          "package_unit": "CARTONS",
          "gross_weight": 6293.8,
          "tare_weight": null,
          "tare_weight_unit": null,
          "weight_unit": "KGS",
          "measurement": 58.6,
          "measurement_unit": "CBM",
          "total_containers_received": 1,
          "total_containers_in_words": "ONE(1) CONTAINER ONLY",
          "freight_payment_terms": "COLLECT",
          "prepaid_at": null,
          "collect_at": "DESTINATION",
          "freight_payable_at": null,
          "place_of_issue": "HO CHI MINH",
          "date_of_issue": "FEB.19,2026",
          "laden_on_board_date": "FEB.19,2026",
          "signed_by": "PHU AN SHIPPING AGENCY LTD. As agent for the Carrier"
        }
      }
    },
    {
      "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996",
      "type": "document",
      "attributes": {
        "document_type": "master_bill_of_lading",
        "source": "email",
        "file_name": "8b1aa25a1decce7380d75b124c0b373e.pdf",
        "file_url": "https://t49-documents-prod.s3.amazonaws.com/..."
      },
      "relationships": {
        "last_document_representation": {
          "data": { "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094", "type": "document_representation" }
        },
        "email_submission": {
          "data": { "id": "3fc27047-54ab-49ac-ab3a-36c8a7a6536d", "type": "email_submission" }
        }
      }
    }
  ]
}
```

### Delivery Order: full webhook payload

`schema_version: dray_delivery_order@2026-03-30`

```json theme={null}
{
  "data": {
    "id": "e80ca7f4-064a-4598-b642-bddb06a003af",
    "type": "webhook_notification",
    "attributes": {
      "event": "document_representation.created",
      "delivery_status": "pending",
      "created_at": "2026-03-27T20:05:39Z"
    },
    "relationships": {
      "reference_object": {
        "data": { "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996", "type": "document" }
      }
    }
  },
  "included": [
    {
      "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094",
      "type": "document_representation",
      "attributes": {
        "schema_version": "dray_delivery_order@2026-03-30",
        "created_at": "2026-03-27T20:05:39Z",
        "updated_at": "2026-03-27T20:05:39Z",
        "payload": {
          "issuer_name": "Meridale Freight Services Inc",
          "issuer_fmc_oti_number": "033160NF",
          "document_date": null,
          "document_number": null,
          "consol_number": null,
          "prepared_by": null,
          "prepared_date": null,
          "pickup_terminal_name": "APM Terminal, New Jersey",
          "pickup_address_name": "New York APM Terminal, New Jersey",
          "pickup_address": null,
          "pickup_address_phone": null,
          "delivery_name": "Ashbury Lane Distribution Center",
          "delivery_address": "88 Wexcombe Dr, Edison, NJ 08837 US",
          "ocean_carrier": "Hapag-Lloyd",
          "mbol": "HLCUSGN2667S5181",
          "hbol": null,
          "vessel_name": "PACIFIC WRENFIELD",
          "voyage_number": "221W",
          "transport_mode": null,
          "port_of_loading": "Vung Tau",
          "port_of_discharge": "New York",
          "eta": "02/20/2026 EST",
          "door_eta": null,
          "entry_number": null,
          "freight_payment_terms": null,
          "service_type": null,
          "movement_type": null,
          "customer": "Thinh Loc Wood Products Co., Ltd",
          "goods_description": null,
          "package_count": null,
          "measurement_cbm": null,
          "measurement_cft": null,
          "cargo_references": ["4554935913"],
          "delivery_notes": null,
          "delivery_carrier": "Pinecroft Drayage LLC",
          "routing_legs": null,
          "containers": [
            {
              "container_number": "HLBU4355847",
              "seal_number": "HLD5141135",
              "container_type": "ISO_45G0",
              "gross_weight_kg": null,
              "gross_weight_lb": 15653.0
            }
          ]
        }
      }
    },
    {
      "id": "2426e112-a8ee-41ab-a68c-0ddf9ac03996",
      "type": "document",
      "attributes": {
        "document_type": "dray_delivery_order",
        "source": "email",
        "file_name": "DO_6219053.pdf",
        "file_url": "https://t49-documents-prod.s3.amazonaws.com/..."
      },
      "relationships": {
        "last_document_representation": {
          "data": { "id": "616fc271-65f6-458f-ba8c-bc5bcc6d5094", "type": "document_representation" }
        },
        "email_submission": {
          "data": { "id": "3fc27047-54ab-49ac-ab3a-36c8a7a6536d", "type": "email_submission" }
        }
      }
    }
  ]
}
```

## Use these endpoints while integrating

* [`GET /webhook_notifications/examples`](https://terminal49.com/docs/api-docs/api-reference/webhook-notifications/get-webhook-notification-payload-examples)
* [`POST /webhooks/trigger`](https://terminal49.com/docs/api-docs/api-reference/webhooks/trigger-a-webhook)

You can trigger a test payload for a specific document type without sending an email:

```bash theme={null}
curl -X POST https://api.terminal49.com/v2/webhooks/trigger \
  -H "Authorization: Token YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-endpoint.example/webhooks",
    "event": "document_representation.created",
    "sample": {
      "document_type": "dray_delivery_order"
    }
  }'
```

> [!NOTE]
>
> Webhook event availability depends on your account configuration. If you are not receiving expected events, contact Terminal49 support.

## APIs involved

* [`GET /documents`](https://terminal49.com/docs/api-docs/api-reference/documents/list-documents)
* [`GET /documents/{id}`](https://terminal49.com/docs/api-docs/api-reference/documents/get-a-document)
* [`GET /documents/{id}/download_url`](https://terminal49.com/docs/api-docs/api-reference/documents/get-a-document-download-url)
* [`GET /email_submissions`](https://terminal49.com/docs/api-docs/api-reference/email-submissions/list-email-submissions)
* [`GET /email_submissions/{id}`](https://terminal49.com/docs/api-docs/api-reference/email-submissions/get-an-email-submission)
* [`GET /document_schemas/{id}`](https://terminal49.com/docs/api-docs/api-reference/document-schemas/get-a-document-schema)
* [`Document representations resource`](https://terminal49.com/docs/api-docs/api-reference/document-representations/document-representations-resource)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.