# Download labels as one PDF

```http
POST https://secure.yoprint.com/v2/api/store/{team_slug}/v2/shipment_package/labels/compile
```

- API version: v2
- Operation ID: `v2_public_shipment_label_compile_goshippo`
- Section: Shipping › [Shipping labels](https://developer.yoprint.com/reference/shipping-labels.md)
- Web page: https://developer.yoprint.com/reference/shipping-labels/v2-shipment-label-compile-goshippo/
- Authentication: `Authorization: Bearer YOUR_API_KEY`

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_slug` (string, required): Your team slug, shown as Team ID next to your API key in Profile. Example `your-team`.

## Request body

Content type `application/json`, required.

Fields:

- `shipment_package_ids` (array of strings, required): 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.

### Example request

```bash
curl -X POST 'https://secure.yoprint.com/v2/api/store/your-team/v2/shipment_package/labels/compile' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'X-Yoprint-Decimal-Format: exact-v1' \
  -H 'Content-Type: application/json' \
  -d '{
    "shipment_package_ids": [
      "o6foWpSAayc79D",
      "UDsG6yjZAVrRNv"
    ]
  }' \
  -o document.pdf
```

## Response

`200` The 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

- `401` The API key is missing or wrong (`unauthenticated`).
- `403` You 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`.
- `404` Not 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.
- `422` The 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.

## Related

- [Buy a shipping label (charges your Shippo account)](https://developer.yoprint.com/reference/shipping-labels/v2-shipment-label-create-goshippo.md): `POST /v2/api/store/{team_slug}/v2/shipment/{hash_id}/label/goshippo`
- [List the packages of a shipment](https://developer.yoprint.com/reference/shipment-packages/v2-shipment-package-index.md): `GET /v2/api/store/{team_slug}/v2/shipment/{hash_id}/packages`
