# 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
{
  "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
}
```

---

## 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.**