# Pickup

The `Pickup` object is used to schedule a pickup from a carrier at a residence or place of business.
Supported carriers include:

- Better Trucks
- Canada Post
- Canpar
- DHL Express
- FedEx
- Lasership
- Loomis Express
- LSO
- Maersk Parcel
- Ontrac
- UPS
- USPS
- USPS Ship
- Veho

Once a `Pickup` is successfully created, `PickupRates` will be automatically fetched for each
specified `CarrierAccount` that supports scheduled pickups. A `PickupRate` must then be selected
and purchased to successfully schedule the pickup.

---

## Pickup object

| Property | Type | Description |
|----------|------|-------------|
| id | string | Unique, begins with "pickup_" |
| object | string | "Pickup" |
| mode | string | "test" or "production" |
| status | string | Possible values: "scheduled" "canceled" "unknown" |
| min_datetime | datetime | The earliest time at which the package is available to pick up |
| max_datetime | datetime | The latest time at which the package is available to pick up. Must be later than min_datetime |
| is_account_address | boolean | Whether the pickup address is the the account's address |
| instructions | string | Additional text to help the driver successfully obtain the package |
| messages | Message array | A list of messages containing carrier errors encountered during pickup rate generation |
| confirmation | string | The confirmation number for a booked pickup from the carrier |
| shipment | Shipment | The associated Shipment |
| address | Address | The associated Address |
| carrier_accounts | CarrierAccount array | The list of carriers (if empty, all carriers were used) used to generate pickup rates |
| pickup_rates | PickupRate array | The list of different pickup rates across valid carrier accounts for the shipment |
| created_at | datetime | When the Pickup was created |
| updated_at | datetime | When the Pickup was last updated |

Example Object:

```json
{
  "id": "pickup_24f4406c58f24fde820759d84d9422fa",
  "object": "Pickup",
  "created_at": "2025-05-09T20:39:27Z",
  "updated_at": "2025-05-09T20:39:27Z",
  "mode": "test",
  "status": "unknown",
  "reference": "my-first-pickup",
  "min_datetime": "2025-05-12T00:00:00Z",
  "max_datetime": "2025-05-12T00:00:00Z",
  "is_account_address": false,
  "instructions": "Special pickup instructions",
  "messages": [],
  "confirmation": null,
  "address": {
    "id": "adr_b379f0df2d1511f0ad1cac1f6bc539ae",
    "object": "Address",
    "created_at": "2025-05-09T20:39:27+00:00",
    "updated_at": "2025-05-09T20:39:27+00:00",
    "name": "Dr. Steve Brule",
    "company": null,
    "street1": "179 N Harbor Dr",
    "street2": null,
    "city": "Redondo Beach",
    "state": "CA",
    "zip": "90277",
    "country": "US",
    "phone": "8573875756",
    "email": "dr_steve_brule@gmail.com",
    "mode": "test",
    "carrier_facility": null,
    "residential": null,
    "federal_tax_id": null,
    "state_tax_id": null,
    "verifications": {}
  },
  "carrier_accounts": [],
  "pickup_rates": [
    {
      "mode": "test",
      "service": "NextDay",
      "rate": "0.00",
      "currency": "USD",
      "created_at": "2025-05-09T20:39:29Z",
      "updated_at": "2025-05-09T20:39:29Z",
      "carrier": "USPS",
      "pickup_id": "pickup_24f4406c58f24fde820759d84d9422fa",
      "id": "pickuprate_df03ccc2da4e4825927464867c7f76b9",
      "object": "PickupRate"
    }
  ]
}
```

---

## PickupRate object

| Property | Type | Description |
|----------|------|-------------|
| id | string | Unique, begins with 'pickuprate_' |
| object | string | "PickupRate" |
| service | string | The service name |
| carrier | string | The name of the carrier |
| rate | string | The actual rate quote for this service |
| currency | string | The currency for the rate |
| pickup_id | string | The ID of the pickup for which this is a quote |
| created_at | datetime | When the PickupRate was created |
| updated_at | datetime | When the PickupRate was last updated |

Example Object:

```json
{
  "id": "pickup_24f4406c58f24fde820759d84d9422fa",
  "object": "Pickup",
  "created_at": "2025-05-09T20:39:27Z",
  "updated_at": "2025-05-09T20:39:27Z",
  "mode": "test",
  "status": "unknown",
  "reference": "my-first-pickup",
  "min_datetime": "2025-05-12T00:00:00Z",
  "max_datetime": "2025-05-12T00:00:00Z",
  "is_account_address": false,
  "instructions": "Special pickup instructions",
  "messages": [],
  "confirmation": null,
  "address": {
    "id": "adr_b379f0df2d1511f0ad1cac1f6bc539ae",
    "object": "Address",
    "created_at": "2025-05-09T20:39:27+00:00",
    "updated_at": "2025-05-09T20:39:27+00:00",
    "name": "Dr. Steve Brule",
    "company": null,
    "street1": "179 N Harbor Dr",
    "street2": null,
    "city": "Redondo Beach",
    "state": "CA",
    "zip": "90277",
    "country": "US",
    "phone": "8573875756",
    "email": "dr_steve_brule@gmail.com",
    "mode": "test",
    "carrier_facility": null,
    "residential": null,
    "federal_tax_id": null,
    "state_tax_id": null,
    "verifications": {}
  },
  "carrier_accounts": [],
  "pickup_rates": [
    {
      "mode": "test",
      "service": "NextDay",
      "rate": "0.00",
      "currency": "USD",
      "created_at": "2025-05-09T20:39:29Z",
      "updated_at": "2025-05-09T20:39:29Z",
      "carrier": "USPS",
      "pickup_id": "pickup_24f4406c58f24fde820759d84d9422fa",
      "id": "pickuprate_df03ccc2da4e4825927464867c7f76b9",
      "object": "PickupRate"
    }
  ]
}
```

---

## Create a Pickup

### Example: POST /pickups

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/pickups \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "pickup": {
      "reference": "my-first-pickup",
      "min_datetime": "2022-10-01 10:30:00",
      "max_datetime": "2022-10-02 10:30:00",
      "shipment": "shp_...",
      "address": "adr_...",
      "is_account_address": "false",
      "instructions": "Special pickup instructions"
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"
	"time"

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

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

	var minDatetime easypost.DateTime = easypost.DateTime(time.Now())
	var maxDatetime easypost.DateTime = easypost.DateTime(time.Now().Add(time.Hour * 24 * 7))

	pickup, _ := client.CreatePickup(
		&easypost.Pickup{
			IsAccountAddress: false,
			Address: &easypost.Address{
				ID: "adr_...",
			},
			Shipment: &easypost.Shipment{
				ID: "shp_...",
			},
			MinDatetime:  &minDatetime,
			MaxDatetime:  &maxDatetime,
			Instructions: "Special pickup instructions",
		},
	)

	fmt.Println(pickup)
}
```

#### Java

```java
package pickups;

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

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> address = new HashMap<String, Object>();
        address.put("id", "adr_...");

        HashMap<String, Object> shipment = new HashMap<String, Object>();
        shipment.put("id", "shp_...");

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("address", address);
        params.put("shipment", shipment);
        params.put("reference", "my-first-pickup");
        params.put("min_datetime", "2022-10-01 10:30:00");
        params.put("max_datetime", "2022-10-02 10:30:00");
        params.put("is_account_address", false);
        params.put("instructions", "Special pickup instructions");

        Pickup pickup = client.pickup.create(params);

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

#### 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.Shipment shipment = await client.Shipment.Retrieve("shp_...");

            EasyPost.Parameters.Pickup.Create parameters = new()
            {
                Address = 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"
                },
                Shipment = shipment,
                Reference = "my-first-pickup",
                MinDatetime = "2022-10-01 10:30:00",
                MaxDatetime = "2022-10-01 17:30:00",
                Instructions = "Special pickup instructions",
                IsAccountAddress = false,
                CarrierAccounts = new List<EasyPost.Models.API.CarrierAccount>
                {
                    new CarrierAccount
                    {
                        Id = "ca_..."
                    }
                }
            };

            EasyPost.Models.API.Pickup pickup = await client.Pickup.Create(parameters);

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

#### Node.js

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

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  const pickup = await client.Pickup.create({
    address: { id: 'adr_...' },
    shipment: { id: 'shp_...' },
    reference: 'my-first-pickup',
    min_datetime: '2022-10-01 10:30:00',
    max_datetime: '2022-10-02 10:30:00',
    is_account_address: false,
    instructions: 'Special pickup instructions',
  });

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

#### PHP

```php
<?php

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

$pickup = $client->pickup->create([
    'address' => ['id' => 'adr_...'],
    'shipment' => ['id' => 'shp_...'],
    'reference' => 'my-first-pickup',
    'min_datetime' => date('2022-10-01 10:30:00'),
    'max_datetime' => date('2022-10-02 10:30:00'),
    'is_account_address' => false,
    'instructions' => 'Special pickup instructions'
]);

echo $pickup;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

pickup = client.pickup.create(
    address={"id": "adr_..."},
    shipment={"id": "shp_..."},
    reference="my-first-pickup",
    min_datetime="2022-10-01 10:30:00",
    max_datetime="2022-10-02 10:30:00",
    is_account_address=False,
    instructions="Special pickup instructions",
)

print(pickup)
```

#### Ruby

```ruby
require 'easypost'

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

pickup = client.pickup.create(
  reference: 'my-first-pickup',
  min_datetime: '2022-10-01 10:30:00',
  max_datetime: '2022-10-02 10:30:00',
  shipment: {
    id: 'shp_...',
  },
  address: {
    id: 'adr_...',
  },
  is_account_address: false,
  instructions: 'Special pickup instructions',
)

puts pickup
```

Creating a `Pickup` will automatically fetch rates for the given time frame and location.

Pickups work with an existing purchased `Shipment` or a fully-purchased `Batch`, and either a fully-specified `Address` object or its `id`.
The examples below assume that a `Shipment` and `Address` have both already been created.

[Note: This object is immutable after creation. Review the rendered documentation for details.]

---

## Buy a Pickup

### Example: POST /pickups/:id/buy

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/pickups \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "pickup": {
      "reference": "my-first-pickup",
      "min_datetime": "2022-10-01 10:30:00",
      "max_datetime": "2022-10-02 10:30:00",
      "shipment": "shp_...",
      "address": "adr_...",
      "is_account_address": "false",
      "instructions": "Special pickup instructions"
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"
	"time"

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

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

	var minDatetime easypost.DateTime = easypost.DateTime(time.Now())
	var maxDatetime easypost.DateTime = easypost.DateTime(time.Now().Add(time.Hour * 24 * 7))

	pickup, _ := client.CreatePickup(
		&easypost.Pickup{
			IsAccountAddress: false,
			Address: &easypost.Address{
				ID: "adr_...",
			},
			Shipment: &easypost.Shipment{
				ID: "shp_...",
			},
			MinDatetime:  &minDatetime,
			MaxDatetime:  &maxDatetime,
			Instructions: "Special pickup instructions",
		},
	)

	fmt.Println(pickup)
}
```

#### Java

```java
package pickups;

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

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> address = new HashMap<String, Object>();
        address.put("id", "adr_...");

        HashMap<String, Object> shipment = new HashMap<String, Object>();
        shipment.put("id", "shp_...");

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("address", address);
        params.put("shipment", shipment);
        params.put("reference", "my-first-pickup");
        params.put("min_datetime", "2022-10-01 10:30:00");
        params.put("max_datetime", "2022-10-02 10:30:00");
        params.put("is_account_address", false);
        params.put("instructions", "Special pickup instructions");

        Pickup pickup = client.pickup.create(params);

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

#### 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.Shipment shipment = await client.Shipment.Retrieve("shp_...");

            EasyPost.Parameters.Pickup.Create parameters = new()
            {
                Address = 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"
                },
                Shipment = shipment,
                Reference = "my-first-pickup",
                MinDatetime = "2022-10-01 10:30:00",
                MaxDatetime = "2022-10-01 17:30:00",
                Instructions = "Special pickup instructions",
                IsAccountAddress = false,
                CarrierAccounts = new List<EasyPost.Models.API.CarrierAccount>
                {
                    new CarrierAccount
                    {
                        Id = "ca_..."
                    }
                }
            };

            EasyPost.Models.API.Pickup pickup = await client.Pickup.Create(parameters);

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

#### Node.js

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

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  const pickup = await client.Pickup.create({
    address: { id: 'adr_...' },
    shipment: { id: 'shp_...' },
    reference: 'my-first-pickup',
    min_datetime: '2022-10-01 10:30:00',
    max_datetime: '2022-10-02 10:30:00',
    is_account_address: false,
    instructions: 'Special pickup instructions',
  });

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

#### PHP

```php
<?php

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

$pickup = $client->pickup->create([
    'address' => ['id' => 'adr_...'],
    'shipment' => ['id' => 'shp_...'],
    'reference' => 'my-first-pickup',
    'min_datetime' => date('2022-10-01 10:30:00'),
    'max_datetime' => date('2022-10-02 10:30:00'),
    'is_account_address' => false,
    'instructions' => 'Special pickup instructions'
]);

echo $pickup;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

pickup = client.pickup.create(
    address={"id": "adr_..."},
    shipment={"id": "shp_..."},
    reference="my-first-pickup",
    min_datetime="2022-10-01 10:30:00",
    max_datetime="2022-10-02 10:30:00",
    is_account_address=False,
    instructions="Special pickup instructions",
)

print(pickup)
```

#### Ruby

```ruby
require 'easypost'

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

pickup = client.pickup.create(
  reference: 'my-first-pickup',
  min_datetime: '2022-10-01 10:30:00',
  max_datetime: '2022-10-02 10:30:00',
  shipment: {
    id: 'shp_...',
  },
  address: {
    id: 'adr_...',
  },
  is_account_address: false,
  instructions: 'Special pickup instructions',
)

puts pickup
```

To purchase a `Pickup`, a `PickupRate` must be specified by its `carrier` and `service` name, instead of its `id`.
Our client libraries will handle this automatically if a `PickupRate` is provided.

---

## Cancel a Pickup

### Example: POST /pickups/:id/cancel

#### cURL

```shell
curl -X POST https://api.easypost.com/v2/pickups \
  -u "EASYPOST_API_KEY": \
  -H 'Content-Type: application/json' \
  -d '{
    "pickup": {
      "reference": "my-first-pickup",
      "min_datetime": "2022-10-01 10:30:00",
      "max_datetime": "2022-10-02 10:30:00",
      "shipment": "shp_...",
      "address": "adr_...",
      "is_account_address": "false",
      "instructions": "Special pickup instructions"
    }
  }'
```

#### Go

```go
package example

import (
	"fmt"
	"time"

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

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

	var minDatetime easypost.DateTime = easypost.DateTime(time.Now())
	var maxDatetime easypost.DateTime = easypost.DateTime(time.Now().Add(time.Hour * 24 * 7))

	pickup, _ := client.CreatePickup(
		&easypost.Pickup{
			IsAccountAddress: false,
			Address: &easypost.Address{
				ID: "adr_...",
			},
			Shipment: &easypost.Shipment{
				ID: "shp_...",
			},
			MinDatetime:  &minDatetime,
			MaxDatetime:  &maxDatetime,
			Instructions: "Special pickup instructions",
		},
	)

	fmt.Println(pickup)
}
```

#### Java

```java
package pickups;

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

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> address = new HashMap<String, Object>();
        address.put("id", "adr_...");

        HashMap<String, Object> shipment = new HashMap<String, Object>();
        shipment.put("id", "shp_...");

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("address", address);
        params.put("shipment", shipment);
        params.put("reference", "my-first-pickup");
        params.put("min_datetime", "2022-10-01 10:30:00");
        params.put("max_datetime", "2022-10-02 10:30:00");
        params.put("is_account_address", false);
        params.put("instructions", "Special pickup instructions");

        Pickup pickup = client.pickup.create(params);

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

#### 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.Shipment shipment = await client.Shipment.Retrieve("shp_...");

            EasyPost.Parameters.Pickup.Create parameters = new()
            {
                Address = 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"
                },
                Shipment = shipment,
                Reference = "my-first-pickup",
                MinDatetime = "2022-10-01 10:30:00",
                MaxDatetime = "2022-10-01 17:30:00",
                Instructions = "Special pickup instructions",
                IsAccountAddress = false,
                CarrierAccounts = new List<EasyPost.Models.API.CarrierAccount>
                {
                    new CarrierAccount
                    {
                        Id = "ca_..."
                    }
                }
            };

            EasyPost.Models.API.Pickup pickup = await client.Pickup.Create(parameters);

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

#### Node.js

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

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  const pickup = await client.Pickup.create({
    address: { id: 'adr_...' },
    shipment: { id: 'shp_...' },
    reference: 'my-first-pickup',
    min_datetime: '2022-10-01 10:30:00',
    max_datetime: '2022-10-02 10:30:00',
    is_account_address: false,
    instructions: 'Special pickup instructions',
  });

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

#### PHP

```php
<?php

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

$pickup = $client->pickup->create([
    'address' => ['id' => 'adr_...'],
    'shipment' => ['id' => 'shp_...'],
    'reference' => 'my-first-pickup',
    'min_datetime' => date('2022-10-01 10:30:00'),
    'max_datetime' => date('2022-10-02 10:30:00'),
    'is_account_address' => false,
    'instructions' => 'Special pickup instructions'
]);

echo $pickup;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

pickup = client.pickup.create(
    address={"id": "adr_..."},
    shipment={"id": "shp_..."},
    reference="my-first-pickup",
    min_datetime="2022-10-01 10:30:00",
    max_datetime="2022-10-02 10:30:00",
    is_account_address=False,
    instructions="Special pickup instructions",
)

print(pickup)
```

#### Ruby

```ruby
require 'easypost'

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

pickup = client.pickup.create(
  reference: 'my-first-pickup',
  min_datetime: '2022-10-01 10:30:00',
  max_datetime: '2022-10-02 10:30:00',
  shipment: {
    id: 'shp_...',
  },
  address: {
    id: 'adr_...',
  },
  is_account_address: false,
  instructions: 'Special pickup instructions',
)

puts pickup
```

You may cancel a `Pickup` any time before it has been completed.
It requires no additional parameters other than the `id` or `reference`.
The `status` will change to "canceled" on success.

---

## Retrieve all Pickups

### Example: GET /pickups

#### cURL

```shell
curl -X GET "https://api.easypost.com/v2/pickups?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")

	pickups, _ := client.ListPickups(
		&easypost.ListOptions{
			PageSize: 5,
		},
	)

	fmt.Println(pickups)
}
```

#### Java

```java
package shipments;

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

import java.util.HashMap;

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

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

        PickupCollection pickupCollection = client.pickup.all(params);

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

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

            Dictionary<string, object> listParams = new Dictionary<string, object>()
            {
                { "page_size", 5 }
            };

            EasyPost.Models.API.PickupCollection pickups = await client.Pickup.All(listParams);

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

#### Node.js

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

const client = new EasyPostClient('EASYPOST_API_KEY');

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

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

#### PHP

```php
<?php

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

$pickups = $client->pickup->all([
    'page_size' => 5,
]);

echo $pickups;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

pickups = client.pickup.all(
    page_size=5,
)

print(pickups)
```

#### Ruby

```ruby
require 'easypost'

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

pickups = client.pickup.all(
  page_size: 5,
)

puts pickups
```

A list of all `Pickup` objects associated with the given `API Key` can also be retrieved.
See the Pagination section of our docs for more details on retrieving all records when multiple pages are available.

---

## Retrieve a Pickup

### Example: GET /pickups/:id

#### cURL

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

#### Go

```go
package example

import (
	"fmt"

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

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

	pickup, _ := client.GetPickup("pickup_...")

	fmt.Println(pickup)
}
```

#### Java

```java
package pickups;

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

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

        Pickup pickup = client.pickup.retrieve("pickup_...");

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

#### 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.Pickup pickup = await client.Pickup.Retrieve("pickup_...");

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

#### Node.js

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

const client = new EasyPostClient('EASYPOST_API_KEY');

(async () => {
  const pickup = await client.Pickup.retrieve('pickup_...');

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

#### PHP

```php
<?php

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

$pickup = $client->pickup->retrieve('pickup_...');

echo $pickup;
```

#### Python

```python
import easypost

client = easypost.EasyPostClient("EASYPOST_API_KEY")

pickup = client.pickup.retrieve("pickup_...")

print(pickup)
```

#### Ruby

```ruby
require 'easypost'

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

pickup = client.pickup.retrieve('pickup_...')

puts pickup
```

A `Pickup` object can be retrieved by either an `id` or `reference`.
However it is recommended to use EasyPost's provided identifiers because uniqueness on `reference` is not enforced.