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

idobjectId

Unique identifier for the shipment.

itemsarray of objectrequired

List of line items describing the products shipped.

order_idobjectIdrequired

The id of the order this shipment was created for.

canceledboolean

Indicates the shipment was canceled.

carrierstring

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

carrier_namestring

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

date_createddateauto

Date and time the shipment was created.

date_estimateddate

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

date_updateddateautorequired

Date and time the shipment was last updated.

destinationobject

The customer's shipping address.

notesstring

Internal admin notes, not visible to the customer.

notificationsNotification

Expandable list of notifications sent on behalf of the shipment.

numberstringauto

Unique incremental shipment number, assigned automatically.

orderOrder

Expandable link to the order.

originobject

The shipment origin location.

packagesarray of object

List of packages included in this shipment.

servicestring

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

service_namestring

Name of the shipping service.

tracking_codestring

Tracking code used to identify the shipment, if applicable.

labelobject

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.

Arguments

itemsarray of objectrequired

List of line items describing the products shipped.

order_idobjectIdrequired

ID of the order this shipment was created for.

tracking_codestring

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

idobjectIdrequired

Unique identifier for the shipment.

itemsarray of objectrequired

List of line items describing the products shipped.

order_idobjectId

ID of the order this shipment was created for.

tracking_codestring

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

idobjectIdrequired

The id of the shipment to retrieve.

expandstring

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.

fieldsstring

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.

includestring

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

expandstring

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.

fieldsstring

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.
includeobject

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

See including for more details.

limitint

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

pageint

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

searchstring

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.

sortstring

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.

whereobject

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
    }
  }
}