- Checkout
- What you can do with Checkout
- Checkout properties
- Endpoints
- Create a checkout with a product variant and quantity
- Creating a checkout with errors, such as using the ID of a variant that doesn’t exist or that isn’t published to your sales channel, fails with a 422 response and returns errors
- Creating a checkout with line item errors fails and returns the errors mapped by index
- Create a checkout without any line items
- Complete a checkout without requiring payment
- Retrieve an existing checkout
- Retrieve a completed checkout
- Retrieve a processing checkout
- Update the shipping address and email of a checkout
- Select a shipping rate
- Updating a shipping address with an invalid zip code fails and returns errors
- Retrieving shipping rates before they’re available returns an empty array
- Retrieve available shipping rates
- Retrieving shipping rates when none are available for the current shipping address or cart returns an empty array
Checkout
If you’re building an app with the Sales Channel SDK, then you can use the Checkout API to let customers purchase products from Shopify stores that have installed your sales channel.
Shopify uses the Checkout resource to manage a user’s cart as it transitions to a paid order. This process includes specifying which line items are included in the checkout, attaching a customer’s shipping and payment details, and calculating tax and shipping rates. Credit card payments can be attached to a Checkout using the Payment resource.
For a detailed tutorial that walks you through the key capabilities of the Checkout API, see Sell through the Checkout API.
Note
You can’t use the Checkout API to create a new checkout user experience for an individual store. For that you need to use an SDK that’s powered by the Storefront API instead, such as the JavaScript Buy, iOS Buy, and Android Buy SDKs.
What you can do with Checkout
The Shopify API lets you do the following with the Checkout resource. More detailed versions of these general actions may be available:
- POST /admin/api/2021-01/checkouts.jsonCreates a checkout
- POST /admin/api/2021-01/checkouts/{token}/complete.jsonCompletes a checkout
- GET /admin/api/2021-01/checkouts/{token}.jsonRetrieves a checkout
- PUT /admin/api/2021-01/checkouts/{token}.jsonModifies an existing checkout
- GET /admin/api/2021-01/checkouts/{token}/shipping_rates.jsonRetrieves a list of shipping rates
Checkout properties
applied_discount | plain "applied_discount": { "amount": "30.00", "title": "XYZ Promotion", "description": "Promotional item for blackfriday.", "value": "30.00", "value_type": "fixed_amount", "non_applicable_reason": null, "applicable": true } A cart-level discount applied to the checkout. Apply a discount by specifying values for amount , title , description , value , and value_type .+ amount: The amount that is deducted from payment_due in presentment currency.+ title: The title to categorize the applied discount. + description: The description of the applied discount. + value: The value that was used to calculate the final applied discount amount. + value_type: The type of value that was used to calculate the final applied discount amount. Valid values: fixed_amount and percentage .+ non_applicable_reason: The reason why the discount is not applicable, if the discount cannot be applied to the checkout. + applicable: Whether this discount code can be applied to the checkout. |
---|---|
billing_address REQUIRED | plain "billing_address": { "address1": "Chestnut Street 92", "address2": "Suite 300", "city": "Louisville", "company": null, "country": "US", "first_name": null, "id": 207119551, "last_name": null, "phone": "555-625-1199", "province": "KY", "zip": "40202", "province_code": null, "country_code": null } The mailing address associated with the payment method. It has the following properties:+ address1: The street address of the billing address. + address2: An optional additional field for the street address of the billing address. + city: The city, town, or village of the billing address. + company: The company of the person associated with the billing address. + country: The name of the country of the billing address. + country_code: The two-letter code (ISO 3166-1 alpha-2 format) for the country of the billing address. + first_name: The first name of the person associated with the payment method. + last_name: The last name of the person associated with the payment method. + phone: The phone number at the billing address. + province: The name of the region (province, state, prefecture, …) of the billing address. + province_code: The two-letter abbreviation of the region of the billing address. + zip: The postal code (zip, postcode, Eircode, …) of the billing address. |
buyer_accepts_marketing | plain "buyer_accepts_marketing": false Whether the customer has consented to receive marketing material via email. |
created_at READ-ONLY | plain "created_at": "2008-01-10T11:00:00-05:00" The date and time (ISO 8601 format) when the checkout was created. |
currency READ-ONLY | plain "currency": "USD" The three-letter code (ISO 4217 format) of the shop’s default currency at the time of checkout. For the currency that the customer used at checkout, see presentment_currency . |
customer_id | plain "customer_id": 1234 The ID of the customer associated with this checkout. |
discount_code | plain "discount_code": "30_DOLLARS_OFF" The discount code that is applied to the checkout. This populates applied_discount with the appropriate metadata for that discount code. To remove a discount code, send an empty string or null . |
plain "email": "bob.norman@hostmail.com" The customer’s email address. A checkout needs to have a value for email or phone before it can be completed. |
|
gift_cards | plain "gift_cards": [ { "amount_used": "30.00", "balance": "70.00", "id": 1014759463, "last_characters": "abdr" } ] A list of gift card objects, each containing information about a gift card applied to this checkout. Gift cards can be applied to a checkout by passing { "checkout": { "gift_cards": [{ "code": "a gift card code" }, { "code": "another gift card code" }] } } . Each gift card object has the following properties:+ amount_used: The amount of the gift card used by this checkout in presentment currency. + code: The gift card code. + balance: The amount left on the gift card after being applied to this checkout in presentment currency. + id: The ID for the applied gift card. + last_characters: The last four characters of the applied gift card for display back to the user. Updating the gift card list overwrites any previous list already defined in the checkout. To remove a gift card from the list of applied gift cards, re-apply the gift_cards array without that gift card. |
line_items REQUIRED | plain "line_items": [ { "compare_at_price": "9.99", "fulfillment_service": "manual", "grams": "20", "id": 39072856, "line_price": "19.99", "price": "19.99", "product_id": 632910392, "quantity": "", "requires_shipping": false, "sku": "IPOD2008GREEN", "taxable": true, "title": "IPod Nano - 8GB", "variant_id": 39072856, "variant_title": "Green", "vendor": "Apple", "applied_discounts": [ { "id": 97651367, "amount": "4.99", "description": "25%OFF", "created_at": "2008-01-10T11:00:00-05:00" } ] } ] A list of line item objects, each containing information about an item in the checkout. Each line item object has the following properties:+ applied_discounts: A list of the discounts applied to the line item. + compare_at_price: The original selling price of the product, if applicable. + fulfillment_service: If the variant is a gift card, allows to override the fulfillment service so the gift card can be activated with a custom code. Valid values: manual .+ grams: The weight of the item in grams. + id: The checkout-specific ID of the line item. + line_price: The line price of the item, based on price multiplied by quantity .+ price: The price of the item in presentment currency. + product_id: The product of the line item. + properties: The customization information for a line item (optional). + quantity: The number of products that were purchased. + requires_shipping: Whether the fulfillment requires shipping. + sku: The unique identifier of the item in the fulfillment. + taxable: Whether this product is taxable. + title: The title of the product. + variant_id: The variant ID of the line item. + variant_title: The title of the product variant. + vendor: The name of the item’s supplier. |
order READ-ONLY | plain "order": { "id": 123, "name": "#0123", "status_url": "https://checkout.shopify.com/123/checkouts/4207896aad57dfb159?key=123abc" } An object containing the ID, name, and status page URL of the associated order when the checkout is complete. Default value: null . |
payment_due READ-ONLY | plain "payment_due": "99.95" The amount left to be paid in presentment currency. This is equal to the sum of the checkout line prices, taxes, and shipping minus discounts and gift cards. |
payment_url READ-ONLY | plain "payment_url": "https://elb.deposit.shopifycs.com/sessions" The URL that must be used to store credit cards in Shopify’s card vault. These URLs are subject to change, so you should always use the one supplied here. The general pattern for the URLs is [https://elb.deposit.shopifycs.com/sessions](https://elb.deposit.shopifycs.com/sessions) . |
phone | plain "phone": "+13125551212" The customer’s phone number for receiving SMS notifications. A checkout needs to have a value for email or phone before it can be completed. |
presentment_currency | plain "presentment_currency": "JPY" The three-letter code (ISO 4217 format) for the currency that the customer used for payment at checkout. For the shop’s default currency, see currency . |
requires_shipping READ-ONLY | plain "requires_shipping": true Whether the checkout requires shipping. If true , then shipping_line must be set before creating a payment. |
reservation_time DEPRECATED | plain "reservation_time": null The reservation time in seconds for the line item products. Default value: null . This property is not writable. |
reservation_time_left DEPRECATED | plain "reservation_time_left": 0 The time in seconds that the line item products will be held. Default value: 0 . This property is not writable. |
shipping_address | plain "shipping_address": { "address1": "Chestnut Street 92", "address2": "Apt 2", "city": "Louisville", "company": null, "country": "United States", "first_name": "Bob", "last_name": "Norman", "phone": "555-625-1199", "province": "Kentucky", "zip": "40202", "country_code": "US", "province_code": "KY" } The mailing address to where the checkout will be shipped. It has the following properties:+ address1: The street address of the shipping address. + address2: An optional additional field for the street address of the shipping address. + city: The city, town, or village of the shipping address. + company: The company of the person associated with the shipping address. + country: The name of the country of the shipping address. + country_code: The two-letter code (ISO 3166-1 alpha-2 format) for the country of the shipping address. + first_name: The first name of the person associated with the shipping address. + last_name: The last name of the person associated with the shipping address. + phone: The phone number at the shipping address. + province: The name of the region (province, state, prefecture, …) of the shipping address. + province_code: The two-letter abbreviation of the region of the shipping address. + zip: The postal code (zip, postcode, Eircode, …) of the shipping address. |
shipping_line | plain "shipping_line": { "handle": "shopify-Standard-10.00", "price": "10.00", "title": "Standard" } The selected shipping rate. A new shipping rate can be selected by updating the value for handle . A shipping line is required when requires_shipping is true . Learn more about selecting shipping rates. |
shipping_rate READ-ONLY | plain "shipping_rate": { "id": "shopify-Standard-10.00", "price": "10.00", "title": "Standard" } The selected shipping rate. This property is not writable. |
source_name | plain "source_name": "my_app" The source of the checkout. Apart from the reserved values of web , pos , iphone , and android , you can set this value to whatever you like. |
subtotal_price READ-ONLY | plain "subtotal_price": "398.00" The price of the checkout in presentment currency before shipping, taxes, and tips. |
tax_lines READ-ONLY | plain "tax_lines": [ { "price": "11.94", "rate": "0.06", "title": "State Tax" } ] An array of tax_line objects, each of which represents a tax rate applicable to the checkout. Each tax line object has the following properties:+ price: The amount of tax to be charged in presentment currency. + rate: The rate of tax to be applied. + title: The name of the tax. |
taxes_included READ-ONLY | plain "taxes_included": false Whether taxes are included in the subtotal price. |
token READ-ONLY | plain "token": "b1946ac92492d2347c6235b4d2611184" A unique identifier for a particular checkout. |
total_price READ-ONLY | plain "total_price": "409.94" The sum of the the checkout line prices, taxes, shipping costs, tips, and discounts in presentment currency. |
total_tax READ-ONLY | plain "total_tax": "11.94" The sum of all the taxes applied to the checkout in presentment currency. |
updated_at READ-ONLY | plain "updated_at": "2012-08-24T14:02:15-04:00" The date and time (ISO 8601 format format) when the checkout was last modified. |
user_id | plain "user_id": 1234 The ID of the user who created the checkout. This value is passed to the order. Default value: null . |
web_url READ-ONLY | plain "web_url": "https://checkout.shopify.com/112233/checkouts/4207896aad57dfb159?key=123abc" The URL pointing to the checkout accessible from the web. |
Endpoints
POST/admin/api/2021-01/checkouts.json Creates a checkoutCreate a checkout with a product variant and quantity
POST /admin/api/2021-01/checkouts.json
{
“checkout”: {
"line_items": [
{
"variant_id": 39072856,
"quantity": 5
}
]
}
}
Creating a checkout with errors, such as using the ID of a variant that doesn’t exist or that isn’t published to your sales channel, fails with a 422 response and returns errors
POST /admin/api/2021-01/checkouts.json
{
“checkout”: {
"line_items": [
{
"variant_id": 123456789,
"quantity": 1
}
]
}
}
Creating a checkout with line item errors fails and returns the errors mapped by index
POST /admin/api/2021-01/checkouts.json
{
“checkout”: {
"line_items": [
{
"variant_id": 39072856,
"quantity": 1
},
{
"variant_id": 1,
"quantity": 1
},
{
"variant_id": 1,
"quantity": 1
},
{
"variant_id": 49148385,
"quantity": 1
},
{
"variant_id": 1,
"quantity": 1
}
]
}
}
Create a checkout without any line items
POST /admin/api/2021-01/checkouts.json
{
“checkout”: {
"email": "me@example.com"
}
}
POST/admin/api/2021-01/checkouts/{token}/complete.json Completes a checkoutComplete a checkout without requiring payment
POST /admin/api/2021-01/checkouts/b490a9220cd14d7344024f4874f640a6/complete.json
{
}
GET/admin/api/2021-01/checkouts/{token}.json Retrieves a checkoutRetrieve an existing checkout
GET /admin/api/2021-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json
Retrieve a completed checkout
GET /admin/api/2021-01/checkouts/bd5a8aa1ecd019dd3520ff791ee3a24c.json
Retrieve a processing checkout
GET /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x.json
PUT/admin/api/2021-01/checkouts/{token}.json Modifies an existing checkoutUpdate the shipping address and email of a checkout
PUT /admin/api/2021-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json
{
“checkout”: {
"token": "exuw7apwoycchjuwtiqg8nytfhphr62a",
"email": "john.smith@example.com",
"shipping_address": {
"first_name": "John",
"last_name": "Smith",
"address1": "126 York St.",
"city": "Los Angeles",
"province_code": "CA",
"country_code": "US",
"phone": "(123)456-7890",
"zip": "90002"
}
}
}
Select a shipping rate
PUT /admin/api/2021-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json
{
“checkout”: {
"token": "exuw7apwoycchjuwtiqg8nytfhphr62a",
"shipping_line": {
"handle": "shopify-Free%20Shipping-0.00"
}
}
}
Updating a shipping address with an invalid zip code fails and returns errors
PUT /admin/api/2021-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json
{
“checkout”: {
"token": "exuw7apwoycchjuwtiqg8nytfhphr62a",
"shipping_address": {
"first_name": "John",
"last_name": "Smith",
"address1": "126 York St.",
"city": "Beverly Hills",
"province_code": "CA",
"country_code": "US",
"phone": "(123)456-7890",
"zip": "1234"
}
}
}
GET/admin/api/2021-01/checkouts/{token}/shipping_rates.json Retrieves a list of available shipping rates for the specified checkout. Implementers need to poll this endpoint until rates become available. Each shipping rate contains the checkout’s new subtotal price, total tax, and total price in the event that this shipping rate is selected. This can be used to update the UI without performing further API requests.To apply a shipping rate, update the checkout’s shipping line with the handle of the selected rate.
Retrieving shipping rates before they’re available returns an empty array
GET /admin/api/2021-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json
Retrieve available shipping rates
GET /admin/api/2021-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json
Retrieving shipping rates when none are available for the current shipping address or cart returns an empty array
GET /admin/api/2021-01/checkouts/zs9ru89kuqcdagk8bz4r9hnxt22wwd42/shipping_rates.json