Skip to main content
Use this guide to assign parties to your shipments from code instead of the dashboard bulk update.

How parties and roles work

  • A party is a company in your account, managed through /v2/parties.
  • A party role links one party to one shipment or container in one role.
  • Roles are a list, not a field. A shipment can carry two parties as consignee. To replace a party, remove its role and assign a new one.
You need an API key. See Start here.

Find or create the party

Search your parties by name:
If the party does not exist, create it:
Request
Keep the returned data.id. It is the PARTY_ID below.

Get the shipment ID

Roles are assigned on the shipment, so the shipment has to exist. A tracking request has a shipment once its status is created. Read the ID from the tracked_object relationship of GET /v2/tracking_requests/TRACKING_REQUEST_ID, or from the tracking_request.succeeded webhook. See Tracking Request Lifecycle. The customer is the exception: pass it in relationships.customer when creating the tracking request. See Add a Customer to a Tracking Request.

Assign roles to the shipment

Endpoint: POST - https://api.terminal49.com/v2/shipments/SHIPMENT_ID/party_roles
Request
Response
Send one request per role. Repeat with "role": "consignee" and "role": "freight_forwarder".

Read the roles on the shipment

Request the shipment with flag[parties]=true and include the parties:
The shipment carries a party_roles relationship and the included array holds each party_role and its party. The same flag works on GET /v2/shipments. -g stops curl from treating the brackets in flag[parties] as a range. To list the roles alone, use GET /v2/shipments/SHIPMENT_ID/party_roles.

Replace a party

To replace the consignee:
  1. List the roles and find the party_role with "role": "consignee".
  2. DELETE https://api.terminal49.com/v2/shipments/SHIPMENT_ID/party_roles/PARTY_ROLE_ID. Returns 204.
  3. POST the new consignee.

Assign a dray carrier to a container

Containers accept one role, pickup_dray_carrier: Endpoint: POST - https://api.terminal49.com/v2/containers/CONTAINER_ID/party_roles Read it back with GET /v2/containers/CONTAINER_ID/party_roles.

Errors