ShipGenius White Logo

Copyright ShipGenius® 2025

✉️ Creating a Shipment

Generate a shipping label and track it — all in one step

📘 Overview

Use the rate_and_ship mutation to create a shipment, generate a label, and assign it to a batch.
This operation returns structured pricing, carrier service info, label file links, and payment handling (if required).

🛠 Mutation Format

mutation rate_and_ship($request: [RateAndShipInput!]!, $service_spec: RateAndShipServiceSpecs!) {
  rate_and_ship(request: $request, service_spec: $service_spec) {
    batch_id
    batch {
      id
      created_at
      batch_pdf_url
      payment_details {
        total_billed
        total_collected
        paid
      }
    }
    shipments {
      ... on Shipment {
        id
        tracking_number
        label {
          png {
            url
          }
        }
      }
      ... on ShipmentPaymentRequired {
        payment_link
        expires_at
      }
      ... on ShipmentError {
        code
        message
      }
    }
  }
}

📥 Required Input

The rate_and_ship mutation requires two inputs:

  1. request: [[RateAndShipInput!]!](/developer/api-reference/type/RateAndShipInput) – one or more full shipment definitions
  2. service_spec: [RateAndShipServiceSpecs](/developer/api-reference/type/RateAndShipServiceSpecs) – how to rate and select a carrier

🧾 RateAndShipInput

Each object in the request array must include:

FieldTypeRequiredDescription
transaction_idUUID!Unique ID for tracking this shipment request
packagePackageShipmentInput!Full shipment details (addresses, packaging, weight, contents)
override_service_specRateAndShipServiceSpecs⛔️🧾 Rate and Ship Service Specs Defines which carrier services to rate, how to prioritize the results, and any filters to apply. This overrides the root service_spec for the specified package
additionalAdditionalInfoInput⛔️Ship Date, and any other metadata for the shipment will be added here
carrier_specificShipmentCarrierInput⛔️Carrier specific information, used for information not all carriers accept
order_infoOrderInfo⛔️Tracking subscriptions, order references, custom metadata

📦 PackageShipmentInput

Defines the physical package and routing info for the shipment.

FieldTypeRequiredDescription
packagingPackaging!Type of package: custom box, softpack, or carrier packaging
weightWeightInput!Total weight of the shipment
content_descriptionString!Short description of the package contents
ship_toAddressInput!Recipient address
ship_fromAddressInput!Origin address
return_addressAddressInput⛔️Optional return address
extra_servicesExtraService⛔️Insurance, signature, etc.
hazmatHazmatInfo⛔️Required for lithium batteries, dry ice, etc.
customsCustomsInput⛔️Required for international shipments

📦 Packaging

Specifies the type of container used for the shipment.
This is a @oneOf input — only one of the following fields can be set:

FieldTypeDescription
custom_boxBoxDimensionsRigid box with length, width, height
custom_bagBagDimensionsSoftpack/bag with length, girth, width, height
carrier_specificCarrierSpecificPackagingPredefined packaging code from a carrier (e.g. USPS Flat Rate Envelope)

🚚 RateAndShipServiceSpecs

Defines which carrier services to consider and how to choose the best one.

FieldTypeRequiredDescription
services[RateAndShipService!]!List of carriers and services to rate
priorityRateAndShipPriority!How to select the final rate (CHEAPEST or FASTEST)
filtersRateAndShipFilters⛔️Optional rules (e.g. max price, guaranteed delivery)

🏷️ RateAndShipService

FieldTypeRequiredDescription
carrierCarrierCode!Carrier to use (e.g. UPS, USPS, FedEx)
service_codeString!Specific carrier service (e.g. GND, PRIORITY_MAIL)
account_numberString⛔️Shipper account to use for rating. Omit to use platform default (if allowed)

🔍 RateAndShipFilters

Optional filters to restrict which services can be selected.

FieldTypeDescription
max_costDecimalExclude any rates above this value
shipping_timeShippingTimeFilterSpecify a max number of days or deadline date
shipping_time_guaranteeShippingTimeGuaranteeLevelRequire either estimated or guaranteed delivery

📝 OrderInfo

Optional metadata to associate with the shipment.

FieldTypeDescription
tracking_subscriptionsTrackingSubscriptionEmail addresses to notify of shipment status
reference_numbersReferenceNumberOrder numbers, invoice IDs, etc. (earlier values take priority)
carrier_specificCarrierSpecificOrderInfoExtra metadata supported by specific carriers
carrier_dependentCarrierDependentOrderInfoMay be ignored by some carriers (e.g. delivery notes)

⚙️ AdditionalInfoInput

Additional information about the Shipment

FieldTypeDescription
ship_dateDateTimeThe DateTime you expect to ship the package

🎯 ShipmentCarrierInput

Carrier-specific options that affect how the shipment is processed.
Each field is an optional nested input tailored to a specific carrier.

FieldTypeDescription
uspsUspsShipmentInputUSPS-specific settings like container type or entry facility
fedexFedExShipmentInputFedEx-specific preferences like drop-off type or special services
dhl_expDhlExpShipmentInputDHL Express options such as duties payment or label format

📦 What You Get Back

The response includes a batch, which contains one or more shipments.
Each shipment will be one of the following:

  • Shipment: fully purchased with label and tracking
  • 💳 ShipmentPaymentRequired: label is ready, but payment must be completed first
  • ShipmentError: something went wrong, like an invalid address or unsupported service

✅ Successful Shipment

{
    "data": {
        "rate_and_ship": {
            "batch_id": "5e7a131e-a21e-47f8-a09b-7abb92a2bca7",
            "batch": {
                "id": "5e7a131e-a21e-47f8-a09b-7abb92a2bca7",
                "created_at": "2025-06-24T16:00:00Z",
                "batch_pdf_url": "https://ENV_URL/api/media/label/44a22efd-2440-4758-a7ac-9a2927a67d64.png",
                "payment_details": {
                    "total_billed": 9.21,
                    "total_collected": 9.21,
                    "paid": true
                }
            },
            "shipments": [
                {
                    "__typename": "Shipment",
                    "id": "shp_7a1b4c",
                    "tracking_number": "1Z12345E0205271688",
                    "label": {
                        "png": {
                            "url": "https://ENV_URL/api/media/label/44a22efd-2440-4758-a7ac-9a2927a67d64.png"
                        }
                    }
                }
            ]
        }
    }
}

💳 Payment Required

WARNING

This response only applies to individual (retail) accounts.
Platform or prepaid accounts will never receive this response.

{
  "__typename": "ShipmentPaymentRequired",
  "id": "shp_9de8f3",
  "payment_link": {
    "url": "PAYMENT_LINK"
  },
  "expires_at": "2025-06-24T17:00:00Z"
}

❌ Shipment Error

Returned when the shipment could not be created due to invalid input, rate failure, or carrier restrictions.

{
  "__typename": "ShipmentError",
  "code": "INVALID_ADDRESS",
  "message": "Postal code is required."
}

🧾 Batch Overview

A batch groups multiple shipments into a single label download and payment group.

FieldDescription
idUnique ID of the batch
batch_pdf_urlDownload link for the combined label PDF
created_atWhen the batch was created
payment_detailsAmounts and status of batch billing
shipmentsList of all attempted shipments in the batch

🔄 Shipment Object (on success)

A Shipment object represents a fully purchased label, complete with carrier info, pricing, and file access.

FieldDescription
idUnique shipment ID
carrierCarrier
carrier_serviceCarrierService
tracking_numberCarrier-assigned tracking number
labelLabel download links (PNG, ZPL)
billing_weightFinal billed weight (actual or dimensional)
total_priceFinal total cost
base_priceCost before surcharges and extras
labelgenius_chargeCharge owed to ShipGenius
itemized_chargesFull charge breakdown (carrier + platform fees)
warningsOptional carrier-level warnings
disclaimersLegal or carrier advisories
estimated_deliveryEstimated delivery date
guaranteed_deliveryWhether delivery date is guaranteed

🧰 Tips

  • You can submit multiple shipments at once using request: [RateAndShipInput!]!
  • Use batch.payment_details to track billing, refunds, and total invoiced
  • Use batch.batch_pdf_url to download all generated labels in one PDF
  • ShipmentError responses are non-blocking — other shipments in the same batch may still succeed
  • Always validate addresses beforehand using the address_validation query to avoid rejections