# JASPER Shipping API — Developer Documentation

Base URL: `https://tms.jaspers.com`
Aggregated truck freight + small parcel shipping by JASPERS LOGISTIC GROUP.
All returned prices are final sell prices with markup already included.
Carrier cost is never exposed.

## Authentication

Send your API key on every request:

```
Authorization: Bearer tms_live_xxxxxxxxxxxxxxxx
```

(or header `X-Api-Key: tms_live_...`)

- **Sandbox keys** start with `tms_test_`. They return sample rates and create
  TEST orders/labels clearly marked test. They never charge and never call
  live carrier booking. A sandbox key is issued immediately when you sign up
  at https://tms.jaspers.com/account
- **Production keys** start with `tms_live_`. They are issued after admin
  approval of your account. Production bookings are real shipments billed at
  the returned price (invoiced to your account).

## Rate limits

60 requests/minute per API key. Exceeding it returns HTTP 429.

## Errors

Errors return JSON `{ "error": "message", "errorEn": "...", "errorZh": "..." }`
(`error` follows your Accept-Language / tms_lang cookie) with HTTP status:
400 bad request / validation, 401 missing or invalid API key,
403 production key not approved, 404 not found, 429 rate limited,
502 carrier error (message included).

## Freight (truck LTL/FTL)

### POST /api/v1/freight/quote

```json
{
  "fromZip": "91761", "toZip": "60607", "pickupDate": "2026-12-08",
  "shipmentType": "LTL",
  "items": [{ "length": 48, "width": 40, "height": 48, "weight": 500, "quantity": 2 }]
}
```

Response: `{ "offers": [{ "token": "...", "service": "JASPER LTL",
"price": 943.00, "transitDays": 5, "test": false }] }`
Prices include markup. `token` identifies the quoted offer for booking (valid 2 hours).

### POST /api/v1/freight/book

```json
{
  "token": "<token from quote>",
  "shipFrom": { "name": "...", "company": "...", "address1": "...", "city": "Ontario",
                "state": "CA", "zip": "91761", "phone": "9094642293", "email": "you@co.com" },
  "shipTo":   { "name": "...", "address1": "...", "city": "Chicago",
                "state": "IL", "zip": "60607", "phone": "3125550100" }
}
```

Response: order object with `ref` (e.g. JSP-AB12CD34), `status: "booked"`,
`trackingNumber`, `sellPrice`, and document URLs `/docs/bol/<ref>` and
`/docs/labels/<ref>` (pallet labels) on the base URL.

## Parcels

### POST /api/v1/parcel/quote

```json
{
  "shipFrom": { "name": "...", "address1": "...", "city": "Ontario", "state": "CA", "zip": "91761", "phone": "..." },
  "shipTo":   { "name": "...", "address1": "...", "city": "Chicago", "state": "IL", "zip": "60607", "phone": "..." },
  "items": [{ "length": 12, "width": 12, "height": 12, "weight": 5, "quantity": 1 }]
}
```

Response: offers across carriers (USPS / FedEx / UPS services),
sorted by price, markup included, each with a booking `token`.

### POST /api/v1/parcel/label

Same body as freight/book: `{ "token": "...", "shipFrom": {...}, "shipTo": {...} }`.
Response: order with `ref` (JSP-P-...), `trackingNumber`, `labelUrl` (printable label PDF).

### POST /api/v1/parcel/cancel

```json
{ "ref": "JSP-P-AB12CD34" }
```

Cancels/voids the label where the channel supports it. Refund per carrier rules.

## Tracking

### GET /api/v1/track/{ref}

Returns the order plus a normalized `tracking` object: `currentStatus`
(booked / picked_up / in_transit / out_for_delivery / delivered / exception),
`events` (chronological: status, description, timestamp, location city/state),
`currentLocation`, `origin`, `destination`, and `carrierTrackingUrl` when
available. Quote offers include `transitDays` (business days) for ETA display.
You can only track your own orders.

## Webhooks

Set a webhook URL in your account page. On order booked and status changes we
POST JSON `{ "event": "order.booked", "ref": "...", "status": "...", "trackingNumber": "..." }`
with header `X-Jasper-Signature: sha256=<hmac>` computed with your webhook
secret (shown in your account page) over the raw body. Verify it before trusting.

## Sandbox behavior

With a `tms_test_` key every endpoint behaves identically in shape, but rates
are samples, bookings create TEST orders (tracking numbers prefixed DEMO-),
documents are stamped DEMO, and nothing is charged or sent to a carrier.
Use sandbox to build your integration, then request production approval.

## Support

JASPERS LOGISTIC GROUP · 1800 S Turner Ave, Ontario, CA 91761 · +1 909 464 2293 · la@jaspers.com
