> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.returnhelper.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 取消退貨面單

> [!WARNING]
>
> 此頁面由 AI 自動翻譯。API 技術規格以英文呈現為標準。如有任何疑問，請參閱[英文版本](/api-reference/returnshipment/cancel-return-label)。

取消由[建立 Return Shipment](/zh-Hant/api-reference/returnshipment/create-return-shipment) 產生的退貨面單。請傳入建立回應或 [`labelGenerated`](/zh-Hant/webhooks#label-result) webhook 中的 `labelId`。

## 可取消面單的條件

必須同時符合以下所有條件。任一條件不符合時，呼叫會傳回驗證軟錯誤——HTTP 200，`meta.status: 400`，`meta.errorCode: VALIDATION_FAILED`——錯誤訊息位於 `meta.error.labelId`。詳見[錯誤代碼](/zh-Hant/reference/error-codes)。

| 條件 | 不符合時的 `meta.error.labelId` |
| - | - |
| 面單屬於您的帳戶 | `Label:{labelId} not found` |
| 面單已產生（`labelRequestStatusCode` 為 `success`） | `Cancel label only when label status is success` |
| 目前時間早於面單的 `cancelCutoffTime` | `The cancellation cutoff Time {cancelCutoffTime} has already passed.` |
| 倉庫尚未收到包裹 | `Cancel label only when shipment status is lb-printed` |

`cancelCutoffTime` 會隨 `labelGenerated` webhook 中的面單一併推送，也會由[取得 Return Shipment 詳情](/zh-Hant/api-reference/returnshipment/get-return-request)傳回。

## 取消成功後

[取得 Return Shipment 詳情](/zh-Hant/api-reference/returnshipment/get-return-request)會傳回：

| 欄位 | 值 |
| - | - |
| `returnStatusCode` | `label-canceled` |
| `shipments[].shipmentStatusCode` | `lb-canceled` |
| `shipments[].labelId` | `0` |
| `shipments[].label` | `null` |

已取消的面單不會再傳回。如之後需要，請在您的系統中保存其 `labelId`。

## 修正運貨單

已取消的 Return Request 無法再取得新面單。如需修正運貨單，請先取消面單，再以修正後的資料重新呼叫[建立 Return Shipment](/zh-Hant/api-reference/returnshipment/create-return-shipment)。新的呼叫會傳回新的 `returnRequestId`、`shipmentId` 與 `labelId`。已取消的 Return Request 會維持 `label-canceled`。

## 等冪性

`x-returnhelper-idempotency-key` 標頭為選填。未帶此標頭的呼叫會正常執行，但不具備防重複的保護。請參閱[等冪性](/zh-Hant/introduction#idempotency)。

## 相關

* [建立 Return Shipment](/zh-Hant/api-reference/returnshipment/create-return-shipment) — 建立替代的運貨單。
* [取得 Return Shipment 詳情](/zh-Hant/api-reference/returnshipment/get-return-request) — 查看 `cancelCutoffTime` 與目前狀態。
* [Webhooks](/zh-Hant/webhooks#label-result) — `labelGenerated` 包含 `labelId` 與 `cancelCutoffTime`。


## OpenAPI

````yaml post /api/Label/CancelLabel
openapi: 3.1.0
info:
  title: Return Helper API
  description: API documentation for Return Helper — covering User and Public endpoints.
  version: 1.0.0
servers:
  - url: https://api.returnshelper.com/uat/user
    description: Sandbox — User API
  - url: https://api.returnshelper.com/uat/public
    description: Sandbox — Public API
  - url: https://api.returnhelpercentre.com/v1/user
    description: Production — User API
  - url: https://api.returnhelpercentre.com/v1/public
    description: Production — Public API
  - url: https://api.returnhelperchina.com/user
    description: Production — User API (China)
security:
  - ApiKey: []
    ApiToken: []
paths:
  /api/Label/CancelLabel:
    post:
      tags:
        - ReturnShipment
      summary: Cancel return label
      operationId: ReturnUserApi_CancelLabel
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelLabelRequest'
      responses:
        '200':
          description: >-
            Success — returns the standard response envelope with no additional
            payload fields. Inspect meta.status to confirm the label was
            cancelled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
        '401':
          description: >-
            Authentication failed. Returned when the `x-rr-apikey` or
            `x-rr-apitoken` header is missing or invalid. The body uses the
            standard `ApiResponse` envelope with `meta.error.message` describing
            the auth failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
      security:
        - ApiKey: []
          ApiToken: []
      servers:
        - url: https://api.returnshelper.com/uat/user
          description: Sandbox — User API
components:
  schemas:
    CancelLabelRequest:
      type: object
      properties:
        labelId:
          type: integer
          format: int64
          description: >-
            ID of the label to cancel, as returned by Create return shipment and
            the `labelGenerated` webhook
      required:
        - labelId
    ApiResponse:
      type: object
      description: >-
        Universal response envelope. Successful responses include the business
        payload as additional top-level fields alongside `correlationId` and
        `meta`. Failed responses (auth errors, validation errors) only populate
        `correlationId` and `meta`, with `meta.errorCode` and `meta.error`
        describing the failure.
      properties:
        correlationId:
          type:
            - string
            - 'null'
          description: >-
            Unique correlation ID for tracing the request through Return Helper
            systems.
        meta:
          $ref: '#/components/schemas/ApiResponseMeta'
    ApiResponseMeta:
      type: object
      description: >-
        Application-level metadata for every API response. Inspect `status` and
        `errorCode` to detect soft-error responses (validation failures arrive
        as HTTP 200 with `meta.status: 400`).
      properties:
        status:
          type: integer
          description: >-
            Application-level status code. For successful operations this
            mirrors the HTTP status (e.g. 200). For validation failures it
            reports the logical status (e.g. 400) even though the wire HTTP
            status is 200.
        data:
          type: object
          additionalProperties:
            type: string
          description: Reserved free-form metadata key/value pairs. Usually empty.
        errorCode:
          type:
            - string
            - 'null'
          description: >-
            Machine-readable error code (e.g. `VALIDATION_FAILED`). Non-null
            only when the operation failed.
        error:
          type: object
          additionalProperties: true
          description: >-
            Field-level or message-level error detail keyed by request property
            name. Empty object on success.
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: x-rr-apikey
      description: Your API key
    ApiToken:
      type: apiKey
      in: header
      name: x-rr-apitoken
      description: Your API token — keep this private

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.