Shipping Methods

Shipping methods are used to provide the customers with more delivery options. Each shipping method can have a price and can be free over a specific order's amount.

The shipping method object

A shipping method object is returned as part of the response body of each successful create, list, retrieve or update API call. The following table contains the list of all its fields along with their type, description and example values.
Object fields:
name
string
The shipping method's name
Example:
Standard shipping
currency_code
string
The international 3-letter currency code as defined by the ISO 4217 standard, automatically inherited from the associated market.
Example:
EUR
price_amount_cents
integer
The price of this shipping method, in cents.
Example:
1000
price_amount_float
float
The price of this shipping method, float.
Example:
10.00
formatted_price_amount
string
The price of this shipping method, formatted.
Example:
€10,00
free_over_amount_cents
integer
Apply free shipping if the order amount is over this value, in cents.
Example:
9900
free_over_amount_float
float
Apply free shipping if the order amount is over this value, float.
Example:
99.00
formatted_free_over_amount
string
Apply free shipping if the order amount is over this value, formatted.
Example:
€99,00
price_amount_for_shipment_cents
integer
The calculated price (zero or price amount) when associated to a shipment, in cents.
Example:
0
price_amount_for_shipment_float
float
The calculated price (zero or price amount) when associated to a shipment, float.
Example:
0.0
formatted_price_amount_for_shipment
string
The calculated price (zero or price amount) when associated to a shipment, formatted.
Example:
€0,00
id
integer
Unique identifier for the resource.
Example:
1234
created_at
datetime
Time at which the resource was created.
Example:
2018-01-01T12:00:00.000Z
updated_at
datetime
Time at which the resource was last updated.
Example:
2018-01-01T12:00:00.000Z
reference
string
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
object
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
{"foo":"bar"}
relationship (N:1)
The market where this shipping method is available.
relationship (N:1)
The shipping zone that is used to match the order shipping address.
relationship (N:1)
The shipping category for which this shipping method is available.
relationship (N:1)
The delivery lead time for the associated shipment.

Create a shipping method

To create a new shipping method, send a POST request to the /api/shipping_methods endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.
Arguments:
name
required
The shipping method's name
Example:
Standard shipping
price_amount_cents
required
The price of this shipping method, in cents.
Example:
1000
free_over_amount_cents
optional
Apply free shipping if the order amount is over this value, in cents.
Example:
9900
reference
optional
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
optional
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
#
required
The market where this shipping method is available.
required
The shipping zone that is used to match the order shipping address.
The shipping category for which this shipping method is available.
Example request:
POST /api/shipping_methods HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "shipping_methods",
    "attributes": {
      "name": "Standard shipping",
      "price_amount_cents": "1000"
    },
    "relationships": {
      "market": {
        "data": {
          "type": "markets",
          "id": "1234"
        }
      },
      "shipping_zone": {
        "data": {
          "type": "shipping_zones",
          "id": "1234"
        }
      },
      "shipping_category": {
        "data": {
          "type": "shipping_categories",
          "id": "1234"
        }
      }
    }
  }
}
Example response: 201 Created
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "shipping_methods",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234"
    },
    "attributes": {
      "name": "Standard shipping",
      "currency_code": "EUR",
      "price_amount_cents": "1000",
      "price_amount_float": "10.00",
      "formatted_price_amount": "€10,00",
      "free_over_amount_cents": "9900",
      "free_over_amount_float": "99.00",
      "formatted_free_over_amount": "€99,00",
      "price_amount_for_shipment_cents": "0",
      "price_amount_for_shipment_float": "0.0",
      "formatted_price_amount_for_shipment": "€0,00",
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "market": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/market",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/market"
        }
      },
      "shipping_zone": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_zone",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_zone"
        }
      },
      "shipping_category": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_category",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_category"
        }
      },
      "delivery_lead_time_for_shipment": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/delivery_lead_time_for_shipment",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/delivery_lead_time_for_shipment"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

List all shipping methods

To fetch a collection of shipping methods, send a GET request to the /api/shipping_methods endpoint.

Example request:
GET /api/shipping_methods HTTP/1.1
Accept: application/vnd.api+json
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": [
    {
      "id": "1234",
      "type": "shipping_methods",
      "links": {
        "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234"
      },
      "attributes": {
        "name": "Standard shipping",
        "currency_code": "EUR",
        "price_amount_cents": "1000",
        "price_amount_float": "10.00",
        "formatted_price_amount": "€10,00",
        "free_over_amount_cents": "9900",
        "free_over_amount_float": "99.00",
        "formatted_free_over_amount": "€99,00",
        "price_amount_for_shipment_cents": "0",
        "price_amount_for_shipment_float": "0.0",
        "formatted_price_amount_for_shipment": "€0,00",
        "id": "1234",
        "created_at": "2018-01-01T12:00:00.000Z",
        "updated_at": "2018-01-01T12:00:00.000Z",
        "reference": "ANYREFEFERNCE",
        "metadata": {
          "foo": "bar"
        }
      },
      "relationships": {
        "market": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/market",
            "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/market"
          }
        },
        "shipping_zone": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_zone",
            "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_zone"
          }
        },
        "shipping_category": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_category",
            "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_category"
          }
        },
        "delivery_lead_time_for_shipment": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/delivery_lead_time_for_shipment",
            "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/delivery_lead_time_for_shipment"
          }
        }
      },
      "meta": {
        "mode": "test"
      }
    },
    {
      "other": "... 24 shipping_methods (first page)"
    }
  ],
  "meta": {
    "record_count": 125,
    "page_count": 5
  },
  "links": {
    "first": "/api/shipping_methods?page[number]=1&page[size]=25",
    "prev": "/api/shipping_methods?page[number]=2&page[size]=25",
    "next": "/api/shipping_methods?page[number]=4&page[size]=25",
    "last": "/api/shipping_methods?page[number]=5&page[size]=25"
  }
}
Available filters
idreferencemarket_idshipping_zone_idshipping_category_ididscreated_at_fromcreated_at_toupdated_at_fromupdated_at_toshipment_id
Sortable attributes
nameprice_amount_centsidcreated_atupdated_atreference

Retrieve a shipping method

To fetch a single shipping method, send a GET request to the /api/shipping_methods/{{id}} endpoint, where {{id}} is the id of the resource that you want to retrieve.
Example request:
GET /api/shipping_methods/1234 HTTP/1.1
Accept: application/vnd.api+json
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "shipping_methods",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234"
    },
    "attributes": {
      "name": "Standard shipping",
      "currency_code": "EUR",
      "price_amount_cents": "1000",
      "price_amount_float": "10.00",
      "formatted_price_amount": "€10,00",
      "free_over_amount_cents": "9900",
      "free_over_amount_float": "99.00",
      "formatted_free_over_amount": "€99,00",
      "price_amount_for_shipment_cents": "0",
      "price_amount_for_shipment_float": "0.0",
      "formatted_price_amount_for_shipment": "€0,00",
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "market": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/market",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/market"
        }
      },
      "shipping_zone": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_zone",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_zone"
        }
      },
      "shipping_category": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_category",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_category"
        }
      },
      "delivery_lead_time_for_shipment": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/delivery_lead_time_for_shipment",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/delivery_lead_time_for_shipment"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

Update a shipping method

To update an existing shipping method, send a PATCH request to the /api/shipping_methods/{{id}} endpoint, where {{id}} is the id of the resource that you want to update. The following table contains the list of all the possible arguments that you can pass with the request body, along with their type, description and examples values. Please note that all arguments are optional.
Arguments:
name
optional
The shipping method's name
Example:
Standard shipping
price_amount_cents
optional
The price of this shipping method, in cents.
Example:
1000
free_over_amount_cents
optional
Apply free shipping if the order amount is over this value, in cents.
Example:
9900
reference
optional
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
optional
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
#
optional
The market where this shipping method is available.
optional
The shipping zone that is used to match the order shipping address.
The shipping category for which this shipping method is available.
Example request:
PATCH /api/shipping_methods/1234 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "shipping_methods",
    "id": 1234,
    "attributes": {
      "name": "Standard shipping"
    },
    "relationships": {
    }
  }
}
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "shipping_methods",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234"
    },
    "attributes": {
      "name": "Standard shipping",
      "currency_code": "EUR",
      "price_amount_cents": "1000",
      "price_amount_float": "10.00",
      "formatted_price_amount": "€10,00",
      "free_over_amount_cents": "9900",
      "free_over_amount_float": "99.00",
      "formatted_free_over_amount": "€99,00",
      "price_amount_for_shipment_cents": "0",
      "price_amount_for_shipment_float": "0.0",
      "formatted_price_amount_for_shipment": "€0,00",
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "market": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/market",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/market"
        }
      },
      "shipping_zone": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_zone",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_zone"
        }
      },
      "shipping_category": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/shipping_category",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/shipping_category"
        }
      },
      "delivery_lead_time_for_shipment": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/shipping_methods/1234/relationships/delivery_lead_time_for_shipment",
          "related": "https://your-brand.commercelayer.io/api/shipping_methods/1234/delivery_lead_time_for_shipment"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

Delete a shipping method

To delete a shipping method, send a DELETE request to the /api/shipping_methods/{{id}} endpoint, where {{id}} is the id of the resource that you want to delete.
Example request:
DELETE /api/shipping_methods/1234 HTTP/1.1
Accept: application/vnd.api+json
Example response: 204 No Content
HTTP/1.1 204 No Content

Get our machine-readable JSON schema that follows the OpenAPI Specification (formerly Swagger).

Get our Postman collection in one click and start making real calls to Commerce Layer API in minutes.

Get in touch with our support team if you have any questions or want to learn more about Commerce Layer.