# Cancel a pickup

> Cancel the carrier pickup of a shipment. The shipment stays booked.

`DELETE https://services.parcelparcel.com/partners-api/v1/shipments/{shipmentId}/pickup`

This endpoint cancels the pickup of a shipment. The shipment itself stays booked: you can drop the parcel off yourself, or [schedule a new pickup](https://www.parcelparcel.com/api-docs/schedule-pickup/).

Want to cancel the whole shipment? Use [Cancel a (draft) shipment](https://www.parcelparcel.com/api-docs/cancel-shipment/). That also cancels the pickup.

Replace `{shipmentId}` with the `id` that you got in the response when you [created the shipment](https://www.parcelparcel.com/api-docs/create-shipment/).

* This works only while the carrier has not picked up the parcel.
* You can only use shipments of your own account. A shipment of another account gives the same `404` as an unknown id.

## Header

Add the following headers:

| Name         | Value                          |
| :----------- | :----------------------------- |
| Content-Type | application/json               |
| X-PP-API     | `{YourAPIKey}@{YourAPISecret}` |

Don't have an API Key and API Secret yet? Check our [Authentication](https://www.parcelparcel.com/api-docs/authentication/) page to see how to get them in under a minute.

## Body

This endpoint does not need a request body.

## Response

The response body is a JSON object with the following elements:

| Name          | Value    | Comments                                                                                                    |
| :------------ | :------- | :---------------------------------------------------------------------------------------------------------- |
| shipmentId    | (int)    | The id of the shipment.                                                                                     |
| cancelled     | (bool)   | `true` if the pickup is cancelled.                                                                          |
| carrierStatus | (string) | How the carrier handled the cancellation: `confirmed`, `requested`, `not_supported` or `sandbox`. See [Carrier status values](https://www.parcelparcel.com/api-docs/schedule-pickup/#carrier-status-values). |
| message       | (string) | Tells you the result in plain English.                                                                      |

Errors have the same format as in [Schedule a pickup](https://www.parcelparcel.com/api-docs/schedule-pickup/#errors).

### Status codes

| Status code              | Meaning                                                                                       |
| :----------------------- | :-------------------------------------------------------------------------------------------- |
| 200 OK                   | The pickup is cancelled. The shipment stays booked.                                           |
| 404 Not Found            | We could not find the shipment in your account. Make sure that the `shipmentId` is correct.   |
| 409 Conflict             | The shipment has no pickup to cancel, the carrier already has the parcel, or the shipment is cancelled. See `message`. |
| 422 Unprocessable Entity | The carrier refused the cancellation. Nothing changed. Read `message` for the reason.         |
| 502 Bad Gateway          | We could not reach the carrier. Nothing changed: try again later.                              |

## Examples

Don't know how to test these requests? Check [our guide](https://www.parcelparcel.com/api-docs/postman-guide/).

### Request example - Cancel the pickup of a shipment

```bash cURL
curl --location --request DELETE 'https://services.parcelparcel.com/partners-api/v1/shipments/1588448/pickup' \
--header 'X-PP-API: {YourAPIKey}@{YourAPISecret}' \
--header 'Content-Type: application/json'
```
```http HTTP
DELETE /partners-api/v1/shipments/1588448/pickup HTTP/1.1
Host: services.parcelparcel.com
X-PP-API: {YourAPIKey}@{YourAPISecret}
Content-Type: application/json
```

Don't forget to change the **X-PP-API** element in the header, or this request will not work.

### Response example - Pickup cancelled (200)

```json
{
  "shipmentId": 1588448,
  "cancelled": true,
  "carrierStatus": "confirmed",
  "message": "The carrier confirmed that the pickup is cancelled. The shipment stays booked: drop it off or schedule a new pickup."
}
```

### Response example - No pickup to cancel (409)

```json
{
  "error": "conflict",
  "message": "The shipment has no pickup to cancel."
}
```

### Response example - Carrier not reachable (502)

```json
{
  "error": "carrier_unavailable",
  "message": "The carrier could not be reached. Nothing was changed; try again later."
}
```

### Response example - Shipment not found (404)

```json
"Shipment not found"
```
