# Form

After a `Shipment` is created, you can create various
associated `Form` objects for that `Shipment`, such as a
return packing slip, QR codes, and other international shipping forms.
For more information about how to use forms with your shipments, please
check our forms guide.

**Forms that may be returned with `Shipment` objects depending on the
carrier and data passed:**

- cn22
- cod_return_label
- commercial_invoice
- high_value_report
- nafta_certificate_of_origin
- order_summary

**Forms that can be created after a `Shipment` has been bought:**

- commercial_invoice
- label_qr_code
- return_packing_slip
- rma_qr_code

---

## Form object

| Property | Type | Description |
|----------|------|-------------|
| id | string | Unique, begins with "form_" |
| object | string | "Form" |
| mode | string | "test" or "production" |
| form_type | string | The type of form. Possible values: "cn22" "cod_return_label" "commercial_invoice" "high_value_report" "label_qr_code" "nafta_certificate_of_origin" "order_summary" "return_packing_slip" "rma_qr_code" |
| form_url | string | The URL from which the form can be downloaded |
| submitted_electronically | boolean | If EasyPost has submitted the form to the carrier on behalf of the user |
| created_at | datetime | When the Form was created |
| updated_at | datetime | When the Form was last updated |

Example Object:

```json
{
  "id": "shp_c1e2946bb3c84b13a383168190a0c7e4",
  "created_at": "2025-05-09T20:39:20Z",
  "is_return": false,
  "messages": [],
  "mode": "test",
  "options": {
    "currency": "USD",
    "payment": {
      "type": "SENDER"
    },
    "date_advance": 0
  },
  "reference": null,
  "status": "unknown",
  "tracking_code": "9405500208303109884083",
  "updated_at": "2025-05-09T20:39:20Z",
  "batch_id": null,
  "batch_status": null,
  "batch_message": null,
  "customs_info": {
    "id": "cstinfo_93e983e34bd044d9ba941f01a59a5654",
    "object": "CustomsInfo",
    "created_at": "2025-05-09T20:39:20Z",
    "updated_at": "2025-05-09T20:39:20Z",
    "contents_explanation": "",
    "contents_type": "merchandise",
    "customs_certify": true,
    "customs_signer": "Steve Brule",
    "eel_pfc": "NOEEI 30.37(a)",
    "non_delivery_option": "return",
    "restriction_comments": null,
    "restriction_type": "none",
    "mode": "test",
    "declaration": null,
    "customs_items": [
      {
        "id": "cstitem_6f7d78c129384937b830e0fc1ad245d7",
        "object": "CustomsItem",
        "created_at": "2025-05-09T20:39:20Z",
        "updated_at": "2025-05-09T20:39:20Z",
        "description": "T-shirt",
        "hs_tariff_number": "123456",
        "origin_country": "US",
        "quantity": 1,
        "value": "10.0",
        "weight": 5.0,
        "code": "123",
        "mode": "test",
        "manufacturer": null,
        "currency": null,
        "eccn": null,
        "printed_commodity_identifier": null
      }
    ]
  },
  "from_address": {
    "id": "adr_af0074a72d1511f0aa27ac1f6bc539ae",
    "object": "Address",
    "created_at": "2025-05-09T20:39:20+00:00",
    "updated_at": "2025-05-09T20:39:20+00:00",
    "name": "EasyPost",
    "company": null,
    "street1": "417 Montgomery Street",
    "street2": "5th Floor",
    "city": "San Francisco",
    "state": "CA",
    "zip": "94104",
    "country": "US",
    "phone": "4153334445",
    "email": "support@easypost.com",
    "mode": "test",
    "carrier_facility": null,
    "residential": null,
    "federal_tax_id": null,
    "state_tax_id": null,
    "verifications": {}
  },
  "insurance": null,
  "order_id": null,
  "parcel": {
    "id": "prcl_6a8fee5bf2a04f3d8b30efe1e28f0edf",
    "object": "Parcel",
    "created_at": "2025-05-09T20:39:20Z",
    "updated_at": "2025-05-09T20:39:20Z",
    "length": 20.2,
    "width": 10.9,
    "height": 5.0,
    "predefined_package": null,
    "weight": 65.9,
    "mode": "test"
  },
  "postage_label": {
    "object": "PostageLabel",
    "id": "pl_14e14fa52a7c46a6ba6468724ee7e6e6",
    "created_at": "2025-05-09T20:39:20Z",
    "updated_at": "2025-05-09T20:39:20Z",
    "date_advance": 0,
    "integrated_form": "none",
    "label_date": "2025-05-09T20:39:20Z",
    "label_resolution": 300,
    "label_size": "4x6",
    "label_type": "default",
    "label_file_type": "image/png",
    "label_url": "https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20250509/e8e22a61dc0dd544f7803aec40ae2da05f.png",
    "label_pdf_url": null,
    "label_zpl_url": null,
    "label_epl2_url": null,
    "label_file": null
  },
  "rates": [
    {
      "id": "rate_9a59180d1ac04c1e9d578575941728c3",
      "object": "Rate",
      "created_at": "2025-05-09T20:39:20Z",
      "updated_at": "2025-05-09T20:39:20Z",
      "mode": "test",
      "service": "Express",
      "carrier": "USPS",
      "rate": "51.20",
      "currency": "USD",
      "retail_rate": "59.25",
      "retail_currency": "USD",
      "list_rate": "51.20",
      "list_currency": "USD",
      "billing_type": "easypost",
      "delivery_days": 2,
      "delivery_date": null,
      "delivery_date_guaranteed": false,
      "est_delivery_days": 2,
      "shipment_id": "shp_c1e2946bb3c84b13a383168190a0c7e4",
      "carrier_account_id": "ca_9685a1198a75477885a3cdca37559bac"
    },
    {
      "id": "rate_1e8725994ca847299188a76543d1ee5c",
      "object": "Rate",
      "created_at": "2025-05-09T20:39:20Z",
      "updated_at": "2025-05-09T20:39:20Z",
      "mode": "test",
      "service": "Priority",
      "carrier": "USPS",
      "rate": "11.01",
      "currency": "USD",
      "retail_rate": "15.40",
      "retail_currency": "USD",
      "list_rate": "11.01",
      "list_currency": "USD",
      "billing_type": "easypost",
      "delivery_days": 2,
      "delivery_date": null,
      "delivery_date_guaranteed": false,
      "est_delivery_days": 2,
      "shipment_id": "shp_c1e2946bb3c84b13a383168190a0c7e4",
      "carrier_account_id": "ca_9685a1198a75477885a3cdca37559bac"
    },
    {
      "id": "rate_89e3dc281a4a4993aa4636b260f9bd74",
      "object": "Rate",
      "created_at": "2025-05-09T20:39:20Z",
      "updated_at": "2025-05-09T20:39:20Z",
      "mode": "test",
      "service": "GroundAdvantage",
      "carrier": "USPS",
      "rate": "8.20",
      "currency": "USD",
      "retail_rate": "13.85",
      "retail_currency": "USD",
      "list_rate": "9.74",
      "list_currency": "USD",
      "billing_type": "easypost",
      "delivery_days": 3,
      "delivery_date": null,
      "delivery_date_guaranteed": false,
      "est_delivery_days": 3,
      "shipment_id": "shp_c1e2946bb3c84b13a383168190a0c7e4",
      "carrier_account_id": "ca_9685a1198a75477885a3cdca37559bac"
    }
  ],
  "refund_status": null,
  "scan_form": null,
  "selected_rate": {
    "id": "rate_1e8725994ca847299188a76543d1ee5c",
    "object": "Rate",
    "created_at": "2025-05-09T20:39:20Z",
    "updated_at": "2025-05-09T20:39:20Z",
    "mode": "test",
    "service": "Priority",
    "carrier": "USPS",
    "rate": "11.01",
    "currency": "USD",
    "retail_rate": "15.40",
    "retail_currency": "USD",
    "list_rate": "11.01",
    "list_currency": "USD",
    "billing_type": "easypost",
    "delivery_days": 2,
    "delivery_date": null,
    "delivery_date_guaranteed": false,
    "est_delivery_days": 2,
    "shipment_id": "shp_c1e2946bb3c84b13a383168190a0c7e4",
    "carrier_account_id": "ca_9685a1198a75477885a3cdca37559bac"
  },
  "tracker": {
    "id": "trk_266fa8e93fa54a408fd1a734054c7743",
    "object": "Tracker",
    "mode": "test",
    "tracking_code": "9405500208303109884083",
    "status": "pre_transit",
    "status_detail": "status_update",
    "created_at": "2025-05-09T20:39:21Z",
    "updated_at": "2025-05-09T20:39:21Z",
    "signed_by": null,
    "weight": null,
    "est_delivery_date": "2025-05-09T20:39:21Z",
    "shipment_id": "shp_c1e2946bb3c84b13a383168190a0c7e4",
    "carrier": "USPS",
    "tracking_details": [
      {
        "object": "TrackingDetail",
        "message": "Pre-Shipment Info Sent to USPS",
        "description": "",
        "status": "pre_transit",
        "status_detail": "status_update",
        "datetime": "2025-04-09T20:39:21Z",
        "source": "USPS",
        "carrier_code": "",
        "tracking_location": {
          "object": "TrackingLocation",
          "city": null,
          "state": null,
          "country": null,
          "zip": null
        },
        "est_delivery_date": null
      },
      {
        "object": "TrackingDetail",
        "message": "Shipping Label Created",
        "description": "",
        "status": "pre_transit",
        "status_detail": "status_update",
        "datetime": "2025-04-10T09:16:21Z",
        "source": "USPS",
        "carrier_code": "",
        "tracking_location": {
          "object": "TrackingLocation",
          "city": "HOUSTON",
          "state": "TX",
          "country": null,
          "zip": "77063"
        },
        "est_delivery_date": null
      }
    ],
    "fees": [],
    "carrier_detail": {
      "object": "CarrierDetail",
      "service": "First-Class Package Service",
      "container_type": null,
      "est_delivery_date_local": null,
      "est_delivery_time_local": null,
      "origin_location": "HOUSTON TX, 77001",
      "origin_tracking_location": {
        "object": "TrackingLocation",
        "city": "HOUSTON",
        "state": "TX",
        "country": null,
        "zip": "77063"
      },
      "destination_location": "CHARLESTON SC, 29401",
      "destination_tracking_location": null,
      "guaranteed_delivery_date": null,
      "alternate_identifier": null,
      "initial_delivery_attempt": null
    },
    "public_url": "https://track.easypost.com/djE6dHJrXzI2NmZhOGU5M2ZhNTRhNDA4ZmQxYTczNDA1NGM3NzQz"
  },
  "to_address": {
    "id": "adr_aefd9a212d1511f0aa26ac1f6bc539ae",
    "object": "Address",
    "created_at": "2025-05-09T20:39:20+00:00",
    "updated_at": "2025-05-09T20:39:20+00:00",
    "name": "DR. STEVE BRULE",
    "company": null,
    "street1": "179 N HARBOR DR",
    "street2": null,
    "city": "REDONDO BEACH",
    "state": "CA",
    "zip": "90277-2506",
    "country": "US",
    "phone": "8573875756",
    "email": "DR_STEVE_BRULE@GMAIL.COM",
    "mode": "test",
    "carrier_facility": null,
    "residential": false,
    "federal_tax_id": null,
    "state_tax_id": null,
    "verifications": {
      "zip4": {
        "success": true,
        "errors": [],
        "details": null
      },
      "delivery": {
        "success": true,
        "errors": [],
        "details": {
          "latitude": 33.8436,
          "longitude": -118.39177,
          "time_zone": "America/Los_Angeles"
        }
      }
    }
  },
  "usps_zone": 4,
  "return_address": {
    "id": "adr_af0074a72d1511f0aa27ac1f6bc539ae",
    "object": "Address",
    "created_at": "2025-05-09T20:39:20+00:00",
    "updated_at": "2025-05-09T20:39:20+00:00",
    "name": "EasyPost",
    "company": null,
    "street1": "417 Montgomery Street",
    "street2": "5th Floor",
    "city": "San Francisco",
    "state": "CA",
    "zip": "94104",
    "country": "US",
    "phone": "4153334445",
    "email": "support@easypost.com",
    "mode": "test",
    "carrier_facility": null,
    "residential": null,
    "federal_tax_id": null,
    "state_tax_id": null,
    "verifications": {}
  },
  "buyer_address": {
    "id": "adr_aefd9a212d1511f0aa26ac1f6bc539ae",
    "object": "Address",
    "created_at": "2025-05-09T20:39:20+00:00",
    "updated_at": "2025-05-09T20:39:20+00:00",
    "name": "DR. STEVE BRULE",
    "company": null,
    "street1": "179 N HARBOR DR",
    "street2": null,
    "city": "REDONDO BEACH",
    "state": "CA",
    "zip": "90277-2506",
    "country": "US",
    "phone": "8573875756",
    "email": "DR_STEVE_BRULE@GMAIL.COM",
    "mode": "test",
    "carrier_facility": null,
    "residential": false,
    "federal_tax_id": null,
    "state_tax_id": null,
    "verifications": {
      "zip4": {
        "success": true,
        "errors": [],
        "details": null
      },
      "delivery": {
        "success": true,
        "errors": [],
        "details": {
          "latitude": 33.8436,
          "longitude": -118.39177,
          "time_zone": "America/Los_Angeles"
        }
      }
    }
  },
  "forms": [
    {
      "object": "Form",
      "id": "form_c7d83834b45544399bf704c468df06b6",
      "created_at": "2025-05-09T20:39:21Z",
      "updated_at": "2025-05-09T20:39:21Z",
      "mode": "test",
      "form_type": "return_packing_slip",
      "form_url": "https://easypost-files.s3-us-west-2.amazonaws.com/files/form/20250509/827694e0c57149079d691ac3fb85e2b1.pdf",
      "submitted_electronically": null
    }
  ],
  "fees": [
    {
      "object": "Fee",
      "type": "PostageFee",
      "amount": "11.01000",
      "charged": true,
      "refunded": false
    }
  ],
  "object": "Shipment"
}
```

---

## Create Form

### Example: POST /shipments/:id/forms

#### cURL

```shell
# type always required
# all other elements differ based on form type
curl -X POST https://api.easypost.com/v2/shipments/shp_.../forms \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "form": {
        "type": "return_packing_slip",
        "barcode": "RMA12345678900",
        "line_items": [
        {
            "product": {
                "title": "Square Reader",
                "barcode": "855658003251"
            },
            "units": 8
        }
      ]
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"

	"github.com/EasyPost/easypost-go/v5"
)

func create() {
	client := easypost.New("EASYPOST_API_KEY")

	shipmentWithForm, _ := client.GenerateShipmentForm("shp_...", "return_packing_slip")

	fmt.Println(shipmentWithForm)
}
```

#### Java

```java
package shipments;

import com.easypost.exception.EasyPostException;
import com.easypost.model.Shipment;
import com.easypost.service.EasyPostClient;

import java.util.ArrayList;
import java.util.HashMap;

public class Create {
    public static void main(String[] args) throws EasyPostException {
        EasyPostClient client = new EasyPostClient("EASYPOST_API_KEY");

        HashMap<String, Object> titleMap = new HashMap<String, Object>();
        titleMap.put("title", "Square Reader");

        HashMap<String, Object> barcodeMap = new HashMap<String, Object>();
        barcodeMap.put("barcode", "855658003251");

        ArrayList<HashMap<String, Object>> lineItemsMap = new ArrayList<HashMap<String, Object>>();
        lineItemsMap.add(titleMap);
        lineItemsMap.add(barcodeMap);

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("barcode", "RMA12345678900");
        params.put("units", 8);
        params.put("line_items", lineItemsMap);

        Shipment shipment = client.shipment.generateForm("shp_...", "return_packing_slip",
                params);

        System.out.println(shipment);
    }
}
```

#### C#

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost;
using Newtonsoft.Json;

namespace EasyPostExamples
{
    public class Examples
    {
        public static async Task Main()
        {
            var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

            EasyPost.Parameters.Shipment.GenerateForm parameters = new()
            {
                Type = "return_packing_slip",
                Data = new()
                {
                    { "barcode", "RMA12345678900" },
                    {
                        "line_items", new List<Dictionary<string, object>>()
                        {
                            {
                                new Dictionary<string, object>
                                {
                                    { "title", "Square Reader" },
                                    { "barcode", "855658003251" }
                                }
                            }
                        }
                    },
                    { "units", 8 }
                }
            };

            EasyPost.Models.API.Shipment shipment = await client.Shipment.GenerateForm("shp_...", parameters);

            Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
        }
    }
}
```

#### Node.js

```javascript
const EasyPostClient = require('@easypost/api');

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  const shipmentWithForm = await client.Shipment.generateForm('shp_...', 'return_packing_slip', {
    barcode: 'RMA12345678900',
    line_items: [
      {
        product: {
          title: 'Square Reader',
          barcode: '855658003251',
        },
        units: '8',
      },
    ],
  });

  console.log(shipmentWithForm);
})();
```

#### PHP

```php
<?php

$client = new \EasyPost\EasyPostClient('EASYPOST_API_KEY');

$formType = 'return_packing_slip';
$formOptions = [
    'barcode' => 'RMA12345678900',
    'line_items' => [
        [
            'product' => [
                'title' => 'Square Reader',
                'barcode' => '855658003251',
            ],
            'units' => 8,
        ],
    ],
];

$shipmentWithForm = $client->shipment->generateForm('shp_...', $formType, $formOptions);

echo $shipmentWithForm;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

form_type = "return_packing_slip"
form_options = {
    "barcode": "RMA12345678900",
    "line_items": [
        {
            "product": {
                "title": "Square Reader",
                "barcode": "855658003251",
            },
            "units": 8,
        },
    ],
}

shipment = client.shipment.generate_form("shp_...", form_type, form_options)

print(shipment)
```

#### Ruby

```ruby
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

form_type = 'return_packing_slip'
form_options = {
  type: 'return_packing_slip',
  barcode: 'RMA12345678900',
  line_items: [
    {
      product: {
        title: 'Square Reader',
        barcode: '855658003251',
      },
      units: '8',
    },
  ],
}

shipment = client.shipment.generate_form('shp_...', form_type, form_options)

puts shipment
```

**Please see forms guide for request parameters.**