# Getting Started with EasyPost Core

This guide provides retailers and brands with a step-by-step process for shipping their first package using the EasyPost Core API Suite, outlining the
necessary steps from setup to label generation.

For alternative solutions:

- **Forge (White-Label Solution):** Designed for marketplaces, platforms, and other technology businesses. Refer to the White Label API Guides for more information.
- **EasyPost Enterprise API Guides:** Contact us for access.

---

## Prerequisites

### Account Registration

Sign up for an EasyPost account to obtain a **Test** and **Production** API
key. See Authentication and Key Management for more information.

> Note: Negotiated rates are only available in Production mode.

### Carrier Account Registration

Upon sign-up with EasyPost, users gain immediate access to Wallet Carrier Accounts,
which can be enabled directly from the Dashboard. For additional carriers,
EasyPost supports a Bring Your Own Account (BYOA) option. This requires users to register
directly with the respective carrier.

### Software Requirements

Download an EasyPost Client Library or utilize the REST API with cURL.

### Documentation Review

Examine the EasyPost Objects section to understand the API's structure, which is critical for constructing requests and interpreting responses.

Related:

- [EasyPost Objects](https://docs.easypost.com/docs/easypost-objects)
- [Manage Carrier Accounts](https://app.easypost.com/account/settings?tab=carriers)

---

## Shipping Process

### Step 1: Create a Shipment and Retrieve Rates

To create and rate a shipment, the API allows the `to_address`, `from_address`, and `parcel` objects nested within the shipment object to be defined.
These objects do not need to be pre-created; they are created during the shipment creation process.

Set parcel `weight` in ounces (oz).

Pass `line_items` on that same shipment when EasyPost should file USPS Claims without asking for product value later. Each item needs `total_line_value` and `item_description`. `line_items` are claims-only: they are not sent to the carrier and are not returned on the Shipment. If the shipment already includes a customs form, EasyPost uses the CustomsItem `value` amounts instead.

Additionally, insurance may be added during the purchase. To specify an amount to insure, pass the insurance attribute as a string.
The currency of all insurance is U.S. Dollars (USD).

**Add more carriers to the EasyPost Dashboard to receive rates beyond the default USPS options!**

### Example: POST /shipments

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/shipments \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "shipment": {
      "to_address": {
        "name": "Dr. Steve Brule",
        "street1": "179 N Harbor Dr",
        "city": "Redondo Beach",
        "state": "CA",
        "zip": "90277",
        "country": "US",
        "phone": "8573875756",
        "email": "dr_steve_brule@gmail.com"
      },
      "from_address": {
        "name": "EasyPost",
        "street1": "417 Montgomery Street",
        "street2": "5th Floor",
        "city": "San Francisco",
        "state": "CA",
        "zip": "94104",
        "country": "US",
        "phone": "4153334445",
        "email": "support@easypost.com"
      },
      "parcel": {
        "length": "20.2",
        "width": "10.9",
        "height": "5",
        "weight": "65.9"
      },
      "line_items": [
        {
          "total_line_value": "129.00",
          "item_description": "Mugs"
        },
        {
          "total_line_value": "45.50",
          "item_description": "T-shirts"
        }
      ]
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"

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

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

	shipment, _ := client.CreateShipment(
		&easypost.Shipment{
			ToAddress: &easypost.Address{
				Name:    "Dr. Steve Brule",
				Street1: "179 N Harbor Dr",
				City:    "Redondo Beach",
				State:   "CA",
				Zip:     "90277",
				Country: "US",
				Phone:   "4155559999",
				Email:   "dr_steve_brule@gmail.com",
			},
			FromAddress: &easypost.Address{
				Name:    "EasyPost",
				Street1: "417 Montgomery Street",
				Street2: "5th Floor",
				City:    "San Francisco",
				State:   "CA",
				Zip:     "90277",
				Country: "US",
				Phone:   "4155559999",
				Email:   "support@easypost.com",
			},
			Parcel: &easypost.Parcel{
				Length: 20.2,
				Width:  10.9,
				Height: 5,
				Weight: 65.9,
			},
			LineItems: []*easypost.LineItem{
				{
					TotalLineValue:  "129.00",
					ItemDescription: "Mugs",
				},
				{
					TotalLineValue:  "45.50",
					ItemDescription: "T-shirts",
				},
			},
		},
	)

	fmt.Println(shipment)
}
```

#### 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;
import java.util.List;

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

        HashMap<String, Object> toAddressMap = new HashMap<String, Object>();
        toAddressMap.put("name", "Dr. Steve Brule");
        toAddressMap.put("street1", "179 N Harbor Dr");
        toAddressMap.put("city", "Redondo Beach");
        toAddressMap.put("state", "CA");
        toAddressMap.put("country", "US");
        toAddressMap.put("phone", "8573875756");
        toAddressMap.put("email", "dr_steve_brule@gmail.com");
        toAddressMap.put("zip", "90277");

        HashMap<String, Object> fromAddressMap = new HashMap<String, Object>();
        fromAddressMap.put("name", "EasyPost");
        fromAddressMap.put("street1", "417 Montgomery Street");
        fromAddressMap.put("street2", "5th Floor");
        fromAddressMap.put("city", "San Francisco");
        fromAddressMap.put("state", "CA");
        fromAddressMap.put("zip", "94104");
        fromAddressMap.put("country", "US");
        fromAddressMap.put("phone", "4153334445");
        fromAddressMap.put("email", "support@easypost.com");

        HashMap<String, Object> parcelMap = new HashMap<String, Object>();
        parcelMap.put("length", 20.2);
        parcelMap.put("width", 10.9);
        parcelMap.put("height", 5);
        parcelMap.put("weight", 65.9);

        HashMap<String, Object> mugLineItem = new HashMap<String, Object>();
        mugLineItem.put("total_line_value", "129.00");
        mugLineItem.put("item_description", "Mugs");

        HashMap<String, Object> shirtLineItem = new HashMap<String, Object>();
        shirtLineItem.put("total_line_value", "45.50");
        shirtLineItem.put("item_description", "T-shirts");

        List<HashMap<String, Object>> lineItems = new ArrayList<HashMap<String, Object>>();
        lineItems.add(mugLineItem);
        lineItems.add(shirtLineItem);

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("to_address", toAddressMap);
        params.put("from_address", fromAddressMap);
        params.put("parcel", parcelMap);
        params.put("line_items", lineItems);

        Shipment shipment = client.shipment.create(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"));

            // Create a shipment using all data in one API call

            EasyPost.Parameters.Shipment.Create parameters = new()
            {
                ToAddress = new EasyPost.Parameters.Address.Create
                {
                    Name = "Dr. Steve Brule",
                    Street1 = "417 Montgomery Street",
                    Street2 = "5th Floor",
                    City = "San Francisco",
                    State = "CA",
                    Country = "US",
                    Zip = "94104"
                },
                FromAddress = new EasyPost.Parameters.Address.Create
                {
                    Company = "EasyPost",
                    Street1 = "417 Montgomery Street",
                    Street2 = "Floor 5",
                    City = "San Francisco",
                    State = "CA",
                    Country = "US",
                    Zip = "94104"
                },
                Parcel = new EasyPost.Parameters.Parcel.Create
                {
                    Length = 8,
                    Width = 6,
                    Height = 5,
                    Weight = 10
                },
                LineItems = new List<EasyPost.Parameters.ILineItemParameter>
                {
                    new EasyPost.Models.API.LineItem { TotalLineValue = "129.00", ItemDescription = "Mugs" },
                    new EasyPost.Models.API.LineItem { TotalLineValue = "45.50", ItemDescription = "T-shirts" },
                }
            };

            EasyPost.Models.API.Shipment shipment = await client.Shipment.Create(parameters);

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

            // Create a shipment using existing addresses and parcel

            EasyPost.Models.API.Address toAddress = await client.Address.Retrieve("adr_...");
            EasyPost.Models.API.Address fromAddress = await client.Address.Retrieve("adr_...");
            EasyPost.Models.API.Parcel parcel = await client.Parcel.Retrieve("prcl_...");

            parameters = new()
            {
                ToAddress = toAddress,
                FromAddress = fromAddress,
                Parcel = parcel,
                LineItems = new List<EasyPost.Parameters.ILineItemParameter>
                {
                    new EasyPost.Models.API.LineItem { TotalLineValue = "129.00", ItemDescription = "Mugs" },
                    new EasyPost.Models.API.LineItem { TotalLineValue = "45.50", ItemDescription = "T-shirts" },
                }
            };

            shipment = await client.Shipment.Create(parameters);

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

#### Node.js

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

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  let shipment;

  shipment = await client.Shipment.create({
    to_address: {
      name: 'Dr. Steve Brule',
      street1: '179 N Harbor Dr',
      city: 'Redondo Beach',
      state: 'CA',
      zip: '90277',
      country: 'US',
      email: 'dr_steve_brule@gmail.com',
      phone: '4155559999',
    },
    from_address: {
      street1: '417 montgomery street',
      street2: 'FL 5',
      city: 'San Francisco',
      state: 'CA',
      zip: '94104',
      country: 'US',
      company: 'EasyPost',
      phone: '415-123-4567',
    },
    parcel: {
      length: 20.2,
      width: 10.9,
      height: 5,
      weight: 65.9,
    },
    line_items: [
      {
        total_line_value: '129.00',
        item_description: 'Mugs',
      },
      {
        total_line_value: '45.50',
        item_description: 'T-shirts',
      },
    ],
  });

  // or create by using IDs

  shipment = await client.Shipment.create({
    to_address: { id: 'adr_...' },
    from_address: { id: 'adr_...' },
    parcel: { id: 'prcl_...' },
    line_items: [
      {
        total_line_value: '129.00',
        item_description: 'Mugs',
      },
      {
        total_line_value: '45.50',
        item_description: 'T-shirts',
      },
    ],
  });

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

#### PHP

```php
<?php

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

$shipment = $client->shipment->create([
    'to_address' => [
        'name' => 'Dr. Steve Brule',
        'street1' => '179 N Harbor Dr',
        'city' => 'Redondo Beach',
        'state' => 'CA',
        'zip' => '90277',
        'country' => 'US',
        'phone' => '3331114444',
        'email' => 'dr_steve_brule@gmail.com'
    ],
    'from_address' => [
        'name' => 'EasyPost',
        'street1' => '417 Montgomery Street',
        'street2' => '5th Floor',
        'city' => 'San Francisco',
        'state' => 'CA',
        'zip' => '94104',
        'country' => 'US',
        'phone' => '3331114444',
        'email' => 'support@easypost.com'
    ],
    'parcel' => [
        'length' => 20.2,
        'width' => 10.9,
        'height' => 5,
        'weight' => 65.9
    ],
    'line_items' => [
        [
            'total_line_value' => '129.00',
            'item_description' => 'Mugs'
        ],
        [
            'total_line_value' => '45.50',
            'item_description' => 'T-shirts'
        ]
    ]
]);

echo $shipment;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

shipment = client.shipment.create(
    to_address={
        "name": "Dr. Steve Brule",
        "street1": "179 N Harbor Dr",
        "city": "Redondo Beach",
        "state": "CA",
        "zip": "90277",
        "country": "US",
        "phone": "4153334444",
        "email": "dr_steve_brule@gmail.com",
    },
    from_address={
        "name": "EasyPost",
        "street1": "417 Montgomery Street",
        "street2": "5th Floor",
        "city": "San Francisco",
        "state": "CA",
        "zip": "94104",
        "country": "US",
        "phone": "4153334444",
        "email": "support@easypost.com",
    },
    parcel={
        "length": 20.2,
        "width": 10.9,
        "height": 5,
        "weight": 65.9,
    },
    line_items=[
        {
            "total_line_value": "129.00",
            "item_description": "Mugs",
        },
        {
            "total_line_value": "45.50",
            "item_description": "T-shirts",
        },
    ],
)

# or create by using IDs

shipment = client.shipment.create(
    to_address={"id": "adr_..."},
    from_address={"id": "adr_..."},
    parcel={"id": "prcl_..."},
    line_items=[
        {
            "total_line_value": "129.00",
            "item_description": "Mugs",
        },
        {
            "total_line_value": "45.50",
            "item_description": "T-shirts",
        },
    ],
)

print(shipment)
```

#### Ruby

```ruby
require 'easypost'

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

shipment = client.shipment.create(
  to_address: {
    name: 'Dr. Steve Brule',
    street1: '179 N Harbor Dr',
    city: 'Redondo Beach',
    state: 'CA',
    zip: '90277',
    country: 'US',
    phone: '4155559999',
    email: 'dr_steve_brule@gmail.com',
  },
  from_address: {
    name: 'EasyPost',
    street1: '417 Montgomery Street',
    street2: '5th Floor',
    city: 'San Francisco',
    state: 'CA',
    zip: '94104',
    country: 'US',
    phone: '4153334445',
    email: 'support@easypost.com',
  },
  parcel: {
    length: 20.2,
    width: 10.9,
    height: 5,
    weight: 65.9,
  },
  line_items: [
    {
      total_line_value: '129.00',
      item_description: 'Mugs',
    },
    {
      total_line_value: '45.50',
      item_description: 'T-shirts',
    },
  ],
)

puts shipment
```

Related:

- [Create a Shipment](https://docs.easypost.com/docs/shipments#create-a-shipment)
- [Rates Object](https://docs.easypost.com/docs/shipments/rates)

---

### Step 2: Buy and Generate a Shipping Label

Buying and generating a shipping label involves selecting a shipping rate, purchasing the label, and retrieving it for printing.

#### Label Purchase

- In client libraries, use the `buy` method on the `Shipment` object and pass the `id` of the chosen rate.
- For REST API users, **POST** the chosen rate `id` to the shipment resource.
- Client libraries have convenience functions for automatically selecting the lowest available rate every time.

#### Label Retrieval

- After purchasing the label, a URL for the label image is provided for download and printing.
- This URL is located in the `postage_label.label_url` property of the `Shipment` object.
- Labels are typically in PNG format, but other formats can be requested.

#### Tracker ID Management

- The response from EasyPost includes a tracking `id` for the package. See the Tracking Guide for additional information.
- This tracker `id` can be used for internal storage or provided to customers for tracking.
- EasyPost also offers automatic tracking updates through webhooks.

### Example: POST /shipments/:id/buy

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/shipments \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "shipment": {
      "to_address": {
        "name": "Dr. Steve Brule",
        "street1": "179 N Harbor Dr",
        "city": "Redondo Beach",
        "state": "CA",
        "zip": "90277",
        "country": "US",
        "phone": "8573875756",
        "email": "dr_steve_brule@gmail.com"
      },
      "from_address": {
        "name": "EasyPost",
        "street1": "417 Montgomery Street",
        "street2": "5th Floor",
        "city": "San Francisco",
        "state": "CA",
        "zip": "94104",
        "country": "US",
        "phone": "4153334445",
        "email": "support@easypost.com"
      },
      "parcel": {
        "length": "20.2",
        "width": "10.9",
        "height": "5",
        "weight": "65.9"
      },
      "line_items": [
        {
          "total_line_value": "129.00",
          "item_description": "Mugs"
        },
        {
          "total_line_value": "45.50",
          "item_description": "T-shirts"
        }
      ]
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"

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

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

	shipment, _ := client.CreateShipment(
		&easypost.Shipment{
			ToAddress: &easypost.Address{
				Name:    "Dr. Steve Brule",
				Street1: "179 N Harbor Dr",
				City:    "Redondo Beach",
				State:   "CA",
				Zip:     "90277",
				Country: "US",
				Phone:   "4155559999",
				Email:   "dr_steve_brule@gmail.com",
			},
			FromAddress: &easypost.Address{
				Name:    "EasyPost",
				Street1: "417 Montgomery Street",
				Street2: "5th Floor",
				City:    "San Francisco",
				State:   "CA",
				Zip:     "90277",
				Country: "US",
				Phone:   "4155559999",
				Email:   "support@easypost.com",
			},
			Parcel: &easypost.Parcel{
				Length: 20.2,
				Width:  10.9,
				Height: 5,
				Weight: 65.9,
			},
			LineItems: []*easypost.LineItem{
				{
					TotalLineValue:  "129.00",
					ItemDescription: "Mugs",
				},
				{
					TotalLineValue:  "45.50",
					ItemDescription: "T-shirts",
				},
			},
		},
	)

	fmt.Println(shipment)
}
```

#### 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;
import java.util.List;

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

        HashMap<String, Object> toAddressMap = new HashMap<String, Object>();
        toAddressMap.put("name", "Dr. Steve Brule");
        toAddressMap.put("street1", "179 N Harbor Dr");
        toAddressMap.put("city", "Redondo Beach");
        toAddressMap.put("state", "CA");
        toAddressMap.put("country", "US");
        toAddressMap.put("phone", "8573875756");
        toAddressMap.put("email", "dr_steve_brule@gmail.com");
        toAddressMap.put("zip", "90277");

        HashMap<String, Object> fromAddressMap = new HashMap<String, Object>();
        fromAddressMap.put("name", "EasyPost");
        fromAddressMap.put("street1", "417 Montgomery Street");
        fromAddressMap.put("street2", "5th Floor");
        fromAddressMap.put("city", "San Francisco");
        fromAddressMap.put("state", "CA");
        fromAddressMap.put("zip", "94104");
        fromAddressMap.put("country", "US");
        fromAddressMap.put("phone", "4153334445");
        fromAddressMap.put("email", "support@easypost.com");

        HashMap<String, Object> parcelMap = new HashMap<String, Object>();
        parcelMap.put("length", 20.2);
        parcelMap.put("width", 10.9);
        parcelMap.put("height", 5);
        parcelMap.put("weight", 65.9);

        HashMap<String, Object> mugLineItem = new HashMap<String, Object>();
        mugLineItem.put("total_line_value", "129.00");
        mugLineItem.put("item_description", "Mugs");

        HashMap<String, Object> shirtLineItem = new HashMap<String, Object>();
        shirtLineItem.put("total_line_value", "45.50");
        shirtLineItem.put("item_description", "T-shirts");

        List<HashMap<String, Object>> lineItems = new ArrayList<HashMap<String, Object>>();
        lineItems.add(mugLineItem);
        lineItems.add(shirtLineItem);

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("to_address", toAddressMap);
        params.put("from_address", fromAddressMap);
        params.put("parcel", parcelMap);
        params.put("line_items", lineItems);

        Shipment shipment = client.shipment.create(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"));

            // Create a shipment using all data in one API call

            EasyPost.Parameters.Shipment.Create parameters = new()
            {
                ToAddress = new EasyPost.Parameters.Address.Create
                {
                    Name = "Dr. Steve Brule",
                    Street1 = "417 Montgomery Street",
                    Street2 = "5th Floor",
                    City = "San Francisco",
                    State = "CA",
                    Country = "US",
                    Zip = "94104"
                },
                FromAddress = new EasyPost.Parameters.Address.Create
                {
                    Company = "EasyPost",
                    Street1 = "417 Montgomery Street",
                    Street2 = "Floor 5",
                    City = "San Francisco",
                    State = "CA",
                    Country = "US",
                    Zip = "94104"
                },
                Parcel = new EasyPost.Parameters.Parcel.Create
                {
                    Length = 8,
                    Width = 6,
                    Height = 5,
                    Weight = 10
                },
                LineItems = new List<EasyPost.Parameters.ILineItemParameter>
                {
                    new EasyPost.Models.API.LineItem { TotalLineValue = "129.00", ItemDescription = "Mugs" },
                    new EasyPost.Models.API.LineItem { TotalLineValue = "45.50", ItemDescription = "T-shirts" },
                }
            };

            EasyPost.Models.API.Shipment shipment = await client.Shipment.Create(parameters);

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

            // Create a shipment using existing addresses and parcel

            EasyPost.Models.API.Address toAddress = await client.Address.Retrieve("adr_...");
            EasyPost.Models.API.Address fromAddress = await client.Address.Retrieve("adr_...");
            EasyPost.Models.API.Parcel parcel = await client.Parcel.Retrieve("prcl_...");

            parameters = new()
            {
                ToAddress = toAddress,
                FromAddress = fromAddress,
                Parcel = parcel,
                LineItems = new List<EasyPost.Parameters.ILineItemParameter>
                {
                    new EasyPost.Models.API.LineItem { TotalLineValue = "129.00", ItemDescription = "Mugs" },
                    new EasyPost.Models.API.LineItem { TotalLineValue = "45.50", ItemDescription = "T-shirts" },
                }
            };

            shipment = await client.Shipment.Create(parameters);

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

#### Node.js

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

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  let shipment;

  shipment = await client.Shipment.create({
    to_address: {
      name: 'Dr. Steve Brule',
      street1: '179 N Harbor Dr',
      city: 'Redondo Beach',
      state: 'CA',
      zip: '90277',
      country: 'US',
      email: 'dr_steve_brule@gmail.com',
      phone: '4155559999',
    },
    from_address: {
      street1: '417 montgomery street',
      street2: 'FL 5',
      city: 'San Francisco',
      state: 'CA',
      zip: '94104',
      country: 'US',
      company: 'EasyPost',
      phone: '415-123-4567',
    },
    parcel: {
      length: 20.2,
      width: 10.9,
      height: 5,
      weight: 65.9,
    },
    line_items: [
      {
        total_line_value: '129.00',
        item_description: 'Mugs',
      },
      {
        total_line_value: '45.50',
        item_description: 'T-shirts',
      },
    ],
  });

  // or create by using IDs

  shipment = await client.Shipment.create({
    to_address: { id: 'adr_...' },
    from_address: { id: 'adr_...' },
    parcel: { id: 'prcl_...' },
    line_items: [
      {
        total_line_value: '129.00',
        item_description: 'Mugs',
      },
      {
        total_line_value: '45.50',
        item_description: 'T-shirts',
      },
    ],
  });

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

#### PHP

```php
<?php

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

$shipment = $client->shipment->create([
    'to_address' => [
        'name' => 'Dr. Steve Brule',
        'street1' => '179 N Harbor Dr',
        'city' => 'Redondo Beach',
        'state' => 'CA',
        'zip' => '90277',
        'country' => 'US',
        'phone' => '3331114444',
        'email' => 'dr_steve_brule@gmail.com'
    ],
    'from_address' => [
        'name' => 'EasyPost',
        'street1' => '417 Montgomery Street',
        'street2' => '5th Floor',
        'city' => 'San Francisco',
        'state' => 'CA',
        'zip' => '94104',
        'country' => 'US',
        'phone' => '3331114444',
        'email' => 'support@easypost.com'
    ],
    'parcel' => [
        'length' => 20.2,
        'width' => 10.9,
        'height' => 5,
        'weight' => 65.9
    ],
    'line_items' => [
        [
            'total_line_value' => '129.00',
            'item_description' => 'Mugs'
        ],
        [
            'total_line_value' => '45.50',
            'item_description' => 'T-shirts'
        ]
    ]
]);

echo $shipment;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

shipment = client.shipment.create(
    to_address={
        "name": "Dr. Steve Brule",
        "street1": "179 N Harbor Dr",
        "city": "Redondo Beach",
        "state": "CA",
        "zip": "90277",
        "country": "US",
        "phone": "4153334444",
        "email": "dr_steve_brule@gmail.com",
    },
    from_address={
        "name": "EasyPost",
        "street1": "417 Montgomery Street",
        "street2": "5th Floor",
        "city": "San Francisco",
        "state": "CA",
        "zip": "94104",
        "country": "US",
        "phone": "4153334444",
        "email": "support@easypost.com",
    },
    parcel={
        "length": 20.2,
        "width": 10.9,
        "height": 5,
        "weight": 65.9,
    },
    line_items=[
        {
            "total_line_value": "129.00",
            "item_description": "Mugs",
        },
        {
            "total_line_value": "45.50",
            "item_description": "T-shirts",
        },
    ],
)

# or create by using IDs

shipment = client.shipment.create(
    to_address={"id": "adr_..."},
    from_address={"id": "adr_..."},
    parcel={"id": "prcl_..."},
    line_items=[
        {
            "total_line_value": "129.00",
            "item_description": "Mugs",
        },
        {
            "total_line_value": "45.50",
            "item_description": "T-shirts",
        },
    ],
)

print(shipment)
```

#### Ruby

```ruby
require 'easypost'

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

shipment = client.shipment.create(
  to_address: {
    name: 'Dr. Steve Brule',
    street1: '179 N Harbor Dr',
    city: 'Redondo Beach',
    state: 'CA',
    zip: '90277',
    country: 'US',
    phone: '4155559999',
    email: 'dr_steve_brule@gmail.com',
  },
  from_address: {
    name: 'EasyPost',
    street1: '417 Montgomery Street',
    street2: '5th Floor',
    city: 'San Francisco',
    state: 'CA',
    zip: '94104',
    country: 'US',
    phone: '4153334445',
    email: 'support@easypost.com',
  },
  parcel: {
    length: 20.2,
    width: 10.9,
    height: 5,
    weight: 65.9,
  },
  line_items: [
    {
      total_line_value: '129.00',
      item_description: 'Mugs',
    },
    {
      total_line_value: '45.50',
      item_description: 'T-shirts',
    },
  ],
)

puts shipment
```

Related:

- [Tracking Guide](https://docs.easypost.com/guides/tracking-guide)
- [Webhooks](https://docs.easypost.com/guides/webhooks-guide)

---

## Additional Resources

### Support and Troubleshooting

EasyPost offers support to assist with FAQs, troubleshooting issues, and inquiries related to the EasyPost platform.

Please visit the Help Center for more information.

Related:

- [Carrier Metadata](https://docs.easypost.com/docs/carrier-metadata)
- [Help Center](https://support.easypost.com/hc/en-us)

---

## Talk to a Shipping Expert

For questions about getting started with the EasyPost API please talk to a Shipping Expert or Contact Support.

Related:

- [Talk to a Shipping Expert](https://www.easypost.com/talk-to-easypost)
- [Contact Support](https://support.easypost.com/hc/requests/new)