# Shipping Methods

Shipping Methods are applied to Violet at the `Bag` level, since each Merchant can have their own shipping configurations. Once a shipping address has been added to a cart, you can use our Shipping Method endpoints to retrieve and apply methods.

{% hint style="info" %}
Violet shows shipping methods based on what the Merchant has configured in their store through their e-commerce platform. They do not configure these in Violet. For example, you can learn about how Shopify stores configure shipping methods [here](https://app.gitbook.com/s/U56rBTO20v6lVxmGUVMK/platform-guides/readme/shipping).
{% endhint %}

**Retrieve Shipping Methods**

You can use the [Retrieve Shipping Methods](/api-reference/orders-and-checkout/cart-shipping/get-available-shipping-methods.md) endpoint to retrieve shipping methods, once a shipping address has been added to the Order, as seen below:

```bash
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"
```

This call is at the Cart level, however, notice that the response contains shipping methods at the Bag (i.e. merchant) level.

```json
[
    {
        "bag_id": 20440,
        "shipping_methods": [
            {
                "carrier": "OTHER",
                "label": "International Shipping",
                "price": 2000,
                "shipping_method_id": "shopify-International%20Shipping-20.00",
                "bag_id": 20440
            }
        ]
    },
		{
        "bag_id": 20441,
        "shipping_methods": [
            {
                "carrier": "USPS",
                "label": "US Domestic",
                "price": 999,
                "shipping_method_id": "shopify-usps%20Shipping-9.99",
                "bag_id": 20441
            }
        ]
    }
]
```

**Applying Shipping Methods**

Once you’ve retrieved shipping methods, you can use the [Apply Shipping Methods](/api-reference/orders-and-checkout/cart-shipping/set-shipping-methods.md) endpoint to attach these shipping methods to `Bags`. 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, as seen below:

```bash
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"}]'
```

The response will then be an `Order` object, on which you will notice that now, each bag on the order you are applying shipping methods to will contain a `shipping_method` object. If there are any errors while applying shipping methods, the order will return with errors listed in the `errors` field on the object.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.violet.io/prism/checkout-guides/carts-and-bags/shipping-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
