# EndShipper

  **Important**: This endpoint only works for users of the EndShipper API. If you feel this is applicable for your use
  case, please contact sales.

The EndShipper API is for platforms purchasing postage on behalf of their users, the EndShipper.
Platforms <ins>must</ins> assert the EndShipper details, as the EndShipper is ultimately responsible for what is in the box. Multiple labels purchased for the same EndShipper <ins>must</ins> use the same `EndShipper` object.

`EndShipper` objects must be created prior to buying a `Shipment`. Once `EndShipper` objects have been created, you must keep track of their public ID in order to use them during a label buy.

---

## EndShipper object

| Property | Type | Description |
|----------|------|-------------|
| object | string | "EndShipper" |
| mode | string | "test" or "production" |
| name | string | Name of responsible person (conditionally required) |
| company | string | Name of responsible company (conditionally required) |
| street1 | string | First line of the address |
| street2 | string | Second line of the address |
| city | string | City the address is located in |
| state | string | State the address is located in |
| zip | string | ZIP or postal code the address is located in |
| country | string | Country code the address is located in. Must be "US" for EndShippers. |
| phone | string | Phone number to reach the person or organization |
| email | string | Email to reach the person or organization |

Example Object:

```json
{
  "id": "es_5e0cd0b751814935bf4826f1db99667f",
  "object": "EndShipper",
  "mode": "test",
  "created_at": "2025-05-09T20:39:16+00:00",
  "updated_at": "2025-05-09T20:39:16+00:00",
  "name": "FOO BAR",
  "company": "BAZ",
  "street1": "164 TOWNSEND ST UNIT 1",
  "street2": "",
  "city": "SAN FRANCISCO",
  "state": "CA",
  "zip": "94107-1990",
  "country": "US",
  "phone": "555 555-5555",
  "email": "FOO@EXAMPLE.COM"
}
```

---

## Create an EndShipper

### Example: POST /end_shippers

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/end_shippers \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "end_shipper": {
      "address": {
        "name": "FOO BAR",
        "company": "BAZ",
        "street1": "164 TOWNSEND STREET UNIT 1",
        "street2": "UNIT 1",
        "city": "SAN FRANCISCO",
        "state": "CA",
        "zip": "94107",
        "country": "US",
        "phone": "555-555-5555",
        "email": "FOO@EXAMPLE.COM"
      }
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"

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

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

	endshipper, _ := client.CreateEndShipper(
		&easypost.Address{
			Name:    "FOO BAR",
			Company: "BAZ",
			Street1: "164 TOWNSEND STREET UNIT 1",
			Street2: "UNIT 1",
			City:    "SAN FRANCISCO",
			State:   "CA",
			Zip:     "94107",
			Country: "US",
			Phone:   "555-555-5555",
			Email:   "FOO@EXAMPLE.COM",
		},
	)

	fmt.Println(endshipper)
}
```

#### Java

```java
package endshipper;

import com.easypost.model.EndShipper;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

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

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put("name", "FOO BAR");
        params.put("company", "BAZ");
        params.put("street1", "164 TOWNSEND STREET UNIT 1");
        params.put("street2", "UNIT 1");
        params.put("city", "SAN FRANCISCO");
        params.put("state", "CA");
        params.put("zip", "94107");
        params.put("country", "US");
        params.put("phone", "555-555-5555");
        params.put("email", "FOO@EXAMPLE.COM");

        EndShipper endShipper = client.endShipper.create(params);

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

#### 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.EndShipper.Create parameters = new()
            {
                Name = "FOO BAR",
                Company = "BAZ",
                Street1 = "164 TOWNSEND STREET UNIT 1",
                Street2 = "UNIT 1",
                City = "SAN FRANCISCO",
                State = "CA",
                Zip = "94107",
                Country = "US",
                Phone = "555-555-5555",
                Email = "FOO@EXAMPLE.COM",
            };

            EasyPost.Models.API.EndShipper endShipper = await client.EndShipper.Create(parameters);

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

#### Node.js

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

(async () => {
  const endShipper = await client.EndShipper.create({
    name: 'FOO BAR',
    company: 'BAZ',
    street1: '164 TOWNSEND STREET UNIT 1',
    street2: 'UNIT 1',
    city: 'SAN FRANCISCO',
    state: 'CA',
    zip: '94107',
    country: 'US',
    phone: '555-555-5555',
    email: 'FOO@EXAMPLE.COM',
  });

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

#### PHP

```php
<?php

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

$endshipper = $client->endShipper->create([
    'name' => 'FOO BAR',
    'company' => 'BAZ',
    'street1' => '164 TOWNSEND STREET UNIT 1',
    'street2' => 'UNIT 1',
    'city' => 'SAN FRANCISCO',
    'state' => 'CA',
    'zip' => '94107',
    'country' => 'US',
    'phone' => '555-555-5555',
    'email' => 'FOO@EXAMPLE.COM'
]);

echo $endshipper;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

end_shipper = client.end_shipper.create(
    name="FOO BAR",
    company="BAZ",
    street1="164 TOWNSEND STREET UNIT 1",
    street2="UNIT 1",
    city="SAN FRANCISCO",
    state="CA",
    zip="94107",
    country="US",
    phone="555-555-5555",
    email="FOO@EXAMPLE.COM",
)

print(end_shipper)
```

#### Ruby

```ruby
require 'easypost'

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

end_shipper = client.end_shipper.create(
  name: 'FOO BAR',
  company: 'BAZ',
  street1: '164 TOWNSEND STREET UNIT 1',
  street2: 'UNIT 1',
  city: 'SAN FRANCISCO',
  state: 'CA',
  zip: '94107',
  country: 'US',
  phone: '555-555-5555',
  email: 'FOO@EXAMPLE.COM',
)

puts end_shipper
```

The `EndShipper` object is meant to represent the person or business entity responsible for the shipment and not necessarily the shipping location.

`EndShipper` objects are fully-qualified `Address` objects and require every field to be filled, with some exceptions:

1. `name` and `company` — at least one of these fields must be filled; when both are present, `name` will take precedence
2. `street2` — this field may be left empty if the address does not include multiple lines

---

## Buy a Shipment with EndShipper

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

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/end_shippers \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "end_shipper": {
      "address": {
        "name": "FOO BAR",
        "company": "BAZ",
        "street1": "164 TOWNSEND STREET UNIT 1",
        "street2": "UNIT 1",
        "city": "SAN FRANCISCO",
        "state": "CA",
        "zip": "94107",
        "country": "US",
        "phone": "555-555-5555",
        "email": "FOO@EXAMPLE.COM"
      }
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"

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

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

	endshipper, _ := client.CreateEndShipper(
		&easypost.Address{
			Name:    "FOO BAR",
			Company: "BAZ",
			Street1: "164 TOWNSEND STREET UNIT 1",
			Street2: "UNIT 1",
			City:    "SAN FRANCISCO",
			State:   "CA",
			Zip:     "94107",
			Country: "US",
			Phone:   "555-555-5555",
			Email:   "FOO@EXAMPLE.COM",
		},
	)

	fmt.Println(endshipper)
}
```

#### Java

```java
package endshipper;

import com.easypost.model.EndShipper;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

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

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put("name", "FOO BAR");
        params.put("company", "BAZ");
        params.put("street1", "164 TOWNSEND STREET UNIT 1");
        params.put("street2", "UNIT 1");
        params.put("city", "SAN FRANCISCO");
        params.put("state", "CA");
        params.put("zip", "94107");
        params.put("country", "US");
        params.put("phone", "555-555-5555");
        params.put("email", "FOO@EXAMPLE.COM");

        EndShipper endShipper = client.endShipper.create(params);

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

#### 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.EndShipper.Create parameters = new()
            {
                Name = "FOO BAR",
                Company = "BAZ",
                Street1 = "164 TOWNSEND STREET UNIT 1",
                Street2 = "UNIT 1",
                City = "SAN FRANCISCO",
                State = "CA",
                Zip = "94107",
                Country = "US",
                Phone = "555-555-5555",
                Email = "FOO@EXAMPLE.COM",
            };

            EasyPost.Models.API.EndShipper endShipper = await client.EndShipper.Create(parameters);

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

#### Node.js

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

(async () => {
  const endShipper = await client.EndShipper.create({
    name: 'FOO BAR',
    company: 'BAZ',
    street1: '164 TOWNSEND STREET UNIT 1',
    street2: 'UNIT 1',
    city: 'SAN FRANCISCO',
    state: 'CA',
    zip: '94107',
    country: 'US',
    phone: '555-555-5555',
    email: 'FOO@EXAMPLE.COM',
  });

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

#### PHP

```php
<?php

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

$endshipper = $client->endShipper->create([
    'name' => 'FOO BAR',
    'company' => 'BAZ',
    'street1' => '164 TOWNSEND STREET UNIT 1',
    'street2' => 'UNIT 1',
    'city' => 'SAN FRANCISCO',
    'state' => 'CA',
    'zip' => '94107',
    'country' => 'US',
    'phone' => '555-555-5555',
    'email' => 'FOO@EXAMPLE.COM'
]);

echo $endshipper;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

end_shipper = client.end_shipper.create(
    name="FOO BAR",
    company="BAZ",
    street1="164 TOWNSEND STREET UNIT 1",
    street2="UNIT 1",
    city="SAN FRANCISCO",
    state="CA",
    zip="94107",
    country="US",
    phone="555-555-5555",
    email="FOO@EXAMPLE.COM",
)

print(end_shipper)
```

#### Ruby

```ruby
require 'easypost'

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

end_shipper = client.end_shipper.create(
  name: 'FOO BAR',
  company: 'BAZ',
  street1: '164 TOWNSEND STREET UNIT 1',
  street2: 'UNIT 1',
  city: 'SAN FRANCISCO',
  state: 'CA',
  zip: '94107',
  country: 'US',
  phone: '555-555-5555',
  email: 'FOO@EXAMPLE.COM',
)

puts end_shipper
```

Buy a `Shipment` and specify an `EndShipper` ID in the request.

---

## Retrieve all EndShippers

### Example: GET /end_shippers

#### cURL

```shell
curl -X GET "https://api.easypost.com/v2/end_shippers?page_size=5" \
  -u "EASYPOST_API_KEY":
```

#### Go

```go
package example

import (
	"fmt"

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

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

	endshippers, _ := client.ListEndShippers(
		&easypost.ListOptions{
			PageSize: 5,
		},
	)

	fmt.Println(endshippers)
}
```

#### Java

```java
package endshipper;

import com.easypost.model.EndShipperCollection;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

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

        HashMap<String, Object> params = new HashMap<>();
        params.put("page_size", 5);

        EndShipperCollection endShippers = client.endShipper.all(params);

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

#### 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.EndShipper.All parameters = new()
            {
                PageSize = 5
            };

            EasyPost.Models.API.EndShipperCollection endShipperCollection = await client.EndShipper.All(parameters);

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

#### Node.js

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

(async () => {
  const endShippers = await client.EndShipper.all({
    page_size: 5,
  });

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

#### PHP

```php
<?php

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

$endshippers = $client->endShipper->all([
    'page_size' => 5
]);

echo $endshippers;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

end_shippers = client.end_shipper.all(page_size=5)

print(end_shippers)
```

#### Ruby

```ruby
require 'easypost'

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

end_shippers = client.end_shipper.all(
  page_size: 5,
)

puts end_shippers
```

List the `EndShippers` that have been created.

---

## Retrieve an EndShipper

### Example: GET /end_shippers/:id

#### cURL

```shell
curl -X GET https://api.easypost.com/v2/end_shippers/es_... \
  -u "EASYPOST_API_KEY":
```

#### Go

```go
package example

import (
	"fmt"

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

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

	retrievedEndShipper, _ := client.GetEndShipper("es_...")

	fmt.Println(retrievedEndShipper)
}
```

#### Java

```java
package endshipper;

import com.easypost.model.EndShipper;
import com.easypost.service.EasyPostClient;

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

        EndShipper endShipper = client.endShipper.retrieve("es_...");

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

#### 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.Models.API.EndShipper endShipper = await client.EndShipper.Retrieve("es_...");

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

#### Node.js

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

(async () => {
  const endShipper = await client.EndShipper.retrieve('es_...');

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

#### PHP

```php
<?php

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

$endshipper = $client->endShipper->retrieve('es_...');

echo $endshipper;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

end_shipper = client.end_shipper.retrieve("es_...")

print(end_shipper)
```

#### Ruby

```ruby
require 'easypost'

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

end_shipper = client.end_shipper.retrieve('es_...')

puts end_shipper
```

Similar to retrieving a list of `EndShippers`, you can retrieve an individual `EndShipper`.

---

## Update an EndShipper

### Example: PUT /end_shippers/:id

#### cURL

```shell
curl -X PUT https://api.easypost.com/v2/end_shippers/es_... \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "end_shipper": {
      "address": {
        "name": "NEW NAME",
        "company": "BAZ",
        "street1": "164 TOWNSEND STREET UNIT 1",
        "street2": "UNIT 1",
        "city": "SAN FRANCISCO",
        "state": "CA",
        "zip": "94107",
        "country": "US",
        "phone": "555-555-5555",
        "email": "FOO@EXAMPLE.COM"
      }
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"

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

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

	endShipper, _ := client.GetEndShipper("es_...")

	endShipper.Name = "NEW NAME"
	endShipper.Company = "BAZ"
	endShipper.Street1 = "164 TOWNSEND STREET UNIT 1"
	endShipper.Street2 = "UNIT 1"
	endShipper.City = "San Francisco"
	endShipper.State = "CA"
	endShipper.Zip = "94107"
	endShipper.Country = "US"
	endShipper.Phone = "555-555-5555"
	endShipper.Email = "FOO@EXAMPLE.COM"

	updatedEndShipper, _ := client.UpdateEndShippers(endShipper)

	fmt.Println(updatedEndShipper)
}
```

#### Java

```java
package endshipper;

import com.easypost.model.EndShipper;
import com.easypost.service.EasyPostClient;

import java.util.HashMap;

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

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put("name", "NEW NAME");
        params.put("company", "BAZ");
        params.put("street1", "164 TOWNSEND STREET UNIT 1");
        params.put("street2", "UNIT 1");
        params.put("city", "SAN FRANCISCO");
        params.put("state", "CA");
        params.put("zip", "94107");
        params.put("country", "US");
        params.put("phone", "555-555-5555");
        params.put("email", "FOO@EXAMPLE.COM");

        EndShipper endShipper = client.endShipper.update("es_...", params);

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

#### 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"));

            // Updating an EndShipper requires all the original data to be sent back + the updated data
            EasyPost.Parameters.EndShipper.Update parameters = new()
            {
                Name = "NEW NAME",
                Company = "BAZ",
                Street1 = "164 TOWNSEND STREET UNIT 1",
                Street2 = "UNIT 1",
                City = "SAN FRANCISCO",
                State = "CA",
                Zip = "94107",
                Country = "US",
                Phone = "555-555-5555",
                Email = "FOO@EXAMPLE.COM",
            };

            EasyPost.Models.API.EndShipper endShipper = await client.EndShipper.Update("es_...", parameters);

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

#### Node.js

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

(async () => {
  const updatedEndShipper = await client.EndShipper.update('es_...', {
    name: 'NEW NAME',
    company: 'BAZ',
    street1: '164 TOWNSEND STREET UNIT 1',
    street2: 'UNIT 1',
    city: 'SAN FRANCISCO',
    state: 'CA',
    zip: '94107',
    country: 'US',
    phone: '555-555-5555',
    email: 'FOO@EXAMPLE.COM',
  });

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

#### PHP

```php
<?php

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

$endShipper = $client->endShipper->update(
    'es_...',
    [
        'name' => 'NEW NAME',
        'company' => 'BAZ',
        'street1' => '164 TOWNSEND STREET UNIT 1',
        'street2' => 'UNIT 1',
        'city' => 'SAN FRANCISCO',
        'state' => 'CA',
        'zip' => '94107',
        'country' => 'US',
        'phone' => '555-555-5555',
        'email' => 'FOO@EXAMPLE.COM',
    ]
);

echo $endShipper;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

end_shipper = client.end_shipper.update(
    "es_...",
    name="NEW NAME",
    company="BAZ",
    street1="164 TOWNSEND STREET UNIT 1",
    street2="UNIT 1",
    city="SAN FRANCISCO",
    state="CA",
    zip="94107",
    country="US",
    phone="555-555-5555",
    email="FOO@EXAMPLE.COM",
)

print(end_shipper)
```

#### Ruby

```ruby
require 'easypost'

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

end_shipper = client.end_shipper.update(
  'es_...',
  {
    name: 'New Name',
    street1: '388 Townsend St',
    street2: 'Apt 20',
    city: 'San Francisco',
    state: 'CA',
    zip: '94107',
    country: 'US',
    email: 'test@example.com',
    phone: '5555555555',
  },
)

puts end_shipper
```

An `EndShipper` object may be updated using the EndShipper API. All required fields for creating an `EndShipper` are required in an update request. Partial updates are not supported.