Skip to content

Buy Label

Request

Creates and pays for a shipment label using the rate_id obtained from a prior get_rates call. This endpoint also allows purchasing shipment insurance in the same request (insurance cannot be purchased separately).

To prevent duplicate purchases caused by network fluctuations or retries, the API checks ether a shipment already exists under the specified platform_uk_id.

  • If a related shipment is found, the existing shipment information will be returned, and the duplicate_label field in the response will be set to true.
  • If no shipment exists, a new shipment will be created as normal, and the duplicate_label field will be false.
Security
BearerAuth
Bodyapplication/jsonrequired
rate_idstring(ShipmentRateId)required

The unique identifier of a shipping rate returned by the get_rates endpoint. Use this value to reference a specific rate when purchasing a label.

Example:"dc288147-f7dd-494d-9353-5ce00020c7aa"
platform_uk_idstring(PlatformUkId)required

A unique identifier provided by the calling party (e.g., the caller’s order number). Each platform_uk_id must correspond to exactly one shipment and cannot be reused across multiple shipments.

Example:"platformUkId175377917713"
insurance_dataobject(InsuranceData)
label_print_typestring(LabelPrintTypeEnum)required

Defines the label print format. Supported types vary by carrier and may also depend on the selected service level. For example, USPS and FedEx may support qrcode, while UPS may support barcode.

Enum:"common""qrcode""barcode"
Example:"common"
is_return_labelboolean(IsReturnLabel)

Indicates whether the label is for a return shipment.

Default:false
Example:false
is_exchange_labelboolean(IsExchangeLabel)

Indicates whether the shipment label belongs to a platform-specific exchange/return workflow. This field is used for certain marketplace integrations and will be stored internally in the tag field.

Default:false
Example:false
POST
/api/shipment/create_and_pay
curl -i -X POST \
  https://x-api.shipsaving.com/api/shipment/create_and_pay \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "rate_id": "dc288147-f7dd-494d-9353-5ce00020c7aa",
    "platform_uk_id": "platformUkId175377917713",
    "insurance_data": {
      "rate_id": "dc288147-f7dd-494d-9353-5ce00020c7aa"
    },
    "label_print_type": "common",
    "is_return_label": false,
    "is_exchange_label": false
  }'

Responses

OK

Bodyapplication/json
codestring
Example:"ok"
msgstring
Example:"ok"
dataobject(ShipmentItem)
Response
{ "code": "ok", "msg": "ok", "data": { "zone": "1", "currency": "USD", "shipment_no": "1222243159", "tracking_no": "9234690381085700XXXXX", "total_fee": 39.39, "label_fee": 39.39, "insurance_fee": null, "label_processing_fee": 0.05, "label_urls": [ … ], "qrcode_urls": [ … ], "commercial_urls": null, "duplicate_label": true, "label_print_type": "common" } }