# Errors

## Format

Every error response produced by the API has the same JSON body:

```json
{
  "message": "Driver phone number is not valid",
  "code": "DRIVER_PHONE_INVALID",
  "requestId": "9607f3c4-ecc9-4321-a3ff-e67040e85dfe"
}
```

| Field | Use it for |
| --- | --- |
| `code` | Branching in your code. Stable - a code is never renamed or reused. |
| `message` | Logs and humans. It can be reworded at any time - never parse it. |
| `requestId` | Support. The same value is in the `X-Request-Id` header of **every** response, successful or not. |

New codes can be added without a new API version. Handle an unknown `code` by its HTTP status
(retry 5xx, fix the request on 4xx).

You can send your own `X-Request-Id` header (8 to 128 characters of `A-Z a-z 0-9 . _ : -`) to
correlate our logs with yours. It is echoed back. Otherwise the server generates one.

## Codes

### Authentication and organization

| HTTP | `code` | Cause | Fix |
| --- | --- | --- | --- |
| 401 | `MISSING_API_KEY` | No `x-api-key` header | Send your partner key |
| 401 | `INVALID_API_KEY` | Unknown or revoked partner key | Check the key. Ask support if it was rotated |
| 400 | `INVALID_CLIENT_KEY` | `x-api-client-key` does not match an organization. Only create-tracking and get-all-tracking-items check it. Other endpoints ignore an unknown client key | Copy it again from Settings > API Key |
| 400 | `CLIENT_KEY_REQUIRED` | The client key is mandatory here (list endpoint, test mode, an ELD or Hybrid tracking, or your key is not allowlisted for MC/DOT creation) | Send `x-api-client-key` |
| 400 | `ORG_IDENTIFIER_REQUIRED` | Create without client key and without `mcNum` / `dotNum` | Send the client key (preferred) or a number |
| 400 | `ORG_IDENTIFIER_INVALID` | Create without client key: the `mcNum` / `dotNum` it uses is not a positive whole number | Send the number as a JSON number, without a prefix such as `MC` |
| 400 | `ORGANIZATION_NOT_FOUND` | No Load Market organization has this MC / DOT number. On edit-tracking: the tracking's organization no longer exists | Check the number, or use the client key |

### Request validation

| HTTP | `code` | Cause | Fix |
| --- | --- | --- | --- |
| 400 | `INVALID_JSON` | The body is not valid JSON, or not a JSON object. Usually the hosting platform rejects invalid JSON before the API sees it: you then get HTTP 400 with an HTML body and no `code` | Send a JSON object with `Content-Type: application/json`. Treat any 400 whose body is not JSON as invalid JSON |
| 400 | `DRIVER_PHONE_REQUIRED` | `driverPhone` missing (a phone or Hybrid tracking) | Send the driver's phone |
| 400 | `DRIVER_PHONE_INVALID` | `driverPhone` is not a JSON number, is too short, or is not a valid US or Canadian number (an area code or exchange starting with `0` or `1`) | Send the driver's 10-digit mobile number as a number: `5555550100` |
| 400 | `REF_ID_REQUIRED` | `refId` missing or empty | Send your load reference |
| 400 | `REF_ID_INVALID` | `refId` is not a string, is longer than 200 characters, or is empty or `null` on edit-tracking | Send your load reference as a string. Leave it out of an edit to keep it |
| 400 | `CUSTOM_ID_INVALID` | `customId` is not a string or is longer than 200 characters | Send a string |
| 400 | `NOTES_INVALID` | `notes` is not a string or is longer than 5000 characters | Send a string |
| 400 | `DRIVER_TYPE_INVALID` | `driverType` is not `solo` or `team` | Send one of the two |
| 400 | `METADATA_INVALID` | `metadata` is not a JSON object or is larger than 20 KB | Send a smaller object |
| 400 | `EXP_DATE_REQUIRED` | Neither `expDate` nor `schedule` sent | Send one of them |
| 400 | `EXP_DATE_INVALID` | `expDate` is not a number, is in the past, or is more than 240 hours ahead (24 hours with a test key) | Send epoch **milliseconds** within the next 10 days (24 hours in test mode) |
| 400 | `EXP_DATE_SCHEDULE_CONFLICT` | Both `expDate` and `schedule` sent | Send only one |
| 400 | `SCHEDULE_INVALID` | `schedule` missing `start`/`end`, starts in the past, or is shorter than 1 hour or longer than 240 hours (with a test key it must end within the next 24 hours) | Fix the window |
| 400 | `LOAD_INSTRUCTIONS_INVALID` | `loadInstructions` is not a string or is longer than 5000 characters | Send a shorter string |
| 400 | `EMAIL_UPDATES_INVALID` | `emailUpdates` breaks a rule (recipients, cadence, times, time zone, flags) | See `message` and the [data formats](/data-formats) |
| 400 | `STOP_LOCATION_INVALID` | A stop has neither a full address nor valid coordinates, `stopLocations` is not an array of stop objects or has more than 50 stops, or an address field is not a string or is longer than 200 characters | Send `streetName`, `city`, `stateProvince`, `zip`, `country`, or `coordinates`. `message` names the field |
| 400 | `EXPECTED_ARRIVAL_INVALID` | `expectedArrival` is not a positive number | Send epoch milliseconds (UTC) |
| 400 | `CREATED_BY_TMS_INVALID` | `createdByTms` is incomplete, `phoneNumber` is not E.164, `email` is not an email address, a text is longer than 200 characters, or `photoURL` is not an `http` / `https` URL | Send all four required fields, phone like `+15555550123`. `message` names the field |
| 400 | `TRACKING_ID_REQUIRED` | `trackingId` missing (query parameter, or body field of `/test/simulate`) | Send it |
| 400 | `STOPS_ETA_INVALID` | `requestStopsEta` is not like `0\|1\|2` | Send pipe-separated stop indexes |
| 400 | `LIST_TYPE_INVALID` | `type` missing or not `active` / `history` | Send a valid `type` |
| 400 | `LIST_PARAMS_INVALID` | Bad `fromDate`, `toDate`, `limit` or `cursor`, or history parameters with `type=active` | See [Pagination](/pagination) |
| 400 | `TEST_EVENT_INVALID` | Unknown simulate event, missing `coords`, a `carrier.*` event on a phone test tracking, or event not allowed from the current status | See [Test mode](/test-mode) |

### Idempotency

Codes of the `Idempotency-Key` header of `POST /create-tracking` (see the create-tracking reference).

| HTTP | `code` | Cause | Fix |
| --- | --- | --- | --- |
| 400 | `IDEMPOTENCY_KEY_INVALID` | `Idempotency-Key` is empty, longer than 255 characters, sent twice, or holds other than visible ASCII without spaces | Send one key, for example a UUID |
| 409 | `IDEMPOTENCY_KEY_REUSED` | The key already created a tracking with another request body | Use a new key for a new tracking. Retry only the same request with the same key |
| 409 | `IDEMPOTENCY_IN_PROGRESS` | A create with this key is still running | Wait for `Retry-After` seconds and retry with the same key |

A retry with the same key and the same request answers the first create's response again, with the header
`Idempotent-Replayed: true`. Nothing is created or billed twice.

### Plan and billing

| HTTP | `code` | Cause | Fix |
| --- | --- | --- | --- |
| 400 | `NO_ACTIVE_SUBSCRIPTION` | The organization has no active Load Market plan. Rare - organizations without a paid plan are on the Free plan and get `TRACKING_LIMIT_REACHED` when its requests are used up | The organization admin subscribes on the Billing page |
| 400 | `TRACKING_LIMIT_REACHED` | The plan has fewer tracking requests left than this tracking needs (`billingWeight` 1, or 2 for more than 5 days) | Upgrade the plan or wait for the next billing period |
| 400 | `PAYMENT_FAILED` | The last payment for the organization's plan failed. The plan is kept, but no new tracking item is created until it is paid. Existing tracking items are not affected | The organization admin updates the payment method on the Billing page of the Load Market web app |
| 403 | `PRO_PLAN_REQUIRED` | A stop has `expectedArrival` on a plan without Smart Arrival Alerts | Remove `expectedArrival` or upgrade to PRO |
| 429 | `TEST_LIMIT_REACHED` | Test mode: the test key already created 200 test tracking items today (UTC) | Wait for `Retry-After` (next midnight UTC). Deleting test tracking items does not reset the quota |
| 429 | `RATE_LIMITED` | Test mode: more than 60 requests in a minute with one test key. On create-tracking also: too many unknown ELD truck numbers for the organization in a short time | Wait for `Retry-After` seconds |
| 403 | `TEST_MODE_ONLY` | `/test/simulate` called with a live key | Use your test key |

### Processing

| HTTP | `code` | Cause | Fix |
| --- | --- | --- | --- |
| 400 | `DRIVER_LOOKUP_FAILED` | The driver's account could not be resolved for this phone | Check the number, retry later, then contact support |
| 400 | `GEOCODING_FAILED` | A stop address could not be geocoded (also when the geocoding service is unavailable) | Correct the address or send `coordinates`. Retry a few times if the address is right |
| 400 / 404 | `TRACKING_NOT_FOUND` | No tracking with this id is visible to your key (404 on edit-tracking only). Also from stop-tracking for pending installation or scheduled tracking items, and for ELD tracking items waiting for the carrier - delete them instead | Check the id and which key created it |
| 400 | `REPORTS_NOT_FOUND` | The tracking does not exist, is not visible to your key, or has no reports yet | Reports start once the driver shares positions |
| 404 | `ROUTE_NOT_FOUND` | Unknown path or HTTP method (under `/v1` only once a valid `x-api-key` was sent) | Check the URL and the method |
| 504 | `UPSTREAM_TIMEOUT` | get-tracking could not be assembled in time, or the ELD truck check of create-tracking took too long | Retry with backoff |
| 500 | `INTERNAL_ERROR` | Unexpected server error | Retry with backoff. Quote `requestId` to support if it persists |

### ELD and Hybrid

Only `POST /create-tracking` answers these, for `trackingSource` and the `eld` block. See
[ELD and Hybrid tracking](/eld-tracking).

| HTTP | `code` | Cause | Fix |
| --- | --- | --- | --- |
| 403 | `ELD_TRACKING_NOT_AVAILABLE` | ELD tracking is not enabled for the organization | Ask Load Market to enable it (office@load-market.com) |
| 400 | `TRACKING_SOURCE_INVALID` | `trackingSource` is not `mobile`, `eld` or `hybrid` | Send one of the three |
| 400 | `ELD_DATA_INVALID` | The `eld` block is missing or has a wrong field, `providerId` is not one of the carrier's, or an approval email is not allowed | Fix the field the message names |
| 400 | `ELD_CARRIER_NOT_INTEGRATED` | The carrier has not connected its ELD to Load Market | Ask the carrier to connect at eld.load-market.com, or track by phone |
| 400 | `ELD_CONNECTION_UNAVAILABLE` | The carrier's ELD connection is not working | Ask the carrier to reconnect its ELD, or track by phone |
| 400 | `ELD_VEHICLE_NOT_FOUND` | The carrier's ELD does not know `truckNumber`, or its ELD plan does not include location tracking for that truck | Check the truck number with the carrier, or ask the carrier to enable location tracking for the truck |
| 503 | `ELD_PROVIDER_UNAVAILABLE` | The carrier's ELD provider did not answer the truck check | Retry after the seconds in `Retry-After` |

### Fallback codes

If an error body was produced without a specific code, it gets one derived from the HTTP status:
`BAD_REQUEST` (400 and any other 4xx not listed), `UNAUTHORIZED` (401), `FORBIDDEN` (403),
`NOT_FOUND` (404), `RATE_LIMITED` (429), `UPSTREAM_TIMEOUT` (504), `INTERNAL_ERROR` (other 5xx).

## Known v1 quirks

These are kept for compatibility and will only change in a new major version:

- **Not found is 400 on most endpoints.** get-tracking, stop-tracking, delete-tracking and get-reports
  answer `400` for an unknown `trackingId`, while edit-tracking answers `404`. Branch on `code`
  (`TRACKING_NOT_FOUND`, or `REPORTS_NOT_FOUND` on get-reports), not on the status.
- **`get-reports` dates are strings.** `data[].date` is an ISO-8601 string. Every other timestamp in a
  response or webhook body is epoch milliseconds.
- **Unknown paths without a key answer 401.** Any path under `/v1` checks the key first, so a typo in
  the path with a missing key reads `401 MISSING_API_KEY` rather than `404`.
- **`200` with a warning.** get-tracking answers `200` when an optional enrichment could not be
  computed: a missing driver address, or an ETA requested without stops or driver coordinates, is
  explained in `message` instead of `Ok`. A stop whose ETA could not be routed is simply missing from
  `stopLocationsEta`.

## Retrying

| Status | Retry? |
| --- | --- |
| 400, 401, 403, 404 | No - fix the request first (except `DRIVER_LOOKUP_FAILED` and `GEOCODING_FAILED`, which can be transient: retry a few times with backoff) |
| 409 | `IDEMPOTENCY_IN_PROGRESS` yes, after `Retry-After`, with the same key. `IDEMPOTENCY_KEY_REUSED` no - use a new key |
| 429 | Yes, after `Retry-After` when present |
| 500, 502, 503, 504 | Yes, with exponential backoff (for example 1 s, 2 s, 4 s, max 5 attempts). When a `503` has `Retry-After`, wait that long first |

Send an `Idempotency-Key` with every `create-tracking` and retry with the same key: a create that already went
through answers its first response again, so a retry never creates or bills a second tracking item. Without the
header a retried create can create two tracking items and use two tracking requests - before retrying a create
that timed out, look for it with `GET /get-all-tracking-items?type=active` and your `customId`. A `5xx` frees the
key, and the tracking may still have been written: check the active list for your `customId` before retrying it.
