# Update Shipping Rate

PUT https://services.leadconnectorhq.com/store/shipping-zone/{shippingZoneId}/shipping-rate/{shippingRateId}

The "update Shipping Rate" API allows update a shipping rate to the system. 

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** No scopes required.

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `shippingZoneId` | string | Yes | ID of the shipping zone |
| `shippingRateId` | string | Yes | ID of the shipping rate that needs to be returned |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/store/shipping-zone/{shippingZoneId}/shipping-rate/{shippingRateId}": {
      "put": {
        "summary": "Update Shipping Rate",
        "operationId": "updateShippingRate",
        "description": "The \"update Shipping Rate\" API allows update a shipping rate to the system. ",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "required": true,
            "description": "API Version",
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "shippingZoneId",
            "required": true,
            "in": "path",
            "description": "ID of the shipping zone",
            "schema": {
              "example": "6578278e879ad2646715ba9c",
              "type": "string"
            }
          },
          {
            "name": "shippingRateId",
            "required": true,
            "in": "path",
            "description": "ID of the shipping rate that needs to be returned",
            "schema": {
              "example": "6578278e879ad2646715ba9c",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateShippingRateDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateShippingRateResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "UpdateShippingRateDto": {
        "type": "object",
        "properties": {
          "altId": {
            "type": "string",
            "description": "Location Id or Agency Id",
            "example": "6578278e879ad2646715ba9c"
          },
          "altType": {
            "type": "string",
            "enum": [
              "location"
            ]
          },
          "name": {
            "type": "string",
            "description": "Name of the shipping zone",
            "example": "North zone"
          },
          "description": {
            "type": "string",
            "description": "Delivery description",
            "example": "Ships next day"
          },
          "currency": {
            "type": "string",
            "description": "The currency of the amount of the rate / handling fee",
            "example": "USD"
          },
          "amount": {
            "type": "number",
            "description": "The amount of the shipping rate if it is normal rate (0 means free ). Fixed Handling fee if it is a carrier rate (it will add to the carrier rate).",
            "example": 99.99
          },
          "conditionType": {
            "type": "string",
            "description": "Type of condition to provide the conditional pricing",
            "enum": [
              "none",
              "price",
              "weight"
            ],
            "example": "price"
          },
          "minCondition": {
            "type": "number",
            "description": "Minimum condition for applying this price. set 0 or null if there is no minimum",
            "example": 99.99
          },
          "maxCondition": {
            "type": "number",
            "description": "Maximum condition for applying this price. set 0 or null if there is no maximum",
            "example": 99.99
          },
          "isCarrierRate": {
            "type": "boolean",
            "description": "is this a carrier rate",
            "example": true
          },
          "shippingCarrierId": {
            "type": "string",
            "description": "Shipping carrier id",
            "example": "655b33a82209e60b6adb87a5"
          },
          "percentageOfRateFee": {
            "type": "number",
            "description": "Percentage of rate fee if it is a carrier rate.",
            "example": 10.99
          },
          "shippingCarrierServices": {
            "description": "An array of items",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Name of the shipping carrier service",
                  "example": "Priority Mail Express International"
                },
                "value": {
                  "type": "string",
                  "description": "Value of the shipping carrier service",
                  "example": "PriorityMailExpressInternational"
                }
              },
              "required": [
                "name",
                "value"
              ],
              "title": "ShippingCarrierServiceDto"
            }
          }
        },
        "title": "UpdateShippingRateDto"
      },
      "UpdateShippingRateResponseDto": {
        "type": "object",
        "properties": {
          "status": {
            "type": "boolean",
            "description": "Status of api action",
            "example": true
          },
          "message": {
            "type": "string",
            "description": "Success message",
            "example": "Successfully created"
          },
          "data": {
            "description": "Shipping zone data",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "altId": {
                    "type": "string",
                    "description": "Location Id or Agency Id",
                    "example": "6578278e879ad2646715ba9c"
                  },
                  "altType": {
                    "type": "string",
                    "enum": [
                      "location"
                    ]
                  },
                  "name": {
                    "type": "string",
                    "description": "Name of the shipping zone",
                    "example": "North zone"
                  },
                  "description": {
                    "type": "string",
                    "description": "Delivery description",
                    "example": "Ships next day"
                  },
                  "currency": {
                    "type": "string",
                    "description": "The currency of the amount of the rate / handling fee",
                    "example": "USD"
                  },
                  "amount": {
                    "type": "number",
                    "description": "The amount of the shipping rate if it is normal rate (0 means free ). Fixed Handling fee if it is a carrier rate (it will add to the carrier rate).",
                    "example": 99.99
                  },
                  "conditionType": {
                    "type": "string",
                    "description": "Type of condition to provide the conditional pricing",
                    "enum": [
                      "none",
                      "price",
                      "weight"
                    ],
                    "example": "price"
                  },
                  "minCondition": {
                    "type": "number",
                    "description": "Minimum condition for applying this price. set 0 or null if there is no minimum",
                    "example": 99.99
                  },
                  "maxCondition": {
                    "type": "number",
                    "description": "Maximum condition for applying this price. set 0 or null if there is no maximum",
                    "example": 99.99
                  },
                  "isCarrierRate": {
                    "type": "boolean",
                    "description": "is this a carrier rate",
                    "example": true
                  },
                  "shippingCarrierId": {
                    "type": "string",
                    "description": "Shipping carrier id",
                    "example": "655b33a82209e60b6adb87a5"
                  },
                  "percentageOfRateFee": {
                    "type": "number",
                    "description": "Percentage of rate fee if it is a carrier rate.",
                    "example": 10.99
                  },
                  "shippingCarrierServices": {
                    "description": "An array of items",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Name of the shipping carrier service",
                          "example": "Priority Mail Express International"
                        },
                        "value": {
                          "type": "string",
                          "description": "Value of the shipping carrier service",
                          "example": "PriorityMailExpressInternational"
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ],
                      "title": "ShippingCarrierServiceDto"
                    }
                  },
                  "_id": {
                    "type": "string",
                    "description": "The unique identifier for the product.",
                    "example": "655b33a82209e60b6adb87a5"
                  },
                  "shippingZoneId": {
                    "type": "string",
                    "description": "The unique identifier for the shipping zone.",
                    "example": "655b33a82209e60b6adb87a5"
                  },
                  "createdAt": {
                    "type": "string",
                    "description": "created at",
                    "example": "2023-12-12T09:27:42.355Z"
                  },
                  "updatedAt": {
                    "type": "string",
                    "description": "updated at",
                    "example": "2023-12-12T09:27:42.355Z"
                  }
                },
                "required": [
                  "altId",
                  "altType",
                  "name",
                  "currency",
                  "amount",
                  "conditionType",
                  "minCondition",
                  "maxCondition",
                  "shippingCarrierId",
                  "_id",
                  "shippingZoneId",
                  "createdAt",
                  "updatedAt"
                ],
                "title": "ShippingRateSchema"
              }
            ]
          }
        },
        "required": [
          "status",
          "data"
        ],
        "title": "UpdateShippingRateResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X PUT 'https://services.leadconnectorhq.com/store/shipping-zone/<shippingZoneId>/shipping-rate/<shippingRateId>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "altId": "6578278e879ad2646715ba9c",
  "name": "North zone",
  "description": "Ships next day",
  "currency": "USD",
  "amount": 99.99,
  "conditionType": "price",
  "minCondition": 99.99,
  "maxCondition": 99.99,
  "isCarrierRate": true,
  "shippingCarrierId": "655b33a82209e60b6adb87a5",
  "percentageOfRateFee": 10.99,
  "shippingCarrierServices": [
    {
      "name": "Priority Mail Express International",
      "value": "PriorityMailExpressInternational"
    }
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "altId": "6578278e879ad2646715ba9c",
      "name": "North zone",
      "description": "Ships next day",
      "currency": "USD",
      "amount": 99.99,
      "conditionType": "price",
      "minCondition": 99.99,
      "maxCondition": 99.99,
      "isCarrierRate": true,
      "shippingCarrierId": "655b33a82209e60b6adb87a5",
      "percentageOfRateFee": 10.99,
      "shippingCarrierServices": [
        {
          "name": "Priority Mail Express International",
          "value": "PriorityMailExpressInternational"
        }
      ]
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/store/shipping-zone/<shippingZoneId>/shipping-rate/<shippingRateId>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/store/shipping-zone/{shippingZoneId}/shipping-rate/{shippingRateId}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "altId": "6578278e879ad2646715ba9c",
    "name": "North zone",
    "description": "Ships next day",
    "currency": "USD",
    "amount": 99.99,
    "conditionType": "price",
    "minCondition": 99.99,
    "maxCondition": 99.99,
    "isCarrierRate": true,
    "shippingCarrierId": "655b33a82209e60b6adb87a5",
    "percentageOfRateFee": 10.99,
    "shippingCarrierServices": [
        {
            "name": "Priority Mail Express International",
            "value": "PriorityMailExpressInternational"
        }
    ]
}

response = requests.put(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/store/shipping-zone/<shippingZoneId>/shipping-rate/<shippingRateId>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "altId": "6578278e879ad2646715ba9c",
  "name": "North zone",
  "description": "Ships next day",
  "currency": "USD",
  "amount": 99.99,
  "conditionType": "price",
  "minCondition": 99.99,
  "maxCondition": 99.99,
  "isCarrierRate": true,
  "shippingCarrierId": "655b33a82209e60b6adb87a5",
  "percentageOfRateFee": 10.99,
  "shippingCarrierServices": [
    {
      "name": "Priority Mail Express International",
      "value": "PriorityMailExpressInternational"
    }
  ]
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/store/shipping-zone/<shippingZoneId>/shipping-rate/<shippingRateId>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"altId\":\"6578278e879ad2646715ba9c\",\"name\":\"North zone\",\"description\":\"Ships next day\",\"currency\":\"USD\",\"amount\":99.99,\"conditionType\":\"price\",\"minCondition\":99.99,\"maxCondition\":99.99,\"isCarrierRate\":true,\"shippingCarrierId\":\"655b33a82209e60b6adb87a5\",\"percentageOfRateFee\":10.99,\"shippingCarrierServices\":[{\"name\":\"Priority Mail Express International\",\"value\":\"PriorityMailExpressInternational\"}]}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/store/shipping-zone/<shippingZoneId>/shipping-rate/<shippingRateId>"
  payload := strings.NewReader(`{
  "altId": "6578278e879ad2646715ba9c",
  "name": "North zone",
  "description": "Ships next day",
  "currency": "USD",
  "amount": 99.99,
  "conditionType": "price",
  "minCondition": 99.99,
  "maxCondition": 99.99,
  "isCarrierRate": true,
  "shippingCarrierId": "655b33a82209e60b6adb87a5",
  "percentageOfRateFee": 10.99,
  "shippingCarrierServices": [
    {
      "name": "Priority Mail Express International",
      "value": "PriorityMailExpressInternational"
    }
  ]
}`)
  req, _ := http.NewRequest("PUT", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/store/shipping-zone/<shippingZoneId>/shipping-rate/<shippingRateId>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "altId": "6578278e879ad2646715ba9c",
  "name": "North zone",
  "description": "Ships next day",
  "currency": "USD",
  "amount": 99.99,
  "conditionType": "price",
  "minCondition": 99.99,
  "maxCondition": 99.99,
  "isCarrierRate": true,
  "shippingCarrierId": "655b33a82209e60b6adb87a5",
  "percentageOfRateFee": 10.99,
  "shippingCarrierServices": [
    {
      "name": "Priority Mail Express International",
      "value": "PriorityMailExpressInternational"
    }
  ]
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "altId": "6578278e879ad2646715ba9c",
  "name": "North zone",
  "description": "Ships next day",
  "currency": "USD",
  "amount": 99.99,
  "conditionType": "price",
  "minCondition": 99.99,
  "maxCondition": 99.99,
  "isCarrierRate": true,
  "shippingCarrierId": "655b33a82209e60b6adb87a5",
  "percentageOfRateFee": 10.99,
  "shippingCarrierServices": [
    {
      "name": "Priority Mail Express International",
      "value": "PriorityMailExpressInternational"
    }
  ]
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/store/shipping-zone/<shippingZoneId>/shipping-rate/<shippingRateId>' -Method 'PUT' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
