# Update a shipping method

URL: https://docs.sparklayer.io/developers/api/core/update-a-shipping-method
Operation: `PATCH /api/v1/shipping-methods/{id}` (operationId `updateShippingMethod`)
OpenAPI spec: https://docs.sparklayer.io/openapi/core.yaml

Updates a shipping method and returns it. Fields you omit keep their current values, but if you send `bands` the list replaces all existing bands. Returns `404` if the shipping method doesn't exist.

`PATCH /api/v1/shipping-methods/{id}`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl -X PATCH "https://app.sparklayer.io/api/v1/shipping-methods/sm_123" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "sku": "SKU001",
  "title": "Standard Shipping",
  "priority": 0,
  "countries": [
    "GB"
  ],
  "regions": {},
  "groups": [
    "default"
  ],
  "bands": [
    {
      "name": "Band 1",
      "priority": 0,
      "sku": "ship_123",
      "requirement": {
        "type": "weight",
        "min": 0,
        "max": 0
      },
      "cost": {
        "type": "free"
      }
    }
  ]
}'
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The shipping method's ID, prefixed with `sm_`. Example: `sm_123` |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Example: `jones-climbing` |

### Request body (`application/json`) (required)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `sku` | string | | Shipping SKU. Length: max 50. |
| `title` | string | | Shiping Method Name shown at checkout. Length: max 50. |
| `priority` | number | | Shown by order (lower first). Default: `0`. Min 0, max 127. |
| `countries` | string[] | | Countries covered by this shipping method (ISO 3166-1 alpha-2) |
| `regions` | object | | Regions covered by this shipping method (per country) Keys are country codes (ISO 3166-1 alpha-2) Values are lists of region codes. If the list is empty, all regions are allowed |
| `groups` | string[] | | Customer groups covered by this shipping method (use default to cover all groups) |
| `bands` | object[] | | |
| `bands[].name` | string | | Internal Band Name. Length: max 50. |
| `bands[].priority` | number | | Filtered by first found by percentage_charge order (lower first). Default: `0`. Min 0, max 127. |
| `bands[].sku` | string \| null | | Shipping SKU (Leave null to use the Shipping Method SKU). Length: max 15. |
| `bands[].requirement` | ShippingMethod.Requirement.Weight \| ShippingMethod.Requirement.GrossTotal \| ShippingMethod.Requirement.NetTotal \| ShippingMethod.Requirement.None | | The band is selected based on the requirement. |
| `bands[].cost` | ShippingMethod.Cost.Free \| ShippingMethod.Cost.FixedCost \| ShippingMethod.Cost.PercentNetTotal \| ShippingMethod.Cost.Custom | | |

```json
{
  "sku": "SKU001",
  "title": "Standard Shipping",
  "priority": 0,
  "countries": [
    "GB"
  ],
  "regions": {},
  "groups": [
    "default"
  ],
  "bands": [
    {
      "name": "Band 1",
      "priority": 0,
      "sku": "ship_123",
      "requirement": {
        "type": "weight",
        "min": 0,
        "max": 0
      },
      "cost": {
        "type": "free"
      }
    }
  ]
}
```

### Responses

#### 200: The updated shipping method.

The `ShippingMethod` object: the request body's fields, plus:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | | Shipping Method ID (always prefixed with sm_). Length: max 15. |
| `created_at` | string (date-time) | | Created At |
| `updated_at` | string (date-time) | | Updated At |

```json
{
  "id": "sm_123",
  "created_at": "2026-01-31T09:00:00Z",
  "updated_at": "2026-01-31T09:00:00Z",
  "sku": "SKU001",
  "title": "Standard Shipping",
  "priority": 0,
  "countries": [
    "GB"
  ],
  "regions": {},
  "groups": [
    "default"
  ],
  "bands": [
    {
      "name": "Band 1",
      "priority": 0,
      "sku": "ship_123",
      "requirement": {
        "type": "weight",
        "min": 0,
        "max": 0
      },
      "cost": {
        "type": "free"
      }
    }
  ]
}
```

#### Other statuses: An error. The body describes the problem: see [Errors](https://docs.sparklayer.io/developers/errors.md).

`application/problem+json`: the standard error body (below).

### Error body

Error responses with a body use this RFC 7807 problem details object. See [Errors](https://docs.sparklayer.io/developers/errors.md) for every status code and which errors to retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string \| null | | |
| `errors` | object[] \| null | | A list of errors related to the call |
| `errors[].code` | string | | Machine-readable error code |
| `errors[].property` | string | | The property the error relates to |
| `errors[].message` | string | | Human readable summary of the error |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://docs.sparklayer.io/api/errors#invalid-api-request-contents",
  "errors": [
    {
      "code": "resource-not-found",
      "property": "stock_location_id",
      "message": "stock_location_id not found"
    }
  ]
}
```
