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;
};
};
};
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["CreateReplacementShipmentWithManualMethod"] | CreateReplacementShipmentWithManualMethod |
components["schemas"]["CreateReplacementShipmentWithAutoMethod"] | CreateReplacementShipmentWithAutoMethod |
components["schemas"]["CreateReplacementShipmentForCollectInStore"] | CreateReplacementShipmentForCollectInStore |
Parameters
- reference_number (path): Reference number of the original shipment being replaced.
Request Body
Content Types: application/json
Responses
200
OK
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"
}
}
],
"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"
}
}
}
}
}
}
},
"security": [
{
"Authorization": []
}
],
"tags": [
"Shipments"
],
"x-speakeasy-group": "pos"
}Auto-generated from OpenAPI spec and TypeScript definitions