> ## Documentation Index
> Fetch the complete documentation index at: https://www.commercengine.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a replacement shipment

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



## OpenAPI

````yaml https://openapi.commercengine.io/ce-pos.json post /pos/shipping/shipments/{reference_number}/replacement
openapi: 3.2.0
info:
  title: CE POS APIs
  description: >-
    The consolidated Point of Sale surface. Every operation is served under the
    storefront base URL; the POS backend proxies some of them to the admin
    service.
  version: '1.0'
servers:
  - url: https://staging.api.commercengine.io/api/v1/{store_id}/storefront
    description: Staging Server
    variables:
      store_id:
        description: Store ID
        default: store_id
    x-speakeasy-server-id: staging
  - url: https://prod.api.commercengine.io/api/v1/{store_id}/storefront
    description: Prod Server
    variables:
      store_id:
        description: Store ID
        default: store_id
    x-speakeasy-server-id: prod
security:
  - Authorization: []
tags:
  - name: section-identity
    summary: Identity
    kind: nav
  - name: Devices
    description: >-
      Set up the till: pair a device with the store using its pairing code, list
      the store's `PosLocation`s and `PosDevice`s, and claim a device for the
      signed-in user or release it.
    summary: Devices
    kind: nav
    parent: section-identity
  - name: Authentication
    description: >-
      Sign a staff member in on a paired device with a one-time password over
      SMS, WhatsApp or email, then refresh the access token or log out.
    summary: Authentication
    kind: nav
    parent: section-identity
  - name: Users
    description: >-
      The staff member signed in on the till, as a `PosUser` with their
      location, device and roles.
    summary: Users
    kind: nav
    parent: section-identity
  - name: section-customers
    summary: Customers
    kind: nav
  - name: Customers
    description: >-
      Look up the shopper at the till: list customers (`CustomerListItem`) and
      read one's full `CustomerDetail`.
    summary: Customers
    kind: nav
    parent: section-customers
  - name: Addresses
    description: >-
      A customer's saved addresses, as `Address` objects: list, add, update and
      remove them.
    summary: Addresses
    kind: nav
    parent: section-customers
  - name: section-catalog
    summary: Catalog
    kind: nav
  - name: Products
    description: >-
      Browse and search the catalog at the till: list `Product`s and SKUs, read
      a product and its variants, and show similar, up-sell and cross-sell
      items.
    summary: Products
    kind: nav
    parent: section-catalog
  - name: Reviews
    description: Read product reviews at the till.
    summary: Reviews
    kind: nav
    parent: section-catalog
  - name: Categories
    description: >-
      The store's categories, as `ProductCategory` objects with their child
      categories.
    summary: Categories
    kind: nav
    parent: section-catalog
  - name: Inventory
    description: >-
      Stock at the store's locations: list it by item, read an item's
      `InventoryDetail`, and follow the `InventoryActivity` that moved it.
    summary: Inventory
    kind: nav
    parent: section-catalog
  - name: section-shopping
    summary: Shopping
    kind: nav
  - name: Carts
    description: >-
      The till's `Cart`: create it, add, update or remove items, link the
      customer, set the address, and apply loyalty points or credit balance.
      Each update returns the full, updated `Cart`.
    summary: Carts
    kind: nav
    parent: section-shopping
  - name: Coupons & promotions
    description: >-
      The coupons and promotions a cart can use: list what the store offers, see
      which apply to a cart and why the rest don't, and apply or remove a
      coupon.
    summary: Coupons & promotions
    kind: nav
    parent: section-shopping
  - name: Fulfillment
    description: >-
      List the delivery and collect-in-store options for a cart, and save the
      cart's choice.
    summary: Fulfillment
    kind: nav
    parent: section-shopping
  - name: section-orders
    summary: Orders
    kind: nav
  - name: Orders
    description: >-
      Place an order from the till's cart and follow it: list orders, read an
      `OrderDetail` and its activity, check stock before it ships, and get its
      invoice, receipt and shipments.
    summary: Orders
    kind: nav
    parent: section-orders
  - name: Order payments
    description: >-
      Collect payment for an order: add payments toward what is left to pay,
      across one or more methods, poll the payment status, and retry a failed or
      expired payment.
    summary: Order payments
    kind: nav
    parent: section-orders
  - name: Shipments
    description: >-
      The shipments that fulfill orders: list them, read a `ShipmentDetail` with
      its activity and invoice, approve, reject or update one, send a
      replacement, and refund a shortfall.
    summary: Shipments
    kind: nav
    parent: section-orders
  - name: section-payments
    summary: Payments
    kind: nav
  - name: Payments
    description: >-
      The payment methods the till accepts and the checks around paying with
      them: card BIN details, VPA verification, and authenticating a payment
      with a direct OTP.
    summary: Payments
    kind: nav
    parent: section-payments
  - name: section-store
    summary: Store
    kind: nav
  - name: Locations
    description: States and pincodes for address forms.
    summary: Locations
    kind: nav
    parent: section-store
paths:
  /pos/shipping/shipments/{reference_number}/replacement:
    post:
      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.
      operationId: pos-create-replacement-shipment
      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
                required:
                  - message
                  - success
                properties:
                  message:
                    type: string
                  success:
                    type: boolean
        '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'
      security:
        - Authorization: []
      externalDocs:
        url: >-
          https://llm-docs.commercengine.io/admin-pos/operations/pos-create-replacement-shipment
components:
  schemas:
    CreateReplacementShipmentWithManualMethod:
      title: CreateReplacementShipmentWithManualMethod
      description: >-
        Replacement shipment payload when fulfilling through a manual courier
        (no carrier integration).
      type: object
      externalDocs:
        url: >-
          https://llm-docs.commercengine.io/admin-pos/schemas/CreateReplacementShipmentWithManualMethod
      required:
        - warehouse_id
        - shipping_option
        - shipping_provider_id
        - packing_option
        - expected_delivery_date
        - tracking_link
        - manual_shipping_charges
        - reason
      properties:
        fulfillment_type:
          description: Set to `delivery` when the replacement is shipped to the customer.
          type: string
          const: delivery
        warehouse_id:
          description: The warehouse from which the replacement items will be shipped.
          type: string
          minLength: 1
        shipment_items:
          description: Omit to reuse the original shipment lines.
          type: array
          items:
            $ref: '#/components/schemas/ReplacementShipmentItem'
        shipping_option:
          description: >-
            Set to `manual` to dispatch the shipment outside of an integrated
            carrier.
          enum:
            - manual
        shipping_provider_id:
          description: The manual shipping provider used to fulfill the replacement.
          type: string
          minLength: 1
        packing_option:
          description: The packing option for the replacement shipment.
          enum:
            - manual
            - auto
        boxes:
          description: The boxes for the replacement shipment.
          type: array
          items:
            $ref: '#/components/schemas/ShipmentBox'
        total_weight:
          description: >-
            Total shipment weight in kilograms, with up to three decimal places.
            Required and nonzero when packing_option is manual.
          type: number
          exclusiveMaximum: 10000000
          exclusiveMinimum: -10000000
        expected_delivery_date:
          description: The expected delivery date communicated to the customer.
          type:
            - string
            - 'null'
          format: date
        tracking_link:
          description: Optional tracking URL shared with the customer.
          type:
            - string
            - 'null'
        manual_shipping_charges:
          description: >-
            Shipping charges incurred for the manual dispatch, with up to two
            decimal places.
          type:
            - number
            - 'null'
          exclusiveMaximum: 100000000
          minimum: 0
        reason:
          description: The reason for the replacement shipment.
          type: string
          minLength: 1
      allOf:
        - if:
            properties:
              packing_option:
                const: manual
            required:
              - packing_option
          then:
            required:
              - total_weight
            properties:
              total_weight:
                not:
                  const: 0
      x-tags:
        - Shipping
    CreateReplacementShipmentWithAutoMethod:
      title: CreateReplacementShipmentWithAutoMethod
      description: >-
        Replacement shipment payload when fulfilling through an integrated
        carrier.
      type: object
      externalDocs:
        url: >-
          https://llm-docs.commercengine.io/admin-pos/schemas/CreateReplacementShipmentWithAutoMethod
      required:
        - warehouse_id
        - shipping_option
        - shipping_provider_id
        - packing_option
        - reason
      properties:
        fulfillment_type:
          description: Set to `delivery` when the replacement is shipped to the customer.
          type: string
          const: delivery
        warehouse_id:
          description: The warehouse from which the replacement items will be shipped.
          type: string
          minLength: 1
        shipment_items:
          description: Omit to reuse the original shipment lines.
          type: array
          items:
            $ref: '#/components/schemas/ReplacementShipmentItem'
        shipping_option:
          description: >-
            Set to `auto` to dispatch the shipment through an integrated
            carrier.
          enum:
            - auto
        shipping_provider_id:
          description: The integrated shipping provider used to fulfill the replacement.
          type: string
          minLength: 1
        packing_option:
          description: >-
            Use `manual` to specify boxes explicitly, or `auto` to let the
            system pack on your behalf.
          enum:
            - auto
            - manual
        boxes:
          description: >-
            Box-wise packing breakdown. Required when `packing_option` is
            `manual`.
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ShipmentBox'
        total_weight:
          description: >-
            Total shipment weight in kilograms, with up to three decimal places.
            Required and nonzero when packing_option is manual.
          type: number
          exclusiveMaximum: 10000000
          exclusiveMinimum: -10000000
        courier_company_id:
          description: >-
            Specific courier company to use. If omitted, the system selects the
            most suitable courier automatically.
          type:
            - string
            - 'null'
        reason:
          description: The reason for the replacement shipment.
          type: string
          minLength: 1
      allOf:
        - if:
            properties:
              packing_option:
                const: manual
            required:
              - packing_option
          then:
            required:
              - total_weight
              - boxes
            properties:
              total_weight:
                not:
                  const: 0
              boxes:
                type: array
                minItems: 1
      x-tags:
        - Shipping
    CreateReplacementShipmentForCollectInStore:
      title: CreateReplacementShipmentForCollectInStore
      description: >-
        Replacement shipment payload when the customer collects the items from a
        store instead of having them delivered.
      type: object
      externalDocs:
        url: >-
          https://llm-docs.commercengine.io/admin-pos/schemas/CreateReplacementShipmentForCollectInStore
      required:
        - warehouse_id
        - shipping_option
        - shipping_provider_id
        - packing_option
        - reason
      properties:
        fulfillment_type:
          description: >-
            Set to `collect-in-store` when the replacement is fulfilled via
            in-store pickup.
          type: string
          const: collect-in-store
        warehouse_id:
          description: The warehouse holding the replacement items for in-store pickup.
          type: string
          minLength: 1
        shipment_items:
          description: Omit to reuse the original shipment lines.
          type: array
          items:
            $ref: '#/components/schemas/ReplacementShipmentItem'
        shipping_option:
          description: >-
            Set to `manual` since in-store pickup is handled outside of an
            integrated carrier.
          enum:
            - manual
        shipping_provider_id:
          description: >-
            The manual shipping provider associated with the in-store pickup
            flow.
          type: string
          minLength: 1
        packing_option:
          description: The packing option for the replacement shipment.
          enum:
            - manual
            - auto
        boxes:
          description: The boxes for the replacement shipment.
          type: array
          items:
            $ref: '#/components/schemas/ShipmentBox'
        reason:
          description: The reason for the replacement shipment.
          type: string
          minLength: 1
        total_weight:
          description: >-
            Total shipment weight in kilograms, with up to three decimal places.
            Required and nonzero when packing_option is manual.
          type: number
          exclusiveMaximum: 10000000
          exclusiveMinimum: -10000000
      allOf:
        - if:
            properties:
              packing_option:
                const: manual
            required:
              - packing_option
          then:
            required:
              - total_weight
            properties:
              total_weight:
                not:
                  const: 0
      x-tags:
        - Shipping
    ReplacementShipmentItem:
      title: ReplacementShipmentItem
      description: >-
        An item for a replacement shipment. Quantity must be nonnegative, and
        quantity plus free_quantity must be at least one. Omit variant_id or
        send null for products without variants.
      type: object
      externalDocs:
        url: >-
          https://llm-docs.commercengine.io/admin-pos/schemas/ReplacementShipmentItem
      required:
        - product_id
        - quantity
      properties:
        product_id:
          type: string
          minLength: 1
        variant_id:
          type:
            - string
            - 'null'
          minLength: 1
        quantity:
          type: integer
          minimum: 0
        free_quantity:
          type: integer
          default: 0
      x-tags:
        - Shipping
    ShipmentBox:
      title: ShipmentBox
      type: object
      externalDocs:
        url: https://llm-docs.commercengine.io/admin-pos/schemas/ShipmentBox
      required:
        - box_name
        - box_length
        - box_width
        - box_height
        - box_weight
        - items_count
        - box_count
      properties:
        box_id:
          type:
            - string
            - 'null'
        max_weight:
          type:
            - number
            - 'null'
          exclusiveMaximum: 100000000
          exclusiveMinimum: -100000000
        used_space:
          type:
            - number
            - 'null'
          exclusiveMaximum: 100000000
          exclusiveMinimum: -100000000
        box_name:
          type: string
          minLength: 1
        box_length:
          type: number
          exclusiveMaximum: 100000000
          exclusiveMinimum: -100000000
        box_width:
          type: number
          exclusiveMaximum: 100000000
          exclusiveMinimum: -100000000
        box_height:
          type: number
          exclusiveMaximum: 100000000
          exclusiveMinimum: -100000000
        box_weight:
          type: number
          exclusiveMaximum: 100000000
          exclusiveMinimum: -100000000
        items_count:
          type:
            - integer
            - 'null'
        box_count:
          type:
            - integer
            - 'null'
      x-tags:
        - Shipping
  responses:
    AdminBadRequest:
      description: The request is invalid or cannot be completed in the current state.
      content:
        application/json:
          schema:
            type: object
            required:
              - message
              - success
            properties:
              message:
                type: string
              success:
                type: boolean
              code:
                type: string
              errors:
                description: Validation details as a field map, a bulk list or a string.
                anyOf:
                  - type: object
                    additionalProperties: true
                  - type: array
                  - type: string
              content:
                type: object
                additionalProperties: true
              details:
                type: string
    AdminUnauthorized:
      description: >-
        The token is missing, invalid or expired, or does not grant access to
        this store and operation.
      content:
        application/json:
          schema:
            type: object
            required:
              - message
              - success
            properties:
              message:
                type: string
              success:
                type: boolean
              code:
                type: string
              details:
                type: string
    Forbidden:
      description: >-
        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.
      content:
        application/json:
          schema:
            type: object
            required:
              - code
              - message
              - success
            properties:
              code:
                type: string
              message:
                type: string
                x-speakeasy-error-message: true
              success:
                type: boolean
              details:
                type: string
    AdminNotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            type: object
            required:
              - message
              - success
            properties:
              message:
                type: string
              success:
                type: boolean
              code:
                type: string
              details:
                type: string
    RequestTimeout:
      description: The request timed out.
      content:
        application/json:
          schema:
            type: object
            required:
              - code
              - message
              - success
            properties:
              code:
                type: string
              message:
                type: string
                x-speakeasy-error-message: true
              success:
                type: boolean
              details:
                type: string
    AdminInternalServerError:
      description: >-
        The request could not be completed. Quote error_id, when present, when
        contacting support.
      content:
        application/json:
          schema:
            type: object
            required:
              - message
              - success
            properties:
              message:
                type: string
              success:
                type: boolean
              code:
                type: string
              details:
                type: string
              error_id:
                type: string
    GatewayTimeout:
      description: The request timed out.
      content:
        application/json:
          schema:
            type: object
            required:
              - code
              - message
              - success
            properties:
              code:
                type: string
              message:
                type: string
                x-speakeasy-error-message: true
              success:
                type: boolean
              details:
                type: string
  securitySchemes:
    Authorization:
      type: http
      description: Access token
      scheme: bearer

````

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