> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goshippo.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.goshippo.com/feedback

```json
{
  "path": "/docs/Carriers/Integration_guides/BetterTrucks/purchase_label",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Purchase label

> Purchase a Better Trucks shipping label from an existing shipment rate or create one in a single API call.

The final step is to purchase the shipment. This will generate your shipping label.

There are two ways to purchase a shipment.

1. You can [purchase the shipment object](#purchase-from-created-shipment) you created in the last step
2. You can purchase a label without a [shipment object in a single call](#purchase-label-in-one-call)

## HTTP Method

POST

## URL

```
https://api.goshippo.com/transactions/
```

## Purchase from created Shipment

This is a flow where we first create a shipment object (and get rates for a given shipment). Then, we purchase a label for the provided `rate`.

### Request Payload

| Parameter           | Description                                                                                                                                                                  |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| rate\*              | `object_id` of the rate object we get in the [create shipments call response](/docs/Carriers/Integration_guides/BetterTrucks/create_shipment#request-sample-for-a-shipment). |
| label\_file\_type\* | Allowed values: `PDF`, `PDF_A4`, `PDF_A6`, `PDF_4x6`, `PDF_4x8`, `PDF_SINGLE_8X11`, `PDF_2.3x7.5`, `PNG`, `PNG_2.3x7.5`, `ZPLII`                                             |
|                     |                                                                                                                                                                              |

Note: Parameters with an \* are mandatory

### Example

#### Request Sample

```shell cURL theme={null}
curl --location --request POST 'https://api.goshippo.com/transactions' \
--header 'Authorization: ShippoToken <API_TOKEN>’ \
--header 'Content-Type: application/json' \
--data-raw '{
   "rate": "4af61f01e2a44ecbb6c278a1d573f1ff",
   "async": false,
   "label_file_type": "PDF"
}’


```

#### Response Sample

```json theme={null}
{
   "object_state": "VALID",
   "status": "SUCCESS",
   "object_created": "2023-02-01T09:38:24.238Z",
   "object_updated": "2023-02-01T09:38:27.042Z",
   "object_id": "48ee2ce651894bf3bb37f1af0612bd6a",
   "object_owner": "expn-prod-test@shippo.com",
   "test": true,
   "rate": "4af61f01e2a44ecbb6c278a1d573f1ff",
   "tracking_number": "BTS_001807L4NVV",
   "tracking_status": "UNKNOWN",
   "eta": null,
   "tracking_url_provider": "https://tracking.bettertrucks.com/Tracking?ShipmentId=jhfBTS_001807L4NVV",
   "label_url": "https://dev-qa-deliver.shippodev.com/48ee2ce651894bf3bb37f1af0612bd6a.pdf?Expires=1706780306&Signature=OFKPm1PuMuFJKVEnVXAkfw-gJ2SsJmUN1VzeZ66VCUj5r~rmOp5ze~XvEhQTGKR8YjWTjv0dVg3Mo1h9sgQBQmVdPZ0tXIgr1g1NVcGrSYf6duqvv~IczKvdtA2aI2lkMvT-Q4Kb1KvdW37dnJTzCGB2jJBNnz-N44n2j4JEpuNc-Iq6jJlJXPAJHKJPLVAxoI77klfthSSzRN0reCfItSCybDs1a~F2PQ1rKl-wf~60en419OI4JR0C0E-aUjaz~EvBh8e2gBvAU-rmxsB13yJiAI3WtTayCIlATAJ5svdiLvZiKAn6oWkOtwQ6rnX3OcOPVJh1mCUCymvTxdGAgg__&Key-Pair-Id=APKAJKRDBHOMWKB2OAVQ",
   "commercial_invoice_url": null,
   "messages": [],
   "order": null,
   "metadata": "",
   "parcel": "ea911c30d3904d9881ebbe698c6d0cca",
   "billing": {
       "payments": []
   },
   "qr_code_url": null
}

```

This is an example of the label that is created.

<img src="https://mintcdn.com/shippo-f4b7b609/Em2SaRCKsbbZ5YDS/images/Carriers/Sample_label_with_shipment_obj.png?fit=max&auto=format&n=Em2SaRCKsbbZ5YDS&q=85&s=259f4d7d4fffa69d506f57b0cbffd0f5" alt="Sample label created using a Shipment object" width="1226" height="1410" data-path="images/Carriers/Sample_label_with_shipment_obj.png" />

## Purchase label in one call

This is a flow where we create a shipment object from the request payload and return label for it in one call

### Request Payload

| Parameter             | Description                                                                                                                                       |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| shipment\*            | [Refer to the Shipment object](#shipment).                                                                                                        |
| carrier\_account\*    | `object_id` of the carrier account to be used for purchasing this label. This carrier account object\_id is available when an account is created. |
| servicelevel\_token\* | Name of the service level to use. For now, only `better_trucks_next_day` is supported. This are case sensitive.                                   |
| label\_file\_type\*   | Allowed values: `PDF`, `PDF_A4`, `PDF_A6`, `PDF_4x6`, `PDF_4x8`, `PDF_SINGLE_8X11`, `PDF_2.3x7.5`, `PNG`, `PNG_2.3x7.5`, ZPLII                    |

### <a name="shipment" /> Shipment

| Parameter       | Description                                                                                                          |
| --------------- | -------------------------------------------------------------------------------------------------------------------- |
| address\_from\* | [Refer to the Address object](/docs/Carriers/Integration_guides/BetterTrucks/create_shipment#address)                |
| address\_to\*   | [Refer to the Address object](/docs/Carriers/Integration_guides/BetterTrucks/create_shipment#address)                |
| parcels\*       | List of Parcel objects. [Refer Parcel object](/docs/Carriers/Integration_guides/BetterTrucks/create_shipment#parcel) |
| extra           | [Refer to the Extra object](/docs/Carriers/Integration_guides/BetterTrucks/create_shipment#extra)                    |

### Examples

#### Request sample for a shipment in one call

```shell cURL theme={null}
curl --location --request POST 'https://api.goshippo.com/transactions' \
--header 'Authorization: ShippoToken <API_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
{
   "shipment": {
       "address_from": {
           "name": "Mr. Hippo",
           "company": "Shippo & Son",
           "street1": "1901 W Madison Street",
           "street2": "Press Box 23",
           "city": "Chicago",
           "state": "IL",
           "zip": "60612",
           "country": "US",
           "phone": "+1 555 341 9393",
           "email": "support@shippo.com"
       },
       "address_to": {
           "name": "Mrs. Hippo",
           "company": "Shippo & Co",
           "street1": "100 STOCKYARD",
           "city": "Nashville",
           "state": "TN",
           "zip": "37201",
           "country": "US",
           "metadata": "Customer ID 123456"
       },
       "parcels": [
           {
               "weight": "8",
               "length": "9",
               "width": "9",
               "height": "8",
                "distance_unit": "in",
               "mass_unit": "lb"
           }
       ],
       "extra": {
           "signature_confirmation": true,
           "alcohol": {
               "contains_alcohol": false
           }
       }
   },
   "carrier_account": "{{BETTER_TRUCKS_ACC}}",
   "async": false,
   "servicelevel_token": "better_trucks_next_day",
   "label_file_type": "PDF_4x6"
 }'



```

#### Response sample for a shipment in one call

```json theme={null}
{
   "object_state": "VALID",
   "status": "SUCCESS",
   "object_created": "2023-01-26T09:52:08.935Z",
   "object_updated": "2023-01-26T09:52:11.715Z",
   "object_id": "09ae917f995e494fa3644d2681c4dbc7",
   "object_owner": "nataliya_eng@shippo.com",
   "test": false,
   "rate": {
       "object_id": "7df6b9381e424b21a682c49aea8c9614",
       "amount": "6.02",
       "currency": "USD",
       "amount_local": "6.02",
       "currency_local": "USD",
       "provider": "Better Trucks",
       "servicelevel_name": "Next Day",
       "servicelevel_token": "better_trucks_next_day",
       "carrier_account": "a00414e75df144b596673979108bbab5"
   },
    "tracking_number": "BTS_0018FQYZ3H5",
   "tracking_status": "UNKNOWN",
   "eta": null,
   "tracking_url_provider": "https://tracking.bettertrucks.com/Tracking?ShipmentId=jhfBTS_0018FQYZ3H5",
   "label_url": "https://dev-qa-deliver.shippodev.com/09ae917f995e494fa3644d2681c4dbc7.pdf?Expires=1706262731&Signature=CtTyLLrL4PB4DD-o7-BTZ9jUB8p2XSCDHmWnZaMoVLFqfSwAsXCfy4MLNRqMceaRfz2uftvWeL5MgsL1TTElKUpuaawgBqaK6nFWj3cxVoWb94skkfiqzqPjqyIL9rsuKg6HxmKEjmQIDfGYjK3r3M2dTBfiauDTB4lueFmKSS41yLdV0JMeJT8y-SY13iBcKTelUMEHNwMiDGQV2D8Cag6nJoTAb-b7Ktw3ogO1xMprqCduv8MuwtvYiYPZfkHzmHdaGZ7YXGNGpH5IkeRvgUFYufzLXRfcYX0e-9d7joRTXmaIOcIRiNrZLdR9TVugg8b87LkciWMjJssCJ7ZW7g__&Key-Pair-Id=APKAJKRDBHOMWKB2OAVQ",
   "commercial_invoice_url": null,
   "messages": [],
   "order": null,
   "metadata": "",
   "parcel": "e03be392226849a3a4ee380a9aced3e2",
   "billing": {
       "payments": []
   },
   "qr_code_url": null
}
```

This is an example of the label that is created.

<img src="https://mintcdn.com/shippo-f4b7b609/Em2SaRCKsbbZ5YDS/images/Carriers/Sample_label_with_single_call.png?fit=max&auto=format&n=Em2SaRCKsbbZ5YDS&q=85&s=44e0d1b63684b35bd5461386407b59c8" alt="Example label created form a single call purchase" width="1226" height="1410" data-path="images/Carriers/Sample_label_with_single_call.png" />

## Response

A successful response includes all the details about your purchased shipment including tracking details and a link to your shipping label.
