Skip to content

pos-create-replacement-shipment ​

Method: POST
Path: /pos/shipping/shipments/{reference_number}/replacement

Tags: Shipments

Summary ​

Create a replacement shipment

Description ​

Creates a replacement shipment against an existing shipment. Use the manual payload to dispatch outside an integrated carrier, or the auto payload to fulfill through an integrated carrier with system-managed packing and rates.

Pos SDK Usage ​

SDK Method: pos.createReplacementShipment()

Example:

typescript
// Replacement shipped through an integrated carrier, system-packed
const { data, error } = await pos.createReplacementShipment(
  { reference_number: "SHIP-2024-001234" },
  {
    fulfillment_type: "delivery",
    warehouse_id: "WH-001",
    shipment_items: [
      { product_id: "PROD-123", variant_id: "VAR-456", quantity: 1 }
    ],
    shipping_option: "auto",
    shipping_provider_id: "SP-001",
    packing_option: "auto",
    total_weight: 1.5,
    reason: "Damaged on delivery"
  }
);

if (error) {
  console.error("Failed to create replacement:", error.message);
} else {
  console.log("Replacement created:", data.message);
}

// Replacement dispatched manually, with explicit box packing
const { data: manualData } = await pos.createReplacementShipment(
  { reference_number: "SHIP-2024-001234" },
  {
    fulfillment_type: "delivery",
    warehouse_id: "WH-001",
    shipment_items: [
      { product_id: "PROD-123", variant_id: null, quantity: 2 }
    ],
    shipping_option: "manual",
    shipping_provider_id: "SP-MANUAL-01",
    packing_option: "manual",
    boxes: [
      {
        box_name: "Medium",
        box_length: 30,
        box_width: 20,
        box_height: 15,
        box_weight: 2,
        items_count: 2,
        box_count: 1
      }
    ],
    total_weight: 2,
    expected_delivery_date: "2024-01-20",
    tracking_link: "https://tracking.example.com/AWB123456789",
    manual_shipping_charges: 120,
    reason: "Wrong item shipped"
  }
);

// Replacement collected by the customer in store
const { data: pickupData } = await pos.createReplacementShipment(
  { reference_number: "SHIP-2024-001234" },
  {
    fulfillment_type: "collect-in-store",
    warehouse_id: "STORE-042",
    shipment_items: [
      { product_id: "PROD-123", variant_id: "VAR-456", quantity: 1 }
    ],
    shipping_option: "manual",
    shipping_provider_id: "SP-MANUAL-01",
    packing_option: "auto",
    reason: "Size exchange"
  }
);

TypeScript Definition ​

typescript
"pos-create-replacement-shipment": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description Reference number of the original shipment being replaced. */
                reference_number: string;
            };
            cookie?: never;
        };
        requestBody: {
            content: {
                "application/json": components["schemas"]["CreateReplacementShipmentWithManualMethod"] | components["schemas"]["CreateReplacementShipmentWithAutoMethod"] | components["schemas"]["CreateReplacementShipmentForCollectInStore"];
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                    };
                };
            };
            400: components["responses"]["AdminBadRequest"];
            401: components["responses"]["AdminUnauthorized"];
            403: components["responses"]["Forbidden"];
            404: components["responses"]["AdminNotFound"];
            408: components["responses"]["RequestTimeout"];
            500: components["responses"]["AdminInternalServerError"];
            504: components["responses"]["GatewayTimeout"];
        };
    };

Component References ​

ReferenceResolves To
components["schemas"]["CreateReplacementShipmentWithManualMethod"]CreateReplacementShipmentWithManualMethod
components["schemas"]["CreateReplacementShipmentWithAutoMethod"]CreateReplacementShipmentWithAutoMethod
components["schemas"]["CreateReplacementShipmentForCollectInStore"]CreateReplacementShipmentForCollectInStore
components["responses"]["AdminBadRequest"]AdminBadRequest
components["responses"]["AdminUnauthorized"]AdminUnauthorized
components["responses"]["Forbidden"]Forbidden
components["responses"]["AdminNotFound"]AdminNotFound
components["responses"]["RequestTimeout"]RequestTimeout
components["responses"]["AdminInternalServerError"]AdminInternalServerError
components["responses"]["GatewayTimeout"]GatewayTimeout

Parameters ​

  • reference_number (path): Reference number of the original shipment being replaced.

Request Body ​

Content Types: application/json

Responses ​

200 ​

OK

400 ​

401 ​

403 ​

Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.

404 ​

408 ​

500 ​

504 ​

The request timed out.

OpenAPI Definition ​

json
{
  "operationId": "pos-create-replacement-shipment",
  "summary": "Create a replacement shipment",
  "description": "Creates a replacement shipment against an existing shipment. Use the `manual` payload to dispatch outside an integrated carrier, or the `auto` payload to fulfill through an integrated carrier with system-managed packing and rates.",
  "parameters": [
    {
      "name": "reference_number",
      "in": "path",
      "description": "Reference number of the original shipment being replaced.",
      "required": true,
      "schema": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^(?:[A-Za-z0-9_-]{1,128}|MS:[A-Za-z0-9_-]{1,125})$"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "oneOf": [
            {
              "$ref": "#/components/schemas/CreateReplacementShipmentWithManualMethod"
            },
            {
              "$ref": "#/components/schemas/CreateReplacementShipmentWithAutoMethod"
            },
            {
              "$ref": "#/components/schemas/CreateReplacementShipmentForCollectInStore"
            }
          ]
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              }
            },
            "required": [
              "message",
              "success"
            ]
          }
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/AdminBadRequest"
    },
    "401": {
      "$ref": "#/components/responses/AdminUnauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "404": {
      "$ref": "#/components/responses/AdminNotFound"
    },
    "408": {
      "$ref": "#/components/responses/RequestTimeout"
    },
    "500": {
      "$ref": "#/components/responses/AdminInternalServerError"
    },
    "504": {
      "$ref": "#/components/responses/GatewayTimeout"
    }
  },
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/admin-pos/operations/pos-create-replacement-shipment"
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "tags": [
    "Shipments"
  ],
  "x-speakeasy-group": "pos"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: