Skip to content

Delete a package (voids its label)

Open .md

DELETE/v2/api/store/{team_slug}/v2/shipment_package/{hash_id}

v2Operation ID v2_public_shipment_package_destroy

Deletes a package. For a Shippo label this is how you void it: YoPrint asks Shippo for a refund in the background, and a refused refund is not reported back. Shippo and the carrier decide whether you get the money back.

In a multi-parcel label, deleting the master makes the next parcel the master; deleting one parcel voids only that parcel. A shipping cost line tied to the package is not removed: when you delete a master that has other parcels, the cost line moves to the new master and keeps billing; otherwise it stays linked to the deleted package. Remove it yourself if you no longer bill it.

Permission

Needs permission to view the shipment's order: the team owner, a role whose Manage Sales Orders permission is "view all", or "view assigned" when you created the order or are assigned to it. Otherwise 403 user_is_not_authorized. Edit rights are not needed, so a role that can only view orders can do this too.

Business rules

  • On a draft order, a package with a label can't be deleted: "Publish this order before deleting a shipment package with a shipping label."
  • On a shipment linked to Shopify: 422 shopify_managed_shipment_locked ("Cannot modify Shopify-managed shipment packages from API."), shopify_fulfilled_shipment_package_locked ("This shipment has already been fulfilled to Shopify. Void fulfillment first to edit packages or create labels.") or shopify_broken_link_shipment_locked; and 422 "Shipment package cannot be deleted because shipment contains items fulfilled by a third-party." (error.code validation_error). There is no carrier check here.

Side effects

  • Requests a refund from Shippo for a Shippo label, in the background.
  • Open Admin Portal pages refresh, and so do Customer Portal pages the order's customer has open.

Path parameters

  • team_slugstringrequired

    Your team slug, shown as Team ID next to your API key in Profile.

    • Example your-team
  • hash_idstringrequired

    The package's hash id. Hash ids only: a unique key or a document number gives 404.

    • Example o6foWpSAayc79D

Request body

This operation takes no request body.

Response

200Successful response.

Errors

  • 401The API key is missing or wrong (unauthenticated).

  • 403You are not allowed to do this. api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only {"message": "Insufficient Permission"}. Other refusals use the error envelope, with unauthorized or user_is_not_authorized.

    When
    Your role can't view the order of the package's shipment (user_is_not_authorized). Nothing is deleted or refunded.
    Fix
    Ask the team owner for permission to view this order, or to be assigned to it.
  • 404Not found. page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. code: null, with a message that starts "No query results for": there is no record with that id.

    When
    The package isn't your team's.
    Fix
    Check the id.
  • 422The request was refused and changed nothing. validation_failed lists what to fix in error.fields; other codes name a business rule, explained in error.message. A few checks answer with only {"message": "..."}. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer connect_timeout ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.

    When
    A draft order, or a Shopify rule (see rules).
    Fix
    Publish the order, or void the fulfillment in Shopify first.