Skip to content

Download labels as one PDF

Open .md

POST/v2/api/store/{team_slug}/v2/shipment_package/labels/compile

v2Operation ID v2_public_shipment_label_compile_goshippo

Merges the label files of up to 40 Shippo packages into one PDF (compiled-labels.pdf, shown inline), ready to print. Nothing is bought. Packages without a Shippo label (external, deleted or unknown ids) are skipped.

Permission

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

Business rules

  • 1 to 40 ids per call.
  • The pages follow the stored package order, not the order you sent.

Path parameters

  • team_slugstringrequired

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

    • Example your-team

Request body

application/json, required.

  • shipment_package_idsarray of stringsrequired

    Package hash ids (id from List the packages of a shipment). Packages have no unique keys. A string of digits is read as an internal numeric id, not a hash id; anything else is skipped.

    • 1 to 40 items

Response

200The merged labels as a PDF, shown inline (Content-Disposition: inline).

The answer is a file (application/pdf), not JSON. The example saves it with curl -o.

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.

  • 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
    None of the ids is a live Shippo package (no_goshippo_labels).
    Fix
    Send ids of packages bought with Buy a shipping label.
    When
    A package has no label file (label_fetch_failed, with { id, reason } rows in error.failed_packages).
    Fix
    Leave out the listed packages and try again.
    When
    The merge failed (pdf_merge_failed). This includes a label link that fails YoPrint's link check before the merge (it must be an http or https link whose host resolves only to public addresses): the message is "One or more labels couldn't be fetched from the carrier. Try again in a moment, or open each label from its package.", error.refused_label_hosts lists the hosts, and no PDF is made rather than one with fewer labels.
    Fix
    Try again in a moment. If it keeps failing, open each label from its package's pdf link.
    When
    More than 40 ids, or none (validation_failed).
    Fix
    Split the list into calls of 40.