# 更新运费模版

> 接口应在服务器端调用，不可在前端（小程序、网页、APP等）直接调用，具体可参考[接口调用指南](/doc/oplatform/developers/dev/guide.md)。

接口英文名：updatefreighttemplate

可通过该接口更新运费模板

## 1. 调用方式

### HTTPS 调用

```bash
POST https://api.weixin.qq.com/channels/ec/merchant/updatefreighttemplate?access_token=ACCESS_TOKEN
```

### 云调用

- 调用方法：channels.ec.merchant.updatefreighttemplate

- 出入参和 HTTPS 调用相同，调用方式可查看 [云调用](/doc/oplatform/developers/dev/cloudCall.md) 说明文档。

### 第三方调用

- 本接口支持第三方平台代供货商调用。[第三方服务商调用模式介绍](/doc/store/supplier/product/service_market_desc)

- 该接口所属的权限集 id 为：130、192

- 服务商获得其中之一权限集授权后，可通过使用 [authorizer_access_token](/doc/oplatform/developers/dev/AuthorizerAccessToken.md) 代供货商进行调用，具体可查看 [第三方调用](/doc/oplatform/Third-party_Platforms/2.0/Before_Develop/call_interface.md) 说明文档。

## 2. 请求参数

### 查询参数 `Query String Parameters`

```json
[
  {
    "参数名": "access_token",
    "类型": "string",
    "必填": "是",
    "示例": "ACCESS_TOKEN",
    "说明": "接口调用凭证，可使用 [access_token](/doc/store/supplier/api/basics/api_getaccesstoken)（供货商）、[authorizer_access_token](/doc/oplatform/openApi/ticket-token/api_getauthorizeraccesstoken.md)（服务商代调用）"
  }
]
```

### 请求体 `Request Payload`

```json
[
  {
    "参数名": "freight_template",
    "类型": "object",
    "必填": "是",
    "说明": "运费模板详细信息"
  }
]
```

### Body.freight_template `Object Payload`

运费模板详细信息

```json
[
  {
    "参数名": "template_id",
    "类型": "string",
    "必填": "是",
    "说明": "模板id",
    "枚举": "-"
  },
  {
    "参数名": "name",
    "类型": "string",
    "必填": "是",
    "说明": "模板名称",
    "枚举": "-"
  },
  {
    "参数名": "valuation_type",
    "类型": "string",
    "必填": "是",
    "说明": "计费类型\nPIECE：按件数\nWEIGHT：按重量",
    "枚举": "-"
  },
  {
    "参数名": "send_time",
    "类型": "string",
    "必填": "是",
    "说明": "发货时间期限[详情](https://store.weixin.qq.com/chengzhang/webdoc/wiki/407/e4ca8eb1ee772cf7/growth_center_rule_for_store?source=6&sourceType=4)",
    "枚举": "枚举值"
  },
  {
    "参数名": "address_info",
    "类型": "object",
    "必填": "是",
    "说明": "发货地址",
    "枚举": "-"
  },
  {
    "参数名": "delivery_type",
    "类型": "string",
    "必填": "是",
    "说明": "运输方式\nEXPRESS：快递",
    "枚举": "-"
  },
  {
    "参数名": "shipping_method",
    "类型": "string",
    "必填": "是",
    "说明": "计费方式\nFREE：包邮\nCONDITION_FREE：条件包邮\nNO_FREE：不包邮",
    "枚举": "-"
  },
  {
    "参数名": "all_freight_calc_method",
    "类型": "object",
    "必填": "是",
    "说明": "具体计费方法，默认运费，指定地区运费等",
    "枚举": "-"
  },
  {
    "参数名": "create_time",
    "类型": "number",
    "必填": "是",
    "说明": "创建时间戳",
    "枚举": "-"
  },
  {
    "参数名": "update_time",
    "类型": "number",
    "必填": "是",
    "说明": "更新时间戳",
    "枚举": "-"
  },
  {
    "参数名": "is_default",
    "类型": "boolean",
    "必填": "是",
    "说明": "是否默认模板",
    "枚举": "-"
  },
  {
    "参数名": "not_send_area",
    "类型": "object",
    "必填": "是",
    "说明": "不发货区域",
    "枚举": "-"
  }
]
```

### Body.freight_template.address_info `Object Payload`

发货地址

```json
[
  {
    "参数名": "user_name",
    "类型": "string",
    "必填": "否",
    "说明": "收货人姓名"
  },
  {
    "参数名": "postal_code",
    "类型": "string",
    "必填": "否",
    "说明": "邮编"
  },
  {
    "参数名": "province_name",
    "类型": "string",
    "必填": "是",
    "说明": "国标收货地址第一级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "city_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第二级地址，如果是直辖市，请填区，比如\"浦东新区\"，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "county_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第三级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "detail_info",
    "类型": "string",
    "必填": "否",
    "说明": "详细收货地址信息"
  },
  {
    "参数名": "national_code",
    "类型": "string",
    "必填": "否",
    "说明": "收货地址国家码"
  },
  {
    "参数名": "tel_number",
    "类型": "string",
    "必填": "否",
    "说明": "收货人手机号码"
  },
  {
    "参数名": "lat",
    "类型": "number",
    "必填": "否",
    "说明": "纬度"
  },
  {
    "参数名": "lng",
    "类型": "number",
    "必填": "否",
    "说明": "经度"
  },
  {
    "参数名": "house_number",
    "类型": "string",
    "必填": "否",
    "说明": "门牌号"
  }
]
```

### Body.freight_template.all_condition_free_detail `Object Payload`

```json
[
  {
    "参数名": "condition_free_detail_list",
    "类型": "objarray",
    "必填": "否",
    "说明": "计费规则列表"
  }
]
```

">

### Body.freight_template.all_condition_free_detail.condition_free_detail_list(Array) `Object Payload`

计费规则列表

```json
[
  {
    "参数名": "address_infos",
    "类型": "objarray",
    "必填": "否",
    "说明": "支持的地址列表"
  },
  {
    "参数名": "min_piece",
    "类型": "number",
    "必填": "否",
    "说明": "最低件数"
  },
  {
    "参数名": "min_weight",
    "类型": "number",
    "必填": "否",
    "说明": "最低重量，单位千克，订单商品总质量小于一千克，算作一千克"
  },
  {
    "参数名": "min_amount",
    "类型": "number",
    "必填": "否",
    "说明": "最低金额，单位（分）"
  },
  {
    "参数名": "valuation_flag",
    "类型": "number",
    "必填": "否",
    "说明": "计费方式对应的选项是否已设置"
  },
  {
    "参数名": "amount_flag",
    "类型": "number",
    "必填": "否",
    "说明": "金额是否设置"
  }
]
```

__address_infos">

### Body.freight_template.all_condition_free_detail.condition_free_detail_list(Array).address_infos `Object Payload`

支持的地址列表

```json
[
  {
    "参数名": "user_name",
    "类型": "string",
    "必填": "否",
    "说明": "收货人姓名"
  },
  {
    "参数名": "postal_code",
    "类型": "string",
    "必填": "否",
    "说明": "邮编"
  },
  {
    "参数名": "province_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第一级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "city_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第二级地址，如果是直辖市，请填区，比如\"浦东新区\"，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "county_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第三级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "detail_info",
    "类型": "string",
    "必填": "否",
    "说明": "详细收货地址信息"
  },
  {
    "参数名": "national_code",
    "类型": "string",
    "必填": "否",
    "说明": "收货地址国家码"
  },
  {
    "参数名": "tel_number",
    "类型": "string",
    "必填": "否",
    "说明": "收货人手机号码"
  },
  {
    "参数名": "lat",
    "类型": "number",
    "必填": "否",
    "说明": "纬度"
  },
  {
    "参数名": "lng",
    "类型": "number",
    "必填": "否",
    "说明": "经度"
  },
  {
    "参数名": "house_number",
    "类型": "string",
    "必填": "否",
    "说明": "门牌号"
  }
]
```

### Body.freight_template.all_freight_calc_method `Object Payload`

具体计费方法，默认运费，指定地区运费等

```json
[
  {
    "参数名": "freight_calc_method_list",
    "类型": "objarray",
    "必填": "否",
    "说明": "freight_calc_method_list"
  }
]
```

">

### Body.freight_template.all_freight_calc_method.freight_calc_method_list(Array) `Object Payload`

freight_calc_method_list

```json
[
  {
    "参数名": "address_infos",
    "类型": "objarray",
    "必填": "否",
    "说明": "支持的地址列表"
  },
  {
    "参数名": "is_default",
    "类型": "boolean",
    "必填": "否",
    "说明": "是否默认运费"
  },
  {
    "参数名": "delivery_id",
    "类型": "string",
    "必填": "否",
    "说明": "快递公司"
  },
  {
    "参数名": "first_val_amount",
    "类型": "number",
    "必填": "否",
    "说明": "首段运费需要满足的数量"
  },
  {
    "参数名": "first_price",
    "类型": "number",
    "必填": "否",
    "说明": "首段运费的金额"
  },
  {
    "参数名": "second_val_amount",
    "类型": "number",
    "必填": "否",
    "说明": "续费的数量"
  },
  {
    "参数名": "second_price",
    "类型": "number",
    "必填": "否",
    "说明": "续费的金额"
  }
]
```

__address_infos">

### Body.freight_template.all_freight_calc_method.freight_calc_method_list(Array).address_infos `Object Payload`

支持的地址列表

```json
[
  {
    "参数名": "user_name",
    "类型": "string",
    "必填": "否",
    "说明": "收货人姓名"
  },
  {
    "参数名": "postal_code",
    "类型": "string",
    "必填": "否",
    "说明": "邮编"
  },
  {
    "参数名": "province_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第一级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "city_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第二级地址，如果是直辖市，请填区，比如\"浦东新区\"，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "county_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第三级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "detail_info",
    "类型": "string",
    "必填": "否",
    "说明": "详细收货地址信息"
  },
  {
    "参数名": "national_code",
    "类型": "string",
    "必填": "否",
    "说明": "收货地址国家码"
  },
  {
    "参数名": "tel_number",
    "类型": "string",
    "必填": "否",
    "说明": "收货人手机号码"
  },
  {
    "参数名": "lat",
    "类型": "number",
    "必填": "否",
    "说明": "纬度"
  },
  {
    "参数名": "lng",
    "类型": "number",
    "必填": "否",
    "说明": "经度"
  },
  {
    "参数名": "house_number",
    "类型": "string",
    "必填": "否",
    "说明": "门牌号"
  }
]
```

### Body.freight_template.not_send_area `Object Payload`

不发货区域

```json
[
  {
    "参数名": "address_infos",
    "类型": "objarray",
    "必填": "否",
    "说明": "不支持的地址列表"
  }
]
```

">

### Body.freight_template.not_send_area.address_infos(Array) `Object Payload`

不支持的地址列表

```json
[
  {
    "参数名": "user_name",
    "类型": "string",
    "必填": "否",
    "说明": "收货人姓名"
  },
  {
    "参数名": "postal_code",
    "类型": "string",
    "必填": "否",
    "说明": "邮编"
  },
  {
    "参数名": "province_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第一级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "city_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第二级地址，如果是直辖市，请填区，比如\"浦东新区\"，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "county_name",
    "类型": "string",
    "必填": "否",
    "说明": "国标收货地址第三级地址，可调用[获取地址编码](/doc/store/shop/API/warehouse/api_getaddresscode.md)获取"
  },
  {
    "参数名": "detail_info",
    "类型": "string",
    "必填": "否",
    "说明": "详细收货地址信息"
  },
  {
    "参数名": "national_code",
    "类型": "string",
    "必填": "否",
    "说明": "收货地址国家码"
  },
  {
    "参数名": "tel_number",
    "类型": "string",
    "必填": "否",
    "说明": "收货人手机号码"
  },
  {
    "参数名": "lat",
    "类型": "number",
    "必填": "否",
    "说明": "纬度"
  },
  {
    "参数名": "lng",
    "类型": "number",
    "必填": "否",
    "说明": "经度"
  },
  {
    "参数名": "house_number",
    "类型": "string",
    "必填": "否",
    "说明": "门牌号"
  }
]
```

## 3. 返回参数

### 返回体 `Response Payload`

```json
[
  {
    "参数名": "errcode",
    "类型": "number",
    "示例": "0",
    "说明": "错误码"
  },
  {
    "参数名": "errmsg",
    "类型": "string",
    "示例": "ok",
    "说明": "错误信息"
  },
  {
    "参数名": "template_id",
    "类型": "string",
    "示例": "-",
    "说明": "运费模板id"
  }
]
```

## 4. 枚举信息

### Body.freight_template.send_time `Enum`

发货时间期限[详情](https://store.weixin.qq.com/chengzhang/webdoc/wiki/407/e4ca8eb1ee772cf7/growth_center_rule_for_store?source=6&sourceType=4) 

```json
[
  {
    "枚举值": "SendTime_TWENTYFOUR_HOUR",
    "描述": "24小时内发货"
  },
  {
    "枚举值": "SendTime_FOUTYEIGHT_HOUR",
    "描述": "48小时内发货"
  },
  {
    "枚举值": "SendTime_SHIP_TODAY",
    "描述": "今日发"
  }
]
```

## 5. 注意事项

当前供货商仅支持配置「包邮」运费模板，后续将支持配置「自定义邮费」运费模板。

## 6. 代码示例

请求示例

```json
{
    "freight_template": {
        "name": "测试api",
        "valuation_type": "PIECE",
        "send_time": "SendTime_FOUR_HOUR",
        "address_info": {
            "user_name": "",
            "postal_code": "12345",
            "province_name": "广东省",
            "city_name": "广州市",
            "county_name": "海珠区",
            "detail_info": "新港中路",
            "national_code": "23456",
            "tel_number": "12345"
        },
        "delivery_type": "EXPRESS",
        "shipping_method": "FREE",
        "is_default": 0
    }
}
```

返回示例

```json
{
    "errcode": 0,
    "errmsg": "ok",
    "template_id": "123123"
}
错误
```

## 7. 错误码

以下是本接口的错误码列表，其他错误码可参考 [通用错误码](/doc/store/shop/dev_before/commErrCode.md)；调用接口遇到报错，可使用官方提供的 [API 诊断工具](https://developers.weixin.qq.com/console/devtools/debug?utm_source=api_errcode) 辅助定位和分析问题。

```json
[
  {
    "错误码": "10020007",
    "错误描述": "没有模板id"
  },
  {
    "错误码": "10021053",
    "错误描述": "非法的默认运费模板规则，默认运费不可以指定地址"
  },
  {
    "错误码": "10021054",
    "错误描述": "非法的省市区信息"
  },
  {
    "错误码": "10021081",
    "错误描述": "运费模板未设置发货地址"
  },
  {
    "错误码": "10021082",
    "错误描述": "非法的发货时间"
  },
  {
    "错误码": "10025501",
    "错误描述": "禁止设置全国不发货"
  },
  {
    "错误码": "10025502",
    "错误描述": "快递公司数量超过上限"
  },
  {
    "错误码": "10025503",
    "错误描述": "条件包邮规则超过上限"
  },
  {
    "错误码": "10025504",
    "错误描述": "计费规则超过上限"
  },
  {
    "错误码": "22192018",
    "错误描述": "地区重叠，不支持一个区域多个计费规则"
  },
  {
    "错误码": "22192019",
    "错误描述": "地区重叠，不支持一个区域多个条件包邮规则"
  },
  {
    "错误码": "22192020",
    "错误描述": "同一个条件包邮规则，不支持同时开启按件和按金额，需分开配置"
  }
]
```

## 8. 适用范围

本接口在不同账号类型下的可调用情况：

```json
[
  {
    "微信小店": "✔",
    "小店供货商": "✔"
  }
]
```

- ✔：该账号可调用此接口。
- 其他未明确声明的账号类型，如无特殊说明，均不可调用此接口。

![](https://res8.wxqcloud.qq.com.cn/wxdoc/56617deb-b17d-4cf1-bccd-71d2c41ccc76.svg)接口变更日志（3条）
2026 年 06 月 04 日补充注意事项
2025 年 12 月 31 日更新  `send_time`  字段说明，新增  `Body.freight_template.send_time`  枚举信息
2025 年 12 月 29 日新增错误码
