# Update COD of Order

> Change the Cash-on-Delivery (COD) amount to collect from the receiver for an existing order.

## Endpoint

| Environment | URL |
| --- | --- |
| Production | `https://online-gateway.ghn.vn/shiip/public-api/v2/shipping-order/updateCOD` |
| Staging | `https://dev-online-gateway.ghn.vn/shiip/public-api/v2/shipping-order/updateCOD` |

**Method**: `POST`

## Headers

| Header | Required | Description |
| --- | --- | --- |
| `Content-Type` | Yes | `application/json` |
| `Token` | Yes | Shop token (issued by GHN) — [get a token](https://developer.ghn.vn/en/docs/token/get-token.md) |
| `ShopId` | Yes | Shop ID (int) |

## Parameters

- **order_code** (String): GHN tracking code. The order must belong to your account (you are its owner or creator), otherwise the request is rejected
- **cod_amount** (Int): New COD amount to collect from the receiver (VND). Maximum `5,000,000` (enforced by GHN's backend). `0` clears the COD

> **NOTE**
> Send only these two fields. Any extra field is forwarded into GHN's order-update system unchecked — keep the payload minimal.

## Request Example

```bash
curl -X POST https://dev-online-gateway.ghn.vn/shiip/public-api/v2/shipping-order/updateCOD \
  -H "Token: 5c1d8a9e-2f4b-11ed-..." \
  -H "ShopId: 92837" \
  -H "Content-Type: application/json" \
  -d '{
    "order_code": "LADHFA",
    "cod_amount": 350000
  }'
```

## Response

### Success (HTTP 200)

_Captured from a real Staging-environment call._

```json
{
  "code": 200,
  "message": "Success",
  "data": null
}
```

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | Int | HTTP code (`200` on success) |
| `message` | String | Result message (`Success`) |
| `data` | null | Always `null` for this endpoint |

### Error — order not found / not yours (HTTP 400)

_Captured from a real Staging-environment call (unknown order code)._

```json
{
  "code": 400,
  "message": "Lỗi gọi API: corev2_tenant_order_detail - Đơn hàng không tồn tại",
  "data": null
}
```

> **NOTE**
> The meaningful part of `message` is the text after the last `-` (here `Đơn hàng không tồn tại` — "order not found"). The prefix is an internal reference — parse `code`/`code_message`, not `message`.

## Error Codes

| Condition | HTTP | Meaning |
| --- | --- | --- |
| Order not found (`Đơn hàng không tồn tại`) | 400 | The order code is unknown |
| Not authorized (`Không có quyền thao tác`) | 400 | The order does not belong to your account (you are neither its owner nor creator) |
| `USER_ERR_COMMON` | 400 | Missing `order_code` or invalid input |
| `SERVER_ERROR_COMMON` | 500 | Internal error |
