# Shipping

> Where RPI Print ships, how to estimate shipping speeds and prices for an address, how a shipping price is calculated, and where to fetch the current destinations and rates.

To get the shipping speeds and prices available for an address, call `POST /orders/shipping/estimate`
with that address. RPI opens and closes destinations without releasing a new version of the API, and the
estimate always reflects the current ones, so use it to confirm an address. For a Generic account, if the
estimate refuses an address with HTTP 400, you cannot place an order to that address. Enterprise accounts can
also order to countries the estimate does not price; see
[Enterprise accounts outside the US and Canada](#enterprise-accounts-outside-the-us-and-canada).

## Where RPI Print API ships

RPI Print API prices every order from a destination group. An order's destination group comes from its
destination country and, within the US, its state or territory. The destinations document at
`GET /shipping/destinations` lists each destination RPI ships to, with its country, the region codes it covers,
and the destination group that prices it.
[Shipping speeds, transit times, and prices by destination](#shipping-speeds-transit-times-and-prices-by-destination)
shows how to fetch it.

Address Puerto Rico and the US territories as country `US`, with the territory as the state. For
example, an order to Guam uses country `US` with `regionCode` set to `GU`, or with `state` set to `Guam`.
For every account, create refuses with HTTP 400 an order that gives Guam as country `GU`, and stores no
order.

For a Generic account, create refuses with HTTP 400 any order whose country is not `US` or `CA`, and
stores no order.

RPI Print API does not ship to military addresses. Create refuses the military state codes `AA`, `AE`
and `AP` with HTTP 400.

Every order item shipping to Canada, Puerto Rico, the US Territories group, or, for an Enterprise
account, any other country must include a `retailPrice`, because customs declaration requires a declared
value. An order to one of those destinations with an item missing `retailPrice` fails validation.

A validation failure such as a missing `retailPrice` does not refuse the create request. The request
succeeds, the order ends in the `FAILED` state, and RPI Print API sends the `OrderValidationFailed`
webhook.

Canadian orders ship DAP (Delivered at Place). RPI collects Canadian sales tax when you are charged,
and the recipient is responsible for any import duties, customs-clearance charges, and fees assessed
at the border.

### Enterprise accounts outside the US and Canada

An Enterprise account may create an order to any country. For a country other than `US` or `CA`, the
`state` and `regionCode` fields are optional, and the value you send is passed to the printer as given.
The printer prefers a code, so when you send both, the order keeps `regionCode`. Reading the order back
returns that value as `state`.

Both `POST /orders/shipping/estimate` and `POST /orders/pricing/estimate` answer a country outside the
published destination groups with HTTP 400 saying the shipping cannot be estimated at this time. The order is
still accepted, and its shipping is priced after the order is placed.

## How a shipping price is calculated

RPI offers up to three speeds to each destination group: Standard, Expedited, and Rush. RPI does
not offer all three to every group. The rates document at `GET /shipping/rates` lists the speeds each group
offers, and a speed it does not list for a group is not offered to that group.

An order for a speed that RPI does not offer for its destination fails validation. An order from a
managed customer is the exception: it keeps the speed it asked for, including `economy`.

Each speed prices an order by quantity, using bands: the price of unit 1 comes from the first band,
and each additional unit is priced from whichever band it falls into. In the following example the prices are
invented and are not RPI's. An order of 12 units on a tier priced at 5.00 for unit 1, 2.00 for units 2-5, 1.50 for
units 6-10, and 1.00 for units 11-20 costs:

5.00 (unit 1) + 4 × 2.00 (units 2-5) + 5 × 1.50 (units 6-10) + 2 × 1.00 (units 11-20) = 22.50

The top band has no upper limit — every unit at or above its starting quantity is priced at that
band's rate.

## Shipping speeds, transit times, and prices by destination

Production time is separate from transit time: it's the number of business days RPI Print API takes to print
and prepare the order before it ships. Production is 4 business days for Standard and Expedited, and
3 business days for Rush, in every destination group that offers it.

Production days count from the day the printer receives the order, in Pacific time. An order the printer
receives by 11:59 PM Pacific counts as received that day, and its production days are the business days after it.
The shipping and pricing estimates assume the order is charged at the next daily charge (02:00 UTC) and then
spends 2 hours in the [holding bin](../documentation/orders.md#holding-bin-and-order-cancellation), so an estimate requested after that
day's charge counts from the next day. When the printer accepts the order, RPI Print API recalculates its ship and
delivery dates from the day the printer received it, and sends `OrderShippingEstimatesRefreshed` if they changed.
On a Managed account (formerly Enterprise), the printer supplies the ship date instead.

Transit time is counted in calendar days from the day the order ships. The rates document gives each speed's
transit time as `minTransitDays` and `maxTransitDays`.

RPI publishes its current destinations and rates as two JSON documents. Fetch them with an unauthenticated `GET`
request to `https://open.api.rpiprint.com/shipping/destinations` and `https://open.api.rpiprint.com/shipping/rates`.
The rates document's `currency` field names the currency of every price, and each destination group lists its
speeds with their production days, transit days, and price bands.
