Skip to content

Record a label bought elsewhere

Open .md

POST/v2/api/store/{team_slug}/v2/shipment/{hash_id}/label/external

v2Operation ID v2_public_shipment_label_create_external

Records on a shipment a label you bought outside YoPrint (for example on the carrier's site), so the shipment has its tracking number. Nothing is bought and Shippo isn't called.

YoPrint stores the carrier and tracking number only: no cost, size, weight or label file. Returns the new package.

Permission

Any member of the team. No sales order permission is checked.

Business rules

  • Only for sales orders: 422 "External labels can't be attached to a quote. Convert it to a sales order first."
  • Unlike a Shippo label, the order doesn't have to be published.
  • On a shipment linked to Shopify: 422 shopify_managed_shipment_locked, 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; 422 "Shipment label cannot be created because shipment contains items fulfilled by a third-party."; and 422 when the carrier differs from the carrier of the shipment's other packages (Shopify needs one carrier per fulfillment).

Side effects

  • Creates a package with status pending. For an order from Shopify with tracking sync on, sends the tracking to Shopify, which may email the customer.
  • Customer Portal pages the order's customer has open refresh.

Path parameters

  • team_slugstringrequired

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

    • Example your-team
  • hash_idstringrequired

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

    • Example MQyJUnd3oty75h

Request body

application/json, required.

  • provider_service_codestringrequired

    The carrier. ups and fedex set the carrier name for you.

    • One of: "ups", "fedex", "other"
  • The tracking number. Not checked for duplicates.

  • The carrier name. Required when provider_service_code is other.

More examples (1)

A UPS label

curl
curl -X POST 'https://secure.yoprint.com/v2/api/store/your-team/v2/shipment/MQyJUnd3oty75h/label/external' \  -H 'Authorization: Bearer YOUR_API_KEY' \  -H 'Accept: application/json' \  -H 'X-Yoprint-Decimal-Format: exact-v1' \  -H 'Content-Type: application/json' \  -d '{    "provider_service_code": "ups",    "provider_tracking_number": "1Z0000000000000000"  }'

Response

200Successful response.

  • dataobjectrequired

    A package.

    Child fields (36)
    • chargesinteger | number | string | null

      The label cost. For a multi-parcel label every package repeats the rate's full amount: read the master's value and don't add packages up. Null for external labels. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • created_atstring (date-time)
    • The address record behind from_address_id, or null when it is not set.

    • from_address_idstring | null

      Older packages only: the ship-from address record; null otherwise.

    • goshippoobject

      Shippo labels only: the Shippo details (shipment, rate, carrier, addresses, parcels).

      Child fields (13)
    • heightnumber | string | null

      Parcel size and weight as stored, in length_unit and weight_unit. Null for external labels.

    • idstring

      The package.

    • is_masterboolean

      The first package of a label (the others have parent_id).

    • lengthnumber | string | null
    • length_unitstring | null

      Shippo labels only, upper case.

    • order_external_idsarray of objects

      The order's links to external systems.

    • order_external_typestring | null

      shopify when the order came from Shopify.

    • order_idstring

      The order.

    • order_object_typestring | null
    • order_scoped_idstring | null
    • parent_idstring | null

      The master package, for the other parcels of a multi-parcel label.

    • pdfarray of objects

      Not on external labels: the label file. label and description are fixed texts that always say 4 x 6, whatever your label size setting.

      Fields of each item (3)
      • labelstring
      • urlstring

        For a Shippo label, Shippo's signed link to the label file: don't publish it.

    • provider_namestring | null

      The carrier.

    • Shippo labels only (absent on external labels); always false today.

    • For external labels, ups, fedex or other. For Shippo labels it may be null: read the service from provider_service_name.

    • The Shippo transaction id (Shippo labels).

    • shopify when the shipment is linked to Shopify.

    • The shipment.

    • Shopify sync state of the shipment.

    • statusstring
      • One of: "pending", "ready-to-ship", "shipped", "delivered"
    • The address record behind to_address_id, or null when it is not set.

    • to_address_idstring | null

      Older packages only: the ship-to address record; null otherwise.

    • typestring

      goshippo a label bought through Shippo; external_label a label recorded from elsewhere.

      • One of: "goshippo", "external_label", "single_label"
    • weightnumber | string | null
    • weight_unitstring | null

      Shippo labels only, upper case.

    • widthnumber | string | null
  • statusintegerrequired
  • successbooleanrequired

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.

  • 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 shipment isn't your team's.
    Fix
    Check the shipment 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 missing tracking number, an unknown provider_service_code, other without provider_name, a quote, or a Shopify or carrier conflict.
    Fix
    Fix the named field or rule.