# Shipping Methods

## Prerequisites

* `access_token` from [headless-api-authentication](https://dev.ucommerce.net/readme/headless/headless-api-authentication "mention")
* `cultureCode`, e.g. `en-US` (string)
* `countryId` from [countries](https://dev.ucommerce.net/readme/headless/reference/countries "mention")
* `priceGroupId` from the cart or from [price-groups](https://dev.ucommerce.net/readme/headless/reference/price-groups "mention")

## Get Shipping Methods

### Optional Parameters

* `maxItems`, limits the number of results returned. in [pagination](https://dev.ucommerce.net/readme/headless/pagination "mention")
* `nextPagingToken`, required to fetch the next page. Read more in [pagination](https://dev.ucommerce.net/readme/headless/pagination "mention")

### Request

```bash
curl -D- -X GET <base_url>/api/v1/shipping-methods?cultureCode=<cultureCode>&countryId=<countryId>&priceGroupId=<priceGroupId> \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \
```

### Response

```json
{
   "nextPagingToken": null,
   "shippingMethods": [
        {
           "description": "{description}",
           "displayName": "{displayName}",
           "id": "{id}",
           "imageUrl": "{imageUrl}",
           "name": "{name}",
           "price": {
           "amount": "{amount}",
           "currency": "{currency}"
           }
        },
        {
           "description": "{description}",
           "displayName": "{displayName}",
           "id": "{id}",
           "imageUrl": "{imageUrl}",
           "name": "{name}",
           "price": {
           "amount": "{amount}",
           "currency": "{currency}"
           }
        },
        {
           "description": "{description}",
           "displayName": "{displayName}",
           "id": "{id}",
           "imageUrl": "{imageUrl}",
           "name": "{name}",
           "price": {
           "amount": "{amount}",
           "currency": "{currency}"
           }
        }
       ]
}
```

## Error Handling

| Error              | Description                                                         |
| ------------------ | ------------------------------------------------------------------- |
| BadRequest (400)   | No shipping methods are found for the given price group or country. |
| Unauthorized (401) | The token is expired.                                               |
| Forbidden (403)    | The token does not have access to this endpoint.                    |

Error Response Example

```json
{
"errors":
    [
        {
            "error-description": "Shipping methods not found on the given context.",
            "error": "BadRequest"
        }
    ]
}
```

## Related Articles

{% content-ref url="../error-handling" %}
[error-handling](https://dev.ucommerce.net/readme/headless/error-handling)
{% endcontent-ref %}
