# Authentication

> Get your API key and secret, and test safely with your sandbox key.

Every request needs your **API Key** and **API Secret**. You find both in MyParcelParcel, together with a separate sandbox pair to test your integration without booking real shipments.

## Get your API key and secret

1. **Log in** to [MyParcelParcel](https://my.parcelparcel.com/login). Don't have an account? [Create one here](https://my.parcelparcel.com/register).
2. Click **Settings** at the bottom of the menu on the left.
3. Under **Developers**, click **API keys**. You can also go there directly: [my.parcelparcel.com/account/partners-api](https://my.parcelparcel.com/account/partners-api).
4. No credentials yet? Click **Generate API credentials**.
5. Click **Copy** next to your **API Key** and **API Secret**.

*(Screen: MyParcelParcel, Settings > Developers > API keys: your API Key and API Secret with a Copy button, and under 'Test your integration' the separate sandbox key pair)*

> [!note] Don't see API keys under Settings?
> API access is for business accounts. If **API keys** is missing under Developers, email [integrations@italogistics.com](mailto:integrations@italogistics.com) and we'll check your account.

## Put your credentials in the request

Add your API Key and API Secret to the `X-PP-API` header of every request, with an `@` between them:

| Name     | Value               |
| :------- | :------------------ |
| X-PP-API | `{YourAPIKey}@{YourAPISecret}` |

So it could look something like this:

```http
X-PP-API: nube0b:1pdahsptd10kw848cccgkckogcgss0@0gw0ssw4-g4ks00ko-48w0sosc-cckw
```

## Test with your sandbox key

Under **Test your integration** on the same page, click **Generate sandbox key**. You get a second key pair; the sandbox API Key starts with `sbx_`. Use it in the `X-PP-API` header exactly like your live key.

With the sandbox key:

- **Rates, tracking, duties and all other calls use live data**, so you test against real prices and transit times.
- **Shipments are never sent to the carrier.** You can create drafts and even book with `bookShipment: true`: you get a sample label and a test tracking number (`SANDBOX` followed by the shipment id), and nothing is charged.
- **Cancelling** a sandbox shipment only cancels it in your account.
- Sandbox shipments show up in **API shipments** in MyParcelParcel with a **Sandbox** badge.

A booking made with the sandbox key returns the same response as a real booking, with `"sandbox": true`:

```json
{
  "errors": [],
  "message": "Your shipment has been booked (sandbox: not sent to the carrier)",
  "data": {
    "id": 1588448,
    "status": "created_at_carrier",
    "carrier": "FedEx",
    "product": "FedEx - FedEx Economy",
    "productId": 79,
    "price": 86.41,
    "trackingNumber": "SANDBOX1588448",
    "trackingUrl": null,
    "labels": "=== base64 encoded sample label ===",
    "sandbox": true
  }
}
```

When your integration works, swap the sandbox key for your live key. Nothing else changes.

## Rotate your credentials

Click **Rotate credentials** to get a new key and secret, for example on a routine schedule or right away if your credentials may have been exposed. Your current pair stops working immediately, and the new pair is shown only once, so copy it straight away and update your integration. The sandbox pair has its own **Rotate sandbox key** button.

## Test your authentication

The quickest test is [Check your API key](https://www.parcelparcel.com/api-docs/me/): it returns the email address of the account your key belongs to, or `X-PP-API header not valid` if something is wrong. After that, try [Compare shipping options](https://www.parcelparcel.com/api-docs/compare-shipping-options/) with your sandbox key, or import the whole [Postman Collection](https://www.parcelparcel.com/api-docs/postman-collection/).
