{
  "openapi": "3.1.0",
  "info": {
    "title": "TrakkHQ API",
    "version": "1.0",
    "description": "Your company's own TrakkHQ data, for your own systems. Every answer carries the usage terms in the X-Usage-Terms header. You may use this company's TrakkHQ data only to do this company's own work. Do not copy, reproduce, scrape or rebuild TrakkHQ, its screens, features or data, and do not keep TrakkHQ data for any other use. Never available, whatever a key's scopes: Prices, rate cards and quotes; Invoices (none are sent, changed or voided, and none are listed); Pay, payroll and timesheets; Xero, MYOB and QuickBooks; Deleting anything; Users, sign-ins and keys."
  },
  "servers": [
    {
      "url": "https://app.trakkhq.com/api/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "What this API is, its endpoints and its usage terms",
        "description": "Start here. Lists every endpoint and gives the usage terms in full.",
        "operationId": "get",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The index.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Index"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/me": {
      "get": {
        "summary": "Who this key is: company, key name, scopes",
        "description": "A quick way to check a key works.",
        "operationId": "get_me",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/openapi.json": {
      "get": {
        "summary": "This API as an OpenAPI 3.1 file",
        "description": "Load it into Postman, Insomnia or a code generator.",
        "operationId": "get_openapi_json",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The OpenAPI document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/jobs": {
      "get": {
        "summary": "Your jobs, newest first, a page at a time",
        "description": "Filter by date range, status, client and reference. Each page has up to `limit` jobs (default 25, at most 100). When there are more, `next_cursor` is set: send it back as `cursor` for the next page. `count` is how many jobs match in all.",
        "operationId": "get_jobs",
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "description": "Jobs on or after this day.",
            "schema": {
              "type": "string",
              "format": "date",
              "description": "YYYY-MM-DD"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Jobs on or before this day.",
            "schema": {
              "type": "string",
              "format": "date",
              "description": "YYYY-MM-DD"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only jobs with this status, e.g. booked, in_transit, delivered.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "client",
            "in": "query",
            "required": false,
            "description": "Only this client (its code or name).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "reference",
            "in": "query",
            "required": false,
            "description": "Your PO/PL number or a TrakkHQ job number, matched exactly.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Any words: PO, address, customer.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Jobs per page, 1 to 100 (default 25).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the page before.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of jobs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobPage"
                }
              }
            }
          },
          "400": {
            "description": "A filter is not in the right format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/jobs/{job}": {
      "get": {
        "summary": "One job in full: times, driver, truck, stops",
        "description": "The same job fields as the list, plus the start and finish times and every stop with what is picked up or dropped off there.",
        "operationId": "get_jobs_job",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobDetail"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/jobs/{job}/pod": {
      "get": {
        "summary": "Proof of delivery: when, who, signed, photos",
        "description": "When it was delivered, who received it, whether it was signed and how many photos were taken, for the job and each drop. `pdf` is the address of the POD PDF once the job is finished.",
        "operationId": "get_jobs_job_pod",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The proof of delivery.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pod"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/jobs/{job}/pod.pdf": {
      "get": {
        "summary": "The POD PDF of a finished job",
        "description": "The same customer-safe POD document your customers get (no prices, no driver pay). Only once the job is finished.",
        "operationId": "get_jobs_job_pod_pdf",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches. Or: The job isn't finished yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/jobs/{job}/tracking": {
      "get": {
        "summary": "Where the job is: status, ETA, position",
        "description": "The job's status and, while the truck is on its way, the arrival time. The truck's position is included only while it is on this job and only when your live map is on for the job's client (the same rules as the tracking link).",
        "operationId": "get_jobs_job_tracking",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job's tracking.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tracking"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/clients": {
      "get": {
        "summary": "Your clients",
        "description": "Each client's code and name. No rates or prices.",
        "operationId": "get_clients",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Your clients.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Clients"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/drivers": {
      "get": {
        "summary": "Your drivers",
        "description": "Each driver's name, board (city) and usual truck. No pay, phone or address.",
        "operationId": "get_drivers",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Your drivers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Drivers"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/trucks": {
      "get": {
        "summary": "Your trucks",
        "description": "Each truck's rego, make, model, type and whether it is in the fleet.",
        "operationId": "get_trucks",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Your trucks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trucks"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "read"
      }
    },
    "/bookings": {
      "post": {
        "summary": "Ask for a booking (a person accepts it)",
        "description": "Sends a booking request. It is NEVER booked straight in: it waits in Booking requests (inside Approvals where your company has Approvals) for a person to accept. A request that looks like a job already on your board for that client and day is refused with 409 and names the job; send `another_truck: true` if it really is another truck. Send an `Idempotency-Key` header (any unique text, e.g. your order number) and a retry gets the first answer back instead of a second request.",
        "operationId": "post_bookings",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique text for this booking. The same key again returns the first answer.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request, waiting for a person.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingRequest"
                }
              }
            }
          },
          "400": {
            "description": "Something is in the wrong format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "It looks like a job or request already there.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Something is missing or isn't one of yours (see needs_choice), or the Idempotency-Key was used with a different booking.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NeedsChoice"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingIn"
              }
            }
          }
        }
      }
    },
    "/jobs/{job}/notes": {
      "post": {
        "summary": "Add a note to a job's instructions",
        "description": "Goes to Approvals for a person to click, unless your admin has set notes to \"Just do it\" in Connect to AI (and the job hasn't started).",
        "operationId": "post_jobs_job_notes",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Sent, or done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangeResult"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "No note.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoteIn"
              }
            }
          }
        }
      }
    },
    "/jobs/{job}/changes/times": {
      "post": {
        "summary": "Ask to change a job's date or times",
        "description": "Goes to Approvals for a person to click, unless your admin has set this change to \"Just do it\" (and the job hasn't started).",
        "operationId": "post_jobs_job_changes_times",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Sent, or done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangeResult"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Nothing to change, or a time in the wrong format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TimesIn"
              }
            }
          }
        }
      }
    },
    "/jobs/{job}/changes/assign": {
      "post": {
        "summary": "Ask to assign a driver or truck",
        "description": "As above. The driver and truck must be your own (see /drivers and /trucks).",
        "operationId": "post_jobs_job_changes_assign",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Sent, or done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangeResult"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Not one of your drivers or trucks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignIn"
              }
            }
          }
        }
      }
    },
    "/jobs/{job}/changes/stops": {
      "post": {
        "summary": "Ask to change a pick-up or drop-off",
        "description": "As above.",
        "operationId": "post_jobs_job_changes_stops",
        "parameters": [
          {
            "name": "job",
            "in": "path",
            "required": true,
            "description": "The job: its TrakkHQ job number (e.g. ABC-1001), your PO/PL number, or its job key. URL-encode it.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Sent, or done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangeResult"
                }
              }
            }
          },
          "404": {
            "description": "No job of yours matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "More than one of your jobs has that reference. Use the TrakkHQ job number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "Nothing to change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Your company isn't on Pro or above, the API isn't switched on for it, or the AI power this needs is off in Settings → Connections → Connect to AI.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests in a minute from this key. Wait a minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-trakkhq-scope": "write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StopsIn"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "trk_<prefix>_<secret>",
        "description": "An API key from Settings → Connections → API keys. A read key can use every GET; a read and write key can also POST."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "NeedsChoice": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "field": {
            "type": "string"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Index": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "usage_terms": {
            "type": "string"
          },
          "endpoints": {
            "type": "object"
          }
        }
      },
      "Me": {
        "type": "object",
        "properties": {
          "company_id": {
            "type": "integer"
          },
          "key_name": {
            "type": "string"
          },
          "key_prefix": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "job_key": {
            "type": "string"
          },
          "tlh_job_id": {
            "type": "string"
          },
          "customer": {
            "type": "string"
          },
          "pl_number": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "driver_name": {
            "type": "string"
          },
          "truck_rego": {
            "type": "string"
          },
          "vehicle_type": {
            "type": "string"
          },
          "pickup_addr": {
            "type": "string"
          },
          "pickup_suburb": {
            "type": "string"
          },
          "dropoff_addr": {
            "type": "string"
          },
          "dropoff_suburb": {
            "type": "string"
          },
          "items": {
            "type": "string"
          },
          "special_instructions": {
            "type": "string"
          },
          "shift_date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "is_cancelled": {
            "type": "boolean"
          }
        }
      },
      "JobPage": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer"
          },
          "truncated": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "jobs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Job"
            }
          }
        }
      },
      "Stop": {
        "type": "object",
        "properties": {
          "seq": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "goods": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "JobDetail": {
        "type": "object",
        "properties": {
          "job": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Job"
              },
              {
                "type": "object",
                "properties": {
                  "pickup_time": {
                    "type": "string"
                  },
                  "end_time": {
                    "type": "string"
                  }
                }
              }
            ]
          },
          "stops": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Stop"
            }
          }
        }
      },
      "Pod": {
        "type": "object",
        "properties": {
          "job_key": {
            "type": "string"
          },
          "delivered_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "received_by": {
            "type": [
              "string",
              "null"
            ]
          },
          "signed": {
            "type": "boolean"
          },
          "no_signature": {
            "type": "boolean"
          },
          "photo_count": {
            "type": "integer"
          },
          "photo_kinds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "pdf": {
            "type": [
              "string",
              "null"
            ]
          },
          "stops": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Tracking": {
        "type": "object",
        "properties": {
          "job_key": {
            "type": "string"
          },
          "job_status": {
            "type": "string"
          },
          "tracking": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "not_started",
                  "not_active",
                  "no_data",
                  "stale"
                ]
              },
              "eta": {
                "type": "string"
              },
              "eta_at": {
                "type": "string"
              },
              "eta_minutes": {
                "type": "integer"
              },
              "lat": {
                "type": "number"
              },
              "lon": {
                "type": "number"
              },
              "speed_kmh": {
                "type": "number"
              },
              "map": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "Clients": {
        "type": "object",
        "properties": {
          "clients": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Drivers": {
        "type": "object",
        "properties": {
          "drivers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "city": {
                  "type": "string"
                },
                "usual_truck": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Trucks": {
        "type": "object",
        "properties": {
          "trucks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rego": {
                  "type": "string"
                },
                "make": {
                  "type": "string"
                },
                "model": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "in_fleet": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "BookingIn": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "client",
          "date",
          "vehicle",
          "pickup_addr",
          "dropoff_addr"
        ],
        "properties": {
          "client": {
            "type": "string",
            "description": "One of your clients."
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "pickup_time": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
            "description": "HH:MM, 24-hour, Melbourne time"
          },
          "vehicle": {
            "type": "string",
            "description": "One of your truck types."
          },
          "pickup_addr": {
            "type": "string"
          },
          "dropoff_addr": {
            "type": "string"
          },
          "reference": {
            "type": "string",
            "description": "Your PO/PL number."
          },
          "goods": {
            "type": "string",
            "description": "What is being carried."
          },
          "instructions": {
            "type": "string"
          },
          "another_truck": {
            "type": "boolean",
            "description": "true when a job already there for that client and day is a different truck."
          }
        }
      },
      "BookingRequest": {
        "type": "object",
        "properties": {
          "done": {
            "type": "boolean",
            "const": false
          },
          "booking_request": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "const": "pending"
          },
          "summary": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "NoteIn": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "note"
        ],
        "properties": {
          "note": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "TimesIn": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reason"
        ],
        "properties": {
          "shift_date": {
            "type": "string",
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "pickup_time": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
            "description": "HH:MM, 24-hour, Melbourne time"
          },
          "end_time": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
            "description": "HH:MM, 24-hour, Melbourne time"
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "AssignIn": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reason"
        ],
        "properties": {
          "driver_name": {
            "type": "string"
          },
          "truck_rego": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "StopsIn": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reason"
        ],
        "properties": {
          "pickup_addr": {
            "type": "string"
          },
          "dropoff_addr": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "ChangeResult": {
        "type": "object",
        "properties": {
          "done": {
            "type": "boolean"
          },
          "sent_to_approvals": {
            "type": "boolean"
          },
          "job_key": {
            "type": "string"
          },
          "cards": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}