> ## Documentation Index
> Fetch the complete documentation index at: https://terminal49-mintlify-847785e1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a Customer to a Tracking Request

> Associate a customer party with a Terminal49 tracking request so new shipments automatically inherit the correct party relationship and metadata.

<Note>
  This guide covers the `customer` role. For shipper, consignee, freight forwarder, notify party, customs broker, and dray carrier, see [Assign Shipper, Consignee, and Other Parties](/api-docs/in-depth-guides/assigning-parties).
</Note>

## Why add a party to a tracking request?

Adding a party to a tracking request associates customer information with the request. The customer is assigned to the shipment when it is created, just like reference numbers and tags. This helps you organize and manage your shipments more effectively.

## How to get the party ID

You can either find an existing party or create a new one.

* To find an existing party, jump to [Listing all parties](#listing-all-parties) section.
* To create a new party, jump to [Adding party for a customer](#adding-party-for-a-customer) section.

## List all parties

You can list all parties associated with your account through the [API](/api-docs/api-reference/parties/list-parties).

Endpoint: **GET** - [https://api.terminal49.com/v2/parties](/api-docs/api-reference/parties/list-parties)

```json Response theme={null}
{
  "data": [
    {
      "id": "PARTY_ID_1",
      "type": "party",
      "attributes": {
        "company_name": "COMPANY NAME 1",
      }
    },
    {
      "id": "PARTY_ID_2",
      "type": "party",
      "attributes": {
        "company_name": "COMPANY NAME 2",
      }
    }
  ],
  "links": {
    "last": "<string>",
    "next": "<string>",
    "prev": "<string>",
    "first": "<string>",
    "self": "<string>"
  },
  "meta": {
    "size": 2,
    "total": 2
  }
}
```

After you get all the parties you would filter the parties by `company_name` to find the correct ID, either by looking through the list manually or using code to automate the process.

## Add a party to a tracking request

To add a customer to a tracking request, include the party as a customer relationship when creating the request. Shipper, consignee, and the other roles are passed the same way, as relationships named after the role. To change roles on an existing shipment, use [party roles](/api-docs/in-depth-guides/assigning-parties).

Endpoint: **POST** - [https://api.terminal49.com/v2/tracking\_requests](/api-docs/api-reference/tracking-requests/create-a-tracking-request)

```json Request theme={null}
{
  "data": {
    "type": "tracking_request",
    "attributes": {
      "request_type": "bill_of_lading",
      "request_number": "MEDUFR030802",
      "ref_numbers": [
        "PO12345",
        "HBL12345",
        "CUSREF1234"
      ],
      "shipment_tags": [
        "camembert"
      ],
      "scac": "MSCU"
    },
    "relationships": {
      "customer": {
        "data": {
          "id": "PARTY_ID",
          "type": "party"
        }
      }
    }
  }
}
```

The response carries the tracking request ID. Its `customer` relationship references the party's linked account and is `null` when the party has none, which is the case for parties created through this API. Once the shipment exists, read the assigned party with [`GET /v2/shipments/SHIPMENT_ID/party_roles`](/api-docs/api-reference/party-roles/list-shipment-party-roles).

```json Response theme={null}
{
  "data": {
    "id": "TRACKING_REQUEST_ID",
    "type": "tracking_request",
    "attributes": {
      "request_type": "bill_of_lading",
      "request_number": "MEDUFR030802",
      "ref_numbers": [
        "PO12345",
        "HBL12345",
        "CUSREF1234"
      ],
      "shipment_tags": [
        "camembert"
      ],
      "scac": "MSCU"
    },
    "relationships": {
      "tracked_object": {
        "data": null
      },
      "customer": {
        "data": null
      }
    },
    "links": {
      "self": "/v2/tracking_requests/TRACKING_REQUEST_ID"
    }
  }
}
```

## Create a party for a customer

To add a customer to a tracking request, you first need to create a party. You can create a party through the [API](/api-docs/api-reference/parties/create-a-party).

Endpoint: **POST** - [https://api.terminal49.com/v2/parties](/api-docs/api-reference/parties/create-a-party)

```json Request theme={null}
{
  "data": {
    "type": "party",
    "attributes": {
      "company_name": "COMPANY NAME"
    }
  }
}
```

After you send a **POST** request to create a party, you will receive a response with the Party ID. You can use this Party ID to add the customer to a tracking request.

```json Response theme={null}
{
  "data": {
    "id": "PARTY_ID",
    "type": "party",
    "attributes": {
      "company_name": "COMPANY NAME"
    }
  }
}
```

## Edit a party

You can update existing parties through the [API](/api-docs/api-reference/parties/edit-a-party).

Endpoint: **PATCH** - [https://api.terminal49.com/v2/parties/PARTY\_ID](/api-docs/api-reference/parties/edit-a-party)

## Read a party

You can retrieve the details of an existing party through the [API](/api-docs/api-reference/parties/get-a-party).

Endpoint: **GET** -  [https://api.terminal49.com/v2/parties/PARTY\_ID](/api-docs/api-reference/parties/get-a-party)
