Skip to content

Latest commit

 

History

History
350 lines (277 loc) · 20.9 KB

File metadata and controls

350 lines (277 loc) · 20.9 KB

CustomsDeclarations

(customsDeclarations)

Overview

Customs declarations are relevant information, including one or multiple customs items, you need to provide for customs clearance for your international shipments.

Available Operations

  • list - List all customs declarations
  • create - Create a new customs declaration
  • get - Retrieve a customs declaration

list

Returns a a list of all customs declaration objects

Example Usage

import { Shippo } from "shippo";

const shippo = new Shippo({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
  shippoApiVersion: "2018-02-08",
});

async function run() {
  const result = await shippo.customsDeclarations.list(1, 5);

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ShippoCore } from "shippo/core.js";
import { customsDeclarationsList } from "shippo/funcs/customsDeclarationsList.js";

// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
  shippoApiVersion: "2018-02-08",
});

async function run() {
  const res = await customsDeclarationsList(shippo, 1, 5);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
page number The page number you want to select
results number The number of results to return per page (max 100, default 5)
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CustomsDeclarationPaginatedList>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

create

Creates a new customs declaration object

Example Usage

import { Shippo } from "shippo";

const shippo = new Shippo({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
  shippoApiVersion: "2018-02-08",
});

async function run() {
  const result = await shippo.customsDeclarations.create({
    b13aFilingOption: "FILED_ELECTRONICALLY",
    certify: true,
    certifySigner: "Shawn Ippotle",
    contentsExplanation: "T-Shirt purchase",
    dutiesPayor: {
      account: "2323434543",
      type: "THIRD_PARTY",
      address: {
        name: "Patrick Kavanagh",
        zip: "80331",
        country: "DE",
      },
    },
    exporterIdentification: {
      eoriNumber: "PL123456790ABCDE",
      taxId: {
        number: "123456789",
        type: "EIN",
      },
    },
    invoice: "#123123",
    metadata: "Order ID #123123",
    addressImporter: {
      name: "Shwan Ippotle",
      company: "Shippo",
      street1: "Blumenstraße",
      street3: "",
      streetNo: "22",
      city: "München",
      state: "CA",
      zip: "80331",
      country: "DE",
      phone: "80331",
      email: "[email protected]",
      isResidential: true,
    },
    contentsType: "MERCHANDISE",
    eelPfc: "NOEEI_30_37_a",
    incoterm: "DDP",
    items: [
      {
        description: "T-Shirt",
        massUnit: "lb",
        metadata: "Order ID \"123454\"",
        netWeight: "5",
        originCountry: "<value>",
        quantity: 20,
        skuCode: "HM-123",
        hsCode: "0901.21",
        valueAmount: "200",
        valueCurrency: "USD",
      },
    ],
    nonDeliveryOption: "RETURN",
    test: true,
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ShippoCore } from "shippo/core.js";
import { customsDeclarationsCreate } from "shippo/funcs/customsDeclarationsCreate.js";

// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
  shippoApiVersion: "2018-02-08",
});

async function run() {
  const res = await customsDeclarationsCreate(shippo, {
    b13aFilingOption: "FILED_ELECTRONICALLY",
    certify: true,
    certifySigner: "Shawn Ippotle",
    contentsExplanation: "T-Shirt purchase",
    dutiesPayor: {
      account: "2323434543",
      type: "THIRD_PARTY",
      address: {
        name: "Patrick Kavanagh",
        zip: "80331",
        country: "DE",
      },
    },
    exporterIdentification: {
      eoriNumber: "PL123456790ABCDE",
      taxId: {
        number: "123456789",
        type: "EIN",
      },
    },
    invoice: "#123123",
    metadata: "Order ID #123123",
    addressImporter: {
      name: "Shwan Ippotle",
      company: "Shippo",
      street1: "Blumenstraße",
      street3: "",
      streetNo: "22",
      city: "München",
      state: "CA",
      zip: "80331",
      country: "DE",
      phone: "80331",
      email: "[email protected]",
      isResidential: true,
    },
    contentsType: "MERCHANDISE",
    eelPfc: "NOEEI_30_37_a",
    incoterm: "DDP",
    items: [
      {
        description: "T-Shirt",
        massUnit: "lb",
        metadata: "Order ID \"123454\"",
        netWeight: "5",
        originCountry: "<value>",
        quantity: 20,
        skuCode: "HM-123",
        hsCode: "0901.21",
        valueAmount: "200",
        valueCurrency: "USD",
      },
    ],
    nonDeliveryOption: "RETURN",
    test: true,
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.CustomsDeclarationCreateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CustomsDeclaration>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

get

Returns an existing customs declaration using an object ID

Example Usage

import { Shippo } from "shippo";

const shippo = new Shippo({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
  shippoApiVersion: "2018-02-08",
});

async function run() {
  const result = await shippo.customsDeclarations.get("<id>", 1);

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { ShippoCore } from "shippo/core.js";
import { customsDeclarationsGet } from "shippo/funcs/customsDeclarationsGet.js";

// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
  apiKeyHeader: "<YOUR_API_KEY_HERE>",
  shippoApiVersion: "2018-02-08",
});

async function run() {
  const res = await customsDeclarationsGet(shippo, "<id>", 1);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
customsDeclarationId string ✔️ Object ID of the customs declaration
page number The page number you want to select
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CustomsDeclaration>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*