Booking the Shipment

We now have enough information to book our shipment! Let's take a look at the rates that were returned in the response to our last request to create a quote.

[
  {
		"id": "VDWLA0",
		"creditsApplied": 0,
		"estimatedPickupDate": "2019-03-26T23:45:40.000Z",
		"estimatedDeliveryDate": "2019-03-28T05:00:40.000Z",
		"price": 79,
		"provider": "mothership",
		"services": [],
		"transitDays": {
			"minimum": 1,
			"maximum": 1
		},
		"truck": {
			"equipment": "straightTruck",
			"specialty": "dryVan"
		},
		"warnings": []
	},
	{
		"id": "G6EMET",
		"creditsApplied": 0,
		"estimatedPickupDate": "2019-03-26T23:45:40.000Z",
		"estimatedDeliveryDate": "2019-03-27T05:00:40.000Z",
		"price": 108,
		"provider": "mothership",
		"services": [
			"guaranteed"
		],
		"transitDays": {
			"minimum": 0,
			"maximum": 0
		},
		"truck": {
			"equipment": "straightTruck",
			"specialty": "dryVan"
		},
		"warnings": []
	},
	{
		"id": "W7MG4A",
		"creditsApplied": 0,
		"estimatedPickupDate": "2019-03-26T23:45:40.000Z",
		"estimatedDeliveryDate": "2019-03-28T05:00:40.000Z",
		"price": 279,
		"provider": "mothership",
		"services": [
			"dedicated"
		],
		"transitDays": {
			"minimum": 1,
			"maximum": 1
		},
		"truck": {
			"equipment": "any",
			"specialty": "dryVan"
		},
		"warnings": []
	},
	{
		"id": "6FFQO0",
		"creditsApplied": 0,
		"estimatedPickupDate": "2019-03-26T23:45:40.000Z",
		"estimatedDeliveryDate": "2019-03-27T05:00:40.000Z",
		"price": 358,
		"provider": "mothership",
		"services": [
			"dedicated",
			"guaranteed"
		],
		"transitDays": {
			"minimum": 0,
			"maximum": 0
		},
		"truck": {
			"equipment": "any",
			"specialty": "dryVan"
		},
		"warnings": []
	}
]

We want to utilize Mothership's same-day service in this example, so we'll use the second rate (the one with the ID G6EMET). It has guaranteed service with zero transit days - in other words, same-day delivery.

🚧

Purchase Eligibility

In the quote response, there is a metadata field that indicates if this quote is purchasable, or missing any fields required to be purchasable.

We allow anyone to quote and get rates with minimal details, such as using place IDs representing general locations (zip code to zip code), or without a phone number. However, in order to book a shipment, we must have a specific location, a description of the freight, and a valid phone number for each location.

Let's use the ID of the quote we requested in the last step (-LawNN52lCcvj6T5qiEp) and the ID of the rate we want to use (G6EMET) to make the request to purchase a shipment.

curl -X POST \
  https://sandbox.api.mothership.com/beta/shipments \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
  -H 'Content-Type: application/json' \
  -d '{
	"quoteId": "-LawNN52lCcvj6T5qiEp",
	"rateId": "G6EMET"
}'

And with that request, our shipment has been booked!

🚧

Payment Sources

Payments for purchases made via API are charged to the organization's default payment source. The payment source can be changed by logging into the customer dashboard and updating your organization's settings.


What’s Next

With our shipment booked, the next step is to track our freight.