Skip to content

Latest commit

 

History

History
261 lines (186 loc) · 18.6 KB

File metadata and controls

261 lines (186 loc) · 18.6 KB

CustomsItems

(customsItems)

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 items
  • create - Create a new customs item
  • get - Retrieve a customs item

list

Returns a list all customs items 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.customsItems.list();
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { ShippoCore } from "shippo/core.js";
import { customsItemsList } from "shippo/funcs/customsItemsList.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 customsItemsList(shippo);

  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)
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.CustomsItemPaginatedList>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

create

Creates a new customs item 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.customsItems.create({
    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",
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { ShippoCore } from "shippo/core.js";
import { customsItemsCreate } from "shippo/funcs/customsItemsCreate.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 customsItemsCreate(shippo, {
    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",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request components.CustomsItemCreateRequest ✔️ 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.CustomsItem>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

get

Returns an existing customs item 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.customsItems.get("<value>");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { ShippoCore } from "shippo/core.js";
import { customsItemsGet } from "shippo/funcs/customsItemsGet.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 customsItemsGet(shippo, "<value>");

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
customsItemId string ✔️ Object ID of the customs item
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.CustomsItem>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /