Anchor to section titled 'undefined'

DeliveryCarrierService
object

Requires Any of orders or shipping access scopes or manage_delivery_settings user permission.

A carrier service (also known as a carrier calculated service or shipping service) provides real-time shipping rates to Shopify. Some common carrier services include Canada Post, FedEx, UPS, and USPS. The term carrier is often used interchangeably with the terms shipping company and rate provider.

Using the CarrierService resource, you can add a carrier service to a shop and then provide a list of applicable shipping rates at checkout. You can even use the cart data to adjust shipping rates and offer shipping discounts based on what is in the customer's cart.

Requirements for accessing the CarrierService resource

To access the CarrierService resource, add the write_shipping permission to your app's requested scopes. For more information, see API access scopes.

Your app's request to create a carrier service will fail unless the store installing your carrier service meets one of the following requirements:

  • It's on the Advanced Shopify plan or higher.
  • It's on the Shopify plan with yearly billing, or the carrier service feature has been added to the store for a monthly fee. For more information, contact Shopify Support.
  • It's a development store.

Note

If a store changes its Shopify plan, then the store's association with a carrier service is deactivated if the store no long meets one of the requirements above.

Providing shipping rates to Shopify

When adding a carrier service to a store, you need to provide a POST endpoint rooted in the callbackUrl property where Shopify can retrieve applicable shipping rates. The callback URL should be a public endpoint that expects these requests from Shopify.

Example shipping rate request sent to a carrier service

Copy

Example response

Copy

The address3, fax, address_type, and company_name fields are returned by specific ActiveShipping providers. For API-created carrier services, you should use only the following shipping address fields:

  • address1
  • address2
  • city
  • zip
  • province
  • country

Other values remain as null and are not sent to the callback URL.

Response fields

When Shopify requests shipping rates using your callback URL, the response object rates must be a JSON array of objects with the following fields. Required fields must be included in the response for the carrier service integration to work properly.

FieldRequiredDescription
service_nameYesThe name of the rate, which customers see at checkout. For example: Expedited Mail.
descriptionYesA description of the rate, which customers see at checkout. For example: Includes tracking and insurance.
service_codeYesA unique code associated with the rate. For example: expedited_mail.
currencyYesThe currency of the shipping rate.
total_priceYesThe total price expressed in subunits. If the currency doesn't use subunits, then the value must be multiplied by 100. For example: "total_price": 500 for 5.00 CAD, "total_price": 100000 for 1000 JPY.
phone_requiredNoWhether the customer must provide a phone number at checkout.
min_delivery_dateNoThe earliest delivery date for the displayed rate.
max_delivery_dateNoThe latest delivery date for the displayed rate to still be valid.

Special conditions

  • To indicate that this carrier service cannot handle this shipping request, return an empty array and any successful (20x) HTTP code.
  • To force backup rates instead, return a 40x or 50x HTTP code with any content. A good choice is the regular 404 Not Found code.
  • Redirects (30x codes) will only be followed for the same domain as the original callback URL. Attempting to redirect to a different domain will trigger backup rates.
  • There is no retry mechanism. The response must be successful on the first try, within the time budget listed below. Timeouts or errors will trigger backup rates.

Response Timeouts

The read timeout for rate requests are dynamic, based on the number of requests per minute (RPM). These limits are applied to each shop-app pair. The timeout values are as follows.

RPM RangeTimeout
Under 150010s
1500 to 30005s
Over 30003s

Note

These values are upper limits and should not be interpretted as a goal to develop towards. Shopify is constantly evaluating the performance of the platform and working towards improving resilience as well as app capabilities. As such, these numbers may be adjusted outside of our normal versioning timelines.

Server-side caching of requests

Shopify provides server-side caching to reduce the number of requests it makes. Any shipping rate request that identically matches the following fields will be retrieved from Shopify's cache of the initial response:

  • variant IDs
  • default shipping box weight and dimensions
  • variant quantities
  • carrier service ID
  • origin address
  • destination address
  • item weights and signatures

If any of these fields differ, or if the cache has expired since the original request, then new shipping rates are requested. The cache expires 15 minutes after rates are successfully returned. If an error occurs, then the cache expires after 30 seconds.


The list of services offered for given destinations.

The properly formatted name of the shipping service provider, ready to display.

The logo of the service provider.

A globally-unique ID.

The name of the shipping service provider.


Was this section helpful?
Map

Fields from

DeliveryCarrierService


Returns a DeliveryCarrierService object by ID.


Was this section helpful?
<?>
DeliveryCarrierService Queries
DeliveryCarrierService

Queried by




Was this section helpful?
||-
DeliveryCarrierService Implements
DeliveryCarrierService

Implements