GET /checkout/cart/{cart_id}/shipping/available

Retrieve a list of all possible shipping methods for a cart. API Reference: Get Available Shipping Methods

Request

cart_id

the ID of the cart the shipping methods are being retrieved for.

This action should only be performed after the items have been added to the cart and a shipping address has been applied as this information may impact the pricing of the shipping methods.

Curl
curl https://sandbox-api.violet.io/v1/checkout/cart/{cart_id}/shipping/available \
-H "X-Violet-App-Id: your-app-id-here" \
-H "X-Violet-App-Secret: your-app-secret-here" \
-H "X-Violet-Token: your-token-here" \
-H "Content-type: application/json"

Response

JSON
[
    {
        "bag_id": 20440,
        "shipping_methods": [
            {
                "carrier": "OTHER",
                "label": "International Shipping",
                "price": 2000,
                "shipping_method_id": "shopify-International%20Shipping-20.00",
                "bag_id": 20440
            }
        ]
    }
]

POST /checkout/cart//shipping/available

Once the desired shipping method(s) have been selected they can be applied to the cart. API Reference: Set Shipping Methods

Request

cart_id

the ID of the cart the shipping method is being applied to.

Each bag in a cart will require its own shipping method. For this reason data is passed in as a collection of shipping methods, one for each bag. If you only have one bag in your cart you will pass in a collection consisting of one shipping method.

Required Body Parameters (for each bag):

bag_idrequired

the ID of the bag this shipping method applies to.

shipping_method_idrequired

the ID of the selected shipping method.

Curl
curl -X POST https://sandbox-api.violet.io/v1/checkout/cart/{cart_id}/shipping \
-H "X-Violet-App-Id: your-app-id-here" \
-H "X-Violet-App-Secret: your-app-secret-here" \
-H "X-Violet-Token: your-token-here" \
-H "Content-type: application/json" \
-d '[{"bag_id": 1, "shipping_method_id": "usps-flatrate"}]'

Response

JSON
{
    "id": 20956,
    "token": "c8f17e9e6fec4268bc9188f039ec68ad",
    "user_id": 10397,
    "app_id": 10382,
    "developer_id": 10292,
    "customer": {
        "user_id": 10397,
        "first_name": "Paul",
        "last_name": "Sherman",
        "email": "dorythefish@disney.com",
        "name": "Paul Sherman"
    },
    "bags": [
        {
            "id": 20440,
            "order_id": 20956,
            "merchant_id": 10000,
            "app_id": 10382,
            "status": "IN_PROGRESS",
            "fulfillment_status": "PROCESSING",
            "financial_status": "UNPAID",
            "skus": [
                {
                    "id": 24987,
                    "merchant_id": 10000,
                    "app_id": 10382,
                    "product_id": "0ff55c5cda7447118d6ae1c8395f8f11",
                    "sku_id": 10064,
                    "external_id": "13884047425654",
                    "name": "GoPro - Karma Quadcopter with HERO6 Black - White - White",
                    "brand": "GoPro",
                    "thumbnail": "https://cdn.shopify.com/s/files/1/0057/6467/7750/products/6029300_ra.jpg",
                    "quantity": 1,
                    "price": 84999,
                    "weight": 13.45,
                    "available": true,
                    "status": "IN_PROGRESS",
                    "line_price": 84999
                }
            ],
            "shipping_method": {
                "type": "FLAT_RATE_PRICE",
                "carrier": "OTHER",
                "label": "International Shipping",
                "price": 2000,
                "id": 17032,
                "shipping_method_id": "shopify-International%20Shipping-20.00",
                "bag_id": 20440,
                "merchant_id": 10000
            },
            "taxes": [],
            "sub_total": 84999,
            "transactions": [],
            "external_checkout": true,
            "commission_rate": 15.0,
            "date_created": "2022-05-11T16:17:16+0000",
            "remorse_period_ends": "2022-06-10T16:17:16+0000",
            "currency": "USD",
            "external_currency": "USD",
            "channel": "APP",
            "platform": "SHOPIFY",
            "fulfillments": [],
            "merchant_name": "Violet-Besties"
        }
    ],
    "shipping_address": {
        "city": "Sydney",
        "state": "NSW",
        "country": "AU",
        "postal_code": "2000",
        "type": "SHIPPING",
        "address_1": "42 Wallaby Way"
    },
    "billing_address": {
        "city": "Sydney",
        "state": "NSW",
        "country": "AU",
        "postal_code": "2000",
        "type": "BILLING",
        "address_1": "42 Wallaby Way"
    },
    "sub_total": 84999,
    "status": "IN_PROGRESS",
    "date_created": "2022-05-11T16:17:16+0000",
    "date_last_modified": "2022-05-12T16:08:19+0000",
    "priced": false,
    "currency": "USD",
    "errors": [],
    "channel": "APP",
    "currency_symbol": "$",
    "stripe_key": "pk_test_UHg8oLvg4rrDCbvtqfwTE8qd",
    "guest": true
}