Service Catalog API - POST /sn_sc/servicecatalog/cart/checkout

This method retrieves the checkout cart details based on the two-step checkout process enabled or disabled. If the user enables two-step checkout, the method returns cart order status and all the information required for two-step checkout. If the user disables two-step checkout, the method checks out the cart and returns the request number and request order ID.

URL format

Versioned URL: /api/sn_sc/v1/servicecatalog/cart/checkout

Default URL: /api/sn_sc/servicecatalog/cart/checkout

Supported request parameters

Table 1. Parameters
Parameter Description
None

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see REST headers.

Table 2. Request headers
Header Description
None
Table 3. Response headers
Header Description
None

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST response codes.

Table 4. Status codes
Status code Description
200 Indicates that the request completed successfully. Returns the cart status with the checkout status of the items in the cart.
400 Indicates that the cart is empty and cannot check out.

Response body

If two-step checkout is enabled, the following are JSON or XML response values for the order status page.

Table 5. Response body values for two-step checkout
Parameter Description
cart_id Specifies the sys_id of the cart.
subtotal_price Specifies the subtotal of the cart.
subtotal_recurring_frequency Specifies the recurring frequency subtotal of the cart.
subtotal_recurring_price Specifies the recurring price subtotal of the cart.
total_title Specifies the title for total field on page.
subtotal_price Specifies the subtotal of the current frequency block.
subtotal_recurring_frequency Specifies the recurring frequency subtotal of the current frequency block.
subtotal_recurring_price Specifies the recurring price subtotal of the current frequency block
total_title Specifies the title for total field on the current frequency block.
items Array consisting of details of all the items in the cart.
  • catalog_item_id: sys_id of the item in the cart.
  • variables:Object consisting of all the variable names and corresponding values for the item in the cart.
  • quantity: Quantity of the item in the cart.
  • localized_price: Price of the item in local currency.
  • price: Price of the item.
  • localized_recurring_price: Recurring price of the item in local currency.
  • recurring_price: Recurring price of the item.
  • recurring_frequency: Recurring frequency of the item.
  • item_name: Name of the item in the cart.
  • cart_item_id:sys_id of the item in the cart.
  • delivery_time:Delivery time of the item.

Sample cURL request

curl "https://instance.service-now.com/api/sn_sc/servicecatalog/cart/checkout" \
--request POST \
--header "Accept:application/json" \
--user 'admin':'admin'
<!-- This example response is returned when two-step checkout is disabled -->
{
    "result": {
        "request_number": "REQ0010009",
        "request_id": "6e240197db21120064301150f0b8f5be"
    }
}

Sample Python request

#Need to install requests package for python
#easy_install requests
import requests

# Set the request parameters
url = 'https://instance.service-now.com/api/sn_sc/servicecatalog/cart/checkout'

# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'

# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}

# Do the HTTP request
response = requests.post(url, auth=(user, pwd), headers=headers  )

# Check for HTTP codes other than 200
if response.status_code != 200: 
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
<!-- This example response is returned when two-step checkout is enabled -->
<?xml version="1.0" encoding="UTF-8" ?>
<root>
    <result>
        <cart_id>616ebdb8db71120076861150f0b8f552</cart_id>
        <subtotal_price>$9,599.88</subtotal_price>
        <subtotal_recurring_frequency>Monthly</subtotal_recurring_frequency>
        <subtotal_recurring_price>$348.00</subtotal_recurring_price>
        <total_title>Total</total_title>
        <delivery_address>
Brasilia, 
Brasil</delivery_address>
        <special_instructions></special_instructions>
        <requested_for_user>System Administrator</requested_for_user>
        <monthly>
            <subtotal_price>$9,599.88</subtotal_price>
            <subtotal_recurring_frequency>Monthly</subtotal_recurring_frequency>
            <subtotal_recurring_price>$348.00</subtotal_recurring_price>
            <total_title>Total</total_title>
            <items>
                <catalog_item_id>0d08837237153000158bbfc8bcbe5d02</catalog_item_id>
                <variables>
                    <Monthly data allowance>500MB</Monthly data allowance>
                    <Storage>16GB</Storage>
                    <Color>Black</Color>
                    <Allocated carrier>AT & T Mobility</Allocated carrier>
                    <Contract duration>18 Months</Contract duration>
                </variables>
                <quantity>12</quantity>
                <localized_price>$799.99</localized_price>
                <price>$799.99</price>
                <recurring_frequency>Monthly</recurring_frequency>
                <localized_recurring_price>$30.00</localized_recurring_price>
                <recurring_price>$29.00</recurring_price>
                <item_name>Apple iPhone 5</item_name>
                <cart_item_id>a21ffdb0db71120076861150f0b8f560</cart_item_id>
                <delivery_time>2 Days</delivery_time>
            </items>
            <show_subtotal_price>true</show_subtotal_price>
            <subtotal_title>Subtotal</subtotal_title>
        </monthly>
        <show_subtotal_price>true</show_subtotal_price>
        <subtotal_title>Subtotal</subtotal_title>
    </result>
</root>