# Errors

CarrierCloud is a gateway in front of the Tranztec Platform, so errors come from three layers. Each layer has its own body style. The status code tells you the category; the body tells you the layer.

## Gateway errors (problem JSON)

Produced by the gateway's own policies. Always `application/json`:

```json
{
  "type": "https://httpproblems.com/http-status/401",
  "title": "Unauthorized",
  "status": 401,
  "detail": "No Authorization Header",
  "instance": "/v1/partner/MIST/loads",
  "trace": { "requestId": "…", "buildId": "…" }
}
```

| Status | `title` / `detail` | Cause |
|---|---|---|
| `401` | `Unauthorized` / `No Authorization Header` | The `Authorization` header is missing. |
| `401` | `Unauthorized` / `Authorization Failed` | The key is not recognised. |
| `401` | `Sandbox Limit` / `This endpoint is not available with Sandbox API tokens.` | The operation is [gated](/docs/environments#gated-operations). |
| `404` | `Not Found` | No route matches the path and method. |

Quote the `trace.requestId` when you contact support.

## Partnership errors (plain text)

Produced when the gateway evaluates the partner code. Always `text/plain`:

| Status | Body | Cause and fix |
|---|---|---|
| `401` | `Not authorized.` | The company behind your key no longer exists on the platform. Contact support. |
| `401` | `Not authorized to partner.` | The partner lists your company but the relationship is not approved or not API-enabled. Ask the partner to approve API access. |
| `404` | `Partner not found.` | No company has this partner code. Use the `Code` values from `GET /v1/partners`. |
| `400` | `Error processing request.` | The partnership could not be evaluated. Today this includes the case where the partner has no relationship with your company at all; request a partnership first. |

## Operation errors (plain text or JSON, per operation)

Produced by the platform or by the gateway's request validation. The reference page of each operation lists its texts; the common ones are:

| Status | Body | Operations |
|---|---|---|
| `404` | `No orders found.` · `No loads found.` · `No tractors found.` · `No trailers found.` · `No drivers found.` · `No carriers found.` · `No positions found.` · `No events found.` · `No partners found in your network.` | Lists and lookups with no results. Not an error in the usual sense: treat it as an empty page. |
| `400` | `Page parameter must be a positive integer` | Paged lists. |
| `404` | `Load not found` · `Load already accepted or rejected` | Accept / reject offer. |
| `422` | `Load Id is required` · `Start Time is required` · `cardid is required` · `type is required` · `Invalid type` · `Webhook already exists` | Missing or invalid input on offers and webhooks. |
| `422` | `{ "detail": "...", "errors": ["..."] }` | Order booking, order update, segment update, location writes, and invoice create and update. `detail` is a sentence; `errors` lists each rejected field when the platform returned more than one. |
| `207` | `{ "status": "ok", "warnings": ["Permission denied for City"] }` | Writes that succeeded with some fields skipped because your partner role may not set them. The record was saved without those fields. Invoice create includes `_id` and `invoiceId`. |
| `403` | `Permission denied` | Your partner role lacks the permission the operation needs (for example viewing attachments). Ask the partner to extend the role. |
| `500` | none | Geocoding found no match above the confidence threshold. Retry with a more specific query. |

## Handling advice

1. Branch on the status code first.
2. If the content type is `text/plain`, the body is a short message meant for logs, not for parsing.
3. Treat the `404 No ... found.` family as an empty result, and `207` as success with warnings worth logging.
4. Back off on `401 Sandbox Limit`; it will not clear by retrying.
5. Include the request's `trace.requestId` (gateway problems) or the full text body (platform errors) in support requests.
