> ## 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.

# 建立 Resend Order

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

建立補寄訂單——將一個或多個已收到的退件庫存項打包，再寄到客戶地址。會觸發非同步面單產生；面單 URL 透過 webhook 推送。

## 前置條件

* 目標庫存項已在您的帳戶中。`returnInventoryId` 由 `newInventoryCreated` webhook 事件推送——請在自有端快取。
* 同一次補寄的所有庫存必須**位於同一倉庫**。
* 每筆庫存目前的 `handlingStatusCode` 必須可推進至 `rsd`（補寄）——通常需為 `ohd`（暫存）。
* 任何項所屬行項目不可存在待處理 VAS。
* 每筆庫存必須實際在庫（非運輸中，亦未處於其他活躍流程）。
* 備妥目的地地址。

## 必填欄位

* **`resendShipment`** — 完整 Shipment payload（目的地址、聯絡人、尺寸、重量、服務類型）。國家代碼為 **ISO3**。
  * `warehouseId` 為**必填**，且必須與 `returnInventoryIdList` 中各項目所屬的倉庫相同（同一次補寄的所有項目共用同一倉庫）。省略將導致驗證失敗。
  * payload 內的 `shipmentServiceType` 是 **Shipment Service Type**（**不是** Return Service Type）— 有效代碼請見 [取得 Warehouse 可用的 Shipment Service Types](/zh-Hant/api-reference/shipmentservicetype/get-available-shipment-service-types-for-warehouse)。傳入 Return Service Type 代碼會在驗證階段失敗。
* **`returnInventoryIdList`** — 非空 `List<long>`。上限為 `ResendConfig.groupResendMaxRmaCount`（通常為個位數；如需打包更多請聯絡客服）。

## 選填欄位

* **`description`** — 補寄訂單的自由文字描述（上限 255 字元）。會保存至訂單，並由[取得補寄訂單詳情](/zh-Hant/api-reference/resend/get-resend-order-details)回傳。
* **`remarks`** — 補寄訂單的商家備註（上限 5000 字元）。會保存至訂單，並由[取得補寄訂單詳情](/zh-Hant/api-reference/resend/get-resend-order-details)回傳。

<Note>兩者對應 Portal 上 Create Resend 表單的 **Description** 與 **Remarks** 欄位。皆為選填——省略即代表該訂單不設描述或備註。</Note>

## 副作用

* 每筆庫存的 `handlingCode` 會被設為 `rsd`。
* 待面單就緒後，倉庫將出貨。

<h2 id="label-generation-auto-vs-manual-service-types">
  標籤產生：自動 vs 手動服務類型
</h2>

補寄是否自動產生運單標籤，取決於您在 `resendShipment.shipmentServiceType` 中傳入的 shipment service type。每個 shipment service type 都帶有 `isEnableAutoCreateLabel` 旗標——請從 [取得 Warehouse 可用的 Shipment Service Types](/zh-Hant/api-reference/shipmentservicetype/get-available-shipment-service-types-for-warehouse) 取得，並讀取您打算使用的代碼的 `isEnableAutoCreateLabel`。

<h3 id="auto-label-isenableautocreatelabel-true">
  自動標籤（`isEnableAutoCreateLabel: true`）
</h3>

標籤在建立後非同步產生。補寄狀態流轉為：

`queued` → `label-success` → `completed`（若標籤產生失敗則 `queued` → `failed`）

僅當補寄處於 `label-success` 且在截止時間之前，才能透過 [取消補寄訂單](/zh-Hant/api-reference/resend/cancel-resend-order) 取消。處於 `queued` 時**無法**取消，因為標籤仍在產生中。

<h3 id="manual-label-isenableautocreatelabel-false">
  手動標籤（`isEnableAutoCreateLabel: false`）
</h3>

不會自動產生標籤；由倉庫處理該補寄。補寄狀態流轉為：

`pending` → `in-progress` → `completed`

當補寄處於 `pending` 且在截止時間之前，可透過 [取消補寄訂單](/zh-Hant/api-reference/resend/cancel-resend-order) 取消。

<h3 id="cancellation-cut-off">
  取消截止時間
</h3>

每個補寄都有取消截止時間，即**工作日的 08:00 UTC**，於補寄建立時設定。只要補寄處於其可取消狀態（自動標籤為 `label-success`，手動標籤為 `pending`），您可在該截止時間之前取消。一旦超過截止時間，便無法再透過 API 取消。

<Note>若已超過截止時間但您仍需取消補寄，請聯絡我們的客服團隊協助。截止時間過後無法保證能取消——包裹可能已經寄出。</Note>

## 相關

* [取得補寄訂單詳情](/zh-Hant/api-reference/resend/get-resend-order-details) — 僅在 webhook 提及您未快取的補寄時呼叫。
* [取消補寄訂單](/zh-Hant/api-reference/resend/cancel-resend-order) — 在倉庫出貨前撤銷。
* [取得所有補寄狀態](/zh-Hant/api-reference/resendstatus/get-all-resend-statuses) — 代碼至標籤對映。
* [Webhooks](/zh-Hant/webhooks) — `labelGenerated` 與補寄狀態更新事件會將生命週期變更推送至您的端點。


## OpenAPI

````yaml post /api/Resend/createResend
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/Resend/createResend:
    post:
      tags:
        - Resend
      summary: Create resend order
      operationId: ReturnUserApi_CreateResend
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateResendRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateResendResponse'
        '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:
    CreateResendRequest:
      type: object
      properties:
        returnInventoryIdList:
          type: array
          items:
            type: integer
            format: int64
          description: List of return inventory IDs for resend
        resendShipment:
          $ref: '#/components/schemas/CreateResendShipmentPayload'
          description: Destination shipment address for the resend
        description:
          type: string
          maxLength: 255
          description: >-
            Optional free-text description for the resend order. Stored against
            the order and returned by Get resend order details.
        remarks:
          type: string
          maxLength: 5000
          description: >-
            Optional merchant remarks/notes for the resend order. Stored against
            the order and returned by Get resend order details.
      required:
        - returnInventoryIdList
        - resendShipment
    CreateResendResponse:
      type: object
      properties:
        resendId:
          type: integer
          format: int64
          description: Created resend identifier
    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'
    CreateResendShipmentPayload:
      type: object
      properties:
        warehouseId:
          type: integer
          description: >-
            Identifier of the warehouse fulfilling the resend. Must match the
            warehouse of the items referenced in `returnInventoryIdList` — all
            items in a single resend belong to one warehouse.
        shipmentCountryCode:
          type: string
          description: ISO3 destination country code (e.g. GBR, USA)
        shipmentServiceType:
          type: string
          description: Shipment service type code
        shipmentName:
          type: string
          description: Recipient name
        shipmentPhone:
          type: string
          description: Recipient phone number
        shipmentFax:
          type: string
          description: Recipient fax number (optional)
        shipmentEmail:
          type: string
          description: Recipient email address (optional)
        shipmentStreet1:
          type: string
          description: Address line 1
        shipmentStreet2:
          type: string
          description: Address line 2
        shipmentStreet3:
          type: string
          description: Address line 3 (optional)
        shipmentState:
          type: string
          description: State / province
        shipmentCity:
          type: string
          description: City
        shipmentPostalCode:
          type: string
          description: Postal code
      required:
        - warehouseId
        - shipmentCountryCode
        - shipmentName
        - shipmentPhone
        - shipmentStreet1
        - shipmentStreet2
        - shipmentCity
        - shipmentPostalCode
        - shipmentState
    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

````