{
 "openapi": "3.1.0",
 "info": {
  "title": "Trellex TMS API",
  "version": "1.0.0",
  "description": "REST API for the Trellex freight broker TMS: loads, tracking, documents, carriers, invoices, telematics and EDI. Keys are made in Trellex under Admin, API & EDI. Each key belongs to one brokerage and may make 120 requests a minute. Guide: https://trellex.net/developers/"
 },
 "servers": [
  {
   "url": "https://trellex.net/tms/api/v1"
  }
 ],
 "security": [
  {
   "bearer": []
  },
  {
   "apiKey": []
  }
 ],
 "tags": [
  {
   "name": "Loads"
  },
  {
   "name": "Tracking and documents"
  },
  {
   "name": "Carriers and invoices"
  },
  {
   "name": "Telematics"
  },
  {
   "name": "EDI"
  }
 ],
 "paths": {
  "/me": {
   "get": {
    "summary": "Who this key belongs to",
    "operationId": "getMe",
    "tags": [
     "Loads"
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "company": {
           "type": "string"
          },
          "key": {
           "type": "object",
           "properties": {
            "name": {
             "type": "string"
            },
            "prefix": {
             "type": "string"
            },
            "scope": {
             "type": "string",
             "enum": [
              "full",
              "read",
              "customer"
             ]
            },
            "customer": {
             "type": [
              "string",
              "null"
             ]
            }
           }
          },
          "endpoints": {
           "type": "array",
           "items": {
            "type": "string"
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/loads": {
   "get": {
    "summary": "List loads",
    "description": "Newest pickup first.",
    "operationId": "listLoads",
    "tags": [
     "Loads"
    ],
    "parameters": [
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "One or more of open, covered, dispatched, in_transit, delivered, invoiced, comma separated."
     },
     {
      "name": "customer",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Exact customer name (not case sensitive). Ignored for one-customer keys."
     },
     {
      "name": "since",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "Only loads that pick up on or after this date."
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 200,
       "default": 50
      }
     },
     {
      "name": "offset",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "default": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Load"
           }
          },
          "total": {
           "type": "integer"
          },
          "offset": {
           "type": "integer"
          },
          "limit": {
           "type": "integer"
          },
          "has_more": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "post": {
    "summary": "Create an open load",
    "operationId": "createLoad",
    "tags": [
     "Loads"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/NewLoad"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/Load"
          },
          "possible_duplicates": {
           "type": "array",
           "description": "Present when this looks like a load already in Trellex.",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "reason": {
              "type": "string"
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "The body is not JSON.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Something required is missing or not valid. The message says what.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/loads/{id}": {
   "get": {
    "summary": "Get one load",
    "operationId": "getLoad",
    "tags": [
     "Loads"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Trellex load ID (L-123) or your reference / PO."
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "$ref": "#/components/schemas/Load"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Load not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/loads/{id}/tracking": {
   "get": {
    "summary": "Tracking for one load",
    "operationId": "getTracking",
    "tags": [
     "Tracking and documents"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Trellex load ID (L-123) or your reference / PO."
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "object",
           "properties": {
            "id": {
             "type": "string"
            },
            "status": {
             "type": [
              "string",
              "null"
             ]
            },
            "percent_complete": {
             "type": [
              "integer",
              "null"
             ],
             "minimum": 0,
             "maximum": 100
            },
            "eta": {
             "type": [
              "string",
              "null"
             ],
             "format": "date-time"
            },
            "last_update": {
             "type": [
              "string",
              "null"
             ],
             "format": "date-time"
            },
            "forecast": {
             "oneOf": [
              {
               "$ref": "#/components/schemas/Forecast"
              },
              {
               "type": "null"
              }
             ]
            },
            "check_calls": {
             "type": "array",
             "description": "Single-load requests only: the last five.",
             "items": {
              "type": "object",
              "properties": {
               "at": {
                "type": [
                 "string",
                 "null"
                ],
                "format": "date-time"
               },
               "source": {
                "type": [
                 "string",
                 "null"
                ]
               },
               "text": {
                "type": [
                 "string",
                 "null"
                ]
               }
              }
             }
            },
            "stops": {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Stop"
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Load not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/loads/{id}/documents": {
   "get": {
    "summary": "Files on a load",
    "description": "One-customer keys see BOLs and PODs only.",
    "operationId": "listDocuments",
    "tags": [
     "Tracking and documents"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Trellex load ID (L-123) or your reference / PO."
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "integer"
             },
             "type": {
              "type": "string"
             },
             "name": {
              "type": "string"
             },
             "mime": {
              "type": "string"
             },
             "size": {
              "type": "integer"
             },
             "uploaded": {
              "type": [
               "string",
               "null"
              ],
              "format": "date-time"
             },
             "download": {
              "type": "string",
              "description": "Path of the file, relative to the API base."
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "Load not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/documents/{documentId}": {
   "get": {
    "summary": "Download one file",
    "operationId": "getDocument",
    "tags": [
     "Tracking and documents"
    ],
    "parameters": [
     {
      "name": "documentId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The file.",
      "content": {
       "*/*": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "404": {
      "description": "Document not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "410": {
      "description": "The file is missing on the server.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/carriers": {
   "get": {
    "summary": "List carriers",
    "description": "Not for one-customer keys.",
    "operationId": "listCarriers",
    "tags": [
     "Carriers and invoices"
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "string"
             },
             "name": {
              "type": [
               "string",
               "null"
              ]
             },
             "mc": {
              "type": [
               "string",
               "null"
              ]
             },
             "dot": {
              "type": [
               "string",
               "null"
              ]
             },
             "phone": {
              "type": [
               "string",
               "null"
              ]
             },
             "email": {
              "type": [
               "string",
               "null"
              ]
             },
             "tier": {
              "type": [
               "string",
               "null"
              ],
              "description": "gold, silver, standard or new."
             },
             "loads": {
              "type": [
               "integer",
               "null"
              ]
             },
             "on_time_pct": {
              "type": [
               "number",
               "null"
              ]
             },
             "blocked": {
              "type": "boolean"
             }
            }
           }
          },
          "total": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/invoices": {
   "get": {
    "summary": "List invoices",
    "operationId": "listInvoices",
    "tags": [
     "Carriers and invoices"
    ],
    "parameters": [
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "open",
        "past_due",
        "paid"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "number": {
              "type": "string"
             },
             "load": {
              "type": "string"
             },
             "reference": {
              "type": [
               "string",
               "null"
              ]
             },
             "customer": {
              "type": [
               "string",
               "null"
              ]
             },
             "amount": {
              "type": "number"
             },
             "currency": {
              "type": "string"
             },
             "invoiced": {
              "type": [
               "string",
               "null"
              ],
              "format": "date-time"
             },
             "due": {
              "type": [
               "string",
               "null"
              ],
              "format": "date"
             },
             "status": {
              "type": "string",
              "enum": [
               "open",
               "past_due",
               "paid"
              ]
             },
             "paid_at": {
              "type": [
               "string",
               "null"
              ]
             }
            }
           }
          },
          "total": {
           "type": "integer"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/loads/{id}/locations": {
   "post": {
    "summary": "Send truck locations",
    "description": "Full-access keys only. One reading as the body, or up to 500 under data.",
    "operationId": "sendLocations",
    "tags": [
     "Telematics"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Trellex load ID (L-123) or your reference / PO."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/Location"
         },
         {
          "type": "object",
          "required": [
           "data"
          ],
          "properties": {
           "data": {
            "type": "array",
            "maxItems": 500,
            "items": {
             "$ref": "#/components/schemas/Location"
            }
           }
          }
         }
        ]
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Accepted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Accepted"
        }
       }
      }
     },
     "404": {
      "description": "Load not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/loads/{id}/temperatures": {
   "post": {
    "summary": "Send reefer temperatures",
    "description": "Full-access keys only. One reading as the body, or up to 2,000 under data.",
    "operationId": "sendTemperatures",
    "tags": [
     "Telematics"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Trellex load ID (L-123) or your reference / PO."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/Temperature"
         },
         {
          "type": "object",
          "required": [
           "data"
          ],
          "properties": {
           "data": {
            "type": "array",
            "maxItems": 2000,
            "items": {
             "$ref": "#/components/schemas/Temperature"
            }
           }
          }
         }
        ]
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Accepted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Accepted"
        }
       }
      }
     },
     "404": {
      "description": "Load not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/edi": {
   "post": {
    "summary": "Send an X12 file",
    "description": "204 load tenders. The body is the raw file, or JSON with the file under x12. Not for one-customer or read-only keys.",
    "operationId": "sendEdi",
    "tags": [
     "EDI"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      },
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "x12"
        ],
        "properties": {
         "x12": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "Received",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "object"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/edi/outbox": {
   "get": {
    "summary": "EDI files waiting for the trading partner",
    "operationId": "listEdiOutbox",
    "tags": [
     "EDI"
    ],
    "parameters": [
     {
      "name": "partner",
      "in": "query",
      "schema": {
       "type": "integer"
      },
      "description": "Trading partner ID, when the key is not tied to one partner."
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "integer"
             },
             "type": {
              "type": "string",
              "description": "990, 997, 214 or 210."
             },
             "control": {
              "type": [
               "string",
               "null"
              ]
             },
             "shipment": {
              "type": [
               "string",
               "null"
              ]
             },
             "load": {
              "type": [
               "string",
               "null"
              ]
             },
             "partner": {
              "type": "string"
             },
             "created": {
              "type": [
               "string",
               "null"
              ],
              "format": "date-time"
             },
             "download": {
              "type": "string"
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/edi/outbox/{ediId}": {
   "get": {
    "summary": "Download one EDI file",
    "operationId": "getEdiFile",
    "tags": [
     "EDI"
    ],
    "parameters": [
     {
      "name": "ediId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The X12 file.",
      "content": {
       "application/edi-x12": {
        "schema": {
         "type": "string"
        }
       }
      }
     },
     "404": {
      "description": "EDI file not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/edi/outbox/{ediId}/ack": {
   "post": {
    "summary": "Mark an EDI file collected",
    "operationId": "ackEdiFile",
    "tags": [
     "EDI"
    ],
    "parameters": [
     {
      "name": "ediId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "ok": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "EDI file not found.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The key is missing, malformed or revoked.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "The key is not allowed to do this, or API & EDI is not in the company's plan.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "More than 120 requests in a minute.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Authorization: Bearer trx_live_…"
   },
   "apiKey": {
    "type": "apiKey",
    "in": "header",
    "name": "X-Api-Key"
   }
  },
  "schemas": {
   "Money": {
    "type": "object",
    "properties": {
     "amount": {
      "type": "number"
     },
     "currency": {
      "type": "string",
      "enum": [
       "USD",
       "CAD"
      ]
     }
    }
   },
   "Stop": {
    "type": "object",
    "properties": {
     "type": {
      "type": "string",
      "enum": [
       "pickup",
       "delivery"
      ]
     },
     "facility": {
      "type": [
       "string",
       "null"
      ]
     },
     "address": {
      "type": [
       "string",
       "null"
      ]
     },
     "city": {
      "type": [
       "string",
       "null"
      ]
     },
     "state": {
      "type": [
       "string",
       "null"
      ]
     },
     "zip": {
      "type": [
       "string",
       "null"
      ]
     },
     "appointment": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "arrived": {
      "type": "boolean"
     }
    }
   },
   "Forecast": {
    "type": "object",
    "description": "Arrival forecast for a load in transit.",
    "properties": {
     "arrival": {
      "type": "string",
      "format": "date-time"
     },
     "risk": {
      "type": "string",
      "enum": [
       "ok",
       "watch",
       "late"
      ]
     },
     "minutes_late": {
      "type": "integer",
      "description": "Negative when early."
     },
     "reasons": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    }
   },
   "Load": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "examples": [
       "L-24191"
      ]
     },
     "reference": {
      "type": [
       "string",
       "null"
      ],
      "description": "Your PO or reference."
     },
     "customer": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": "string",
      "enum": [
       "open",
       "covered",
       "dispatched",
       "in_transit",
       "delivered",
       "invoiced",
       "cancelled"
      ]
     },
     "equipment": {
      "type": [
       "string",
       "null"
      ]
     },
     "temperature": {
      "type": [
       "string",
       "null"
      ],
      "description": "Set point as text, such as 34F."
     },
     "weight_lbs": {
      "type": [
       "integer",
       "null"
      ]
     },
     "commodity": {
      "type": [
       "string",
       "null"
      ]
     },
     "miles": {
      "type": [
       "integer",
       "null"
      ]
     },
     "rate": {
      "$ref": "#/components/schemas/Money"
     },
     "stops": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Stop"
      }
     },
     "tracking": {
      "type": "object",
      "properties": {
       "eta": {
        "type": [
         "string",
         "null"
        ],
        "format": "date-time"
       },
       "last_update": {
        "type": [
         "string",
         "null"
        ],
        "format": "date-time"
       }
      }
     },
     "documents": {
      "type": "object",
      "properties": {
       "bol": {
        "type": "boolean"
       },
       "pod": {
        "type": "boolean"
       },
       "invoice": {
        "type": "boolean"
       }
      }
     },
     "invoice": {
      "type": "object",
      "description": "Present once the load is invoiced.",
      "properties": {
       "number": {
        "type": "string"
       },
       "replaces": {
        "type": [
         "string",
         "null"
        ]
       },
       "credit_note": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     "carrier": {
      "type": [
       "object",
       "null"
      ],
      "description": "One-customer keys get the name only.",
      "properties": {
       "id": {
        "type": "string"
       },
       "name": {
        "type": [
         "string",
         "null"
        ]
       },
       "mc": {
        "type": [
         "string",
         "null"
        ]
       },
       "dot": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     "carrier_pay": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Money"
       }
      ],
      "description": "Not sent to one-customer keys."
     },
     "sales_rep": {
      "type": [
       "string",
       "null"
      ],
      "description": "Not sent to one-customer keys."
     },
     "edi": {
      "type": "object",
      "properties": {
       "shipment_id": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     "check_calls": {
      "type": "array",
      "description": "Single-load requests only: the last five.",
      "items": {
       "type": "object",
       "properties": {
        "at": {
         "type": [
          "string",
          "null"
         ],
         "format": "date-time"
        },
        "source": {
         "type": [
          "string",
          "null"
         ]
        },
        "text": {
         "type": [
          "string",
          "null"
         ]
        }
       }
      }
     },
     "forecast": {
      "$ref": "#/components/schemas/Forecast"
     }
    }
   },
   "NewLoad": {
    "type": "object",
    "required": [
     "customer",
     "stops"
    ],
    "properties": {
     "customer": {
      "type": "string"
     },
     "reference": {
      "type": "string"
     },
     "equipment": {
      "type": "string",
      "enum": [
       "Dry Van",
       "Reefer",
       "Flatbed",
       "Step Deck",
       "Power Only"
      ],
      "default": "Dry Van"
     },
     "temperature": {
      "type": "string"
     },
     "weight_lbs": {
      "type": "integer"
     },
     "commodity": {
      "type": "string"
     },
     "rate": {
      "type": "number"
     },
     "currency": {
      "type": "string",
      "enum": [
       "USD",
       "CAD"
      ],
      "default": "USD"
     },
     "miles": {
      "type": "integer",
      "description": "Worked out from the stops when left out."
     },
     "sales_rep": {
      "type": "string"
     },
     "notes": {
      "type": "string"
     },
     "stops": {
      "type": "array",
      "minItems": 2,
      "description": "A pickup first and a delivery last.",
      "items": {
       "type": "object",
       "required": [
        "type",
        "city",
        "state",
        "appointment"
       ],
       "properties": {
        "type": {
         "type": "string",
         "enum": [
          "pickup",
          "delivery"
         ]
        },
        "facility": {
         "type": "string"
        },
        "address": {
         "type": "string"
        },
        "city": {
         "type": "string"
        },
        "state": {
         "type": "string"
        },
        "zip": {
         "type": "string"
        },
        "appointment": {
         "type": "string",
         "format": "date-time"
        }
       }
      }
     }
    }
   },
   "Location": {
    "type": "object",
    "required": [
     "lat",
     "lng"
    ],
    "properties": {
     "lat": {
      "type": "number"
     },
     "lng": {
      "type": "number"
     },
     "speed_mph": {
      "type": "number"
     },
     "at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "Temperature": {
    "type": "object",
    "properties": {
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "temp_f": {
      "type": "number"
     },
     "temp_c": {
      "type": "number"
     }
    }
   },
   "Accepted": {
    "type": "object",
    "properties": {
     "ok": {
      "type": "boolean"
     },
     "accepted": {
      "type": "integer"
     }
    }
   },
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "object",
      "properties": {
       "message": {
        "type": "string"
       },
       "status": {
        "type": "integer"
       }
      }
     }
    }
   }
  }
 }
}