1. Shipments
  2. Refund Shipments

Shipments

Refund Shipments

This endpoint allows you to request a refund for a previously purchased shipment. When a refund is processed, the shipment status is updated to canceled and refund status is set to refunded

POST
`/v1/shipments/:shipment/refund`

The endpoint requires only the shipment ID as a URL parameter. No request body is needed.

Request Example

js
        const response = await fetch(`https://api.packagex.io/v1/shipments/${shipment_id}/refund`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json"
  }
});

const result = await response.json();

      

Provider Support

Not all shipping providers support refunds. The system automatically checks provider capabilities before processing the refund request. If a provider doesn't support refunds, the request will be rejected with an appropriate error message.

Refund Process

The refund process involves several automated steps:

  1. Validation

    • Verifies the shipment exists and has been purchased.
    • Confirms the shipping provider supports refunds.
    • Checks if the shipment is eligible for refund.
  2. Provider Integration

    • Processes the refund with the shipping provider.
    • Updates tracking information accordingly.
    • Cancels any pending pickup or delivery requests.
  3. Status Updates

    • Updates shipment status to canceled
    • Sets refund status to refunded
    • Creates tracking update records.

Status Changes

When a refund is processed, the following status changes occur:

  • Shipment status: Changed to canceled
  • Refund status: Set to refunded
  • Tracking updates: New update created with canceled status

Error Scenarios

The endpoint may return the following errors:

Error Code Description
400 Shipment has not been purchased yet.
400 Shipment cannot be refunded (provider doesn't support refunds).
404 Shipment not found.
500 Internal server error during refund processing.