# Guide for customers and shippers

You are a shipper, customer or broker. You book transportation orders with a carrier (or an agent) on the Partner Network and follow them to delivery. In every call below, `{partnercode}` is the **carrier or agent's** code.

```bash
export CC=https://carriercloud.ai
export KEY="Authorization: Bearer YOUR_API_KEY"
export P=MIST
```

## 1. Know the partner's codes

Order bookings reference partner-specific codes for equipment, service and reference types. Fetch them once and cache them:

```bash
curl "$CC/v1/partner/$P/options/equipmenttypes" -H "$KEY"
curl "$CC/v1/partner/$P/options/servicetypes"   -H "$KEY"
curl "$CC/v1/partner/$P/options/referencetypes" -H "$KEY"
```

Each list is an array of `{ "Abbr": "V", "Name": "Dry Van" }`; send the `Abbr`.

## 2. Set up your locations

Create the pickup and delivery locations you will reuse, with the roles they play:

```bash
curl -X POST "$CC/v1/partner/$P/locations" -H "$KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Perrysburg DC",
    "Address1": "28000 Oregon Rd", "City": "Perrysburg", "State": "OH", "ZipCode": "43551", "Country": "USA",
    "Roles": { "Shipper": {}, "Consignee": {} }
  }'
```

The response returns the stored location with its `_id`; `GET .../locations?page=1` lists them in a paged envelope (`page`, `pageSize`, `totalCount`, `locations[]`). `PUT .../locations/{id}` updates a location, and `DELETE .../locations/{id}/roles/{role}` retires one role without deleting the location.

## 3. Book an order

An order needs at least two stops in sequence, each with a `StopType`, `Sequence`, `City` and `State`. Freight details and reference numbers are optional but valuable:

```bash
curl -X POST "$CC/v1/partner/$P/orders" -H "$KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "Stops": [
      { "StopType": "Pickup",   "Sequence": 1, "Company": "Perrysburg DC",      "City": "Perrysburg", "State": "OH", "ZipCode": "43551",
        "EarliestDate": "2026-09-30T12:00:00Z", "LatestDate": "2026-09-30T14:00:00Z" },
      { "StopType": "Delivery", "Sequence": 2, "Company": "Columbus Receiving", "City": "Columbus",   "State": "OH", "ZipCode": "43232",
        "EarliestDate": "2026-10-01T08:00:00Z", "LatestDate": "2026-10-01T10:00:00Z" }
    ],
    "FreightDetails": [
      { "Description": "Palletized consumer goods", "Weight": 38500, "WeightUnit": "lbs", "ItemCount": 22, "CommodityCode": "GENERAL" }
    ],
    "RefNumbers": [ { "RefType": "PO", "RefNumber": "PO-448812" } ]
  }'
```

A successful booking answers `201`:

```json
{ "status": "ok", "messsage": "Order successfully booked.", "objectId": "…", "orderId": "…", "orderNumber": "1049822" }
```

Keep `orderId`; it is the `orderid` for the calls that follow. A `207` means the order was created but some fields were skipped (`warnings[]`). A `422` returns `{ "detail": "...", "errors": [...] }` and nothing was created.

:::tip
`Create Order Quote` (`POST .../quotes`) books a tentative order for pricing before you commit. It is [gated](/docs/environments#gated-operations) at the moment.
:::

## 4. Change or cancel an order

Update stops, freight or references by their identifiers (`_id` for stops, `DataGUID` for freight and references). Send only what changes:

```bash
curl -X PUT "$CC/v1/partner/$P/orders/$ORDERID" -H "$KEY" \
  -H "Content-Type: application/json" \
  -d '{ "Stops": [ { "_id": "stop-2", "LatestDate": "2026-10-01T12:00:00Z" } ] }'
```

Cancel with `DELETE .../orders/{orderid}`; the order is archived on the partner's side.

## 5. Follow the order

```bash
curl "$CC/v1/partner/$P/orders?page=1&status=Dispatched" -H "$KEY"
curl "$CC/v1/partner/$P/orders/byNumber/1049822" -H "$KEY"
curl "$CC/v1/partner/$P/orders/$ORDERID/positions" -H "$KEY"
```

`Get Orders` returns `TripActor` records with `TripStatus`, `PercentCompleted`, `StopsCompleted`, each stop's `Arrived` / `Completed` flags and dates, and the latest known position in `ProximityDescription`. `Get GPS Positions` returns up to 100 recent fixes in `positions[]` with `moreAvailable`.

If you only have the order number (the `orderNumber` from the booking response), `Get Order by Order Number` returns the order card with its full `carddata` in a paged envelope (`page`, `pageSize`, `totalCount`, `orders[]`), so one call gets you the order without listing first. `orders[]` can hold more than one card because order numbers are not guaranteed to be unique, and it is empty when nothing matches.

For pushes instead of polling, register webhooks for `arrive`, `depart`, `update` and `gps` on the `order` object type; see [Webhooks](/docs/webhooks/overview).

## 6. Collect documents

`GET .../orders/{orderid}/documents` lists the documents the carrier attached (proof of delivery, bills of lading) that your partner role may see. The operation is gated today; until it is enabled, documents are available in the platform.

## 7. Create an invoice

Create an invoice on the partner's invoice board. `title` is required. `Status` and `Terms` are `Abbr` values from the invoice option lists. `boardId` and `listId` can be omitted; they default to the partner's first invoice board and its first list.

Attach orders only together with `BillToCardId`. That id is a location card with a BillTo role, and each order must already be billed to it.

```bash
curl "$CC/v1/partner/$P/options/invoicestatuses" -H "$KEY"
curl "$CC/v1/partner/$P/options/invoiceterms" -H "$KEY"

curl -X POST "$CC/v1/partner/$P/invoices" -H "$KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Invoice 1001",
    "Status": "New",
    "Terms": "NET30",
    "InvoiceDate": "2026-11-03T12:00:00Z",
    "BillToCardId": "LOCATION_ID",
    "OrderCardIds": ["ORDER_ID"]
  }'
```

A successful create answers `200` with the stored invoice card and `status: "ok"`. Keep `_id`; it is the invoice card id. A `207` means the invoice was created but some fields were skipped (`warnings[]`). A `422` means nothing was created.

Update with `PUT .../invoices/{id}`. Send only the fields that change. `BillToCardId` replaces the bill-to; `""` or `null` removes it, which fails while orders are still attached. `OrderCardIds` replaces the whole set of orders (an empty array detaches them all). Omit either field to leave it unchanged.

```bash
curl -X PUT "$CC/v1/partner/$P/invoices/$INVOICEID" -H "$KEY" \
  -H "Content-Type: application/json" \
  -d '{ "Status": "Sent", "AmountPaid": "100.00" }'
```

Read invoices back with `GET .../invoices/{id}` for one invoice, or `GET .../invoices` for a page of them, newest first (100 per page, `page` selects the page). Narrow the list with `invoicenum` (exact invoice number) or `ordernum` (the order number of an attached order). The list answers `{ page, pageSize, totalCount, invoices[] }`; `invoices[]` is empty when nothing matches. Fields your partner role cannot view are left out.

```bash
curl "$CC/v1/partner/$P/invoices?ordernum=1049822" -H "$KEY"
curl "$CC/v1/partner/$P/invoices/$INVOICEID" -H "$KEY"
```

## Errors you will see

| Response | Meaning |
|---|---|
| `422 { "detail": "Stops must contain at least two entries" }` | Booking rules not met; `errors[]` names each problem. |
| `422 { "detail": "Bill-to customer not found" }` | Invoice was not created or updated. The same shape covers a missing board or list, an unknown invoice or order, or an order billed to a different location. |
| `207` with `warnings` | Saved without the listed fields. |
| `404 No orders found.` | Nothing on that page or no match for the filters. |

See the [error catalog](/docs/concepts/errors).
