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

# Examples

> Copyable workflows for Shipments, NCTS, RTO, and webhooks.

These examples use fictional identifiers. **Staging — For Integration Testing:** `https://staging.api.eazecustoms.com`. Do not append `/public/v1` to that host. The credential belongs in your own secret store.

```javascript theme={null}
const baseUrl = 'https://staging.api.eazecustoms.com';
const credential = process.env.EAZE_CUSTOMS_API_CREDENTIAL;
const clientRef = 'ACME-AMS';

async function api(path, { method = 'GET', body, idempotencyKey, client = true } = {}) {
  const response = await fetch(`${baseUrl}${path}`, {
    method,
    headers: {
      Authorization: `Bearer ${credential}`,
      ...(client ? { 'X-Eaze-Client-Ref': clientRef } : {}),
      ...(body ? { 'Content-Type': 'application/json' } : {}),
      ...(idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : {}),
    },
    body: body ? JSON.stringify(body) : undefined,
  });
  const text = await response.text();
  const payload = text ? JSON.parse(text) : null;
  if (!response.ok) throw new Error(`${response.status} ${text}`);
  return payload;
}
```

Set `EAZE_CUSTOMS_API_CREDENTIAL` to the full value, for example `EZ_11111111-1111-4111-8111-111111111111_exampleSecretValueNotReal`.

## Shipment and manifest import

Authenticate, select the client, create an Import Shipment, upload a manifest, import it, and read the Declaration.

```javascript theme={null}
import { createHash, randomUUID } from 'node:crypto';
import { readFile } from 'node:fs/promises';

const me = await api('/public/v1/me', { client: false });
if (!me.scopes.includes('import') || !me.scopes.includes('ncts')) {
  throw new Error('This import needs the import and ncts modules.');
}

const shipment = await api('/public/v1/shipments', {
  method: 'POST',
  idempotencyKey: randomUUID(),
  body: {
    shipmentNumber: 'SHP-2026-0142',
    shipmentType: 'IMPORT',
    enabledServices: ['clearance'],
    clientReference: 'PO-44821',
  },
});

const templates = await api('/public/v1/manifest-templates?shipmentType=IMPORT');
const manifestTemplateId = templates.data[0].id;
const fileBytes = await readFile('./manifest.csv');
const created = await api('/public/v1/uploads', {
  method: 'POST',
  idempotencyKey: randomUUID(),
  body: {
    purpose: 'shipment_manifest',
    filename: 'manifest.csv',
    contentType: 'text/csv',
    byteLength: fileBytes.byteLength,
    sha256: createHash('sha256').update(fileBytes).digest('hex'),
  },
});
const put = await fetch(created.upload.url, {
  method: 'PUT',
  headers: created.upload.requiredHeaders,
  body: fileBytes,
});
if (!put.ok) throw new Error(`Storage upload failed: ${put.status}`);
const ready = await api(`/public/v1/uploads/${created.id}/complete`, {
  method: 'POST',
  idempotencyKey: randomUUID(),
});

const accepted = await api(`/public/v1/shipments/${shipment.id}/details/import`, {
  method: 'POST',
  idempotencyKey: randomUUID(),
  body: { uploadId: ready.id, manifestTemplateId, mode: 'INITIAL' },
});
const operation = await api(`/public/v1/operations/${accepted.operationId}`);
if (operation.status === 'succeeded') {
  const declarations = await api(`/public/v1/shipments/${shipment.id}/declarations`);
  const declarationId = declarations.data[0].id;
  await api(`/public/v1/declarations/${declarationId}/goods-items`);
}
```

Poll until the Operation status is terminal. The snippet reads it once so the sequence stays short. See [Operations](https://docs.eazecustoms.com/implementation/operations.md).

Omitting `declarationTemplateIds` uses mapped defaults. See [Templates](https://docs.eazecustoms.com/implementation/templates.md).

## NCTS Departure

```javascript theme={null}
const templates = await api('/public/v1/ncts/declaration-templates?movementType=DEPARTURE');
const departure = await api('/public/v1/ncts/transit-declarations', {
  method: 'POST',
  idempotencyKey: randomUUID(),
  body: {
    commercialReference: 'TR-2026-0188',
    clientReference: 'PO-44821',
    templateId: templates.data[0].id,
    declarationType: 'T1',
    additionalDeclarationType: 'A',
    countryOfDispatch: 'NL',
    countryOfDestination: 'DE',
  },
});
```

Upload the goods file with `purpose: ncts_items`, complete it, then:

```javascript theme={null}
const accepted = await api(`/public/v1/ncts/transit-declarations/${departure.id}/details/import`, {
  method: 'POST',
  idempotencyKey: randomUUID(),
  body: { uploadId, mode: 'replace_all' },
});
const operation = await api(`/public/v1/operations/${accepted.operationId}`);
if (operation.status === 'succeeded') {
  await api(`/public/v1/ncts/transit-declarations/${departure.id}/house-consignments`);
}
```

## NCTS Arrival

Arrival does not import a goods file.

```javascript theme={null}
const arrival = await api('/public/v1/ncts/transit-declarations', {
  method: 'POST',
  idempotencyKey: randomUUID(),
  body: {
    movementType: 'ARRIVAL',
    commercialReference: 'ARR-2026-0042',
    mrn: '26NL00000000001881',
    arrivalNotificationDateTime: '2026-11-17T10:30:00Z',
  },
});
const current = await api(`/public/v1/ncts/transit-declarations/${arrival.id}`);
```

Subscribe to `ncts.arrival.released` and keep reading `current.status`. `current.businessData` and `current.finalDocumentStatuses` are on that Get response. See [NCTS Arrival](https://docs.eazecustoms.com/implementation/ncts-arrival.md).

## RTO

```javascript theme={null}
const configurations = await api('/public/v1/rto-configurations');
const shipment = await api('/public/v1/shipments', {
  method: 'POST',
  idempotencyKey: randomUUID(),
  body: {
    shipmentNumber: 'SHP-2026-0148',
    shipmentType: 'IMPORT',
    enabledServices: ['clearance', 'rto'],
    rtoConfigurationId: configurations.data[0].id,
    rtoProcessType: 'IMPORT_HANDLING',
    packageCount: 4,
    totalWeight: 86.4,
  },
});
const movements = await api(`/public/v1/shipments/${shipment.id}/movements`);
const latest = await api(`/public/v1/shipments/${shipment.id}`);
```

`latest.businessStatus.rto` is the overall process. `latest.businessData.rto` has the process, public configuration id, and account totals. `movements.data[0].status` is one movement. `rto.completed` fires when the overall status first becomes `COMPLETED`.

## Webhooks

Configure the endpoint in the Eaze Customs Portal. Store the signing secret, verify every delivery, ignore an event ID you have already handled, then read the resource. See [Set Up Webhooks](https://docs.eazecustoms.com/webhooks/setup.md), [Verify Signatures](https://docs.eazecustoms.com/webhooks/verify-signatures.md), and [Deliveries & Retries](https://docs.eazecustoms.com/webhooks/retries.md). The full receiver is in [Webhook examples](https://docs.eazecustoms.com/webhooks/examples.md).

```javascript theme={null}
if (event.type === 'import.declaration.released') {
  await fetch(`${baseUrl}/public/v1/declarations/${event.data.resource.id}`, {
    headers: {
      Authorization: `Bearer ${credential}`,
      'X-Eaze-Client-Ref': event.clientRef,
    },
  });
}
```

The helper at the top of this page sends one fixed client. For a webhook, send `event.clientRef` as `X-Eaze-Client-Ref` instead.

## Other languages

Pagination in Python:

```python theme={null}
import requests

cursor = None
while True:
    params = {"limit": 100}
    if cursor:
        params["cursor"] = cursor
    page = requests.get(
        "https://staging.api.eazecustoms.com/public/v1/shipments",
        headers={"Authorization": f"Bearer {credential}", "X-Eaze-Client-Ref": "ACME-AMS"},
        params=params,
        timeout=30,
    ).json()
    for shipment in page["data"]:
        handle(shipment)
    if not page["pagination"]["hasMore"]:
        break
    cursor = page["pagination"]["nextCursor"]
```

Authentication in C#:

```csharp theme={null}
var baseUrl = "https://staging.api.eazecustoms.com";
using var request = new HttpRequestMessage(HttpMethod.Get, $"{baseUrl}/public/v1/me");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", credential);
var response = await http.SendAsync(request);
```

Do not add `X-Eaze-Client-Ref` to Get Credential Details.

Next: [Webhooks overview](https://docs.eazecustoms.com/webhooks/overview.md).


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