Backend API

A shipment represents physical fulfillment of a number of items after an order is placed. Shipments contain information about items being fulfilled, and shipping details such as address and tracking number.

Fields

id

objectId

Unique identifier for the shipment.

items

array of objectrequired

List of line items describing the products shipped.

order_id

objectIdrequired

The id of the order this shipment was created for.

canceled

boolean

Indicates the shipment was canceled.

carrier

string

The id of a third-party carrier offering the service, if applicable.

carrier_name

string

Name of a third-party carrier offering the service, if applicable.

date_created

dateauto

Date and time the shipment was created.

date_estimated

date

Date the expected shipment is meant to arrive at the destination, if applicable.

date_updated

daterequiredauto

Date and time the shipment was last updated.

destination

object

The customer's shipping address.

notes

string

Internal admin notes, not visible to the customer.

notifications

Notification

Expandable list of notifications sent on behalf of the shipment.

number

stringauto

Unique incremental shipment number, assigned automatically.

order

Order

Expandable link to the order.

origin

object

The shipment origin location.

packages

array of object

List of packages included in this shipment.

service

string

The id of a shipping service as configured in shipment settings.

service_name

string

Name of the shipping service.

tracking_code

string

Tracking code used to identify the shipment, if applicable.

label

object

The order’s shipping label.

The shipment model
{
  "id": "60f199509111e70000000089",
  "items": [
    {
      "id": "5ca537326a0ec32a521139dd",
      "order_item_id": null,
      "product_id": "5cad15bc9b14d1990724663b",
      "quantity": 2
    }
  ],
  "order_id": "60f199509111e7000000008b",
  "date_created": "2021-07-16T14:36:00.413Z",
  "date_updated": "2021-07-16T14:36:00.413Z",
  "destination": {
    "name": "Hieronymus Lex",
    "address1": "South Watch Tower, Captain's Quarters",
    "city": "Imperial City",
    "state": "NY",
    "zip": 11201,
    "country": "US",
    "phone": "(555) 555-5555"
  },
  "service": "imperial_express",
  "tracking_code": "T192000000XYZ"
}

Create a new shipment. If you wish to generate your own unique ID for the record, it must use BSON ObjectID format for compatibility.

When fulfilling bundle items within a shipment, each item within the bundle will need to have shipment information added individually.

Arguments

items

array of objectrequired

List of line items describing the products shipped.

order_id

objectIdrequired

ID of the order this shipment was created for.

tracking_code

string

Tracking code used to identify the shipment, if applicable.

POST/shipments
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.post('/shipments', {
  order_id: '5a9ea7ba3f95740a914267f1',
  items: [
    {
      order_item_id: '5a9ea7ba3f95740a914267f2',
      product_id: '5cad15bc9b14d1990724663a',
      quantity: 2,
    }
  ],
  tracking_code: 'T192000000XYZ',
});
Response
{
  "id": "5cad15bc9b14d1990724663a",
  "number": "S10001",
  "order_id": "5a9ea7ba3f95740a914267f1",
  "items": [
    {
      "id": "5a9ea7ba3f95740a914267f2",
      "order_item_id": "5a9ea7ba3f95740a914267f2",
      "product_id": "5cad15bc9b14d1990724663b",
      "quantity": 2,
      ...
    }
  ],
  "tracking_code": "T192000000XYZ",
  ...
}

Update an existing shipment using the ID that was obtained when it was created.

Arguments

id

objectIdrequired

Unique identifier for the shipment.

items

array of objectrequired

List of line items describing the products shipped.

order_id

objectIdrequired

ID of the order this shipment was created for.

tracking_code

string

Tracking code used to identify the shipment, if applicable.

PUT/shipments/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.put('/shipments/{id}', {
  id: '60f199509111e70000000089',
  tracking_code: 'T192000000XYZ'
});
Response
{
  "id": "60f199509111e70000000089",
  "items": [
    {
      "id": "5ca537326a0ec32a521139dd",
      "order_item_id": null,
      "product_id": "5cad15bc9b14d1990724663b",
      "quantity": 2
    }
  ],
  "order_id": "60f199509111e7000000008e",
  "date_created": "2021-07-16T14:36:00.413Z",
  "date_updated": "2021-07-16T14:36:00.413Z",
  "destination": {
    "name": "Jon Snow",
    "address1": "1 Main Street",
    "city": "Brooklyn",
    "state": "NY",
    "zip": 11201,
    "country": "US",
    "phone": "(555) 555-5555"
  },
  "service": "fedex_ground",
  "tracking_code": "T192000000XYZ"
}
Arguments

id

objectIdrequired

The id of the shipment to retrieve.

expand

string

Expanding link fields and child collections is performed using the expand argument.

  • For example, expand=account would return a related customer account if one exists.

When the field represents a collection, you can specify the query limit.

  • For example, expand=variants:10 would return up to 10 records of the variants collection.

See expanding for more details.

fields

string

Return only the specified fields in the result. For example fields=name,slug would return only the fields name and slug in the response. Supports nested object and array fields using dot-notation, for example, items.product_id. The category id is always returned.

include

string

Include one or more arbitrary queries in the response, possibly related to the main query.

See including for more details.

GET/shipmets/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/shipments/{id}', {
  id: '60f199509111e70000000090'
});
Response
{
  "id": "60f199509111e70000000094",
  "items": [
    {
      "id": "5ca537326a0ec32a521139dd",
      "order_item_id": null,
      "product_id": "5cad15bc9b14d1990724663b",
      "quantity": 2
    }
  ],
  "order_id": "60f199509111e70000000095",
  "date_created": "2021-07-16T14:36:00.413Z",
  "date_updated": "2021-07-16T14:36:00.413Z",
  "destination": {
    "name": "Jon Snow",
    "address1": "1 Main Street",
    "city": "Brooklyn",
    "state": "NY",
    "zip": 11201,
    "country": "US",
    "phone": "(555) 555-5555"
  },
  "service": "fedex_ground",
  "tracking_code": "T192000000XYZ"
}

Return a list of shipments.

Arguments

expand

string

Expand link fields and child collections by using the expand argument.

  • For example, expand=account would return a related customer account if one exists.

When the field represents a collection, you can specify the query limit.

  • For example, expand=variants:10 would return up to 10 records of the variants collection.

See expanding for more details.

fields

string

Returns only the specified fields in the result.

  • For example fields=name,slug would return only the fields name and slug in the response.

Supports nested object and array fields using dot-notation.

  • For example, items.product_id. The product id is always returned.

include

object

Include one or more arbitrary queries in the response which are potentially related to the main query.

See including for more details.

limit

int

Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.

page

int

The page number of results to return given the specified or default limit.

search

string

A text search is performed using the search argument. Searchable fields are defined by the model.

  • For example, search=red would return records containing the word "red" anywhere in the defined text fields.

See searching for more details.

sort

string

Expression to sort results by using a format similar to a SQL sort statement.

  • For example, sort=name asc would return records sorted by name ascending.

See sorting for more details.

where

object

An object with criteria to filter the result.

  • For example, active=true would return records containing a field active with the value true.

It's also possible to use query operators, for example, $eq, $ne, $gt, and more.

See querying for more details.

GET/shipments
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/shipments', {
  limit: 25,
  page: 1
});
Response
{
  "count": 51,
  "results": [
    {
      "id": "60f199509111e70000000089",
      "items": [
        {
          "id": "5ca537326a0ec32a521139dd",
          "order_item_id": null,
          "product_id": "5cad15bc9b14d1990724663b",
          "quantity": 2
        }
      ],
      "order_id": "60f199509111e70000000099",
      "date_created": "2021-07-16T14:36:00.413Z",
      "date_updated": "2021-07-16T14:36:00.413Z",
      "destination": {
        "name": "Jon Snow",
        "address1": "1 Main Street",
        "city": "Brooklyn",
        "state": "NY",
        "zip": 11201,
        "country": "US",
        "phone": "(555) 555-5555"
      },
      "service": "fedex_ground",
      "tracking_code": "T192000000XYZ"
    },
    {...},
    {...}
  ],
  "page": 1,
  "pages": {
    "1": {
      "start": 1,
      "end": 25
    },
    "2": {
      "start": 26,
      "end": 50
    },
    "2": {
      "start": 51,
      "end": 51
    }
  }
}